diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-02 15:34:58 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-02 22:11:42 -0700 |
| commit | 5c49e4f4e92997869de1f75f9089c9db7e7a6ebe (patch) | |
| tree | 947f6d58da06e589a0ab0627319917a9d2352a8c /src/test/stdtest | |
| parent | b5f905342337a3dc12bdc5dc6d98d3ecdf60439d (diff) | |
| download | rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.tar.gz rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.zip | |
Reformat. Issue #855
Diffstat (limited to 'src/test/stdtest')
| -rw-r--r-- | src/test/stdtest/comm.rs | 5 | ||||
| -rw-r--r-- | src/test/stdtest/fs.rs | 22 | ||||
| -rw-r--r-- | src/test/stdtest/getopts.rs | 223 | ||||
| -rw-r--r-- | src/test/stdtest/int.rs | 10 | ||||
| -rw-r--r-- | src/test/stdtest/io.rs | 6 | ||||
| -rw-r--r-- | src/test/stdtest/map.rs | 144 | ||||
| -rw-r--r-- | src/test/stdtest/net.rs | 6 | ||||
| -rw-r--r-- | src/test/stdtest/os.rs | 18 | ||||
| -rw-r--r-- | src/test/stdtest/path.rs | 8 | ||||
| -rw-r--r-- | src/test/stdtest/qsort.rs | 4 | ||||
| -rw-r--r-- | src/test/stdtest/run.rs | 17 | ||||
| -rw-r--r-- | src/test/stdtest/sha1.rs | 18 | ||||
| -rw-r--r-- | src/test/stdtest/str.rs | 279 | ||||
| -rw-r--r-- | src/test/stdtest/sys.rs | 4 | ||||
| -rw-r--r-- | src/test/stdtest/task.rs | 6 | ||||
| -rw-r--r-- | src/test/stdtest/test.rs | 46 | ||||
| -rw-r--r-- | src/test/stdtest/treemap.rs | 41 | ||||
| -rw-r--r-- | src/test/stdtest/vec.rs | 4 |
18 files changed, 409 insertions, 452 deletions
diff --git a/src/test/stdtest/comm.rs b/src/test/stdtest/comm.rs index 1fafd1a0375..9c31c5e6f72 100644 --- a/src/test/stdtest/comm.rs +++ b/src/test/stdtest/comm.rs @@ -2,10 +2,7 @@ use std; import std::comm; #[test] -fn create_port_and_chan() { - let p = comm::port::<int>(); - comm::chan(p); -} +fn create_port_and_chan() { let p = comm::port::<int>(); comm::chan(p); } #[test] fn send_recv_fn() { diff --git a/src/test/stdtest/fs.rs b/src/test/stdtest/fs.rs index f2e49232800..36e8ae23c5d 100644 --- a/src/test/stdtest/fs.rs +++ b/src/test/stdtest/fs.rs @@ -5,28 +5,26 @@ import std::fs; #[test] fn test_connect() { let slash = fs::path_sep(); - log_err fs::connect(~"a", ~"b"); - assert (fs::connect(~"a", ~"b") == ~"a" + slash + ~"b"); - assert (fs::connect(~"a" + slash, ~"b") == ~"a" + slash + ~"b"); + log_err fs::connect("a", "b"); + assert (fs::connect("a", "b") == "a" + slash + "b"); + assert (fs::connect("a" + slash, "b") == "a" + slash + "b"); } // Issue #712 #[test] -fn test_list_dir_no_invalid_memory_access() { fs::list_dir(~"."); } +fn test_list_dir_no_invalid_memory_access() { fs::list_dir("."); } #[test] fn list_dir() { - let dirs = fs::list_dir(~"."); + let dirs = fs::list_dir("."); // Just assuming that we've got some contents in the current directory - assert std::vec::len(dirs) > 0u; + assert (std::vec::len(dirs) > 0u); - for dir in dirs { - log dir; - } + for dir in dirs { log dir; } } #[test] fn file_is_dir() { - assert fs::file_is_dir(~"."); - assert !fs::file_is_dir(~"test/stdtest/fs.rs"); -} \ No newline at end of file + assert (fs::file_is_dir(".")); + assert (!fs::file_is_dir("test/stdtest/fs.rs")); +} diff --git a/src/test/stdtest/getopts.rs b/src/test/stdtest/getopts.rs index 332ec484c95..55d67729129 100644 --- a/src/test/stdtest/getopts.rs +++ b/src/test/stdtest/getopts.rs @@ -27,13 +27,13 @@ fn check_fail_type(f: opt::fail_, ft: fail_type) { // Tests for reqopt #[test] fn test_reqopt_long() { - let args = [~"--test=20"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test=20"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -41,8 +41,8 @@ fn test_reqopt_long() { #[test] fn test_reqopt_long_missing() { - let args = [~"blah"]; - let opts = [opt::reqopt(~"test")]; + let args = ["blah"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_missing); } @@ -52,8 +52,8 @@ fn test_reqopt_long_missing() { #[test] fn test_reqopt_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -63,8 +63,8 @@ fn test_reqopt_long_no_arg() { #[test] fn test_reqopt_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -74,13 +74,13 @@ fn test_reqopt_long_multi() { #[test] fn test_reqopt_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -88,8 +88,8 @@ fn test_reqopt_short() { #[test] fn test_reqopt_short_missing() { - let args = [~"blah"]; - let opts = [opt::reqopt(~"t")]; + let args = ["blah"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_missing); } @@ -99,8 +99,8 @@ fn test_reqopt_short_missing() { #[test] fn test_reqopt_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -110,8 +110,8 @@ fn test_reqopt_short_no_arg() { #[test] fn test_reqopt_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -123,13 +123,13 @@ fn test_reqopt_short_multi() { // Tests for optopt #[test] fn test_optopt_long() { - let args = [~"--test=20"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -137,19 +137,19 @@ fn test_optopt_long() { #[test] fn test_optopt_long_missing() { - let args = [~"blah"]; - let opts = [opt::optopt(~"test")]; + let args = ["blah"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optopt_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -159,8 +159,8 @@ fn test_optopt_long_no_arg() { #[test] fn test_optopt_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -170,13 +170,13 @@ fn test_optopt_long_multi() { #[test] fn test_optopt_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -184,19 +184,19 @@ fn test_optopt_short() { #[test] fn test_optopt_short_missing() { - let args = [~"blah"]; - let opts = [opt::optopt(~"t")]; + let args = ["blah"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optopt_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -206,8 +206,8 @@ fn test_optopt_short_no_arg() { #[test] fn test_optopt_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -219,30 +219,30 @@ fn test_optopt_short_multi() { // Tests for optflag #[test] fn test_optflag_long() { - let args = [~"--test"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (opt::opt_present(m, ~"test")); } + opt::success(m) { assert (opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optflag_long_missing() { - let args = [~"blah"]; - let opts = [opt::optflag(~"test")]; + let args = ["blah"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optflag_long_arg() { - let args = [~"--test=20"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { @@ -255,8 +255,8 @@ fn test_optflag_long_arg() { #[test] fn test_optflag_long_multi() { - let args = [~"--test", ~"--test"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test", "--test"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -266,36 +266,36 @@ fn test_optflag_long_multi() { #[test] fn test_optflag_short() { - let args = [~"-t"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (opt::opt_present(m, ~"t")); } + opt::success(m) { assert (opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optflag_short_missing() { - let args = [~"blah"]; - let opts = [opt::optflag(~"t")]; + let args = ["blah"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optflag_short_arg() { - let args = [~"-t", ~"20"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { // The next variable after the flag is just a free argument - assert (m.free[0] == ~"20"); + assert (m.free[0] == "20"); } _ { fail; } } @@ -303,8 +303,8 @@ fn test_optflag_short_arg() { #[test] fn test_optflag_short_multi() { - let args = [~"-t", ~"-t"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t", "-t"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -316,13 +316,13 @@ fn test_optflag_short_multi() { // Tests for optmulti #[test] fn test_optmulti_long() { - let args = [~"--test=20"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -330,19 +330,19 @@ fn test_optmulti_long() { #[test] fn test_optmulti_long_missing() { - let args = [~"blah"]; - let opts = [opt::optmulti(~"test")]; + let args = ["blah"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optmulti_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -352,15 +352,15 @@ fn test_optmulti_long_no_arg() { #[test] fn test_optmulti_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); - assert (opt::opt_strs(m, ~"test")[0] == ~"20"); - assert (opt::opt_strs(m, ~"test")[1] == ~"30"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); + assert (opt::opt_strs(m, "test")[0] == "20"); + assert (opt::opt_strs(m, "test")[1] == "30"); } _ { fail; } } @@ -368,13 +368,13 @@ fn test_optmulti_long_multi() { #[test] fn test_optmulti_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -382,19 +382,19 @@ fn test_optmulti_short() { #[test] fn test_optmulti_short_missing() { - let args = [~"blah"]; - let opts = [opt::optmulti(~"t")]; + let args = ["blah"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optmulti_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -404,15 +404,15 @@ fn test_optmulti_short_no_arg() { #[test] fn test_optmulti_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); - assert (opt::opt_strs(m, ~"t")[0] == ~"20"); - assert (opt::opt_strs(m, ~"t")[1] == ~"30"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); + assert (opt::opt_strs(m, "t")[0] == "20"); + assert (opt::opt_strs(m, "t")[1] == "30"); } _ { fail; } } @@ -420,8 +420,8 @@ fn test_optmulti_short_multi() { #[test] fn test_unrecognized_option_long() { - let args = [~"--untest"]; - let opts = [opt::optmulti(~"t")]; + let args = ["--untest"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, unrecognized_option); } @@ -431,8 +431,8 @@ fn test_unrecognized_option_long() { #[test] fn test_unrecognized_option_short() { - let args = [~"-t"]; - let opts = [opt::optmulti(~"test")]; + let args = ["-t"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, unrecognized_option); } @@ -443,25 +443,24 @@ fn test_unrecognized_option_short() { #[test] fn test_combined() { let args = - [~"prog", ~"free1", ~"-s", ~"20", ~"free2", ~"--flag", - ~"--long=30", ~"-f", ~"-m", ~"40", ~"-m", ~"50"]; + ["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f", + "-m", "40", "-m", "50"]; let opts = - [opt::optopt(~"s"), opt::optflag(~"flag"), opt::reqopt(~"long"), - opt::optflag(~"f"), opt::optmulti(~"m"), - opt::optopt(~"notpresent")]; + [opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"), + opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (m.free[0] == ~"prog"); - assert (m.free[1] == ~"free1"); - assert (opt::opt_str(m, ~"s") == ~"20"); - assert (m.free[2] == ~"free2"); - assert (opt::opt_present(m, ~"flag")); - assert (opt::opt_str(m, ~"long") == ~"30"); - assert (opt::opt_present(m, ~"f")); - assert (opt::opt_strs(m, ~"m")[0] == ~"40"); - assert (opt::opt_strs(m, ~"m")[1] == ~"50"); - assert (!opt::opt_present(m, ~"notpresent")); + assert (m.free[0] == "prog"); + assert (m.free[1] == "free1"); + assert (opt::opt_str(m, "s") == "20"); + assert (m.free[2] == "free2"); + assert (opt::opt_present(m, "flag")); + assert (opt::opt_str(m, "long") == "30"); + assert (opt::opt_present(m, "f")); + assert (opt::opt_strs(m, "m")[0] == "40"); + assert (opt::opt_strs(m, "m")[1] == "50"); + assert (!opt::opt_present(m, "notpresent")); } _ { fail; } } diff --git a/src/test/stdtest/int.rs b/src/test/stdtest/int.rs index bc13e248d0b..61d3448a175 100644 --- a/src/test/stdtest/int.rs +++ b/src/test/stdtest/int.rs @@ -5,11 +5,11 @@ import std::str::eq; #[test] fn test_to_str() { - assert (eq(int::to_str(0, 10u), ~"0")); - assert (eq(int::to_str(1, 10u), ~"1")); - assert (eq(int::to_str(-1, 10u), ~"-1")); - assert (eq(int::to_str(255, 16u), ~"ff")); - assert (eq(int::to_str(100, 10u), ~"100")); + assert (eq(int::to_str(0, 10u), "0")); + assert (eq(int::to_str(1, 10u), "1")); + assert (eq(int::to_str(-1, 10u), "-1")); + assert (eq(int::to_str(255, 16u), "ff")); + assert (eq(int::to_str(100, 10u), "100")); } #[test] diff --git a/src/test/stdtest/io.rs b/src/test/stdtest/io.rs index a66b3bab464..08330c619fc 100644 --- a/src/test/stdtest/io.rs +++ b/src/test/stdtest/io.rs @@ -7,9 +7,9 @@ import std::str; #[cfg(target_os = "win32")] #[test] fn test_simple() { - let tmpfile: istr = ~"test/run-pass/lib-io-test-simple.tmp"; + let tmpfile: str = "test/run-pass/lib-io-test-simple.tmp"; log tmpfile; - let frood: istr = ~"A hoopy frood who really knows where his towel is."; + let frood: str = "A hoopy frood who really knows where his towel is."; log frood; { let out: io::writer = @@ -17,7 +17,7 @@ fn test_simple() { out.write_str(frood); } let inp: io::reader = io::file_reader(tmpfile); - let frood2: istr = inp.read_c_str(); + let frood2: str = inp.read_c_str(); log frood2; assert (str::eq(frood, frood2)); } diff --git a/src/test/stdtest/map.rs b/src/test/stdtest/map.rs index 585bae03cc9..67240a7c69b 100644 --- a/src/test/stdtest/map.rs +++ b/src/test/stdtest/map.rs @@ -14,8 +14,8 @@ fn test_simple() { fn eq_uint(x: &uint, y: &uint) -> bool { ret x == y; } let hasher_uint: map::hashfn<uint> = util::id; let eqer_uint: map::eqfn<uint> = eq_uint; - let hasher_str: map::hashfn<istr> = str::hash; - let eqer_str: map::eqfn<istr> = str::eq; + let hasher_str: map::hashfn<str> = str::hash; + let eqer_str: map::eqfn<str> = str::eq; log "uint -> uint"; let hm_uu: map::hashmap<uint, uint> = map::mk_hashmap::<uint, uint>(hasher_uint, eqer_uint); @@ -29,49 +29,49 @@ fn test_simple() { assert (hm_uu.get(12u) == 14u); assert (!hm_uu.insert(12u, 12u)); assert (hm_uu.get(12u) == 12u); - let ten: istr = ~"ten"; - let eleven: istr = ~"eleven"; - let twelve: istr = ~"twelve"; + let ten: str = "ten"; + let eleven: str = "eleven"; + let twelve: str = "twelve"; log "str -> uint"; - let hm_su: map::hashmap<istr, uint> = - map::mk_hashmap::<istr, uint>(hasher_str, eqer_str); - assert (hm_su.insert(~"ten", 12u)); + let hm_su: map::hashmap<str, uint> = + map::mk_hashmap::<str, uint>(hasher_str, eqer_str); + assert (hm_su.insert("ten", 12u)); assert (hm_su.insert(eleven, 13u)); - assert (hm_su.insert(~"twelve", 14u)); + assert (hm_su.insert("twelve", 14u)); assert (hm_su.get(eleven) == 13u); - assert (hm_su.get(~"eleven") == 13u); - assert (hm_su.get(~"twelve") == 14u); - assert (hm_su.get(~"ten") == 12u); - assert (!hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(~"twelve") == 14u); - assert (!hm_su.insert(~"twelve", 12u)); - assert (hm_su.get(~"twelve") == 12u); + assert (hm_su.get("eleven") == 13u); + assert (hm_su.get("twelve") == 14u); + assert (hm_su.get("ten") == 12u); + assert (!hm_su.insert("twelve", 14u)); + assert (hm_su.get("twelve") == 14u); + assert (!hm_su.insert("twelve", 12u)); + assert (hm_su.get("twelve") == 12u); log "uint -> str"; - let hm_us: map::hashmap<uint, istr> = - map::mk_hashmap::<uint, istr>(hasher_uint, eqer_uint); - assert (hm_us.insert(10u, ~"twelve")); - assert (hm_us.insert(11u, ~"thirteen")); - assert (hm_us.insert(12u, ~"fourteen")); - assert (str::eq(hm_us.get(11u), ~"thirteen")); - assert (str::eq(hm_us.get(12u), ~"fourteen")); - assert (str::eq(hm_us.get(10u), ~"twelve")); - assert (!hm_us.insert(12u, ~"fourteen")); - assert (str::eq(hm_us.get(12u), ~"fourteen")); - assert (!hm_us.insert(12u, ~"twelve")); - assert (str::eq(hm_us.get(12u), ~"twelve")); + let hm_us: map::hashmap<uint, str> = + map::mk_hashmap::<uint, str>(hasher_uint, eqer_uint); + assert (hm_us.insert(10u, "twelve")); + assert (hm_us.insert(11u, "thirteen")); + assert (hm_us.insert(12u, "fourteen")); + assert (str::eq(hm_us.get(11u), "thirteen")); + assert (str::eq(hm_us.get(12u), "fourteen")); + assert (str::eq(hm_us.get(10u), "twelve")); + assert (!hm_us.insert(12u, "fourteen")); + assert (str::eq(hm_us.get(12u), "fourteen")); + assert (!hm_us.insert(12u, "twelve")); + assert (str::eq(hm_us.get(12u), "twelve")); log "str -> str"; - let hm_ss: map::hashmap<istr, istr> = - map::mk_hashmap::<istr, istr>(hasher_str, eqer_str); - assert (hm_ss.insert(ten, ~"twelve")); - assert (hm_ss.insert(eleven, ~"thirteen")); - assert (hm_ss.insert(twelve, ~"fourteen")); - assert (str::eq(hm_ss.get(~"eleven"), ~"thirteen")); - assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); - assert (str::eq(hm_ss.get(~"ten"), ~"twelve")); - assert (!hm_ss.insert(~"twelve", ~"fourteen")); - assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); - assert (!hm_ss.insert(~"twelve", ~"twelve")); - assert (str::eq(hm_ss.get(~"twelve"), ~"twelve")); + let hm_ss: map::hashmap<str, str> = + map::mk_hashmap::<str, str>(hasher_str, eqer_str); + assert (hm_ss.insert(ten, "twelve")); + assert (hm_ss.insert(eleven, "thirteen")); + assert (hm_ss.insert(twelve, "fourteen")); + assert (str::eq(hm_ss.get("eleven"), "thirteen")); + assert (str::eq(hm_ss.get("twelve"), "fourteen")); + assert (str::eq(hm_ss.get("ten"), "twelve")); + assert (!hm_ss.insert("twelve", "fourteen")); + assert (str::eq(hm_ss.get("twelve"), "fourteen")); + assert (!hm_ss.insert("twelve", "twelve")); + assert (str::eq(hm_ss.get("twelve"), "twelve")); log "*** finished test_simple"; } @@ -92,14 +92,14 @@ fn test_growth() { let i: uint = 0u; while i < num_to_insert { assert (hm_uu.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 1u; } log "-----"; i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; @@ -110,44 +110,42 @@ fn test_growth() { hm_uu.rehash(); i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } log "str -> str"; - let hasher_str: map::hashfn<istr> = str::hash; - let eqer_str: map::eqfn<istr> = str::eq; - let hm_ss: map::hashmap<istr, istr> = - map::mk_hashmap::<istr, istr>(hasher_str, eqer_str); + let hasher_str: map::hashfn<str> = str::hash; + let eqer_str: map::eqfn<str> = str::eq; + let hm_ss: map::hashmap<str, str> = + map::mk_hashmap::<str, str>(hasher_str, eqer_str); i = 0u; while i < num_to_insert { - assert (hm_ss.insert(uint::to_str(i, 2u), - uint::to_str(i * i, 2u))); - log ~"inserting \"" + uint::to_str(i, 2u) + ~"\" -> \"" + - uint::to_str(i * i, 2u) + ~"\""; + assert (hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u))); + log "inserting \"" + uint::to_str(i, 2u) + "\" -> \"" + + uint::to_str(i * i, 2u) + "\""; i += 1u; } log "-----"; i = 0u; while i < num_to_insert { - log ~"get(\"" + uint::to_str(i, 2u) + ~"\") = \"" + - hm_ss.get(uint::to_str(i, 2u)) + ~"\""; + log "get(\"" + uint::to_str(i, 2u) + "\") = \"" + + hm_ss.get(uint::to_str(i, 2u)) + "\""; assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), uint::to_str(i * i, 2u))); i += 1u; } assert (hm_ss.insert(uint::to_str(num_to_insert, 2u), uint::to_str(17u, 2u))); - assert (str::eq(hm_ss.get( - uint::to_str(num_to_insert, 2u)), + assert (str::eq(hm_ss.get(uint::to_str(num_to_insert, 2u)), uint::to_str(17u, 2u))); log "-----"; hm_ss.rehash(); i = 0u; while i < num_to_insert { - log ~"get(\"" + uint::to_str(i, 2u) + ~"\") = \"" + - hm_ss.get(uint::to_str(i, 2u)) + ~"\""; + log "get(\"" + uint::to_str(i, 2u) + "\") = \"" + + hm_ss.get(uint::to_str(i, 2u)) + "\""; assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), uint::to_str(i * i, 2u))); i += 1u; @@ -176,7 +174,7 @@ fn test_removal() { let i: uint = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 1u; } @@ -186,10 +184,8 @@ fn test_removal() { i = 0u; while i < num_to_insert { let v = hm.remove(i); - alt (v) { - option::some(u) { - assert (u == (i * i)); - } + alt v { + option::some(u) { assert (u == i * i); } option::none. { fail; } } i += 2u; @@ -198,7 +194,7 @@ fn test_removal() { log "-----"; i = 1u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; @@ -209,7 +205,7 @@ fn test_removal() { log "-----"; i = 1u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; @@ -218,7 +214,7 @@ fn test_removal() { i = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 2u; } @@ -226,7 +222,7 @@ fn test_removal() { log "-----"; i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; @@ -238,7 +234,7 @@ fn test_removal() { assert (hm.size() == num_to_insert); i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; @@ -248,18 +244,18 @@ fn test_removal() { #[test] fn test_contains_key() { - let key = ~"k"; - let map = map::mk_hashmap::<istr, istr>(str::hash, str::eq); + let key = "k"; + let map = map::mk_hashmap::<str, str>(str::hash, str::eq); assert (!map.contains_key(key)); - map.insert(key, ~"val"); + map.insert(key, "val"); assert (map.contains_key(key)); } #[test] fn test_find() { - let key = ~"k"; - let map = map::mk_hashmap::<istr, istr>(str::hash, str::eq); + let key = "k"; + let map = map::mk_hashmap::<str, str>(str::hash, str::eq); assert (std::option::is_none(map.find(key))); - map.insert(key, ~"val"); - assert (std::option::get(map.find(key)) == ~"val"); + map.insert(key, "val"); + assert (std::option::get(map.find(key)) == "val"); } diff --git a/src/test/stdtest/net.rs b/src/test/stdtest/net.rs index d2f185a4fde..9da7a12a060 100644 --- a/src/test/stdtest/net.rs +++ b/src/test/stdtest/net.rs @@ -3,12 +3,10 @@ import std::net; #[test] fn test_format_ip() { - assert (net::format_addr(net::ipv4( - 127u8, 0u8, 0u8, 1u8)) == ~"127.0.0.1") + assert (net::format_addr(net::ipv4(127u8, 0u8, 0u8, 1u8)) == "127.0.0.1") } #[test] fn test_parse_ip() { - assert (net::parse_addr(~"127.0.0.1") - == net::ipv4(127u8, 0u8, 0u8, 1u8)); + assert (net::parse_addr("127.0.0.1") == net::ipv4(127u8, 0u8, 0u8, 1u8)); } diff --git a/src/test/stdtest/os.rs b/src/test/stdtest/os.rs index fc508595329..49ebb217dbf 100644 --- a/src/test/stdtest/os.rs +++ b/src/test/stdtest/os.rs @@ -6,26 +6,26 @@ import std::option; fn test_setenv() { // NB: Each test of setenv needs to use different variable names or the // tests will not be threadsafe - setenv(~"NAME1", ~"VALUE"); - assert (getenv(~"NAME1") == option::some(~"VALUE")); + setenv("NAME1", "VALUE"); + assert (getenv("NAME1") == option::some("VALUE")); } #[test] fn test_setenv_overwrite() { - setenv(~"NAME2", ~"1"); - setenv(~"NAME2", ~"2"); - assert (getenv(~"NAME2") == option::some(~"2")); + setenv("NAME2", "1"); + setenv("NAME2", "2"); + assert (getenv("NAME2") == option::some("2")); } // Windows GetEnvironmentVariable requires some extra work to make sure // the buffer the variable is copied into is the right size #[test] fn test_getenv_big() { - let s = ~""; + let s = ""; let i = 0; - while i < 100 { s += ~"aaaaaaaaaa"; i += 1; } - setenv(~"NAME3", s); - assert (getenv(~"NAME3") == option::some(s)); + while i < 100 { s += "aaaaaaaaaa"; i += 1; } + setenv("NAME3", s); + assert (getenv("NAME3") == option::some(s)); } // Local Variables: diff --git a/src/test/stdtest/path.rs b/src/test/stdtest/path.rs index 82fe54413d9..911bc6b0dd9 100644 --- a/src/test/stdtest/path.rs +++ b/src/test/stdtest/path.rs @@ -8,10 +8,10 @@ import std::os; #[test] fn test() { - assert (!fs::path_is_absolute(~"test-path")); + assert (!fs::path_is_absolute("test-path")); - log ~"Current working directory: " + os::getcwd(); + log "Current working directory: " + os::getcwd(); - log fs::make_absolute(~"test-path"); - log fs::make_absolute(~"/usr/bin"); + log fs::make_absolute("test-path"); + log fs::make_absolute("/usr/bin"); } diff --git a/src/test/stdtest/qsort.rs b/src/test/stdtest/qsort.rs index 32109dc1caa..609adf3afe4 100644 --- a/src/test/stdtest/qsort.rs +++ b/src/test/stdtest/qsort.rs @@ -51,8 +51,8 @@ fn test_simple() { let immut_names = vec::from_mut(names); - // Silly, but what else can we do? - check vec::same_length(expected, immut_names); + // Silly, but what else can we do? + check (vec::same_length(expected, immut_names)); let pairs = vec::zip(expected, immut_names); for (a, b) in pairs { log #fmt["%d %d", a, b]; assert (a == b); } } diff --git a/src/test/stdtest/run.rs b/src/test/stdtest/run.rs index 5c62ed3eb0e..b60a3935500 100644 --- a/src/test/stdtest/run.rs +++ b/src/test/stdtest/run.rs @@ -11,9 +11,9 @@ import std::vec; #[cfg(target_os = "macos")] #[test] fn test_leaks() { - run::run_program(~"echo", []); - run::start_program(~"echo", []); - run::program_output(~"echo", []); + run::run_program("echo", []); + run::start_program("echo", []); + run::program_output("echo", []); } // FIXME @@ -29,14 +29,13 @@ fn test_pipes() { let pipe_err = os::pipe(); let pid = - run::spawn_process(~"cat", [], - pipe_in.in, pipe_out.out, pipe_err.out); + run::spawn_process("cat", [], pipe_in.in, pipe_out.out, pipe_err.out); os::libc::close(pipe_in.in); os::libc::close(pipe_out.out); os::libc::close(pipe_err.out); if pid == -1 { fail; } - let expected = ~"test"; + let expected = "test"; writeclose(pipe_in.out, expected); let actual = readclose(pipe_out.in); readclose(pipe_err.in); @@ -46,18 +45,18 @@ fn test_pipes() { log actual; assert (expected == actual); - fn writeclose(fd: int, s: &istr) { + fn writeclose(fd: int, s: &str) { let writer = io::new_writer(io::fd_buf_writer(fd, option::none)); writer.write_str(s); os::libc::close(fd); } - fn readclose(fd: int) -> istr { + fn readclose(fd: int) -> str { // Copied from run::program_output let file = os::fd_FILE(fd); let reader = io::new_reader(io::FILE_buf_reader(file, option::none)); - let buf = ~""; + let buf = ""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::unsafe_from_bytes(bytes); diff --git a/src/test/stdtest/sha1.rs b/src/test/stdtest/sha1.rs index a66b898ddfa..6b72be20dd5 100644 --- a/src/test/stdtest/sha1.rs +++ b/src/test/stdtest/sha1.rs @@ -9,24 +9,24 @@ import std::str; #[test] fn test() { - type test = {input: istr, output: [u8]}; + type test = {input: str, output: [u8]}; - fn a_million_letter_a() -> istr { + fn a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaaaaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaaaaaaa"; i += 1; } ret rs; } // Test messages from FIPS 180-1 let fips_180_1_tests: [test] = - [{input: ~"abc", + [{input: "abc", output: [0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8, 0x06u8, 0x81u8, 0x6Au8, 0xBAu8, 0x3Eu8, 0x25u8, 0x71u8, 0x78u8, 0x50u8, 0xC2u8, 0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]}, - {input: ~"abcdbcdecdefdefgefghfghighij" - + ~"hijkijkljklmklmnlmnomnopnopq", + {input: + "abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq", output: [0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8, 0xE5u8, @@ -39,12 +39,12 @@ fn test() { // Examples from wikipedia let wikipedia_tests: [test] = - [{input: ~"The quick brown fox jumps over the lazy dog", + [{input: "The quick brown fox jumps over the lazy dog", output: [0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8, 0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8, 0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8, 0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8]}, - {input: ~"The quick brown fox jumps over the lazy cog", + {input: "The quick brown fox jumps over the lazy cog", output: [0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8, 0x5eu8, 0x1bu8, 0x3au8, 0xfau8, 0xd3u8, 0xe8u8, 0x5au8, 0x0bu8, 0xd1u8, 0x7du8, 0x9bu8, diff --git a/src/test/stdtest/str.rs b/src/test/stdtest/str.rs index a559b61d3f2..2852822f8d4 100644 --- a/src/test/stdtest/str.rs +++ b/src/test/stdtest/str.rs @@ -3,105 +3,103 @@ import std::vec; #[test] fn test_eq() { - assert str::eq(~"", ~""); - assert str::eq(~"foo", ~"foo"); - assert !str::eq(~"foo", ~"bar"); + assert (str::eq("", "")); + assert (str::eq("foo", "foo")); + assert (!str::eq("foo", "bar")); } #[test] fn test_lteq() { - assert str::lteq(~"", ~""); - assert str::lteq(~"", ~"foo"); - assert str::lteq(~"foo", ~"foo"); - assert !str::eq(~"foo", ~"bar"); + assert (str::lteq("", "")); + assert (str::lteq("", "foo")); + assert (str::lteq("foo", "foo")); + assert (!str::eq("foo", "bar")); } #[test] fn test_bytes_len() { - assert (str::byte_len(~"") == 0u); - assert (str::byte_len(~"hello world") == 11u); - assert (str::byte_len(~"\x63") == 1u); - assert (str::byte_len(~"\xa2") == 2u); - assert (str::byte_len(~"\u03c0") == 2u); - assert (str::byte_len(~"\u2620") == 3u); - assert (str::byte_len(~"\U0001d11e") == 4u); + assert (str::byte_len("") == 0u); + assert (str::byte_len("hello world") == 11u); + assert (str::byte_len("\x63") == 1u); + assert (str::byte_len("\xa2") == 2u); + assert (str::byte_len("\u03c0") == 2u); + assert (str::byte_len("\u2620") == 3u); + assert (str::byte_len("\U0001d11e") == 4u); } #[test] fn test_index_and_rindex() { - assert (str::index(~"hello", 'e' as u8) == 1); - assert (str::index(~"hello", 'o' as u8) == 4); - assert (str::index(~"hello", 'z' as u8) == -1); - assert (str::rindex(~"hello", 'l' as u8) == 3); - assert (str::rindex(~"hello", 'h' as u8) == 0); - assert (str::rindex(~"hello", 'z' as u8) == -1); + assert (str::index("hello", 'e' as u8) == 1); + assert (str::index("hello", 'o' as u8) == 4); + assert (str::index("hello", 'z' as u8) == -1); + assert (str::rindex("hello", 'l' as u8) == 3); + assert (str::rindex("hello", 'h' as u8) == 0); + assert (str::rindex("hello", 'z' as u8) == -1); } #[test] fn test_split() { - fn t(s: &istr, c: char, i: int, k: &istr) { - log ~"splitting: " + s; + fn t(s: &str, c: char, i: int, k: &str) { + log "splitting: " + s; log i; let v = str::split(s, c as u8); - log ~"split to: "; - for z: istr in v { log z; } - log ~"comparing: " + v[i] + ~" vs. " + k; + log "split to: "; + for z: str in v { log z; } + log "comparing: " + v[i] + " vs. " + k; assert (str::eq(v[i], k)); } - t(~"abc.hello.there", '.', 0, ~"abc"); - t(~"abc.hello.there", '.', 1, ~"hello"); - t(~"abc.hello.there", '.', 2, ~"there"); - t(~".hello.there", '.', 0, ~""); - t(~".hello.there", '.', 1, ~"hello"); - t(~"...hello.there.", '.', 3, ~"hello"); - t(~"...hello.there.", '.', 5, ~""); + t("abc.hello.there", '.', 0, "abc"); + t("abc.hello.there", '.', 1, "hello"); + t("abc.hello.there", '.', 2, "there"); + t(".hello.there", '.', 0, ""); + t(".hello.there", '.', 1, "hello"); + t("...hello.there.", '.', 3, "hello"); + t("...hello.there.", '.', 5, ""); } #[test] fn test_find() { - fn t(haystack: &istr, needle: &istr, i: int) { + fn t(haystack: &str, needle: &str, i: int) { let j: int = str::find(haystack, needle); - log ~"searched for " + needle; + log "searched for " + needle; log j; assert (i == j); } - t(~"this is a simple", ~"is a", 5); - t(~"this is a simple", ~"is z", -1); - t(~"this is a simple", ~"", 0); - t(~"this is a simple", ~"simple", 10); - t(~"this", ~"simple", -1); + t("this is a simple", "is a", 5); + t("this is a simple", "is z", -1); + t("this is a simple", "", 0); + t("this is a simple", "simple", 10); + t("this", "simple", -1); } #[test] fn test_substr() { - fn t(a: &istr, b: &istr, start: int) { - assert (str::eq(str::substr(a, start as uint, - str::byte_len(b)), b)); + fn t(a: &str, b: &str, start: int) { + assert (str::eq(str::substr(a, start as uint, str::byte_len(b)), b)); } - t(~"hello", ~"llo", 2); - t(~"hello", ~"el", 1); - t(~"substr should not be a challenge", ~"not", 14); + t("hello", "llo", 2); + t("hello", "el", 1); + t("substr should not be a challenge", "not", 14); } #[test] fn test_concat() { - fn t(v: &[istr], s: &istr) { assert (str::eq(str::concat(v), s)); } - t([~"you", ~"know", ~"I'm", ~"no", ~"good"], ~"youknowI'mnogood"); - let v: [istr] = []; - t(v, ~""); - t([~"hi"], ~"hi"); + fn t(v: &[str], s: &str) { assert (str::eq(str::concat(v), s)); } + t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); + let v: [str] = []; + t(v, ""); + t(["hi"], "hi"); } #[test] fn test_connect() { - fn t(v: &[istr], sep: &istr, s: &istr) { + fn t(v: &[str], sep: &str, s: &str) { assert (str::eq(str::connect(v, sep), s)); } - t([~"you", ~"know", ~"I'm", ~"no", ~"good"], ~" ", - ~"you know I'm no good"); - let v: [istr] = []; - t(v, ~" ", ~""); - t([~"hi"], ~" ", ~"hi"); + t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); + let v: [str] = []; + t(v, " ", ""); + t(["hi"], " ", "hi"); } #[test] @@ -109,28 +107,28 @@ fn test_to_upper() { // to_upper doesn't understand unicode yet, // but we need to at least preserve it - let unicode = ~"\u65e5\u672c"; - let input = ~"abcDEF" + unicode + ~"xyz:.;"; - let expected = ~"ABCDEF" + unicode + ~"XYZ:.;"; + let unicode = "\u65e5\u672c"; + let input = "abcDEF" + unicode + "xyz:.;"; + let expected = "ABCDEF" + unicode + "XYZ:.;"; let actual = str::to_upper(input); assert (str::eq(expected, actual)); } #[test] fn test_slice() { - assert (str::eq(~"ab", str::slice(~"abc", 0u, 2u))); - assert (str::eq(~"bc", str::slice(~"abc", 1u, 3u))); - assert (str::eq(~"", str::slice(~"abc", 1u, 1u))); - fn a_million_letter_a() -> istr { + assert (str::eq("ab", str::slice("abc", 0u, 2u))); + assert (str::eq("bc", str::slice("abc", 1u, 3u))); + assert (str::eq("", str::slice("abc", 1u, 1u))); + fn a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaaaaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaaaaaaa"; i += 1; } ret rs; } - fn half_a_million_letter_a() -> istr { + fn half_a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaa"; i += 1; } ret rs; } assert (str::eq(half_a_million_letter_a(), @@ -139,123 +137,122 @@ fn test_slice() { #[test] fn test_starts_with() { - assert (str::starts_with(~"", ~"")); - assert (str::starts_with(~"abc", ~"")); - assert (str::starts_with(~"abc", ~"a")); - assert (!str::starts_with(~"a", ~"abc")); - assert (!str::starts_with(~"", ~"abc")); + assert (str::starts_with("", "")); + assert (str::starts_with("abc", "")); + assert (str::starts_with("abc", "a")); + assert (!str::starts_with("a", "abc")); + assert (!str::starts_with("", "abc")); } #[test] fn test_ends_with() { - assert (str::ends_with(~"", ~"")); - assert (str::ends_with(~"abc", ~"")); - assert (str::ends_with(~"abc", ~"c")); - assert (!str::ends_with(~"a", ~"abc")); - assert (!str::ends_with(~"", ~"abc")); + assert (str::ends_with("", "")); + assert (str::ends_with("abc", "")); + assert (str::ends_with("abc", "c")); + assert (!str::ends_with("a", "abc")); + assert (!str::ends_with("", "abc")); } #[test] fn test_is_empty() { - assert (str::is_empty(~"")); - assert (!str::is_empty(~"a")); + assert (str::is_empty("")); + assert (!str::is_empty("a")); } #[test] fn test_is_not_empty() { - assert (str::is_not_empty(~"a")); - assert (!str::is_not_empty(~"")); + assert (str::is_not_empty("a")); + assert (!str::is_not_empty("")); } #[test] fn test_replace() { - let a = ~"a"; + let a = "a"; check (str::is_not_empty(a)); - assert (str::replace(~"", a, ~"b") == ~""); - assert (str::replace(~"a", a, ~"b") == ~"b"); - assert (str::replace(~"ab", a, ~"b") == ~"bb"); - let test = ~"test"; + assert (str::replace("", a, "b") == ""); + assert (str::replace("a", a, "b") == "b"); + assert (str::replace("ab", a, "b") == "bb"); + let test = "test"; check (str::is_not_empty(test)); - assert (str::replace(~" test test ", test, ~"toast") - == ~" toast toast "); - assert (str::replace(~" test test ", test, ~"") == ~" "); + assert (str::replace(" test test ", test, "toast") == " toast toast "); + assert (str::replace(" test test ", test, "") == " "); } #[test] fn test_char_slice() { - assert (str::eq(~"ab", str::char_slice(~"abc", 0u, 2u))); - assert (str::eq(~"bc", str::char_slice(~"abc", 1u, 3u))); - assert (str::eq(~"", str::char_slice(~"abc", 1u, 1u))); - assert (str::eq(~"\u65e5", str::char_slice(~"\u65e5\u672c", 0u, 1u))); + assert (str::eq("ab", str::char_slice("abc", 0u, 2u))); + assert (str::eq("bc", str::char_slice("abc", 1u, 3u))); + assert (str::eq("", str::char_slice("abc", 1u, 1u))); + assert (str::eq("\u65e5", str::char_slice("\u65e5\u672c", 0u, 1u))); } #[test] fn trim_left() { - assert (str::trim_left(~"") == ~""); - assert (str::trim_left(~"a") == ~"a"); - assert (str::trim_left(~" ") == ~""); - assert (str::trim_left(~" blah") == ~"blah"); - assert (str::trim_left(~" \u3000 wut") == ~"wut"); - assert (str::trim_left(~"hey ") == ~"hey "); + assert (str::trim_left("") == ""); + assert (str::trim_left("a") == "a"); + assert (str::trim_left(" ") == ""); + assert (str::trim_left(" blah") == "blah"); + assert (str::trim_left(" \u3000 wut") == "wut"); + assert (str::trim_left("hey ") == "hey "); } #[test] fn trim_right() { - assert (str::trim_right(~"") == ~""); - assert (str::trim_right(~"a") == ~"a"); - assert (str::trim_right(~" ") == ~""); - assert (str::trim_right(~"blah ") == ~"blah"); - assert (str::trim_right(~"wut \u3000 ") == ~"wut"); - assert (str::trim_right(~" hey") == ~" hey"); + assert (str::trim_right("") == ""); + assert (str::trim_right("a") == "a"); + assert (str::trim_right(" ") == ""); + assert (str::trim_right("blah ") == "blah"); + assert (str::trim_right("wut \u3000 ") == "wut"); + assert (str::trim_right(" hey") == " hey"); } #[test] fn trim() { - assert (str::trim(~"") == ~""); - assert (str::trim(~"a") == ~"a"); - assert (str::trim(~" ") == ~""); - assert (str::trim(~" blah ") == ~"blah"); - assert (str::trim(~"\nwut \u3000 ") == ~"wut"); - assert (str::trim(~" hey dude ") == ~"hey dude"); + assert (str::trim("") == ""); + assert (str::trim("a") == "a"); + assert (str::trim(" ") == ""); + assert (str::trim(" blah ") == "blah"); + assert (str::trim("\nwut \u3000 ") == "wut"); + assert (str::trim(" hey dude ") == "hey dude"); } #[test] fn is_whitespace() { - assert (str::is_whitespace(~"")); - assert (str::is_whitespace(~" ")); - assert (str::is_whitespace(~"\u2009")); // Thin space - assert (str::is_whitespace(~" \n\t ")); - assert (!str::is_whitespace(~" _ ")); + assert (str::is_whitespace("")); + assert (str::is_whitespace(" ")); + assert (str::is_whitespace("\u2009")); // Thin space + assert (str::is_whitespace(" \n\t ")); + assert (!str::is_whitespace(" _ ")); } #[test] fn is_ascii() { - assert str::is_ascii(~""); - assert str::is_ascii(~"a"); - assert !str::is_ascii(~"\u2009"); + assert (str::is_ascii("")); + assert (str::is_ascii("a")); + assert (!str::is_ascii("\u2009")); } #[test] fn shift_byte() { - let s = ~"ABC"; + let s = "ABC"; let b = str::shift_byte(s); - assert s == ~"BC"; - assert b == 65u8; + assert (s == "BC"); + assert (b == 65u8); } #[test] fn pop_byte() { - let s = ~"ABC"; + let s = "ABC"; let b = str::pop_byte(s); - assert s == ~"AB"; - assert b == 67u8; + assert (s == "AB"); + assert (b == 67u8); } #[test] fn unsafe_from_bytes() { let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]; let b = str::unsafe_from_bytes(a); - assert b == ~"AAAAAAA"; + assert (b == "AAAAAAA"); } #[test] @@ -263,43 +260,37 @@ fn str_from_cstr() { let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::to_ptr(a); let c = str::str_from_cstr(b); - assert c == ~"AAAAAAA"; + assert (c == "AAAAAAA"); } #[test] fn as_buf() { - let a = ~"Abcdefg"; - let b = str::as_buf(a, { |buf| - assert *buf == 65u8; - 100 - }); - assert b == 100; + let a = "Abcdefg"; + let b = str::as_buf(a, {|buf| assert (*buf == 65u8); 100 }); + assert (b == 100); } #[test] fn as_buf_small() { - let a = ~"A"; - let b = str::as_buf(a, { |buf| - assert *buf == 65u8; - 100 - }); - assert b == 100; + let a = "A"; + let b = str::as_buf(a, {|buf| assert (*buf == 65u8); 100 }); + assert (b == 100); } #[test] fn as_buf2() { - let s = ~"hello"; - let sb = str::as_buf(s, { |b| b }); + let s = "hello"; + let sb = str::as_buf(s, {|b| b }); let s_cstr = str::str_from_cstr(sb); assert (str::eq(s_cstr, s)); } #[test] fn vec_str_conversions() { - let s1: istr = ~"All mimsy were the borogoves"; + let s1: str = "All mimsy were the borogoves"; let v: [u8] = str::bytes(s1); - let s2: istr = str::unsafe_from_bytes(v); + let s2: str = str::unsafe_from_bytes(v); let i: uint = 0u; let n1: uint = str::byte_len(s1); let n2: uint = vec::len::<u8>(v); diff --git a/src/test/stdtest/sys.rs b/src/test/stdtest/sys.rs index 006aaaa8f5e..56cafe9217a 100644 --- a/src/test/stdtest/sys.rs +++ b/src/test/stdtest/sys.rs @@ -1,6 +1,4 @@ import std::sys; #[test] -fn last_os_error() { - log sys::rustrt::last_os_error(); -} \ No newline at end of file +fn last_os_error() { log sys::rustrt::last_os_error(); } diff --git a/src/test/stdtest/task.rs b/src/test/stdtest/task.rs index 1984202fd93..8c1776aa36f 100644 --- a/src/test/stdtest/task.rs +++ b/src/test/stdtest/task.rs @@ -67,12 +67,10 @@ fn test_join_convenient() { #[test] fn spawn_polymorphic() { - fn foo<~T>(x : -T) { - log_err x; - } + fn foo<~T>(x: -T) { log_err x; } let fb = bind foo(true); task::spawn(fb); task::spawn(bind foo(42)); -} \ No newline at end of file +} diff --git a/src/test/stdtest/test.rs b/src/test/stdtest/test.rs index cb4b9313029..eaecb80ba6b 100644 --- a/src/test/stdtest/test.rs +++ b/src/test/stdtest/test.rs @@ -9,7 +9,7 @@ fn do_not_run_ignored_tests() { let ran = @mutable false; let f = bind fn (ran: @mutable bool) { *ran = true; }(ran); - let desc = {name: ~"whatever", fn: f, ignore: true}; + let desc = {name: "whatever", fn: f, ignore: true}; test::run_test(desc, test::default_test_to_task); @@ -19,22 +19,22 @@ fn do_not_run_ignored_tests() { #[test] fn ignored_tests_result_in_ignored() { fn f() { } - let desc = {name: ~"whatever", fn: f, ignore: true}; + let desc = {name: "whatever", fn: f, ignore: true}; let res = test::run_test(desc, test::default_test_to_task).wait(); assert (res == test::tr_ignored); } #[test] fn first_free_arg_should_be_a_filter() { - let args = [~"progname", ~"filter"]; + let args = ["progname", "filter"]; check (vec::is_not_empty(args)); let opts = alt test::parse_opts(args) { either::left(o) { o } }; - assert (str::eq(~"filter", option::get(opts.filter))); + assert (str::eq("filter", option::get(opts.filter))); } #[test] fn parse_ignored_flag() { - let args = [~"progname", ~"filter", ~"--ignored"]; + let args = ["progname", "filter", "--ignored"]; check (vec::is_not_empty(args)); let opts = alt test::parse_opts(args) { either::left(o) { o } }; assert (opts.run_ignored); @@ -47,12 +47,12 @@ fn filter_for_ignored_option() { let opts = {filter: option::none, run_ignored: true}; let tests = - [{name: ~"1", fn: fn () { }, ignore: true}, - {name: ~"2", fn: fn () { }, ignore: false}]; + [{name: "1", fn: fn () { }, ignore: true}, + {name: "2", fn: fn () { }, ignore: false}]; let filtered = test::filter_tests(opts, tests); assert (vec::len(filtered) == 1u); - assert (filtered[0].name == ~"1"); + assert (filtered[0].name == "1"); assert (filtered[0].ignore == false); } @@ -61,17 +61,17 @@ fn sort_tests() { let opts = {filter: option::none, run_ignored: false}; let names = - [~"sha1::test", ~"int::test_to_str", ~"int::test_pow", - ~"test::do_not_run_ignored_tests", - ~"test::ignored_tests_result_in_ignored", - ~"test::first_free_arg_should_be_a_filter", - ~"test::parse_ignored_flag", ~"test::filter_for_ignored_option", - ~"test::sort_tests"]; + ["sha1::test", "int::test_to_str", "int::test_pow", + "test::do_not_run_ignored_tests", + "test::ignored_tests_result_in_ignored", + "test::first_free_arg_should_be_a_filter", + "test::parse_ignored_flag", "test::filter_for_ignored_option", + "test::sort_tests"]; let tests = { let testfn = fn () { }; let tests = []; - for name: istr in names { + for name: str in names { let test = {name: name, fn: testfn, ignore: false}; tests += [test]; } @@ -80,15 +80,13 @@ fn sort_tests() { let filtered = test::filter_tests(opts, tests); let expected = - [~"int::test_pow", ~"int::test_to_str", ~"sha1::test", - ~"test::do_not_run_ignored_tests", - ~"test::filter_for_ignored_option", - ~"test::first_free_arg_should_be_a_filter", - ~"test::ignored_tests_result_in_ignored", - ~"test::parse_ignored_flag", - ~"test::sort_tests"]; - - check vec::same_length(expected, filtered); + ["int::test_pow", "int::test_to_str", "sha1::test", + "test::do_not_run_ignored_tests", "test::filter_for_ignored_option", + "test::first_free_arg_should_be_a_filter", + "test::ignored_tests_result_in_ignored", "test::parse_ignored_flag", + "test::sort_tests"]; + + check (vec::same_length(expected, filtered)); let pairs = vec::zip(expected, filtered); diff --git a/src/test/stdtest/treemap.rs b/src/test/stdtest/treemap.rs index 9a2ef1e8e68..0f4119c6c3d 100644 --- a/src/test/stdtest/treemap.rs +++ b/src/test/stdtest/treemap.rs @@ -5,41 +5,29 @@ import std::option::none; import std::str; #[test] -fn init_treemap() { - let m = init::<int, int>(); -} +fn init_treemap() { let m = init::<int, int>(); } #[test] -fn insert_one() { - let m = init(); - insert(m, 1, 2); -} +fn insert_one() { let m = init(); insert(m, 1, 2); } #[test] -fn insert_two() { - let m = init(); - insert(m, 1, 2); - insert(m, 3, 4); -} +fn insert_two() { let m = init(); insert(m, 1, 2); insert(m, 3, 4); } #[test] fn insert_find() { let m = init(); insert(m, 1, 2); - assert(find(m, 1) == some(2)); + assert (find(m, 1) == some(2)); } #[test] -fn find_empty() { - let m = init::<int, int>(); - assert(find(m, 1) == none); -} +fn find_empty() { let m = init::<int, int>(); assert (find(m, 1) == none); } #[test] fn find_not_found() { let m = init(); insert(m, 1, 2); - assert(find(m, 2) == none); + assert (find(m, 2) == none); } #[test] @@ -52,10 +40,7 @@ fn traverse_in_order() { insert(m, 1, ()); let n = 0; - fn t(n : &mutable int, k : &int, v : &()) { - assert(n == k); - n += 1; - } + fn t(n: &mutable int, k: &int, v: &()) { assert (n == k); n += 1; } traverse(m, bind t(n, _, _)); } @@ -63,12 +48,12 @@ fn traverse_in_order() { fn u8_map() { let m = init(); - let k1 = str::bytes(~"foo"); - let k2 = str::bytes(~"bar"); + let k1 = str::bytes("foo"); + let k2 = str::bytes("bar"); - insert(m, k1, ~"foo"); - insert(m, k2, ~"bar"); + insert(m, k1, "foo"); + insert(m, k2, "bar"); - assert(find(m, k2) == some(~"bar")); - assert(find(m, k1) == some(~"foo")); + assert (find(m, k2) == some("bar")); + assert (find(m, k1) == some("foo")); } diff --git a/src/test/stdtest/vec.rs b/src/test/stdtest/vec.rs index 3d1df459067..6194c461c15 100644 --- a/src/test/stdtest/vec.rs +++ b/src/test/stdtest/vec.rs @@ -303,7 +303,7 @@ fn test_zip_unzip() { let v1 = [1, 2, 3]; let v2 = [4, 5, 6]; - check same_length(v1, v2); // Silly, but what else can we do? + check (same_length(v1, v2)); // Silly, but what else can we do? let z1 = vec::zip(v1, v2); assert ((1, 4) == z1[0]); @@ -351,7 +351,7 @@ fn reverse_and_reversed() { // Make sure they work with 0-length vectors too. let v4 = vec::reversed::<int>([]); - assert v4 == []; + assert (v4 == []); let v3: [mutable int] = [mutable]; vec::reverse::<int>(v3); } |
