提交 83ced67d 编写于 作者: P Patrick Walton

librustdoc: De-export compiletest, combine-tests, libcargo, libfuzzer, and...

librustdoc: De-export compiletest, combine-tests, libcargo, libfuzzer, and librustdoc. rs=deexporting
上级 d73bf629
......@@ -12,16 +12,15 @@
use cmp;
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
impl mode : cmp::Eq {
pure fn eq(&self, other: &mode) -> bool {
(*other) as int == (*self) as int
}
pure fn ne(&self, other: &mode) -> bool { !(*self).eq(other) }
#[deriving_eq]
pub enum mode {
mode_compile_fail,
mode_run_fail,
mode_run_pass,
mode_pretty,
}
type config = {
pub type config = {
// The library paths required for running the compiler
compile_lib_path: ~str,
......
......@@ -11,7 +11,6 @@
#[crate_type = "bin"];
#[no_core];
#[legacy_exports];
#[legacy_records];
#[allow(vecs_implicitly_copyable)];
......@@ -24,17 +23,11 @@ extern mod std(vers = "0.6");
use core::*;
#[legacy_exports]
mod procsrv;
#[legacy_exports]
mod util;
#[legacy_exports]
mod header;
#[legacy_exports]
mod runtest;
#[legacy_exports]
mod common;
#[legacy_exports]
mod errors;
use std::getopts;
......@@ -51,14 +44,14 @@ use common::mode_pretty;
use common::mode;
use util::logv;
fn main() {
pub fn main() {
let args = os::args();
let config = parse_config(args);
log_config(config);
run_tests(config);
}
fn parse_config(args: ~[~str]) -> config {
pub fn parse_config(args: ~[~str]) -> config {
let opts =
~[getopts::reqopt(~"compile-lib-path"),
getopts::reqopt(~"run-lib-path"),
......@@ -105,7 +98,7 @@ fn parse_config(args: ~[~str]) -> config {
verbose: getopts::opt_present(matches, ~"verbose")};
}
fn log_config(config: config) {
pub fn log_config(config: config) {
let c = config;
logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
......@@ -124,15 +117,15 @@ fn log_config(config: config) {
logv(c, fmt!("\n"));
}
fn opt_str(maybestr: Option<~str>) -> ~str {
pub fn opt_str(maybestr: Option<~str>) -> ~str {
match maybestr { option::Some(s) => s, option::None => ~"(none)" }
}
fn str_opt(maybestr: ~str) -> Option<~str> {
pub fn str_opt(maybestr: ~str) -> Option<~str> {
if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None }
}
fn str_mode(s: ~str) -> mode {
pub fn str_mode(s: ~str) -> mode {
match s {
~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail,
......@@ -142,7 +135,7 @@ fn str_mode(s: ~str) -> mode {
}
}
fn mode_str(mode: mode) -> ~str {
pub fn mode_str(mode: mode) -> ~str {
match mode {
mode_compile_fail => ~"compile-fail",
mode_run_fail => ~"run-fail",
......@@ -151,14 +144,14 @@ fn mode_str(mode: mode) -> ~str {
}
}
fn run_tests(config: config) {
pub fn run_tests(config: config) {
let opts = test_opts(config);
let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests);
if !res { fail ~"Some tests failed"; }
}
fn test_opts(config: config) -> test::TestOpts {
pub fn test_opts(config: config) -> test::TestOpts {
test::TestOpts {
filter: config.filter,
run_ignored: config.run_ignored,
......@@ -166,7 +159,7 @@ fn test_opts(config: config) -> test::TestOpts {
}
}
fn make_tests(config: config) -> ~[test::TestDesc] {
pub fn make_tests(config: config) -> ~[test::TestDesc] {
debug!("making tests from %s",
config.src_base.to_str());
let mut tests = ~[];
......@@ -180,7 +173,7 @@ fn make_tests(config: config) -> ~[test::TestDesc] {
move tests
}
fn is_test(config: config, testfile: &Path) -> bool {
pub fn is_test(config: config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
......@@ -203,7 +196,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
return valid;
}
fn make_test(config: config, testfile: &Path) ->
pub fn make_test(config: config, testfile: &Path) ->
test::TestDesc {
test::TestDesc {
name: make_test_name(config, testfile),
......@@ -213,11 +206,11 @@ fn make_test(config: config, testfile: &Path) ->
}
}
fn make_test_name(config: config, testfile: &Path) -> ~str {
pub fn make_test_name(config: config, testfile: &Path) -> ~str {
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
}
fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str();
fn~() { runtest::run(config, testfile) }
}
......
......@@ -15,13 +15,10 @@
use io::ReaderUtil;
use str;
export load_errors;
export ExpectedError;
struct ExpectedError { line: uint, kind: ~str, msg: ~str }
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
// Load any test directives embedded in the file
fn load_errors(testfile: &Path) -> ~[ExpectedError] {
pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
let mut error_patterns = ~[];
let rdr = io::file_reader(testfile).get();
let mut line_num = 1u;
......
......@@ -17,11 +17,7 @@
use os;
use str;
export TestProps;
export load_props;
export is_test_ignored;
struct TestProps {
pub struct TestProps {
// Lines that should be expected, in order, on standard out
error_patterns: ~[~str],
// Extra flags to pass to the compiler
......@@ -36,7 +32,7 @@ struct TestProps {
}
// Load any test directives embedded in the file
fn load_props(testfile: &Path) -> TestProps {
pub fn load_props(testfile: &Path) -> TestProps {
let mut error_patterns = ~[];
let mut aux_builds = ~[];
let mut exec_env = ~[];
......@@ -73,7 +69,7 @@ fn load_props(testfile: &Path) -> TestProps {
};
}
fn is_test_ignored(config: config, testfile: &Path) -> bool {
pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false;
for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; }
......
......@@ -22,8 +22,6 @@
use task;
use vec;
export run;
#[cfg(target_os = "win32")]
fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
......@@ -54,12 +52,11 @@ fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] {
struct Result {status: int, out: ~str, err: ~str}
// FIXME (#2659): This code is duplicated in core::run::program_output
fn run(lib_path: ~str,
prog: ~str,
args: ~[~str],
env: ~[(~str, ~str)],
input: Option<~str>) -> Result {
pub fn run(lib_path: ~str,
prog: ~str,
args: ~[~str],
env: ~[(~str, ~str)],
input: Option<~str>) -> Result {
let pipe_in = os::pipe();
let pipe_out = os::pipe();
let pipe_err = os::pipe();
......
......@@ -31,9 +31,7 @@
use util;
use util::logv;
export run;
fn run(config: config, testfile: ~str) {
pub fn run(config: config, testfile: ~str) {
if config.verbose {
// We're going to be dumping a lot of info. Start on a new line.
io::stdout().write_str(~"\n\n");
......
......@@ -17,7 +17,7 @@
use common;
use common::config;
fn make_new_path(path: ~str) -> ~str {
pub fn make_new_path(path: ~str) -> ~str {
// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
......@@ -31,23 +31,23 @@ fn make_new_path(path: ~str) -> ~str {
#[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")]
fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" }
pub fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" }
#[cfg(target_os = "macos")]
fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" }
pub fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" }
#[cfg(target_os = "win32")]
fn lib_path_env_var() -> ~str { ~"PATH" }
pub fn lib_path_env_var() -> ~str { ~"PATH" }
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
fn path_div() -> ~str { ~":" }
pub fn path_div() -> ~str { ~":" }
#[cfg(target_os = "win32")]
fn path_div() -> ~str { ~";" }
pub fn path_div() -> ~str { ~";" }
fn logv(config: config, s: ~str) {
pub fn logv(config: config, s: ~str) {
log(debug, s);
if config.verbose { io::println(s); }
}
......@@ -37,14 +37,12 @@ stage2_tests.sort()
c = open("tmp/run_pass_stage2.rc", "w")
i = 0
c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
c.write("#[legacy_exports];\n")
c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n")
for t in stage2_tests:
p = os.path.join(run_pass, t)
p = p.replace("\\", "\\\\")
c.write("#[path = \"%s\"]" % p);
c.write("#[legacy_exports]");
c.write("mod t_%d;\n" % i)
c.write("pub mod t_%d;\n" % i)
i += 1
c.close()
......
此差异已折叠。
......@@ -12,11 +12,11 @@
use core::path::Path;
use core::run;
fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
pub fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
return run::program_output(~"gpgv", args);
}
fn signing_key() -> ~str {
pub fn signing_key() -> ~str {
~"
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.0
......@@ -68,16 +68,16 @@ fn signing_key() -> ~str {
"
}
fn signing_key_fp() -> ~str {
pub fn signing_key_fp() -> ~str {
~"FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376"
}
fn supported() -> bool {
pub fn supported() -> bool {
let r = gpgv(~[~"--version"]);
r.status == 0
}
fn init(root: &Path) {
pub fn init(root: &Path) {
let p = root.push("gpg");
if !os::path_is_dir(&p) {
os::make_dir(&p, 0x1c0i32);
......@@ -92,7 +92,7 @@ fn init(root: &Path) {
}
}
fn add(root: &Path, key: &Path) {
pub fn add(root: &Path, key: &Path) {
let path = root.push("gpg");
let p =
run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
......@@ -102,7 +102,7 @@ fn add(root: &Path, key: &Path) {
}
}
fn verify(root: &Path, data: &Path, sig: &Path) -> bool {
pub fn verify(root: &Path, data: &Path, sig: &Path) -> bool {
let path = root.push("gpg");
let res = gpgv(~[~"--homedir", path.to_str(),
~"--keyring", ~"pubring.gpg",
......
......@@ -20,7 +20,6 @@
#[no_core];
#[legacy_modes];
#[legacy_exports];
#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
......@@ -40,27 +39,22 @@ use syntax::parse;
use syntax::print::pprust;
use syntax::diagnostic;
enum test_mode { tm_converge, tm_run, }
struct Context { mode: test_mode } // + rng
#[deriving_eq]
pub enum test_mode { tm_converge, tm_run, }
impl test_mode : cmp::Eq {
pure fn eq(&self, other: &test_mode) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &test_mode) -> bool { !(*self).eq(other) }
}
pub struct Context { mode: test_mode } // + rng
fn write_file(filename: &Path, content: ~str) {
pub fn write_file(filename: &Path, content: ~str) {
result::get(
&io::file_writer(filename, ~[io::Create, io::Truncate]))
.write_str(content);
}
fn contains(haystack: ~str, needle: ~str) -> bool {
pub fn contains(haystack: ~str, needle: ~str) -> bool {
str::contains(haystack, needle)
}
fn find_rust_files(files: &mut ~[Path], path: &Path) {
pub fn find_rust_files(files: &mut ~[Path], path: &Path) {
if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") {
// ignoring "utf8" tests because something is broken
files.push(*path);
......@@ -74,7 +68,7 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) {
}
fn common_exprs() -> ~[ast::expr] {
pub fn common_exprs() -> ~[ast::expr] {
fn dse(e: ast::expr_) -> ast::expr {
ast::expr {
id: 0,
......@@ -104,11 +98,11 @@ fn common_exprs() -> ~[ast::expr] {
]
}
pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
pub pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
safe_to_use_expr(*e, tm)
}
pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
match tm {
tm_converge => {
match e.node {
......@@ -142,33 +136,37 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
}
}
fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
// Restrictions happen to be the same.
safe_to_replace_ty(t.node, tm)
}
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
es: @mut ~[ast::expr],
e: @ast::expr,
tm: test_mode) {
pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
es: @mut ~[ast::expr],
e: @ast::expr,
tm: test_mode) {
if c(e, tm) {
*es += ~[*e];
} else {/* now my indices are wrong :( */ }
} else {
/* now my indices are wrong :( */
}
}
fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool,
es: @mut ~[ast::Ty],
e: @ast::Ty,
tm: test_mode) {
pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool,
es: @mut ~[ast::Ty],
e: @ast::Ty,
tm: test_mode) {
if c(e, tm) {
es.push(*e);
} else {/* now my indices are wrong :( */ }
} else {
/* now my indices are wrong :( */
}
}
struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]}
pub struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]}
fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
let exprs = @mut ~[];
let tys = @mut ~[];
let v = visit::mk_simple_visitor(@visit::SimpleVisitor {
......@@ -181,7 +179,7 @@ fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
}
fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
match e {
// https://github.com/mozilla/rust/issues/652
ast::expr_if(*) => { false }
......@@ -194,7 +192,7 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
}
}
fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
match t {
ast::ty_infer => { false } // always implicit, always top level
ast::ty_bot => { false } // in source, can only appear
......@@ -205,8 +203,8 @@ fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
}
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
fn replace_expr_in_crate(crate: ast::crate, i: uint,
newexpr: ast::expr, tm: test_mode) ->
pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
newexpr: ast::expr, tm: test_mode) ->
ast::crate {
let j: @mut uint = @mut 0u;
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
......@@ -233,8 +231,8 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint,
// Replace the |i|th ty (in fold order) of |crate| with |newty|.
fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
tm: test_mode) -> ast::crate {
pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
tm: test_mode) -> ast::crate {
let j: @mut uint = @mut 0u;
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
original: ast::ty_, fld: fold::ast_fold,
......@@ -254,17 +252,17 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
*crate2
}
fn under(n: uint, it: fn(uint)) {
pub fn under(n: uint, it: fn(uint)) {
let mut i: uint = 0u;
while i < n { it(i); i += 1u; }
}
fn as_str(f: fn@(+x: io::Writer)) -> ~str {
pub fn as_str(f: fn@(+x: io::Writer)) -> ~str {
io::with_str_writer(f)
}
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
filename: &Path, cx: Context) {
pub fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
filename: &Path, cx: Context) {
let stolen = steal(crate, cx.mode);
let extra_exprs = do common_exprs().filtered |a| {
safe_to_use_expr(*a, cx.mode)
......@@ -276,7 +274,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
pprust::ty_to_str, replace_ty_in_crate, cx);
}
fn check_variants_T<T: Copy>(
pub fn check_variants_T<T: Copy>(
crate: ast::crate,
codemap: @codemap::CodeMap,
filename: &Path,
......@@ -334,12 +332,12 @@ fn check_variants_T<T: Copy>(
}
}
fn last_part(filename: ~str) -> ~str {
pub fn last_part(filename: ~str) -> ~str {
let ix = option::get(str::rfind_char(filename, '/'));
str::slice(filename, ix + 1u, str::len(filename) - 3u)
}
enum happiness {
pub enum happiness {
passed,
cleanly_rejected(~str),
known_bug(~str),
......@@ -351,8 +349,8 @@ enum happiness {
// - that would be tricky, requiring use of tasks or serialization
// or randomness.
// This seems to find plenty of bugs as it is :)
fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
allow_running: bool) {
pub fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
allow_running: bool) {
let filename = &suggested_filename_prefix.with_filetype("rs");
write_file(filename, code);
......@@ -376,19 +374,19 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
}
}
fn removeIfExists(filename: &Path) {
pub fn removeIfExists(filename: &Path) {
// So sketchy!
assert !contains(filename.to_str(), ~" ");
run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]);
}
fn removeDirIfExists(filename: &Path) {
pub fn removeDirIfExists(filename: &Path) {
// So sketchy!
assert !contains(filename.to_str(), ~" ");
run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]);
}
fn check_running(exe_filename: &Path) -> happiness {
pub fn check_running(exe_filename: &Path) -> happiness {
let p = run::program_output(
~"/Users/jruderman/scripts/timed_run_rust_program.py",
~[exe_filename.to_str()]);
......@@ -427,7 +425,7 @@ fn check_running(exe_filename: &Path) -> happiness {
}
}
fn check_compiling(filename: &Path) -> happiness {
pub fn check_compiling(filename: &Path) -> happiness {
let p = run::program_output(
~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
stage1/bin/rustc",
......@@ -460,7 +458,7 @@ fn check_compiling(filename: &Path) -> happiness {
}
fn parse_and_print(code: @~str) -> ~str {
pub fn parse_and_print(code: @~str) -> ~str {
let filename = Path("tmp.rs");
let sess = parse::new_parse_sess(option::None);
write_file(&filename, *code);
......@@ -481,7 +479,7 @@ fn parse_and_print(code: @~str) -> ~str {
}
}
fn has_raw_pointers(c: ast::crate) -> bool {
pub fn has_raw_pointers(c: ast::crate) -> bool {
let has_rp = @mut false;
fn visit_ty(flag: @mut bool, t: @ast::Ty) {
match t.node {
......@@ -497,7 +495,7 @@ fn has_raw_pointers(c: ast::crate) -> bool {
return *has_rp;
}
fn content_is_dangerous_to_run(code: ~str) -> bool {
pub fn content_is_dangerous_to_run(code: ~str) -> bool {
let dangerous_patterns =
~[~"xfail-test",
~"import", // espeically fs, run
......@@ -509,7 +507,7 @@ fn content_is_dangerous_to_run(code: ~str) -> bool {
return false;
}
fn content_is_dangerous_to_compile(code: ~str) -> bool {
pub fn content_is_dangerous_to_compile(code: ~str) -> bool {
let dangerous_patterns =
~[~"xfail-test"];
......@@ -517,7 +515,7 @@ fn content_is_dangerous_to_compile(code: ~str) -> bool {
return false;
}
fn content_might_not_converge(code: ~str) -> bool {
pub fn content_might_not_converge(code: ~str) -> bool {
let confusing_patterns =
~[~"xfail-test",
~"xfail-pretty",
......@@ -533,7 +531,7 @@ fn content_might_not_converge(code: ~str) -> bool {
return false;
}
fn file_might_not_converge(filename: &Path) -> bool {
pub fn file_might_not_converge(filename: &Path) -> bool {
let confusing_files = ~[
~"expr-alt.rs", // pretty-printing "(a = b) = c"
// vs "a = b = c" and wrapping
......@@ -552,7 +550,7 @@ fn file_might_not_converge(filename: &Path) -> bool {
return false;
}
fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
let mut i = 0u;
let mut newv = code;
......@@ -579,7 +577,7 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
}
}
fn check_convergence(files: &[Path]) {
pub fn check_convergence(files: &[Path]) {
error!("pp convergence tests: %u files", vec::len(files));
for files.each |file| {
if !file_might_not_converge(file) {
......@@ -594,7 +592,7 @@ fn check_convergence(files: &[Path]) {
}
}
fn check_variants(files: &[Path], cx: Context) {
pub fn check_variants(files: &[Path], cx: Context) {
for files.each |file| {
if cx.mode == tm_converge &&
file_might_not_converge(file) {
......@@ -639,7 +637,7 @@ fn check_variants(files: &[Path], cx: Context) {
}
}
fn main() {
pub fn main() {
let args = os::args();
if vec::len(args) != 2u {
error!("usage: %s <testdir>", args[0]);
......
......@@ -75,7 +75,6 @@ fn take_my_order_please(
}
mod fortress_of_solitude {
#[legacy_exports];
/*!
* Superman's vacation home
*
......@@ -90,7 +89,6 @@ mod fortress_of_solitude {
}
mod blade_runner {
#[legacy_exports];
/*!
* Blade Runner is probably the best movie ever
*
......
......@@ -343,8 +343,6 @@ fn should_extract_struct_fields() {
#[cfg(test)]
mod test {
#[legacy_exports];
use astsrv;
use doc;
use extract::{extract, from_srv};
......@@ -352,20 +350,20 @@ mod test {
use core::vec;
fn mk_doc(+source: ~str) -> doc::Doc {
pub fn mk_doc(+source: ~str) -> doc::Doc {
let ast = parse::from_str(source);
extract(ast, ~"")
}
#[test]
fn extract_empty_crate() {
pub fn extract_empty_crate() {
let doc = mk_doc(~"");
assert vec::is_empty(doc.cratemod().mods());
assert vec::is_empty(doc.cratemod().fns());
}
#[test]
fn extract_mods() {
pub fn extract_mods() {
let doc = mk_doc(~"mod a { mod b { } mod c { } }");
assert doc.cratemod().mods()[0].name() == ~"a";
assert doc.cratemod().mods()[0].mods()[0].name() == ~"b";
......@@ -373,47 +371,47 @@ fn extract_mods() {
}
#[test]
fn extract_foreign_mods() {
pub fn extract_foreign_mods() {
let doc = mk_doc(~"extern mod a { }");
assert doc.cratemod().nmods()[0].name() == ~"a";
}
#[test]
fn extract_fns_from_foreign_mods() {
pub fn extract_fns_from_foreign_mods() {
let doc = mk_doc(~"extern mod a { fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].name() == ~"a";
}
#[test]
fn extract_mods_deep() {
pub fn extract_mods_deep() {
let doc = mk_doc(~"mod a { mod b { mod c { } } }");
assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c";
}
#[test]
fn extract_should_set_mod_ast_id() {
pub fn extract_should_set_mod_ast_id() {
let doc = mk_doc(~"mod a { }");
assert doc.cratemod().mods()[0].id() != 0;
}
#[test]
fn extract_fns() {
pub fn extract_fns() {
let doc = mk_doc(
~"fn a() { } \
mod b {
#[legacy_exports]; fn c() { } }");
} }");
assert doc.cratemod().fns()[0].name() == ~"a";
assert doc.cratemod().mods()[0].fns()[0].name() == ~"c";
}
#[test]
fn extract_should_set_fn_ast_id() {
pub fn extract_should_set_fn_ast_id() {
let doc = mk_doc(~"fn a() { }");
assert doc.cratemod().fns()[0].id() != 0;
}
#[test]
fn extract_should_use_default_crate_name() {
pub fn extract_should_use_default_crate_name() {
let source = ~"";
let ast = parse::from_str(source);
let doc = extract(ast, ~"burp");
......@@ -421,7 +419,7 @@ fn extract_should_use_default_crate_name() {
}
#[test]
fn extract_from_seq_srv() {
pub fn extract_from_seq_srv() {
let source = ~"";
do astsrv::from_str(source) |srv| {
let doc = from_srv(srv, ~"name");
......
......@@ -96,7 +96,7 @@ fn should_write_modules_last() {
~"mod a { }\
fn b() { }\
mod c {
#[legacy_exports]; }\
}\
fn d() { }"
);
......@@ -371,7 +371,7 @@ fn should_write_sections() {
# Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert str::contains(markdown, ~"#### Header\n\nBody\n\n");
}
......@@ -832,8 +832,6 @@ fn should_write_struct_header() {
#[cfg(test)]
mod test {
#[legacy_exports];
use astsrv;
use attr_pass;
use config;
......@@ -853,14 +851,14 @@ mod test {
use core::path::Path;
use core::str;
fn render(+source: ~str) -> ~str {
pub fn render(+source: ~str) -> ~str {
let (srv, doc) = create_doc_srv(source);
let markdown = write_markdown_str_srv(srv, doc);
debug!("markdown: %s", markdown);
markdown
}
fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) {
pub fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) {
do astsrv::from_str(source) |srv| {
let config = config::Config {
......@@ -890,12 +888,12 @@ fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) {
}
}
fn create_doc(+source: ~str) -> doc::Doc {
pub fn create_doc(+source: ~str) -> doc::Doc {
let (_, doc) = create_doc_srv(source);
doc
}
fn write_markdown_str(
pub fn write_markdown_str(
+doc: doc::Doc
) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory();
......@@ -903,7 +901,7 @@ fn write_markdown_str(
return oldcomm::recv(po).second();
}
fn write_markdown_str_srv(
pub fn write_markdown_str_srv(
srv: astsrv::Srv,
+doc: doc::Doc
) -> ~str {
......@@ -914,13 +912,13 @@ fn write_markdown_str_srv(
}
#[test]
fn write_markdown_should_write_mod_headers() {
pub fn write_markdown_should_write_mod_headers() {
let markdown = render(~"mod moo { }");
assert str::contains(markdown, ~"# Module `moo`");
}
#[test]
fn should_leave_blank_line_after_header() {
pub fn should_leave_blank_line_after_header() {
let markdown = render(~"mod morp { }");
assert str::contains(markdown, ~"Module `morp`\n\n");
}
......
......@@ -272,14 +272,12 @@ fn should_name_mod_file_names_by_path() {
#[cfg(test)]
mod test {
#[legacy_exports];
use astsrv;
use doc;
use extract;
use path_pass;
fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc {
pub fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc {
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv, name);
let doc = (path_pass::mk_pass().f)(srv, doc);
......
......@@ -10,8 +10,6 @@
//! Prune things that are private
#[legacy_exports];
use core::prelude::*;
use astsrv;
......@@ -24,10 +22,7 @@
use core::vec;
use syntax::ast;
export mk_pass;
export run;
fn mk_pass() -> Pass {
pub fn mk_pass() -> Pass {
Pass {
name: ~"prune_private",
f: run
......
......@@ -171,7 +171,7 @@ fn should_create_section_headers() {
# Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert str::contains(
doc.cratemod().mods()[0].item.sections[0].header,
~"Header");
......@@ -184,7 +184,7 @@ fn should_create_section_bodies() {
# Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert str::contains(
doc.cratemod().mods()[0].item.sections[0].body,
~"Body");
......@@ -197,7 +197,7 @@ fn should_not_create_sections_from_indented_headers() {
Text\n # Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert vec::is_empty(doc.cratemod().mods()[0].item.sections);
}
......@@ -209,7 +209,7 @@ fn should_remove_section_text_from_main_desc() {
# Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert !str::contains(
doc.cratemod().mods()[0].desc().get(),
~"Header");
......@@ -225,7 +225,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() {
# Header\n\
Body\"]\
mod a {
#[legacy_exports]; }");
}");
assert doc.cratemod().mods()[0].desc() == None;
}
......
......@@ -46,7 +46,7 @@ fn test() {
let source =
~"mod imod { } \
extern mod inmod {
#[legacy_exports]; } \
} \
const iconst: int = 0; \
fn ifn() { } \
enum ienum { ivar } \
......
......@@ -31,7 +31,7 @@ pub fn mk_pass() -> Pass {
fn should_trim_text() {
let doc = test::mk_doc(~"#[doc = \" desc \"] \
mod m {
#[legacy_exports]; }");
}");
assert doc.cratemod().mods()[0].desc() == Some(~"desc");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册