From 866d329919e9f8c717635c43b26eccb653f1ba69 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 8 Feb 2014 22:00:39 +1100 Subject: [PATCH 1/4] std: Rename `assert` and `assert_eq` to `fail_unless` and `fail_unless_eq`. These macros are always enabled so there's no particular need to fly in the face of established convention where assertions are removed in production code. Closes #12049. --- src/libstd/macros.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 490f2c9b198d2..4cde84fbaaaaf 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -167,28 +167,23 @@ macro_rules! fail( /// ``` /// // the failure message for these assertions is the stringified value of the /// // expression given. -/// assert!(true); +/// fail_unless!(true); /// # fn some_computation() -> bool { true } -/// assert!(some_computation()); +/// fail_unless!(some_computation()); /// /// // assert with a custom message /// # let x = true; -/// assert!(x, "x wasn't true!"); +/// fail_unless!(x, "x wasn't true!"); /// # let a = 3; let b = 27; -/// assert!(a + b == 30, "a = {}, b = {}", a, b); +/// fail_unless!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] -macro_rules! assert( +macro_rules! fail_unless( ($cond:expr) => ( if !$cond { fail!("assertion failed: {:s}", stringify!($cond)) } ); - ($cond:expr, $msg:expr) => ( - if !$cond { - fail!($msg) - } - ); ($cond:expr, $($arg:expr),+) => ( if !$cond { fail!($($arg),+) @@ -199,17 +194,18 @@ macro_rules! assert( /// Asserts that two expressions are equal to each other, testing equality in /// both directions. /// -/// On failure, this macro will print the values of the expressions. +/// If the expressions are not equal, `fail!` is invoked, with a +/// message containing the two values. /// /// # Example /// /// ``` /// let a = 3; /// let b = 1 + 2; -/// assert_eq!(a, b); +/// fail_unless_eq!(a, b); /// ``` #[macro_export] -macro_rules! assert_eq( +macro_rules! fail_unless_eq ( ($given:expr , $expected:expr) => ({ let given_val = &($given); let expected_val = &($expected); @@ -367,4 +363,3 @@ macro_rules! vec( temp }) ) - From 737f94b0909643d559fbf2176cd9cb56b896566b Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 8 Feb 2014 22:15:48 +1100 Subject: [PATCH 2/4] std: add `debug_assert!` and `debug_assert_eq!`, removed for --cfg ndebug. --- src/libstd/macros.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 4cde84fbaaaaf..ef70882d73359 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -218,6 +218,37 @@ macro_rules! fail_unless_eq ( }) ) +#[macro_export] +macro_rules! debug_assert { + ($cond:expr) => { + if cfg!(not(ndebug)) && !$cond { + fail!("assertion failed: {:s}", stringify!($cond)) + } + }; + ($cond:expr, $( $arg:expr ),+) => { + if cfg!(not(ndebug)) && !$cond { + fail!( $($arg),+ ) + } + } + +} + +#[macro_export] +macro_rules! debug_assert_eq { + ($given:expr , $expected:expr) => ( + if cfg!(not(ndebug)) { + let given_val = &($given); + let expected_val = &($expected); + // check both directions of equality.... + if !((*given_val == *expected_val) && + (*expected_val == *given_val)) { + fail!("assertion failed: `(left == right) && (right == left)` \ + (left: `{:?}`, right: `{:?}`)", *given_val, *expected_val) + } + } + ) +} + /// A utility macro for indicating unreachable code. It will fail if /// executed. This is occasionally useful to put after loops that never /// terminate normally, but instead directly return from a function. From 0b2231c08841fb35c9bbc122e10608dc0124e8ed Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 22 Feb 2014 17:49:34 +1100 Subject: [PATCH 3/4] Rename uses of `assert!` to `fail_unless!`. --- src/compiletest/compiletest.rs | 2 +- src/compiletest/procsrv.rs | 2 +- src/doc/guide-container.md | 2 +- src/doc/guide-ffi.md | 2 +- src/doc/guide-tasks.md | 10 +- src/doc/guide-testing.md | 2 +- src/doc/po/ja/complement-cheatsheet.md.po | 16 +- src/doc/po/ja/rust.md.po | 14 +- src/doc/po/ja/tutorial.md.po | 10 +- src/doc/rust.md | 10 +- src/doc/tutorial.md | 18 +- src/libcollections/bitv.rs | 206 ++++++------ src/libcollections/btree.rs | 16 +- src/libcollections/dlist.rs | 72 ++--- src/libcollections/enum_set.rs | 26 +- src/libcollections/list.rs | 16 +- src/libcollections/lru_cache.rs | 22 +- src/libcollections/priority_queue.rs | 28 +- src/libcollections/ringbuf.rs | 22 +- src/libcollections/smallintmap.rs | 98 +++--- src/libcollections/treemap.rs | 292 +++++++++--------- src/libextra/c_vec.rs | 8 +- src/libextra/json.rs | 2 +- src/libextra/stats.rs | 14 +- src/libextra/unicode.rs | 16 +- src/libextra/url.rs | 52 ++-- src/libextra/workcache.rs | 4 +- src/libflate/lib.rs | 4 +- src/libgetopts/lib.rs | 132 ++++---- src/libglob/lib.rs | 176 +++++------ src/libgreen/lib.rs | 2 +- src/libgreen/sched.rs | 18 +- src/libgreen/simple.rs | 2 +- src/libgreen/sleeper_list.rs | 2 +- src/libgreen/task.rs | 12 +- src/libnative/io/addrinfo.rs | 2 +- src/libnative/io/file.rs | 12 +- src/libnative/io/net.rs | 4 +- src/libnative/io/pipe_unix.rs | 4 +- src/libnative/io/pipe_win32.rs | 2 +- src/libnative/io/process.rs | 20 +- src/libnative/io/timer_helper.rs | 6 +- src/libnative/io/timer_other.rs | 2 +- src/libnative/io/timer_timerfd.rs | 2 +- src/libnative/io/timer_win32.rs | 2 +- src/libnative/task.rs | 4 +- src/libnum/bigint.rs | 216 ++++++------- src/libnum/complex.rs | 4 +- src/libnum/lib.rs | 40 +-- src/libnum/rational.rs | 28 +- src/librustc/back/archive.rs | 2 +- src/librustc/back/link.rs | 4 +- src/librustc/back/rpath.rs | 6 +- src/librustc/driver/driver.rs | 6 +- src/librustc/lib/llvm.rs | 2 +- src/librustc/metadata/creader.rs | 2 +- src/librustc/metadata/cstore.rs | 2 +- src/librustc/metadata/encoder.rs | 10 +- src/librustc/metadata/filesearch.rs | 2 +- src/librustc/middle/astencode.rs | 4 +- src/librustc/middle/borrowck/check_loans.rs | 4 +- .../middle/borrowck/gather_loans/mod.rs | 2 +- src/librustc/middle/borrowck/mod.rs | 2 +- src/librustc/middle/cfg/construct.rs | 2 +- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/dataflow.rs | 8 +- src/librustc/middle/graph.rs | 4 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/lint.rs | 2 +- src/librustc/middle/liveness.rs | 10 +- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/middle/privacy.rs | 4 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 6 +- src/librustc/middle/resolve.rs | 18 +- src/librustc/middle/trans/_match.rs | 4 +- src/librustc/middle/trans/adt.rs | 16 +- src/librustc/middle/trans/base.rs | 12 +- src/librustc/middle/trans/build.rs | 2 +- src/librustc/middle/trans/builder.rs | 6 +- src/librustc/middle/trans/callee.rs | 14 +- src/librustc/middle/trans/cleanup.rs | 12 +- src/librustc/middle/trans/common.rs | 10 +- src/librustc/middle/trans/consts.rs | 14 +- src/librustc/middle/trans/controlflow.rs | 2 +- src/librustc/middle/trans/datum.rs | 10 +- src/librustc/middle/trans/debuginfo.rs | 12 +- src/librustc/middle/trans/expr.rs | 12 +- src/librustc/middle/trans/foreign.rs | 6 +- src/librustc/middle/trans/glue.rs | 2 +- src/librustc/middle/trans/intrinsic.rs | 2 +- src/librustc/middle/trans/meth.rs | 4 +- src/librustc/middle/trans/monomorphize.rs | 8 +- src/librustc/middle/trans/tvec.rs | 10 +- src/librustc/middle/ty.rs | 6 +- src/librustc/middle/typeck/check/method.rs | 2 +- src/librustc/middle/typeck/check/mod.rs | 4 +- src/librustc/middle/typeck/check/regionck.rs | 2 +- src/librustc/middle/typeck/check/vtable.rs | 4 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/librustc/middle/typeck/collect.rs | 2 +- src/librustc/middle/typeck/infer/glb.rs | 4 +- src/librustc/middle/typeck/infer/lub.rs | 4 +- src/librustc/middle/typeck/infer/mod.rs | 2 +- .../typeck/infer/region_inference/mod.rs | 8 +- src/librustc/middle/typeck/infer/resolve.rs | 4 +- src/librustc/middle/typeck/infer/test.rs | 2 +- src/librustc/middle/typeck/mod.rs | 4 +- src/librustc/middle/typeck/rscope.rs | 2 +- src/librustc/middle/typeck/variance.rs | 8 +- src/librustc/util/sha2.rs | 16 +- src/librustdoc/passes.rs | 2 +- src/librustuv/access.rs | 6 +- src/librustuv/addrinfo.rs | 4 +- src/librustuv/async.rs | 2 +- src/librustuv/file.rs | 40 +-- src/librustuv/homing.rs | 2 +- src/librustuv/idle.rs | 2 +- src/librustuv/lib.rs | 22 +- src/librustuv/net.rs | 32 +- src/librustuv/pipe.rs | 14 +- src/librustuv/process.rs | 6 +- src/librustuv/stream.rs | 4 +- src/librustuv/uvll.rs | 4 +- src/libsemver/lib.rs | 82 ++--- src/libserialize/base64.rs | 8 +- src/libserialize/ebml.rs | 2 +- src/libserialize/hex.rs | 6 +- src/libstd/any.rs | 40 +-- src/libstd/ascii.rs | 44 +-- src/libstd/bool.rs | 26 +- src/libstd/c_str.rs | 18 +- src/libstd/cast.rs | 8 +- src/libstd/cell.rs | 14 +- src/libstd/char.rs | 64 ++-- src/libstd/cmp.rs | 6 +- src/libstd/comm/mod.rs | 28 +- src/libstd/comm/oneshot.rs | 4 +- src/libstd/comm/select.rs | 14 +- src/libstd/comm/shared.rs | 14 +- src/libstd/comm/stream.rs | 16 +- src/libstd/fmt/num.rs | 2 +- src/libstd/fmt/parse.rs | 2 +- src/libstd/gc.rs | 6 +- src/libstd/hash.rs | 46 +-- src/libstd/hashmap.rs | 248 +++++++-------- src/libstd/io/buffered.rs | 12 +- src/libstd/io/extensions.rs | 54 ++-- src/libstd/io/fs.rs | 54 ++-- src/libstd/io/mem.rs | 32 +- src/libstd/io/mod.rs | 4 +- src/libstd/io/net/addrinfo.rs | 2 +- src/libstd/io/net/ip.rs | 4 +- src/libstd/io/net/tcp.rs | 38 +-- src/libstd/io/net/udp.rs | 4 +- src/libstd/io/net/unix.rs | 14 +- src/libstd/io/process.rs | 28 +- src/libstd/io/stdio.rs | 2 +- src/libstd/io/timer.rs | 4 +- src/libstd/io/util.rs | 2 +- src/libstd/iter.rs | 174 +++++------ src/libstd/local_data.rs | 18 +- src/libstd/macros.rs | 2 +- src/libstd/managed.rs | 8 +- src/libstd/mem.rs | 4 +- src/libstd/num/f32.rs | 80 ++--- src/libstd/num/f64.rs | 80 ++--- src/libstd/num/float_macros.rs | 2 +- src/libstd/num/int_macros.rs | 78 ++--- src/libstd/num/mod.rs | 2 +- src/libstd/num/strconv.rs | 4 +- src/libstd/num/uint_macros.rs | 30 +- src/libstd/option.rs | 30 +- src/libstd/os.rs | 44 +-- src/libstd/path/mod.rs | 8 +- src/libstd/path/posix.rs | 28 +- src/libstd/path/windows.rs | 46 +-- src/libstd/ptr.rs | 28 +- src/libstd/rand/distributions/exponential.rs | 6 +- src/libstd/rand/distributions/gamma.rs | 12 +- src/libstd/rand/distributions/mod.rs | 4 +- src/libstd/rand/distributions/normal.rs | 4 +- src/libstd/rand/distributions/range.rs | 10 +- src/libstd/rand/mod.rs | 14 +- src/libstd/rand/rand_impls.rs | 12 +- src/libstd/rand/reseeding.rs | 2 +- src/libstd/rc.rs | 6 +- src/libstd/result.rs | 2 +- src/libstd/rt/args.rs | 6 +- src/libstd/rt/crate_map.rs | 8 +- src/libstd/rt/global_heap.rs | 2 +- src/libstd/rt/local.rs | 2 +- src/libstd/rt/local_heap.rs | 2 +- src/libstd/rt/logging.rs | 40 +-- src/libstd/rt/task.rs | 20 +- src/libstd/rt/thread.rs | 6 +- src/libstd/rt/thread_local_storage.rs | 6 +- src/libstd/rt/unwind.rs | 2 +- src/libstd/run.rs | 28 +- src/libstd/str.rs | 246 +++++++-------- src/libstd/sync/arc.rs | 8 +- src/libstd/sync/atomics.rs | 20 +- src/libstd/sync/deque.rs | 2 +- src/libstd/sync/mpmc_bounded_queue.rs | 2 +- src/libstd/sync/mpsc_queue.rs | 4 +- src/libstd/sync/spsc_queue.rs | 4 +- src/libstd/task.rs | 20 +- src/libstd/to_str.rs | 6 +- src/libstd/trie.rs | 70 ++--- src/libstd/tuple.rs | 50 +-- src/libstd/unstable/finally.rs | 4 +- src/libstd/unstable/mod.rs | 2 +- src/libstd/unstable/mutex.rs | 2 +- src/libstd/unstable/sync.rs | 2 +- src/libstd/vec.rs | 124 ++++---- src/libstd/vec_ng.rs | 2 +- src/libsync/arc.rs | 66 ++-- src/libsync/comm.rs | 8 +- src/libsync/sync/mod.rs | 40 +-- src/libsync/sync/mutex.rs | 14 +- src/libsync/sync/one.rs | 8 +- src/libsync/task_pool.rs | 2 +- src/libsyntax/abi.rs | 14 +- src/libsyntax/ast_util.rs | 4 +- src/libsyntax/codemap.rs | 8 +- src/libsyntax/crateid.rs | 6 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/expand.rs | 4 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/opt_vec.rs | 2 +- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/comments.rs | 6 +- src/libsyntax/parse/lexer.rs | 8 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/parse/token.rs | 4 +- src/libsyntax/print/pp.rs | 14 +- src/libsyntax/print/pprust.rs | 8 +- src/libterm/terminfo/parm.rs | 26 +- src/libterm/terminfo/parser/compiled.rs | 2 +- src/libterm/terminfo/searcher.rs | 8 +- src/libtest/lib.rs | 16 +- src/libtime/lib.rs | 216 ++++++------- src/libuuid/lib.rs | 160 +++++----- .../auxiliary/extern_calling_convention.rs | 16 +- src/test/auxiliary/linkage-visibility.rs | 6 +- src/test/bench/core-map.rs | 6 +- src/test/bench/core-set.rs | 8 +- src/test/bench/sudoku.rs | 4 +- src/test/bench/task-perf-linked-failure.rs | 4 +- .../arc-rw-read-mode-shouldnt-escape.rs | 2 +- .../arc-rw-write-mode-shouldnt-escape.rs | 2 +- .../compile-fail/bind-by-move-no-guards.rs | 2 +- .../builtin-superkinds-self-type.rs | 2 +- src/test/compile-fail/cast-from-nil.rs | 2 +- src/test/compile-fail/crateresolve5.rs | 2 +- .../kindck-owned-trait-contains.rs | 2 +- .../compile-fail/match-static-const-lc.rs | 6 +- .../compile-fail/mod_file_correct_spans.rs | 2 +- .../compile-fail/omitted-arg-wrong-types.rs | 4 +- .../once-cant-call-twice-on-heap.rs | 2 +- .../once-cant-call-twice-on-stack.rs | 2 +- ...once-cant-move-out-of-non-once-on-stack.rs | 2 +- .../private-struct-field-cross-crate.rs | 2 +- src/test/compile-fail/private-struct-field.rs | 2 +- .../regions-infer-borrow-scope-within-loop.rs | 2 +- src/test/compile-fail/tag-type-args.rs | 2 +- src/test/pretty/do1.rs | 2 +- src/test/run-fail/assert-as-macro.rs | 2 +- src/test/run-fail/assert-macro-explicit.rs | 2 +- src/test/run-fail/assert-macro-fmt.rs | 2 +- src/test/run-fail/assert-macro-owned.rs | 2 +- src/test/run-fail/assert-macro-static.rs | 2 +- src/test/run-fail/fail.rs | 2 +- src/test/run-fail/issue-2761.rs | 2 +- src/test/run-fail/linked-failure.rs | 2 +- src/test/run-fail/linked-failure4.rs | 2 +- src/test/run-fail/task-spawn-barefn.rs | 2 +- src/test/run-fail/unwind-assert.rs | 2 +- src/test/run-make/rustdoc-hidden-line/foo.rs | 2 +- src/test/run-make/static-unwinding/main.rs | 4 +- src/test/run-pass/arith-2.rs | 2 +- src/test/run-pass/arith-unsigned.rs | 24 +- src/test/run-pass/artificial-block.rs | 2 +- src/test/run-pass/assignability-trait.rs | 4 +- src/test/run-pass/auto-encode.rs | 2 +- src/test/run-pass/binops.rs | 44 +-- src/test/run-pass/bool-not.rs | 4 +- .../borrowck-borrow-from-expr-block.rs | 2 +- .../borrowck-preserve-box-in-field.rs | 2 +- .../run-pass/borrowck-preserve-box-in-uniq.rs | 2 +- src/test/run-pass/borrowck-preserve-box.rs | 2 +- .../run-pass/borrowck-preserve-expl-deref.rs | 2 +- src/test/run-pass/borrowed-ptr-pattern-2.rs | 4 +- src/test/run-pass/borrowed-ptr-pattern-3.rs | 4 +- src/test/run-pass/box-compare.rs | 6 +- src/test/run-pass/box.rs | 2 +- src/test/run-pass/break.rs | 8 +- ...ltin-superkinds-capabilities-transitive.rs | 2 +- .../builtin-superkinds-capabilities-xc.rs | 2 +- .../builtin-superkinds-capabilities.rs | 2 +- .../run-pass/builtin-superkinds-self-type.rs | 2 +- src/test/run-pass/c-stack-returning-int64.rs | 2 +- src/test/run-pass/cci_impl_exe.rs | 2 +- src/test/run-pass/cci_iter_exe.rs | 2 +- src/test/run-pass/cci_no_inline_exe.rs | 2 +- src/test/run-pass/cfg-macros-foo.rs | 2 +- src/test/run-pass/cfg-macros-notfoo.rs | 2 +- .../class-impl-very-parameterized-trait.rs | 4 +- .../class-implement-trait-cross-crate.rs | 4 +- src/test/run-pass/class-implement-traits.rs | 2 +- src/test/run-pass/classes-cross-crate.rs | 4 +- src/test/run-pass/classes.rs | 4 +- src/test/run-pass/cleanup-copy-mode.rs | 2 +- src/test/run-pass/cmp-default.rs | 36 +-- src/test/run-pass/compare-generic-enums.rs | 8 +- src/test/run-pass/conditional-compile.rs | 2 +- src/test/run-pass/const-big-enum.rs | 2 +- src/test/run-pass/const-binops.rs | 2 +- src/test/run-pass/const-enum-struct.rs | 2 +- src/test/run-pass/const-enum-struct2.rs | 2 +- src/test/run-pass/const-enum-structlike.rs | 2 +- src/test/run-pass/const-enum-tuple.rs | 2 +- src/test/run-pass/const-enum-tuple2.rs | 2 +- src/test/run-pass/const-enum-tuplestruct.rs | 2 +- src/test/run-pass/const-enum-tuplestruct2.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 2 +- src/test/run-pass/const-enum-vec-ptr.rs | 2 +- src/test/run-pass/const-enum-vector.rs | 2 +- src/test/run-pass/const-str-ptr.rs | 4 +- src/test/run-pass/core-run-destroy.rs | 4 +- src/test/run-pass/crateresolve2.rs | 6 +- src/test/run-pass/crateresolve3.rs | 4 +- src/test/run-pass/crateresolve4.rs | 4 +- src/test/run-pass/crateresolve5.rs | 6 +- src/test/run-pass/deep.rs | 2 +- .../run-pass/deriving-cmp-shortcircuit.rs | 6 +- .../run-pass/deriving-encodable-decodable.rs | 2 +- ...deriving-self-lifetime-totalord-totaleq.rs | 4 +- src/test/run-pass/deriving-self-lifetime.rs | 16 +- .../run-pass/deriving-via-extension-c-enum.rs | 6 +- .../run-pass/deriving-via-extension-enum.rs | 6 +- .../deriving-via-extension-struct-empty.rs | 2 +- ...-via-extension-struct-like-enum-variant.rs | 2 +- .../deriving-via-extension-struct-tuple.rs | 12 +- .../run-pass/deriving-via-extension-struct.rs | 6 +- .../deriving-via-extension-type-params.rs | 6 +- src/test/run-pass/else-if.rs | 18 +- src/test/run-pass/enum-alignment.rs | 2 +- src/test/run-pass/enum-discr.rs | 4 +- src/test/run-pass/enum-disr-val-pretty.rs | 4 +- .../enum-nullable-const-null-with-fields.rs | 2 +- src/test/run-pass/estr-slice.rs | 32 +- src/test/run-pass/evec-internal.rs | 32 +- src/test/run-pass/evec-slice.rs | 40 +-- src/test/run-pass/export-unexported-dep.rs | 2 +- src/test/run-pass/expr-block-box.rs | 2 +- src/test/run-pass/expr-block-fn.rs | 2 +- src/test/run-pass/expr-block-generic-box1.rs | 2 +- src/test/run-pass/expr-block-generic-box2.rs | 2 +- .../run-pass/expr-block-generic-unique1.rs | 2 +- .../run-pass/expr-block-generic-unique2.rs | 2 +- src/test/run-pass/expr-block-generic.rs | 2 +- src/test/run-pass/expr-block-unique.rs | 2 +- src/test/run-pass/expr-block.rs | 4 +- src/test/run-pass/expr-if-fail.rs | 2 +- src/test/run-pass/expr-if-generic-box1.rs | 2 +- src/test/run-pass/expr-if-generic-box2.rs | 2 +- src/test/run-pass/expr-if-generic.rs | 2 +- src/test/run-pass/expr-if.rs | 18 +- src/test/run-pass/expr-match-generic-box1.rs | 2 +- src/test/run-pass/expr-match-generic-box2.rs | 2 +- .../run-pass/expr-match-generic-unique1.rs | 2 +- .../run-pass/expr-match-generic-unique2.rs | 2 +- src/test/run-pass/expr-match-generic.rs | 2 +- src/test/run-pass/expr-match.rs | 10 +- src/test/run-pass/exterior.rs | 4 +- .../extern-compare-with-return-type.rs | 2 +- src/test/run-pass/extern-fn-reachable.rs | 10 +- src/test/run-pass/extern-take-value.rs | 2 +- .../run-pass/extoption_env-not-defined.rs | 2 +- .../run-pass/fail-in-dtor-drops-fields.rs | 4 +- src/test/run-pass/field-destruction-order.rs | 4 +- src/test/run-pass/float-nan.rs | 128 ++++---- src/test/run-pass/float2.rs | 10 +- src/test/run-pass/floatlits.rs | 8 +- .../foreach-external-iterators-break.rs | 2 +- .../foreach-external-iterators-nested.rs | 2 +- .../run-pass/foreach-external-iterators.rs | 2 +- src/test/run-pass/generic-fn-infer.rs | 2 +- src/test/run-pass/generic-tag-match.rs | 2 +- src/test/run-pass/generic-tag-values.rs | 2 +- src/test/run-pass/generic-temporary.rs | 2 +- src/test/run-pass/getopts_ref.rs | 2 +- src/test/run-pass/glob-std.rs | 2 +- src/test/run-pass/global-scope.rs | 2 +- src/test/run-pass/i32-sub.rs | 2 +- src/test/run-pass/inner-attrs-on-impl.rs | 2 +- src/test/run-pass/intrinsics-math.rs | 10 +- src/test/run-pass/issue-10734.rs | 6 +- src/test/run-pass/issue-2718.rs | 2 +- src/test/run-pass/issue-2735-2.rs | 2 +- src/test/run-pass/issue-2735-3.rs | 2 +- src/test/run-pass/issue-2904.rs | 4 +- src/test/run-pass/issue-3168.rs | 2 +- src/test/run-pass/issue-333.rs | 2 +- src/test/run-pass/issue-3424.rs | 2 +- src/test/run-pass/issue-3556.rs | 6 +- src/test/run-pass/issue-3559.rs | 2 +- src/test/run-pass/issue-3563-3.rs | 6 +- src/test/run-pass/issue-3574.rs | 4 +- src/test/run-pass/issue-3935.rs | 2 +- src/test/run-pass/issue-5239-2.rs | 2 +- src/test/run-pass/issue-6130.rs | 6 +- src/test/run-pass/issue-8498.rs | 8 +- src/test/run-pass/istr.rs | 14 +- src/test/run-pass/iter-range.rs | 2 +- src/test/run-pass/lazy-and-or.rs | 6 +- src/test/run-pass/linear-for-loop.rs | 10 +- .../log-knows-the-names-of-variants-in-std.rs | 2 +- src/test/run-pass/logging-only-prints-once.rs | 4 +- src/test/run-pass/loop-break-cont-1.rs | 2 +- src/test/run-pass/loop-break-cont.rs | 4 +- src/test/run-pass/macro-2.rs | 2 +- src/test/run-pass/macro-interpolation.rs | 2 +- src/test/run-pass/macro-local-data-key.rs | 4 +- .../run-pass/match-implicit-copy-unique.rs | 2 +- src/test/run-pass/match-pattern-lit.rs | 2 +- .../match-ref-binding-in-guard-3256.rs | 2 +- .../run-pass/match-static-const-rename.rs | 12 +- src/test/run-pass/monad.rs | 2 +- src/test/run-pass/move-2-unique.rs | 2 +- src/test/run-pass/move-2.rs | 2 +- src/test/run-pass/move-4-unique.rs | 2 +- src/test/run-pass/move-arg-2-unique.rs | 2 +- src/test/run-pass/move-arg-2.rs | 2 +- src/test/run-pass/move-arg.rs | 2 +- src/test/run-pass/multi-let.rs | 2 +- src/test/run-pass/mut-function-arguments.rs | 2 +- ...ility-inherits-through-fixed-length-vec.rs | 2 +- src/test/run-pass/nested-patterns.rs | 2 +- src/test/run-pass/no-landing-pads.rs | 2 +- src/test/run-pass/non-boolean-pure-fns.rs | 4 +- src/test/run-pass/nul-characters.rs | 4 +- .../nullable-pointer-iotareduction.rs | 10 +- src/test/run-pass/once-move-out-on-heap.rs | 2 +- src/test/run-pass/once-move-out-on-stack.rs | 2 +- src/test/run-pass/operator-associativity.rs | 2 +- src/test/run-pass/overload-index-operator.rs | 8 +- src/test/run-pass/readalias.rs | 2 +- .../reexported-static-methods-cross-crate.rs | 2 +- .../regions-infer-borrow-scope-addr-of.rs | 2 +- .../regions-infer-borrow-scope-view.rs | 2 +- ...-lifetime-static-items-enclosing-scopes.rs | 2 +- src/test/run-pass/rename-directory.rs | 6 +- src/test/run-pass/resolve-issue-2428.rs | 2 +- src/test/run-pass/resource-destruct.rs | 2 +- src/test/run-pass/resource-in-struct.rs | 2 +- src/test/run-pass/self-re-assign.rs | 4 +- src/test/run-pass/self-shadowing-import.rs | 2 +- src/test/run-pass/send_str_hashmap.rs | 40 +-- src/test/run-pass/send_str_treemap.rs | 42 +-- src/test/run-pass/seq-compare.rs | 22 +- src/test/run-pass/shadow.rs | 2 +- src/test/run-pass/spawn.rs | 2 +- src/test/run-pass/stat.rs | 2 +- src/test/run-pass/static-mut-foreign.rs | 10 +- src/test/run-pass/static-mut-xc.rs | 10 +- src/test/run-pass/structured-compare.rs | 14 +- src/test/run-pass/swap-1.rs | 2 +- src/test/run-pass/syntax-extension-minor.rs | 2 +- .../includeme.fragment | 4 +- .../run-pass/syntax-extension-source-utils.rs | 12 +- src/test/run-pass/tag-align-dyn-u64.rs | 2 +- src/test/run-pass/tag-align-dyn-variants.rs | 40 +-- src/test/run-pass/tag-align-u64.rs | 2 +- src/test/run-pass/tag-variant-disr-val.rs | 6 +- src/test/run-pass/tag.rs | 2 +- src/test/run-pass/tail-cps.rs | 2 +- src/test/run-pass/tail-direct.rs | 2 +- src/test/run-pass/task-comm-10.rs | 4 +- src/test/run-pass/tempfile.rs | 36 +-- src/test/run-pass/test-ignore-cfg.rs | 4 +- src/test/run-pass/trait-bounds-in-arc.rs | 6 +- src/test/run-pass/trait-cast.rs | 4 +- src/test/run-pass/trait-default-method-xc.rs | 18 +- .../trait-inheritance-overloading-simple.rs | 2 +- .../trait-inheritance-self-in-supertype.rs | 24 +- src/test/run-pass/trait-inheritance-subst.rs | 2 +- src/test/run-pass/trait-to-str.rs | 8 +- .../run-pass/traits-default-method-self.rs | 2 +- .../run-pass/traits-default-method-trivial.rs | 2 +- src/test/run-pass/type-namespace.rs | 2 +- src/test/run-pass/type-sizes.rs | 2 +- .../run-pass/typeclasses-eq-example-static.rs | 16 +- src/test/run-pass/typeclasses-eq-example.rs | 16 +- src/test/run-pass/typeid-intrinsic.rs | 6 +- src/test/run-pass/typestate-multi-decl.rs | 2 +- src/test/run-pass/unique-cmp.rs | 10 +- src/test/run-pass/unique-in-tag.rs | 2 +- src/test/run-pass/unique-in-vec.rs | 2 +- src/test/run-pass/unique-kinds.rs | 6 +- src/test/run-pass/unique-pat-2.rs | 2 +- src/test/run-pass/unique-pat-3.rs | 2 +- src/test/run-pass/unwind-resource.rs | 2 +- src/test/run-pass/utf8_chars.rs | 38 +-- src/test/run-pass/utf8_idents.rs | 2 +- src/test/run-pass/vec-tail-matching.rs | 6 +- src/test/run-pass/vector-sort-failure-safe.rs | 2 +- src/test/run-pass/weird-exprs.rs | 6 +- src/test/run-pass/while-cont.rs | 2 +- src/test/run-pass/while-loop-constraints-2.rs | 2 +- src/test/run-pass/writealias.rs | 2 +- src/test/run-pass/x86stdcall2.rs | 4 +- .../run-pass/zero-size-type-destructors.rs | 2 +- 514 files changed, 3361 insertions(+), 3361 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index c5ec19813065c..2be5646ca1658 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -78,7 +78,7 @@ pub fn parse_config(args: ~[~str]) -> config { optflag("h", "help", "show this message"), ]; - assert!(!args.is_empty()); + fail_unless!(!args.is_empty()); let argv0 = args[0].clone(); let args_ = args.tail(); if args[1] == ~"-h" || args[1] == ~"--help" { diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 1016c3cf0e61b..910b0879c0684 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -19,7 +19,7 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] { let mut env = os::env(); // Make sure we include the aux directory in the path - assert!(prog.ends_with(".exe")); + fail_unless!(prog.ends_with(".exe")); let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux"; env = env.map(|pair| { diff --git a/src/doc/guide-container.md b/src/doc/guide-container.md index ebad650a5340b..5bb9780c8b276 100644 --- a/src/doc/guide-container.md +++ b/src/doc/guide-container.md @@ -256,7 +256,7 @@ for (x, y) in it { println!("last: {:?}", it.next()); // the iterator is now fully consumed -assert!(it.next().is_none()); +fail_unless!(it.next().is_none()); ~~~ ## Conversion diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index c279ff314b474..3a9b646ce8ef1 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -195,7 +195,7 @@ impl Unique { pub fn new(value: T) -> Unique { unsafe { let ptr = malloc(std::mem::size_of::() as size_t) as *mut T; - assert!(!ptr.is_null()); + fail_unless!(!ptr.is_null()); // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it // move_val_init moves a value into this memory without // attempting to drop the original value. diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 0d27071494fea..a9e0052996462 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -427,7 +427,7 @@ The `arc` module also implements Arcs around mutable data that are not covered h Rust has a built-in mechanism for raising exceptions. The `fail!()` macro (which can also be written with an error string as an argument: `fail!( -~reason)`) and the `assert!` construct (which effectively calls `fail!()` +~reason)`) and the `fail_unless!` construct (which effectively calls `fail!()` if a boolean expression is false) are both ways to raise exceptions. When a task raises an exception the task unwinds its stack---running destructors and freeing memory along the way---and then exits. Unlike exceptions in C++, @@ -455,7 +455,7 @@ let result: Result = task::try(proc() { fail!("oops!"); } }); -assert!(result.is_err()); +fail_unless!(result.is_err()); ~~~ Unlike `spawn`, the function spawned using `try` may return a value, @@ -540,13 +540,13 @@ spawn(proc() { }); from_child.send(22); -assert!(from_child.recv() == ~"22"); +fail_unless!(from_child.recv() == ~"22"); from_child.send(23); from_child.send(0); -assert!(from_child.recv() == ~"23"); -assert!(from_child.recv() == ~"0"); +fail_unless!(from_child.recv() == ~"23"); +fail_unless!(from_child.recv() == ~"0"); # } ~~~~ diff --git a/src/doc/guide-testing.md b/src/doc/guide-testing.md index f129f7db72994..aa5de7612cd2c 100644 --- a/src/doc/guide-testing.md +++ b/src/doc/guide-testing.md @@ -12,7 +12,7 @@ fn return_two() -> int { #[test] fn return_two_test() { let x = return_two(); - assert!(x == 2); + fail_unless!(x == 2); } ~~~ diff --git a/src/doc/po/ja/complement-cheatsheet.md.po b/src/doc/po/ja/complement-cheatsheet.md.po index 72ef1d5a0102b..1d2767057a2d4 100644 --- a/src/doc/po/ja/complement-cheatsheet.md.po +++ b/src/doc/po/ja/complement-cheatsheet.md.po @@ -33,13 +33,13 @@ msgstr "" #: src/doc/complement-cheatsheet.md:13 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "~~~ let x: int = 42; let y: ~str = x.to_str(); ~~~" msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -60,13 +60,13 @@ msgstr "" #: src/doc/complement-cheatsheet.md:22 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "~~~ let x: Option = from_str(\"42\"); let y: int = x.unwrap(); ~~~" msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -95,13 +95,13 @@ msgstr "" #: src/doc/complement-cheatsheet.md:33 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "let x: int = 42; let y: ~str = x.to_str_radix(16); ~~~" msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -131,7 +131,7 @@ msgstr "" #: src/doc/complement-cheatsheet.md:44 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "" "let x: Option = from_str_radix(\"deadbeef\", 16); let y: i64 = x." "unwrap(); ~~~" @@ -139,7 +139,7 @@ msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text diff --git a/src/doc/po/ja/rust.md.po b/src/doc/po/ja/rust.md.po index 0e96f4db84bf4..1d4a6ab9d042b 100644 --- a/src/doc/po/ja/rust.md.po +++ b/src/doc/po/ja/rust.md.po @@ -1190,7 +1190,7 @@ msgstr "" #: src/doc/rust.md:2637 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "" "let x: int = add(1, 2); let pi: Option = FromStr::from_str(\"3.14\"); " "~~~~" @@ -1198,7 +1198,7 @@ msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -1354,7 +1354,7 @@ msgstr "## 構文拡張" msgid "" "fn main() {\n" " let a = Cons(6, ~Cons(7, ~Cons(42, ~Nil)));\n" -" assert!(is_sorted(&a));\n" +" fail_unless!(is_sorted(&a));\n" "}\n" msgstr "" "~~~~ {.ignore}\n" @@ -1498,14 +1498,14 @@ msgstr "## 最小限の例" #: src/doc/rust.md:3129 #, fuzzy #| msgid "" -#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgid "" -"~~~~ let v: &[int] = &[7, 5, 3]; let i: int = v[2]; assert!(i == 3); ~~~~" +"~~~~ let v: &[int] = &[7, 5, 3]; let i: int = v[2]; fail_unless!(i == 3); ~~~~" msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -1795,7 +1795,7 @@ msgstr "" #| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: " #| "20f }; println(fmt!(\"%f\", point.x)); ~~~" msgid "" -"~~~~ struct Foo { y: int } let x = @Foo{y: 10}; assert!(x.y == 10); ~~~~" +"~~~~ struct Foo { y: int } let x = @Foo{y: 10}; fail_unless!(x.y == 10); ~~~~" msgstr "" "~~~\n" "# struct Point { x: f64, y: f64 }\n" diff --git a/src/doc/po/ja/tutorial.md.po b/src/doc/po/ja/tutorial.md.po index 34769b320b7d0..0799fa50f3d55 100644 --- a/src/doc/po/ja/tutorial.md.po +++ b/src/doc/po/ja/tutorial.md.po @@ -990,12 +990,12 @@ msgstr "" #. type: Plain text #: src/doc/tutorial.md:383 -msgid "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~" +msgid "~~~~ let x: f64 = 4.0; let y: uint = x as uint; fail_unless!(y == 4u); ~~~~" msgstr "" "~~~~\n" "let x: f64 = 4.0;\n" "let y: uint = x as uint;\n" -"assert!(y == 4u);\n" +"fail_unless!(y == 4u);\n" "~~~~" #. type: Plain text @@ -1980,10 +1980,10 @@ msgstr "" #. type: Plain text #: src/doc/tutorial.md:875 -msgid "assert!(8 == line(5, 3, 1)); assert!(() == oops(5, 3, 1)); ~~~~" +msgid "fail_unless!(8 == line(5, 3, 1)); fail_unless!(() == oops(5, 3, 1)); ~~~~" msgstr "" -"assert!(8 == line(5, 3, 1));\n" -"assert!(() == oops(5, 3, 1));\n" +"fail_unless!(8 == line(5, 3, 1));\n" +"fail_unless!(() == oops(5, 3, 1));\n" "~~~~" #. type: Plain text diff --git a/src/doc/rust.md b/src/doc/rust.md index 9173156d91db6..33db8cda03651 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -2926,8 +2926,8 @@ fn is_symmetric(list: &[uint]) -> bool { fn main() { let sym = &[0, 1, 4, 2, 4, 1, 0]; let not_sym = &[0, 1, 7, 2, 4, 1, 0]; - assert!(is_symmetric(sym)); - assert!(!is_symmetric(not_sym)); + fail_unless!(is_symmetric(sym)); + fail_unless!(!is_symmetric(not_sym)); } ~~~~ @@ -2995,7 +2995,7 @@ fn is_sorted(list: &List) -> bool { fn main() { let a = Cons(6, ~Cons(7, ~Cons(42, ~Nil))); - assert!(is_sorted(&a)); + fail_unless!(is_sorted(&a)); } ~~~~ @@ -3163,7 +3163,7 @@ An example of a tuple type and its use: type Pair<'a> = (int,&'a str); let p: Pair<'static> = (10,"hello"); let (a, b) = p; -assert!(b != "world"); +fail_unless!(b != "world"); ~~~~ ### Vector types @@ -3189,7 +3189,7 @@ An example of a vector type and its use: ~~~~ let v: &[int] = &[7, 5, 3]; let i: int = v[2]; -assert!(i == 3); +fail_unless!(i == 3); ~~~~ All in-bounds elements of a vector are always initialized, diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 6454e22b896a4..4efa152c0d560 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -378,7 +378,7 @@ unsafe C-like casting of same-sized types. ~~~~ let x: f64 = 4.0; let y: uint = x as uint; -assert!(y == 4u); +fail_unless!(y == 4u); ~~~~ [transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute.html @@ -893,8 +893,8 @@ Ending the function with a semicolon like so is equivalent to returning `()`. fn line(a: int, b: int, x: int) -> int { a * x + b } fn oops(a: int, b: int, x: int) -> () { a * x + b; } -assert!(8 == line(5, 3, 1)); -assert!(() == oops(5, 3, 1)); +fail_unless!(8 == line(5, 3, 1)); +fail_unless!(() == oops(5, 3, 1)); ~~~~ As with `match` expressions and `let` bindings, function arguments support @@ -1204,7 +1204,7 @@ fn eq(xs: &List, ys: &List) -> bool { let xs = Cons(5, ~Cons(10, ~Nil)); let ys = Cons(5, ~Cons(10, ~Nil)); -assert!(eq(&xs, &ys)); +fail_unless!(eq(&xs, &ys)); ~~~ Note that Rust doesn't guarantee [tail-call](http://en.wikipedia.org/wiki/Tail_call) optimization, @@ -1307,7 +1307,7 @@ fn eq(xs: &List, ys: &List) -> bool { let xs = Cons('c', ~Cons('a', ~Cons('t', ~Nil))); let ys = Cons('c', ~Cons('a', ~Cons('t', ~Nil))); -assert!(eq(&xs, &ys)); +fail_unless!(eq(&xs, &ys)); ~~~ This would be a good opportunity to implement the `Eq` trait for our list type, making the `==` and @@ -1336,10 +1336,10 @@ impl Eq for List { let xs = Cons(5, ~Cons(10, ~Nil)); let ys = Cons(5, ~Cons(10, ~Nil)); -assert!(xs.eq(&ys)); -assert!(xs == ys); -assert!(!xs.ne(&ys)); -assert!(!(xs != ys)); +fail_unless!(xs.eq(&ys)); +fail_unless!(xs == ys); +fail_unless!(!xs.ne(&ys)); +fail_unless!(!(xs != ys)); ~~~ # More on boxes diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 0e14b28eda326..ee7624c35eb1e 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -322,7 +322,7 @@ impl Bitv { /// Retrieve the value at index `i` #[inline] pub fn get(&self, i: uint) -> bool { - assert!((i < self.nbits)); + fail_unless!((i < self.nbits)); match self.rep { Big(ref b) => b.get(i), Small(ref s) => s.get(i) @@ -336,7 +336,7 @@ impl Bitv { */ #[inline] pub fn set(&mut self, i: uint, x: bool) { - assert!((i < self.nbits)); + fail_unless!((i < self.nbits)); match self.rep { Big(ref mut b) => b.set(i, x), Small(ref mut s) => s.set(i, x) @@ -846,7 +846,7 @@ impl MutableSet for BitvSet { let nbits = self.capacity(); if value >= nbits { let newsize = cmp::max(value, nbits * 2) / uint::BITS + 1; - assert!(newsize > self.bitv.storage.len()); + fail_unless!(newsize > self.bitv.storage.len()); self.bitv.storage.grow(newsize, &0); } self.size += 1; @@ -965,15 +965,15 @@ mod tests { fn test_0_elements() { let act = Bitv::new(0u, false); let exp = vec::from_elem::(0u, false); - assert!(act.eq_vec(exp)); + fail_unless!(act.eq_vec(exp)); } #[test] fn test_1_element() { let mut act = Bitv::new(1u, false); - assert!(act.eq_vec([false])); + fail_unless!(act.eq_vec([false])); act = Bitv::new(1u, true); - assert!(act.eq_vec([true])); + fail_unless!(act.eq_vec([true])); } #[test] @@ -990,12 +990,12 @@ mod tests { // all 0 act = Bitv::new(10u, false); - assert!((act.eq_vec( + fail_unless!((act.eq_vec( [false, false, false, false, false, false, false, false, false, false]))); // all 1 act = Bitv::new(10u, true); - assert!((act.eq_vec([true, true, true, true, true, true, true, true, true, true]))); + fail_unless!((act.eq_vec([true, true, true, true, true, true, true, true, true, true]))); // mixed act = Bitv::new(10u, false); @@ -1004,7 +1004,7 @@ mod tests { act.set(2u, true); act.set(3u, true); act.set(4u, true); - assert!((act.eq_vec([true, true, true, true, true, false, false, false, false, false]))); + fail_unless!((act.eq_vec([true, true, true, true, true, false, false, false, false, false]))); // mixed act = Bitv::new(10u, false); @@ -1013,7 +1013,7 @@ mod tests { act.set(7u, true); act.set(8u, true); act.set(9u, true); - assert!((act.eq_vec([false, false, false, false, false, true, true, true, true, true]))); + fail_unless!((act.eq_vec([false, false, false, false, false, true, true, true, true, true]))); // mixed act = Bitv::new(10u, false); @@ -1021,7 +1021,7 @@ mod tests { act.set(3u, true); act.set(6u, true); act.set(9u, true); - assert!((act.eq_vec([true, false, false, true, false, false, true, false, false, true]))); + fail_unless!((act.eq_vec([true, false, false, true, false, false, true, false, false, true]))); } #[test] @@ -1030,14 +1030,14 @@ mod tests { // all 0 act = Bitv::new(31u, false); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::new(31u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); @@ -1052,7 +1052,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); @@ -1067,7 +1067,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false])); @@ -1081,7 +1081,7 @@ mod tests { act.set(28u, true); act.set(29u, true); act.set(30u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true])); @@ -1091,7 +1091,7 @@ mod tests { act.set(3u, true); act.set(17u, true); act.set(30u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true])); @@ -1103,14 +1103,14 @@ mod tests { // all 0 act = Bitv::new(32u, false); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::new(32u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); @@ -1125,7 +1125,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); @@ -1140,7 +1140,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false])); @@ -1155,7 +1155,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true])); @@ -1166,7 +1166,7 @@ mod tests { act.set(17u, true); act.set(30u, true); act.set(31u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true])); @@ -1178,14 +1178,14 @@ mod tests { // all 0 act = Bitv::new(33u, false); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); // all 1 act = Bitv::new(33u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true])); @@ -1200,7 +1200,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])); @@ -1215,7 +1215,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false])); @@ -1230,7 +1230,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, false])); @@ -1242,7 +1242,7 @@ mod tests { act.set(30u, true); act.set(31u, true); act.set(32u, true); - assert!(act.eq_vec( + fail_unless!(act.eq_vec( [false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true])); @@ -1252,14 +1252,14 @@ mod tests { fn test_equal_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(11u, false); - assert!(!v0.equal(&v1)); + fail_unless!(!v0.equal(&v1)); } #[test] fn test_equal_greatly_differing_sizes() { let v0 = Bitv::new(10u, false); let v1 = Bitv::new(110u, false); - assert!(!v0.equal(&v1)); + fail_unless!(!v0.equal(&v1)); } #[test] @@ -1270,7 +1270,7 @@ mod tests { let mut b = bitv::Bitv::new(1, true); b.set(0, true); - assert!(a.equal(&b)); + fail_unless!(a.equal(&b)); } #[test] @@ -1285,7 +1285,7 @@ mod tests { b.set(i, true); } - assert!(a.equal(&b)); + fail_unless!(a.equal(&b)); } #[test] @@ -1309,7 +1309,7 @@ mod tests { #[test] fn test_from_bools() { - assert!(from_bools([true, false, true, true]).to_str() == + fail_unless!(from_bools([true, false, true, true]).to_str() == ~"1011"); } @@ -1347,7 +1347,7 @@ mod tests { let bitset = BitvSet::from_bitv(Bitv::new(l, b)); assert_eq!(bitset.contains(&1u), b) assert_eq!(bitset.contains(&(l-1u)), b) - assert!(!bitset.contains(&l)) + fail_unless!(!bitset.contains(&l)) } } } @@ -1360,10 +1360,10 @@ mod tests { b1.set(1, true); b2.set(1, true); b2.set(2, true); - assert!(b1.difference(&b2)); - assert!(b1[0]); - assert!(!b1[1]); - assert!(!b1[2]); + fail_unless!(b1.difference(&b2)); + fail_unless!(b1[0]); + fail_unless!(!b1[1]); + fail_unless!(!b1[2]); } #[test] @@ -1374,10 +1374,10 @@ mod tests { b1.set(40, true); b2.set(40, true); b2.set(80, true); - assert!(b1.difference(&b2)); - assert!(b1[0]); - assert!(!b1[40]); - assert!(!b1[80]); + fail_unless!(b1.difference(&b2)); + fail_unless!(b1[0]); + fail_unless!(!b1[40]); + fail_unless!(!b1[80]); } #[test] @@ -1401,12 +1401,12 @@ mod tests { #[test] fn test_bitv_set_basic() { let mut b = BitvSet::new(); - assert!(b.insert(3)); - assert!(!b.insert(3)); - assert!(b.contains(&3)); - assert!(b.insert(400)); - assert!(!b.insert(400)); - assert!(b.contains(&400)); + fail_unless!(b.insert(3)); + fail_unless!(!b.insert(3)); + fail_unless!(b.contains(&3)); + fail_unless!(b.insert(400)); + fail_unless!(!b.insert(400)); + fail_unless!(b.contains(&400)); assert_eq!(b.len(), 2); } @@ -1415,18 +1415,18 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - assert!(a.insert(11)); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(77)); - assert!(a.insert(103)); - assert!(a.insert(5)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(77)); + fail_unless!(a.insert(103)); + fail_unless!(a.insert(5)); - assert!(b.insert(2)); - assert!(b.insert(11)); - assert!(b.insert(77)); - assert!(b.insert(5)); - assert!(b.insert(3)); + fail_unless!(b.insert(2)); + fail_unless!(b.insert(11)); + fail_unless!(b.insert(77)); + fail_unless!(b.insert(5)); + fail_unless!(b.insert(3)); let mut i = 0; let expected = [3, 5, 11, 77]; @@ -1443,14 +1443,14 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(200)); - assert!(a.insert(500)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(200)); + fail_unless!(a.insert(500)); - assert!(b.insert(3)); - assert!(b.insert(200)); + fail_unless!(b.insert(3)); + fail_unless!(b.insert(200)); let mut i = 0; let expected = [1, 5, 500]; @@ -1467,16 +1467,16 @@ mod tests { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(9)); - assert!(a.insert(11)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(9)); + fail_unless!(a.insert(11)); - assert!(b.insert(3)); - assert!(b.insert(9)); - assert!(b.insert(14)); - assert!(b.insert(220)); + fail_unless!(b.insert(3)); + fail_unless!(b.insert(9)); + fail_unless!(b.insert(14)); + fail_unless!(b.insert(220)); let mut i = 0; let expected = [1, 5, 11, 14, 220]; @@ -1492,20 +1492,20 @@ mod tests { fn test_bitv_set_union() { let mut a = BitvSet::new(); let mut b = BitvSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(9)); - assert!(a.insert(11)); - assert!(a.insert(160)); - assert!(a.insert(19)); - assert!(a.insert(24)); - - assert!(b.insert(1)); - assert!(b.insert(5)); - assert!(b.insert(9)); - assert!(b.insert(13)); - assert!(b.insert(19)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(9)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(160)); + fail_unless!(a.insert(19)); + fail_unless!(a.insert(24)); + + fail_unless!(b.insert(1)); + fail_unless!(b.insert(5)); + fail_unless!(b.insert(9)); + fail_unless!(b.insert(13)); + fail_unless!(b.insert(19)); let mut i = 0; let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160]; @@ -1521,14 +1521,14 @@ mod tests { fn test_bitv_remove() { let mut a = BitvSet::new(); - assert!(a.insert(1)); - assert!(a.remove(&1)); + fail_unless!(a.insert(1)); + fail_unless!(a.remove(&1)); - assert!(a.insert(100)); - assert!(a.remove(&100)); + fail_unless!(a.insert(100)); + fail_unless!(a.remove(&100)); - assert!(a.insert(1000)); - assert!(a.remove(&1000)); + fail_unless!(a.insert(1000)); + fail_unless!(a.remove(&1000)); assert_eq!(a.capacity(), uint::BITS); } @@ -1536,19 +1536,19 @@ mod tests { fn test_bitv_clone() { let mut a = BitvSet::new(); - assert!(a.insert(1)); - assert!(a.insert(100)); - assert!(a.insert(1000)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(100)); + fail_unless!(a.insert(1000)); let mut b = a.clone(); assert_eq!(&a, &b); - assert!(b.remove(&1)); - assert!(a.contains(&1)); + fail_unless!(b.remove(&1)); + fail_unless!(a.contains(&1)); - assert!(a.remove(&1000)); - assert!(b.contains(&1000)); + fail_unless!(a.remove(&1000)); + fail_unless!(b.contains(&1000)); } fn rng() -> rand::IsaacRng { diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 13b39da0756e0..571d0e2bddec1 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -735,7 +735,7 @@ mod test_btree { let b = BTree::new(1, ~"abc", 2); let is_insert = b.insert(2, ~"xyz"); //println!("{}", is_insert.clone().to_str()); - assert!(is_insert.root.is_leaf()); + fail_unless!(is_insert.root.is_leaf()); } #[test] @@ -746,7 +746,7 @@ mod test_btree { let n = Node::new_leaf(~[leaf_elt_1, leaf_elt_2, leaf_elt_3]); let b = BTree::new_with_node_len(n, 3, 2); //println!("{}", b.clone().insert(4, ~"ddd").to_str()); - assert!(b.insert(4, ~"ddd").root.is_leaf()); + fail_unless!(b.insert(4, ~"ddd").root.is_leaf()); } #[test] @@ -758,7 +758,7 @@ mod test_btree { let n = Node::new_leaf(~[leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4]); let b = BTree::new_with_node_len(n, 3, 2); //println!("{}", b.clone().insert(5, ~"eee").to_str()); - assert!(!b.insert(5, ~"eee").root.is_leaf()); + fail_unless!(!b.insert(5, ~"eee").root.is_leaf()); } #[test] @@ -775,7 +775,7 @@ mod test_btree { b = b.clone().insert(8, ~"hhh"); b = b.clone().insert(0, ~"omg"); //println!("{}", b.clone().to_str()); - assert!(!b.root.is_leaf()); + fail_unless!(!b.root.is_leaf()); } #[test] @@ -825,7 +825,7 @@ mod test_btree { fn btree_clone_test() { let b = BTree::new(1, ~"abc", 2); let b2 = b.clone(); - assert!(b.root.equals(&b2.root)) + fail_unless!(b.root.equals(&b2.root)) } //Tests the BTree's cmp() method when one node is "less than" another. @@ -833,7 +833,7 @@ mod test_btree { fn btree_cmp_test_less() { let b = BTree::new(1, ~"abc", 2); let b2 = BTree::new(2, ~"bcd", 2); - assert!(&b.cmp(&b2) == &Less) + fail_unless!(&b.cmp(&b2) == &Less) } //Tests the BTree's cmp() method when two nodes are equal. @@ -841,7 +841,7 @@ mod test_btree { fn btree_cmp_test_eq() { let b = BTree::new(1, ~"abc", 2); let b2 = BTree::new(1, ~"bcd", 2); - assert!(&b.cmp(&b2) == &Equal) + fail_unless!(&b.cmp(&b2) == &Equal) } //Tests the BTree's cmp() method when one node is "greater than" another. @@ -849,7 +849,7 @@ mod test_btree { fn btree_cmp_test_greater() { let b = BTree::new(1, ~"abc", 2); let b2 = BTree::new(2, ~"bcd", 2); - assert!(&b2.cmp(&b) == &Greater) + fail_unless!(&b2.cmp(&b) == &Greater) } //Tests the BTree's to_str() method. diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 591561d775eb2..cec83562f5575 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -899,21 +899,21 @@ mod tests { } assert_eq!(len, 0); let mut n = DList::new(); - assert!(n.mut_iter().next().is_none()); + fail_unless!(n.mut_iter().next().is_none()); n.push_front(4); n.push_back(5); let mut it = n.mut_iter(); assert_eq!(it.size_hint(), (2, Some(2))); - assert!(it.next().is_some()); - assert!(it.next().is_some()); + fail_unless!(it.next().is_some()); + fail_unless!(it.next().is_some()); assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] fn test_iterator_mut_double_end() { let mut n = DList::new(); - assert!(n.mut_iter().next_back().is_none()); + fail_unless!(n.mut_iter().next_back().is_none()); n.push_front(4); n.push_front(5); n.push_front(6); @@ -924,8 +924,8 @@ mod tests { assert_eq!(*it.next_back().unwrap(), 4); assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(*it.next_back().unwrap(), 5); - assert!(it.next_back().is_none()); - assert!(it.next().is_none()); + fail_unless!(it.next_back().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -989,11 +989,11 @@ mod tests { assert_eq!((6-i) as int, *elt); } let mut n = DList::new(); - assert!(n.mut_rev_iter().next().is_none()); + fail_unless!(n.mut_rev_iter().next().is_none()); n.push_front(4); let mut it = n.mut_rev_iter(); - assert!(it.next().is_some()); - assert!(it.next().is_none()); + fail_unless!(it.next().is_some()); + fail_unless!(it.next().is_none()); } #[test] @@ -1011,23 +1011,23 @@ mod tests { let mut m = list_from([]); assert_eq!(&n, &m); n.push_front(1); - assert!(n != m); + fail_unless!(n != m); m.push_back(1); assert_eq!(&n, &m); let n = list_from([2,3,4]); let m = list_from([1,2,3]); - assert!(n != m); + fail_unless!(n != m); } #[test] fn test_ord() { let n: DList = list_from([]); let m = list_from([1,2,3]); - assert!(n < m); - assert!(m > n); - assert!(n <= n); - assert!(n >= n); + fail_unless!(n < m); + fail_unless!(m > n); + fail_unless!(n <= n); + fail_unless!(n >= n); } #[test] @@ -1035,31 +1035,31 @@ mod tests { let nan = 0.0/0.0; let n = list_from([nan]); let m = list_from([nan]); - assert!(!(n < m)); - assert!(!(n > m)); - assert!(!(n <= m)); - assert!(!(n >= m)); + fail_unless!(!(n < m)); + fail_unless!(!(n > m)); + fail_unless!(!(n <= m)); + fail_unless!(!(n >= m)); let n = list_from([nan]); let one = list_from([1.0]); - assert!(!(n < one)); - assert!(!(n > one)); - assert!(!(n <= one)); - assert!(!(n >= one)); + fail_unless!(!(n < one)); + fail_unless!(!(n > one)); + fail_unless!(!(n <= one)); + fail_unless!(!(n >= one)); let u = list_from([1.0,2.0,nan]); let v = list_from([1.0,2.0,3.0]); - assert!(!(u < v)); - assert!(!(u > v)); - assert!(!(u <= v)); - assert!(!(u >= v)); + fail_unless!(!(u < v)); + fail_unless!(!(u > v)); + fail_unless!(!(u <= v)); + fail_unless!(!(u >= v)); let s = list_from([1.0,2.0,4.0,2.0]); let t = list_from([1.0,2.0,3.0,2.0]); - assert!(!(s < t)); - assert!(s > one); - assert!(!(s <= one)); - assert!(s >= one); + fail_unless!(!(s < t)); + fail_unless!(s > one); + fail_unless!(!(s <= one)); + fail_unless!(s >= one); } #[test] @@ -1175,7 +1175,7 @@ mod tests { let v = &[0, ..128]; let m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.iter().len() == 128); + fail_unless!(m.iter().len() == 128); }) } #[bench] @@ -1183,7 +1183,7 @@ mod tests { let v = &[0, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.mut_iter().len() == 128); + fail_unless!(m.mut_iter().len() == 128); }) } #[bench] @@ -1191,7 +1191,7 @@ mod tests { let v = &[0, ..128]; let m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.rev_iter().len() == 128); + fail_unless!(m.rev_iter().len() == 128); }) } #[bench] @@ -1199,7 +1199,7 @@ mod tests { let v = &[0, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { - assert!(m.mut_rev_iter().len() == 128); + fail_unless!(m.mut_rev_iter().len() == 128); }) } } diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 94d378b9dc4ce..6ab61eb91a83f 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -160,7 +160,7 @@ mod test { #[test] fn test_empty() { let e: EnumSet = EnumSet::empty(); - assert!(e.is_empty()); + fail_unless!(e.is_empty()); } /////////////////////////////////////////////////////////////////////////// @@ -170,7 +170,7 @@ mod test { fn test_two_empties_do_not_intersect() { let e1: EnumSet = EnumSet::empty(); let e2: EnumSet = EnumSet::empty(); - assert!(!e1.intersects(e2)); + fail_unless!(!e1.intersects(e2)); } #[test] @@ -182,7 +182,7 @@ mod test { e2.add(B); e2.add(C); - assert!(!e1.intersects(e2)); + fail_unless!(!e1.intersects(e2)); } #[test] @@ -193,7 +193,7 @@ mod test { let mut e2: EnumSet = EnumSet::empty(); e2.add(B); - assert!(!e1.intersects(e2)); + fail_unless!(!e1.intersects(e2)); } #[test] @@ -205,7 +205,7 @@ mod test { e2.add(A); e2.add(B); - assert!(e1.intersects(e2)); + fail_unless!(e1.intersects(e2)); } /////////////////////////////////////////////////////////////////////////// @@ -220,23 +220,23 @@ mod test { e2.add(A); e2.add(B); - assert!(!e1.contains(e2)); - assert!(e2.contains(e1)); + fail_unless!(!e1.contains(e2)); + fail_unless!(e2.contains(e1)); } #[test] fn test_contains_elem() { let mut e1: EnumSet = EnumSet::empty(); e1.add(A); - assert!(e1.contains_elem(A)); - assert!(!e1.contains_elem(B)); - assert!(!e1.contains_elem(C)); + fail_unless!(e1.contains_elem(A)); + fail_unless!(!e1.contains_elem(B)); + fail_unless!(!e1.contains_elem(C)); e1.add(A); e1.add(B); - assert!(e1.contains_elem(A)); - assert!(e1.contains_elem(B)); - assert!(!e1.contains_elem(C)); + fail_unless!(e1.contains_elem(A)); + fail_unless!(e1.contains_elem(B)); + fail_unless!(!e1.contains_elem(C)); } /////////////////////////////////////////////////////////////////////////// diff --git a/src/libcollections/list.rs b/src/libcollections/list.rs index 0dc13aa2b49e2..f4f9332825a48 100644 --- a/src/libcollections/list.rs +++ b/src/libcollections/list.rs @@ -184,9 +184,9 @@ mod tests { let full1 = from_vec([1]); let full2 = from_vec(['r', 'u']); - assert!(is_empty(empty)); - assert!(!is_empty(full1)); - assert!(!is_empty(full2)); + fail_unless!(is_empty(empty)); + fail_unless!(!is_empty(full1)); + fail_unless!(!is_empty(full2)); } #[test] @@ -255,10 +255,10 @@ mod tests { fn test_has() { let l = from_vec([5, 8, 6]); let empty = @list::Nil::; - assert!((list::has(l, 5))); - assert!((!list::has(l, 7))); - assert!((list::has(l, 8))); - assert!((!list::has(empty, 5))); + fail_unless!((list::has(l, 5))); + fail_unless!((!list::has(l, 7))); + fail_unless!((list::has(l, 8))); + fail_unless!((!list::has(empty, 5))); } #[test] @@ -271,7 +271,7 @@ mod tests { #[test] fn test_append() { - assert!(from_vec([1,2,3,4]) + fail_unless!(from_vec([1,2,3,4]) == list::append(list::from_vec([1,2]), list::from_vec([3,4]))); } } diff --git a/src/libcollections/lru_cache.rs b/src/libcollections/lru_cache.rs index de7b511fd41f1..b33f0278b91c6 100644 --- a/src/libcollections/lru_cache.rs +++ b/src/libcollections/lru_cache.rs @@ -23,7 +23,7 @@ //! cache.put(1, 10); //! cache.put(2, 20); //! cache.put(3, 30); -//! assert!(cache.get(&1).is_none()); +//! fail_unless!(cache.get(&1).is_none()); //! assert_eq!(*cache.get(&2).unwrap(), 20); //! assert_eq!(*cache.get(&3).unwrap(), 30); //! @@ -31,10 +31,10 @@ //! assert_eq!(*cache.get(&2).unwrap(), 22); //! //! cache.put(6, 60); -//! assert!(cache.get(&3).is_none()); +//! fail_unless!(cache.get(&3).is_none()); //! //! cache.change_capacity(1); -//! assert!(cache.get(&2).is_none()); +//! fail_unless!(cache.get(&2).is_none()); //! ``` use std::container::Container; @@ -278,7 +278,7 @@ mod tests { use super::LruCache; fn assert_opt_eq(opt: Option<&V>, v: V) { - assert!(opt.is_some()); + fail_unless!(opt.is_some()); assert_eq!(opt.unwrap(), &v); } @@ -307,10 +307,10 @@ mod tests { cache.put(~"foo1", ~"bar1"); cache.put(~"foo2", ~"bar2"); cache.put(~"foo3", ~"bar3"); - assert!(cache.get(&~"foo1").is_none()); + fail_unless!(cache.get(&~"foo1").is_none()); cache.put(~"foo2", ~"bar2update"); cache.put(~"foo4", ~"bar4"); - assert!(cache.get(&~"foo3").is_none()); + fail_unless!(cache.get(&~"foo3").is_none()); } #[test] @@ -320,9 +320,9 @@ mod tests { cache.put(2, 20); assert_eq!(cache.len(), 2); let opt1 = cache.pop(&1); - assert!(opt1.is_some()); + fail_unless!(opt1.is_some()); assert_eq!(opt1.unwrap(), 10); - assert!(cache.get(&1).is_none()); + fail_unless!(cache.get(&1).is_none()); assert_eq!(cache.len(), 1); } @@ -333,7 +333,7 @@ mod tests { cache.put(1, 10); cache.put(2, 20); cache.change_capacity(1); - assert!(cache.get(&1).is_none()); + fail_unless!(cache.get(&1).is_none()); assert_eq!(cache.capacity(), 1); } @@ -360,8 +360,8 @@ mod tests { cache.put(1, 10); cache.put(2, 20); cache.clear(); - assert!(cache.get(&1).is_none()); - assert!(cache.get(&2).is_none()); + fail_unless!(cache.get(&1).is_none()); + fail_unless!(cache.get(&2).is_none()); assert_eq!(cache.to_str(), ~"{}"); } } diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 5463d267787db..5005d5cfce30a 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -246,44 +246,44 @@ mod tests { fn test_push() { let mut heap = PriorityQueue::from_vec(~[2, 4, 9]); assert_eq!(heap.len(), 3); - assert!(*heap.top() == 9); + fail_unless!(*heap.top() == 9); heap.push(11); assert_eq!(heap.len(), 4); - assert!(*heap.top() == 11); + fail_unless!(*heap.top() == 11); heap.push(5); assert_eq!(heap.len(), 5); - assert!(*heap.top() == 11); + fail_unless!(*heap.top() == 11); heap.push(27); assert_eq!(heap.len(), 6); - assert!(*heap.top() == 27); + fail_unless!(*heap.top() == 27); heap.push(3); assert_eq!(heap.len(), 7); - assert!(*heap.top() == 27); + fail_unless!(*heap.top() == 27); heap.push(103); assert_eq!(heap.len(), 8); - assert!(*heap.top() == 103); + fail_unless!(*heap.top() == 103); } #[test] fn test_push_unique() { let mut heap = PriorityQueue::from_vec(~[~2, ~4, ~9]); assert_eq!(heap.len(), 3); - assert!(*heap.top() == ~9); + fail_unless!(*heap.top() == ~9); heap.push(~11); assert_eq!(heap.len(), 4); - assert!(*heap.top() == ~11); + fail_unless!(*heap.top() == ~11); heap.push(~5); assert_eq!(heap.len(), 5); - assert!(*heap.top() == ~11); + fail_unless!(*heap.top() == ~11); heap.push(~27); assert_eq!(heap.len(), 6); - assert!(*heap.top() == ~27); + fail_unless!(*heap.top() == ~27); heap.push(~3); assert_eq!(heap.len(), 7); - assert!(*heap.top() == ~27); + fail_unless!(*heap.top() == ~27); heap.push(~103); assert_eq!(heap.len(), 8); - assert!(*heap.top() == ~103); + fail_unless!(*heap.top() == ~103); } #[test] @@ -351,7 +351,7 @@ mod tests { #[test] fn test_empty_maybe_pop() { let mut heap: PriorityQueue = PriorityQueue::new(); - assert!(heap.maybe_pop().is_none()); + fail_unless!(heap.maybe_pop().is_none()); } #[test] @@ -364,7 +364,7 @@ mod tests { #[test] fn test_empty_maybe_top() { let empty: PriorityQueue = PriorityQueue::new(); - assert!(empty.maybe_top().is_none()); + fail_unless!(empty.maybe_top().is_none()); } #[test] diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 8abc5a3ca115b..2aafed97abc0f 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -151,8 +151,8 @@ impl RingBuf { /// /// Fails if there is no element with the given index pub fn swap(&mut self, i: uint, j: uint) { - assert!(i < self.len()); - assert!(j < self.len()); + fail_unless!(i < self.len()); + fail_unless!(j < self.len()); let ri = self.raw_index(i); let rj = self.raw_index(j); self.elts.swap(ri, rj); @@ -301,7 +301,7 @@ impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> { let r = if self.remaining1.len() > 0 { &mut self.remaining1 } else { - assert!(self.remaining2.len() > 0); + fail_unless!(self.remaining2.len() > 0); &mut self.remaining2 }; self.nelts -= 1; @@ -323,7 +323,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> { let r = if self.remaining2.len() > 0 { &mut self.remaining2 } else { - assert!(self.remaining1.len() > 0); + fail_unless!(self.remaining1.len() > 0); &mut self.remaining1 }; self.nelts -= 1; @@ -355,7 +355,7 @@ fn grow(nelts: uint, loptr: &mut uint, elts: &mut ~[Option]) { B [o o o|. . . . . . . .|o o o o o] */ - assert!(newlen - nelts/2 >= nelts); + fail_unless!(newlen - nelts/2 >= nelts); if lo <= (nelts - lo) { // A for i in range(0u, lo) { elts.swap(i, nelts + i); @@ -745,7 +745,7 @@ mod tests { #[test] fn test_mut_rev_iter_wrap() { let mut d = RingBuf::with_capacity(3); - assert!(d.mut_rev_iter().next().is_none()); + fail_unless!(d.mut_rev_iter().next().is_none()); d.push_back(1); d.push_back(2); @@ -760,7 +760,7 @@ mod tests { #[test] fn test_mut_iter() { let mut d = RingBuf::new(); - assert!(d.mut_iter().next().is_none()); + fail_unless!(d.mut_iter().next().is_none()); for i in range(0u, 3) { d.push_front(i); @@ -776,14 +776,14 @@ mod tests { assert_eq!(*it.next().unwrap(), 0); assert_eq!(*it.next().unwrap(), 1); assert_eq!(*it.next().unwrap(), 2); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } } #[test] fn test_mut_rev_iter() { let mut d = RingBuf::new(); - assert!(d.mut_rev_iter().next().is_none()); + fail_unless!(d.mut_rev_iter().next().is_none()); for i in range(0u, 3) { d.push_front(i); @@ -799,7 +799,7 @@ mod tests { assert_eq!(*it.next().unwrap(), 0); assert_eq!(*it.next().unwrap(), 1); assert_eq!(*it.next().unwrap(), 2); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } } @@ -852,7 +852,7 @@ mod tests { assert_eq!(&e, &d); e.pop_back(); e.push_back(0); - assert!(e != d); + fail_unless!(e != d); e.clear(); assert_eq!(e, RingBuf::new()); } diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index d7b0e66aad7e3..391c5fd6d1940 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -261,9 +261,9 @@ mod test_map { #[test] fn test_find_mut() { let mut m = SmallIntMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + fail_unless!(m.insert(1, 12)); + fail_unless!(m.insert(2, 8)); + fail_unless!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -275,29 +275,29 @@ mod test_map { fn test_len() { let mut map = SmallIntMap::new(); assert_eq!(map.len(), 0); - assert!(map.is_empty()); - assert!(map.insert(5, 20)); + fail_unless!(map.is_empty()); + fail_unless!(map.insert(5, 20)); assert_eq!(map.len(), 1); - assert!(!map.is_empty()); - assert!(map.insert(11, 12)); + fail_unless!(!map.is_empty()); + fail_unless!(map.insert(11, 12)); assert_eq!(map.len(), 2); - assert!(!map.is_empty()); - assert!(map.insert(14, 22)); + fail_unless!(!map.is_empty()); + fail_unless!(map.insert(14, 22)); assert_eq!(map.len(), 3); - assert!(!map.is_empty()); + fail_unless!(!map.is_empty()); } #[test] fn test_clear() { let mut map = SmallIntMap::new(); - assert!(map.insert(5, 20)); - assert!(map.insert(11, 12)); - assert!(map.insert(14, 22)); + fail_unless!(map.insert(5, 20)); + fail_unless!(map.insert(11, 12)); + fail_unless!(map.insert(14, 22)); map.clear(); - assert!(map.is_empty()); - assert!(map.find(&5).is_none()); - assert!(map.find(&11).is_none()); - assert!(map.find(&14).is_none()); + fail_unless!(map.is_empty()); + fail_unless!(map.find(&5).is_none()); + fail_unless!(map.find(&11).is_none()); + fail_unless!(map.find(&14).is_none()); } #[test] @@ -327,7 +327,7 @@ mod test_map { assert_eq!(map.find(&9).unwrap(), &1); // sadly, no sevens were counted - assert!(map.find(&7).is_none()); + fail_unless!(map.find(&7).is_none()); } #[test] @@ -350,11 +350,11 @@ mod test_map { fn test_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); - assert!(m.insert(1, 2)); - assert!(m.insert(3, 5)); - assert!(m.insert(6, 10)); - assert!(m.insert(10, 11)); + fail_unless!(m.insert(0, 1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(3, 5)); + fail_unless!(m.insert(6, 10)); + fail_unless!(m.insert(10, 11)); let mut it = m.iter(); assert_eq!(it.size_hint(), (0, Some(11))); @@ -368,18 +368,18 @@ mod test_map { assert_eq!(it.size_hint(), (0, Some(4))); assert_eq!(it.next().unwrap(), (10, &11)); assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] fn test_iterator_size_hints() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); - assert!(m.insert(1, 2)); - assert!(m.insert(3, 5)); - assert!(m.insert(6, 10)); - assert!(m.insert(10, 11)); + fail_unless!(m.insert(0, 1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(3, 5)); + fail_unless!(m.insert(6, 10)); + fail_unless!(m.insert(10, 11)); assert_eq!(m.iter().size_hint(), (0, Some(11))); assert_eq!(m.rev_iter().size_hint(), (0, Some(11))); @@ -391,11 +391,11 @@ mod test_map { fn test_mut_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); - assert!(m.insert(1, 2)); - assert!(m.insert(3, 5)); - assert!(m.insert(6, 10)); - assert!(m.insert(10, 11)); + fail_unless!(m.insert(0, 1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(3, 5)); + fail_unless!(m.insert(6, 10)); + fail_unless!(m.insert(10, 11)); for (k, v) in m.mut_iter() { *v += k as int; @@ -407,18 +407,18 @@ mod test_map { assert_eq!(it.next().unwrap(), (3, &8)); assert_eq!(it.next().unwrap(), (6, &16)); assert_eq!(it.next().unwrap(), (10, &21)); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] fn test_rev_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); - assert!(m.insert(1, 2)); - assert!(m.insert(3, 5)); - assert!(m.insert(6, 10)); - assert!(m.insert(10, 11)); + fail_unless!(m.insert(0, 1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(3, 5)); + fail_unless!(m.insert(6, 10)); + fail_unless!(m.insert(10, 11)); let mut it = m.rev_iter(); assert_eq!(it.next().unwrap(), (10, &11)); @@ -426,18 +426,18 @@ mod test_map { assert_eq!(it.next().unwrap(), (3, &5)); assert_eq!(it.next().unwrap(), (1, &2)); assert_eq!(it.next().unwrap(), (0, &1)); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] fn test_mut_rev_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); - assert!(m.insert(1, 2)); - assert!(m.insert(3, 5)); - assert!(m.insert(6, 10)); - assert!(m.insert(10, 11)); + fail_unless!(m.insert(0, 1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(3, 5)); + fail_unless!(m.insert(6, 10)); + fail_unless!(m.insert(10, 11)); for (k, v) in m.mut_rev_iter() { *v += k as int; @@ -449,7 +449,7 @@ mod test_map { assert_eq!(it.next().unwrap(), (3, &8)); assert_eq!(it.next().unwrap(), (6, &16)); assert_eq!(it.next().unwrap(), (10, &21)); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -458,12 +458,12 @@ mod test_map { m.insert(1, ~2); let mut called = false; for (k, v) in m.move_iter() { - assert!(!called); + fail_unless!(!called); called = true; assert_eq!(k, 1); assert_eq!(v, ~2); } - assert!(called); + fail_unless!(called); m.insert(2, ~1); } } diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index a4b2357960656..77b80c59ffc6f 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1082,24 +1082,24 @@ mod test_treemap { #[test] fn find_empty() { let m: TreeMap = TreeMap::new(); - assert!(m.find(&5) == None); + fail_unless!(m.find(&5) == None); } #[test] fn find_not_found() { let mut m = TreeMap::new(); - assert!(m.insert(1, 2)); - assert!(m.insert(5, 3)); - assert!(m.insert(9, 3)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 3)); assert_eq!(m.find(&2), None); } #[test] fn test_find_mut() { let mut m = TreeMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + fail_unless!(m.insert(1, 12)); + fail_unless!(m.insert(2, 8)); + fail_unless!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -1110,9 +1110,9 @@ mod test_treemap { #[test] fn insert_replace() { let mut m = TreeMap::new(); - assert!(m.insert(5, 2)); - assert!(m.insert(2, 9)); - assert!(!m.insert(2, 11)); + fail_unless!(m.insert(5, 2)); + fail_unless!(m.insert(2, 9)); + fail_unless!(!m.insert(2, 11)); assert_eq!(m.find(&2).unwrap(), &11); } @@ -1120,14 +1120,14 @@ mod test_treemap { fn test_clear() { let mut m = TreeMap::new(); m.clear(); - assert!(m.insert(5, 11)); - assert!(m.insert(12, -3)); - assert!(m.insert(19, 2)); + fail_unless!(m.insert(5, 11)); + fail_unless!(m.insert(12, -3)); + fail_unless!(m.insert(19, 2)); m.clear(); - assert!(m.find(&5).is_none()); - assert!(m.find(&12).is_none()); - assert!(m.find(&19).is_none()); - assert!(m.is_empty()); + fail_unless!(m.find(&5).is_none()); + fail_unless!(m.find(&12).is_none()); + fail_unless!(m.find(&19).is_none()); + fail_unless!(m.is_empty()); } #[test] @@ -1151,19 +1151,19 @@ mod test_treemap { assert_eq!(ctrl.is_empty(), map.is_empty()); for x in ctrl.iter() { let &(ref k, ref v) = x; - assert!(map.find(k).unwrap() == v) + fail_unless!(map.find(k).unwrap() == v) } for (map_k, map_v) in map.iter() { let mut found = false; for x in ctrl.iter() { let &(ref ctrl_k, ref ctrl_v) = x; if *map_k == *ctrl_k { - assert!(*map_v == *ctrl_v); + fail_unless!(*map_v == *ctrl_v); found = true; break; } } - assert!(found); + fail_unless!(found); } } @@ -1172,11 +1172,11 @@ mod test_treemap { match *node { Some(ref r) => { assert_eq!(r.key.cmp(&parent.key), Less); - assert!(r.level == parent.level - 1); // left is black + fail_unless!(r.level == parent.level - 1); // left is black check_left(&r.left, r); check_right(&r.right, r, false); } - None => assert!(parent.level == 1) // parent is leaf + None => fail_unless!(parent.level == 1) // parent is leaf } } @@ -1187,13 +1187,13 @@ mod test_treemap { Some(ref r) => { assert_eq!(r.key.cmp(&parent.key), Greater); let red = r.level == parent.level; - if parent_red { assert!(!red) } // no dual horizontal links + if parent_red { fail_unless!(!red) } // no dual horizontal links // Right red or black - assert!(red || r.level == parent.level - 1); + fail_unless!(red || r.level == parent.level - 1); check_left(&r.left, r); check_right(&r.right, r, red); } - None => assert!(parent.level == 1) // parent is leaf + None => fail_unless!(parent.level == 1) // parent is leaf } } @@ -1213,7 +1213,7 @@ mod test_treemap { let mut ctrl = ~[]; check_equal(ctrl, &map); - assert!(map.find(&5).is_none()); + fail_unless!(map.find(&5).is_none()); let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(&[42]); @@ -1222,7 +1222,7 @@ mod test_treemap { let k = rng.gen(); let v = rng.gen(); if !ctrl.iter().any(|x| x == &(k, v)) { - assert!(map.insert(k, v)); + fail_unless!(map.insert(k, v)); ctrl.push((k, v)); check_structure(&map); check_equal(ctrl, &map); @@ -1232,7 +1232,7 @@ mod test_treemap { for _ in range(0, 30) { let r = rng.gen_range(0, ctrl.len()); let (key, _) = ctrl.remove(r).unwrap(); - assert!(map.remove(&key)); + fail_unless!(map.remove(&key)); check_structure(&map); check_equal(ctrl, &map); } @@ -1242,19 +1242,19 @@ mod test_treemap { #[test] fn test_len() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); + fail_unless!(m.insert(3, 6)); assert_eq!(m.len(), 1); - assert!(m.insert(0, 0)); + fail_unless!(m.insert(0, 0)); assert_eq!(m.len(), 2); - assert!(m.insert(4, 8)); + fail_unless!(m.insert(4, 8)); assert_eq!(m.len(), 3); - assert!(m.remove(&3)); + fail_unless!(m.remove(&3)); assert_eq!(m.len(), 2); - assert!(!m.remove(&5)); + fail_unless!(!m.remove(&5)); assert_eq!(m.len(), 2); - assert!(m.insert(2, 4)); + fail_unless!(m.insert(2, 4)); assert_eq!(m.len(), 3); - assert!(m.insert(1, 2)); + fail_unless!(m.insert(1, 2)); assert_eq!(m.len(), 4); } @@ -1262,11 +1262,11 @@ mod test_treemap { fn test_iterator() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); - assert!(m.insert(0, 0)); - assert!(m.insert(4, 8)); - assert!(m.insert(2, 4)); - assert!(m.insert(1, 2)); + fail_unless!(m.insert(3, 6)); + fail_unless!(m.insert(0, 0)); + fail_unless!(m.insert(4, 8)); + fail_unless!(m.insert(2, 4)); + fail_unless!(m.insert(1, 2)); let mut n = 0; for (k, v) in m.iter() { @@ -1281,7 +1281,7 @@ mod test_treemap { fn test_interval_iteration() { let mut m = TreeMap::new(); for i in range(1, 100) { - assert!(m.insert(i * 2, i * 4)); + fail_unless!(m.insert(i * 2, i * 4)); } for i in range(1, 198) { @@ -1305,11 +1305,11 @@ mod test_treemap { fn test_rev_iter() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); - assert!(m.insert(0, 0)); - assert!(m.insert(4, 8)); - assert!(m.insert(2, 4)); - assert!(m.insert(1, 2)); + fail_unless!(m.insert(3, 6)); + fail_unless!(m.insert(0, 0)); + fail_unless!(m.insert(4, 8)); + fail_unless!(m.insert(2, 4)); + fail_unless!(m.insert(1, 2)); let mut n = 4; for (k, v) in m.rev_iter() { @@ -1323,7 +1323,7 @@ mod test_treemap { fn test_mut_iter() { let mut m = TreeMap::new(); for i in range(0u, 10) { - assert!(m.insert(i, 100 * i)); + fail_unless!(m.insert(i, 100 * i)); } for (i, (&k, v)) in m.mut_iter().enumerate() { @@ -1338,7 +1338,7 @@ mod test_treemap { fn test_mut_rev_iter() { let mut m = TreeMap::new(); for i in range(0u, 10) { - assert!(m.insert(i, 100 * i)); + fail_unless!(m.insert(i, 100 * i)); } for (i, (&k, v)) in m.mut_rev_iter().enumerate() { @@ -1355,8 +1355,8 @@ mod test_treemap { let mut m_lower = TreeMap::new(); let mut m_upper = TreeMap::new(); for i in range(1, 100) { - assert!(m_lower.insert(i * 2, i * 4)); - assert!(m_upper.insert(i * 2, i * 4)); + fail_unless!(m_lower.insert(i * 2, i * 4)); + fail_unless!(m_upper.insert(i * 2, i * 4)); } for i in range(1, 199) { @@ -1374,12 +1374,12 @@ mod test_treemap { *v -= k; } - assert!(m_lower.mut_lower_bound(&199).next().is_none()); + fail_unless!(m_lower.mut_lower_bound(&199).next().is_none()); - assert!(m_upper.mut_upper_bound(&198).next().is_none()); + fail_unless!(m_upper.mut_upper_bound(&198).next().is_none()); - assert!(m_lower.iter().all(|(_, &x)| x == 0)); - assert!(m_upper.iter().all(|(_, &x)| x == 0)); + fail_unless!(m_lower.iter().all(|(_, &x)| x == 0)); + fail_unless!(m_upper.iter().all(|(_, &x)| x == 0)); } #[test] @@ -1387,17 +1387,17 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - assert!(a == b); - assert!(a.insert(0, 5)); - assert!(a != b); - assert!(b.insert(0, 4)); - assert!(a != b); - assert!(a.insert(5, 19)); - assert!(a != b); - assert!(!b.insert(0, 5)); - assert!(a != b); - assert!(b.insert(5, 19)); - assert!(a == b); + fail_unless!(a == b); + fail_unless!(a.insert(0, 5)); + fail_unless!(a != b); + fail_unless!(b.insert(0, 4)); + fail_unless!(a != b); + fail_unless!(a.insert(5, 19)); + fail_unless!(a != b); + fail_unless!(!b.insert(0, 5)); + fail_unless!(a != b); + fail_unless!(b.insert(5, 19)); + fail_unless!(a == b); } #[test] @@ -1405,17 +1405,17 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - assert!(!(a < b) && !(b < a)); - assert!(b.insert(0, 5)); - assert!(a < b); - assert!(a.insert(0, 7)); - assert!(!(a < b) && b < a); - assert!(b.insert(-2, 0)); - assert!(b < a); - assert!(a.insert(-5, 2)); - assert!(a < b); - assert!(a.insert(6, 2)); - assert!(a < b && !(b < a)); + fail_unless!(!(a < b) && !(b < a)); + fail_unless!(b.insert(0, 5)); + fail_unless!(a < b); + fail_unless!(a.insert(0, 7)); + fail_unless!(!(a < b) && b < a); + fail_unless!(b.insert(-2, 0)); + fail_unless!(b < a); + fail_unless!(a.insert(-5, 2)); + fail_unless!(a < b); + fail_unless!(a.insert(6, 2)); + fail_unless!(a < b && !(b < a)); } #[test] @@ -1423,13 +1423,13 @@ mod test_treemap { let mut a = TreeMap::new(); let mut b = TreeMap::new(); - assert!(a <= b && a >= b); - assert!(a.insert(1, 1)); - assert!(a > b && a >= b); - assert!(b < a && b <= a); - assert!(b.insert(2, 2)); - assert!(b > a && b >= a); - assert!(a < b && a <= b); + fail_unless!(a <= b && a >= b); + fail_unless!(a.insert(1, 1)); + fail_unless!(a > b && a >= b); + fail_unless!(b < a && b <= a); + fail_unless!(b.insert(2, 2)); + fail_unless!(b > a && b >= a); + fail_unless!(a < b && a <= b); } #[test] @@ -1441,11 +1441,11 @@ mod test_treemap { let (x4, y4) = (29, 5); let (x5, y5) = (103, 3); - assert!(m.insert(x1, y1)); - assert!(m.insert(x2, y2)); - assert!(m.insert(x3, y3)); - assert!(m.insert(x4, y4)); - assert!(m.insert(x5, y5)); + fail_unless!(m.insert(x1, y1)); + fail_unless!(m.insert(x2, y2)); + fail_unless!(m.insert(x3, y3)); + fail_unless!(m.insert(x4, y4)); + fail_unless!(m.insert(x5, y5)); let m = m; let mut a = m.iter(); @@ -1456,7 +1456,7 @@ mod test_treemap { assert_eq!(a.next().unwrap(), (&x4, &y4)); assert_eq!(a.next().unwrap(), (&x5, &y5)); - assert!(a.next().is_none()); + fail_unless!(a.next().is_none()); let mut b = m.iter(); @@ -1561,76 +1561,76 @@ mod test_set { fn test_clear() { let mut s = TreeSet::new(); s.clear(); - assert!(s.insert(5)); - assert!(s.insert(12)); - assert!(s.insert(19)); + fail_unless!(s.insert(5)); + fail_unless!(s.insert(12)); + fail_unless!(s.insert(19)); s.clear(); - assert!(!s.contains(&5)); - assert!(!s.contains(&12)); - assert!(!s.contains(&19)); - assert!(s.is_empty()); + fail_unless!(!s.contains(&5)); + fail_unless!(!s.contains(&12)); + fail_unless!(!s.contains(&19)); + fail_unless!(s.is_empty()); } #[test] fn test_disjoint() { let mut xs = TreeSet::new(); let mut ys = TreeSet::new(); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(5)); - assert!(ys.insert(11)); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(7)); - assert!(xs.insert(19)); - assert!(xs.insert(4)); - assert!(ys.insert(2)); - assert!(ys.insert(-11)); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(ys.insert(7)); - assert!(!xs.is_disjoint(&ys)); - assert!(!ys.is_disjoint(&xs)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(xs.insert(5)); + fail_unless!(ys.insert(11)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(xs.insert(7)); + fail_unless!(xs.insert(19)); + fail_unless!(xs.insert(4)); + fail_unless!(ys.insert(2)); + fail_unless!(ys.insert(-11)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(ys.insert(7)); + fail_unless!(!xs.is_disjoint(&ys)); + fail_unless!(!ys.is_disjoint(&xs)); } #[test] fn test_subset_and_superset() { let mut a = TreeSet::new(); - assert!(a.insert(0)); - assert!(a.insert(5)); - assert!(a.insert(11)); - assert!(a.insert(7)); + fail_unless!(a.insert(0)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(7)); let mut b = TreeSet::new(); - assert!(b.insert(0)); - assert!(b.insert(7)); - assert!(b.insert(19)); - assert!(b.insert(250)); - assert!(b.insert(11)); - assert!(b.insert(200)); + fail_unless!(b.insert(0)); + fail_unless!(b.insert(7)); + fail_unless!(b.insert(19)); + fail_unless!(b.insert(250)); + fail_unless!(b.insert(11)); + fail_unless!(b.insert(200)); - assert!(!a.is_subset(&b)); - assert!(!a.is_superset(&b)); - assert!(!b.is_subset(&a)); - assert!(!b.is_superset(&a)); + fail_unless!(!a.is_subset(&b)); + fail_unless!(!a.is_superset(&b)); + fail_unless!(!b.is_subset(&a)); + fail_unless!(!b.is_superset(&a)); - assert!(b.insert(5)); + fail_unless!(b.insert(5)); - assert!(a.is_subset(&b)); - assert!(!a.is_superset(&b)); - assert!(!b.is_subset(&a)); - assert!(b.is_superset(&a)); + fail_unless!(a.is_subset(&b)); + fail_unless!(!a.is_superset(&b)); + fail_unless!(!b.is_subset(&a)); + fail_unless!(b.is_superset(&a)); } #[test] fn test_iterator() { let mut m = TreeSet::new(); - assert!(m.insert(3)); - assert!(m.insert(0)); - assert!(m.insert(4)); - assert!(m.insert(2)); - assert!(m.insert(1)); + fail_unless!(m.insert(3)); + fail_unless!(m.insert(0)); + fail_unless!(m.insert(4)); + fail_unless!(m.insert(2)); + fail_unless!(m.insert(1)); let mut n = 0; for x in m.iter() { @@ -1643,11 +1643,11 @@ mod test_set { fn test_rev_iter() { let mut m = TreeSet::new(); - assert!(m.insert(3)); - assert!(m.insert(0)); - assert!(m.insert(4)); - assert!(m.insert(2)); - assert!(m.insert(1)); + fail_unless!(m.insert(3)); + fail_unless!(m.insert(0)); + fail_unless!(m.insert(4)); + fail_unless!(m.insert(2)); + fail_unless!(m.insert(1)); let mut n = 4; for x in m.rev_iter() { @@ -1663,7 +1663,7 @@ mod test_set { m.insert(1); m.insert(2); - assert!(m.clone() == m); + fail_unless!(m.clone() == m); } fn check(a: &[int], @@ -1673,8 +1673,8 @@ mod test_set { let mut set_a = TreeSet::new(); let mut set_b = TreeSet::new(); - for x in a.iter() { assert!(set_a.insert(*x)) } - for y in b.iter() { assert!(set_b.insert(*y)) } + for x in a.iter() { fail_unless!(set_a.insert(*x)) } + for y in b.iter() { fail_unless!(set_b.insert(*y)) } let mut i = 0; f(&set_a, &set_b, |x| { @@ -1771,7 +1771,7 @@ mod test_set { assert_eq!(result.unwrap(), (&11u, & &"foo")); let result: Option<(&uint, & &'static str)> = z.next(); - assert!(result.is_none()); + fail_unless!(result.is_none()); } #[test] @@ -1797,7 +1797,7 @@ mod test_set { let set: TreeSet = xs.iter().map(|&x| x).collect(); for x in xs.iter() { - assert!(set.contains(x)); + fail_unless!(set.contains(x)); } } } diff --git a/src/libextra/c_vec.rs b/src/libextra/c_vec.rs index fec5b105c4b18..b49876b200ece 100644 --- a/src/libextra/c_vec.rs +++ b/src/libextra/c_vec.rs @@ -81,7 +81,7 @@ impl CVec { * * len - The number of elements in the buffer */ pub unsafe fn new(base: *mut T, len: uint) -> CVec { - assert!(base != ptr::mut_null()); + fail_unless!(base != ptr::mut_null()); CVec { base: base, len: len, @@ -103,7 +103,7 @@ impl CVec { * for freeing the buffer, etc. */ pub unsafe fn new_with_dtor(base: *mut T, len: uint, dtor: proc()) -> CVec { - assert!(base != ptr::mut_null()); + fail_unless!(base != ptr::mut_null()); CVec { base: base, len: len, @@ -117,7 +117,7 @@ impl CVec { * Fails if `ofs` is greater or equal to the length of the vector */ pub fn get<'a>(&'a self, ofs: uint) -> &'a T { - assert!(ofs < self.len); + fail_unless!(ofs < self.len); unsafe { &*self.base.offset(ofs as int) } @@ -129,7 +129,7 @@ impl CVec { * Fails if `ofs` is greater or equal to the length of the vector */ pub fn get_mut<'a>(&'a mut self, ofs: uint) -> &'a mut T { - assert!(ofs < self.len); + fail_unless!(ofs < self.len); unsafe { &mut *self.base.offset(ofs as int) } diff --git a/src/libextra/json.rs b/src/libextra/json.rs index 370d1026c415d..f362e62e80bab 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -2260,7 +2260,7 @@ mod tests { to_parse, expected_error), Err(e) => { let err = e.as_ref::<~str>().unwrap(); - assert!(err.contains(expected_error), + fail_unless!(err.contains(expected_error), "`{}` errored incorrectly, found `{}` expecting `{}`", to_parse, *err, expected_error); } diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index 181ea6766c575..8b4d6945a29d5 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -201,17 +201,17 @@ impl<'a> Stats for &'a [f64] { } fn min(self) -> f64 { - assert!(self.len() != 0); + fail_unless!(self.len() != 0); self.iter().fold(self[0], |p,q| cmp::min(p, *q)) } fn max(self) -> f64 { - assert!(self.len() != 0); + fail_unless!(self.len() != 0); self.iter().fold(self[0], |p,q| cmp::max(p, *q)) } fn mean(self) -> f64 { - assert!(self.len() != 0); + fail_unless!(self.len() != 0); self.sum() / (self.len() as f64) } @@ -282,12 +282,12 @@ impl<'a> Stats for &'a [f64] { // linear interpolation. If samples are not sorted, return nonsensical value. fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 { - assert!(sorted_samples.len() != 0); + fail_unless!(sorted_samples.len() != 0); if sorted_samples.len() == 1 { return sorted_samples[0]; } - assert!(0.0 <= pct); - assert!(pct <= 100.0); + fail_unless!(0.0 <= pct); + fail_unless!(pct <= 100.0); if pct == 100.0 { return sorted_samples[sorted_samples.len() - 1]; } @@ -445,7 +445,7 @@ mod tests { macro_rules! assert_approx_eq( ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, + fail_unless!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) ) diff --git a/src/libextra/unicode.rs b/src/libextra/unicode.rs index 094a4b02a249f..1f73190e5bc47 100644 --- a/src/libextra/unicode.rs +++ b/src/libextra/unicode.rs @@ -238,25 +238,25 @@ mod tests { #[test] fn test_is_digit() { - assert!((is_digit('0'))); - assert!((!is_digit('m'))); + fail_unless!((is_digit('0'))); + fail_unless!((!is_digit('m'))); } #[test] fn test_is_lower() { - assert!((is_lower('m'))); - assert!((!is_lower('M'))); + fail_unless!((is_lower('m'))); + fail_unless!((!is_lower('M'))); } #[test] fn test_is_space() { - assert!((is_space(' '))); - assert!((!is_space('m'))); + fail_unless!((is_space(' '))); + fail_unless!((!is_space('m'))); } #[test] fn test_is_upper() { - assert!((is_upper('M'))); - assert!((!is_upper('m'))); + fail_unless!((is_upper('M'))); + fail_unless!((!is_upper('m'))); } } diff --git a/src/libextra/url.rs b/src/libextra/url.rs index 4580dd9309883..b1c85ddef6b95 100644 --- a/src/libextra/url.rs +++ b/src/libextra/url.rs @@ -887,21 +887,21 @@ fn test_get_authority() { "//user:pass@rust-lang.org/something").unwrap(); assert_eq!(u, Some(UserInfo::new(~"user", Some(~"pass")))); assert_eq!(h, ~"rust-lang.org"); - assert!(p.is_none()); + fail_unless!(p.is_none()); assert_eq!(r, ~"/something"); let (u, h, p, r) = get_authority( "//rust-lang.org:8000?something").unwrap(); - assert!(u.is_none()); + fail_unless!(u.is_none()); assert_eq!(h, ~"rust-lang.org"); assert_eq!(p, Some(~"8000")); assert_eq!(r, ~"?something"); let (u, h, p, r) = get_authority( "//rust-lang.org#blah").unwrap(); - assert!(u.is_none()); + fail_unless!(u.is_none()); assert_eq!(h, ~"rust-lang.org"); - assert!(p.is_none()); + fail_unless!(p.is_none()); assert_eq!(r, ~"#blah"); // ipv6 tests @@ -922,11 +922,11 @@ fn test_get_authority() { assert_eq!(p, Some(~"8000")); // invalid authorities; - assert!(get_authority("//user:pass@rust-lang:something").is_err()); - assert!(get_authority("//user@rust-lang:something:/path").is_err()); - assert!(get_authority( + fail_unless!(get_authority("//user:pass@rust-lang:something").is_err()); + fail_unless!(get_authority("//user@rust-lang:something:/path").is_err()); + fail_unless!(get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err()); - assert!(get_authority( + fail_unless!(get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err()); // these parse as empty, because they don't start with '//' @@ -949,7 +949,7 @@ fn test_get_path() { assert_eq!(r, ~"?q=v"); //failure cases - assert!(get_path("something?q", true).is_err()); + fail_unless!(get_path("something?q", true).is_err()); } #[cfg(test)] @@ -989,15 +989,15 @@ mod tests { fn test_url_parse_host_slash() { let urlstr = ~"http://0.42.42.42/"; let url = from_str(urlstr).unwrap(); - assert!(url.host == ~"0.42.42.42"); - assert!(url.path == ~"/"); + fail_unless!(url.host == ~"0.42.42.42"); + fail_unless!(url.path == ~"/"); } #[test] fn test_path_parse_host_slash() { let pathstr = ~"/"; let path = path_from_str(pathstr).unwrap(); - assert!(path.path == ~"/"); + fail_unless!(path.path == ~"/"); } #[test] @@ -1020,39 +1020,39 @@ mod tests { fn test_url_with_underscores() { let urlstr = ~"http://dotcom.com/file_name.html"; let url = from_str(urlstr).unwrap(); - assert!(url.path == ~"/file_name.html"); + fail_unless!(url.path == ~"/file_name.html"); } #[test] fn test_path_with_underscores() { let pathstr = ~"/file_name.html"; let path = path_from_str(pathstr).unwrap(); - assert!(path.path == ~"/file_name.html"); + fail_unless!(path.path == ~"/file_name.html"); } #[test] fn test_url_with_dashes() { let urlstr = ~"http://dotcom.com/file-name.html"; let url = from_str(urlstr).unwrap(); - assert!(url.path == ~"/file-name.html"); + fail_unless!(url.path == ~"/file-name.html"); } #[test] fn test_path_with_dashes() { let pathstr = ~"/file-name.html"; let path = path_from_str(pathstr).unwrap(); - assert!(path.path == ~"/file-name.html"); + fail_unless!(path.path == ~"/file-name.html"); } #[test] fn test_no_scheme() { - assert!(get_scheme("noschemehere.html").is_err()); + fail_unless!(get_scheme("noschemehere.html").is_err()); } #[test] fn test_invalid_scheme_errors() { - assert!(from_str("99://something").is_err()); - assert!(from_str("://something").is_err()); + fail_unless!(from_str("99://something").is_err()); + fail_unless!(from_str("://something").is_err()); } #[test] @@ -1120,16 +1120,16 @@ mod tests { fn test_url_component_encoding() { let url = ~"http://rust-lang.org/doc%20uments?ba%25d%20=%23%26%2B"; let u = from_str(url).unwrap(); - assert!(u.path == ~"/doc uments"); - assert!(u.query == ~[(~"ba%d ", ~"#&+")]); + fail_unless!(u.path == ~"/doc uments"); + fail_unless!(u.query == ~[(~"ba%d ", ~"#&+")]); } #[test] fn test_path_component_encoding() { let path = ~"/doc%20uments?ba%25d%20=%23%26%2B"; let p = path_from_str(path).unwrap(); - assert!(p.path == ~"/doc uments"); - assert!(p.query == ~[(~"ba%d ", ~"#&+")]); + fail_unless!(p.path == ~"/doc uments"); + fail_unless!(p.query == ~[(~"ba%d ", ~"#&+")]); } #[test] @@ -1169,9 +1169,9 @@ mod tests { #[test] fn test_encode_component() { assert_eq!(encode_component(""), ~""); - assert!(encode_component("http://example.com") == + fail_unless!(encode_component("http://example.com") == ~"http%3A%2F%2Fexample.com"); - assert!(encode_component("foo bar% baz") == + fail_unless!(encode_component("foo bar% baz") == ~"foo%20bar%25%20baz"); assert_eq!(encode_component(" "), ~"%20"); assert_eq!(encode_component("!"), ~"%21"); @@ -1266,7 +1266,7 @@ mod tests { let mut m = HashMap::new(); m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]); - assert!(encode_form_urlencoded(&m) == + fail_unless!(encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34"); } diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index 007b54adbe51a..fe2de282f9da8 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -178,8 +178,8 @@ impl Database { } fn load(&mut self) { - assert!(!self.db_dirty); - assert!(self.db_filename.exists()); + fail_unless!(!self.db_dirty); + fail_unless!(self.db_filename.exists()); match File::open(&self.db_filename) { Err(e) => fail!("Couldn't load workcache database {}: {}", self.db_filename.display(), diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index d4a85b01324fe..1bd33a0fb8919 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -54,7 +54,7 @@ fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { bytes.len() as size_t, &mut outsz, flags); - assert!(res as int != 0); + fail_unless!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); libc::free(res as *mut c_void); @@ -77,7 +77,7 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { bytes.len() as size_t, &mut outsz, flags); - assert!(res as int != 0); + fail_unless!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); libc::free(res as *mut c_void); diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 537c2d40c66bf..c5dadf123ada9 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -372,7 +372,7 @@ fn find_opt(opts: &[Opt], nm: Name) -> Option { /// Create a long option that is required and takes an argument. pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -386,7 +386,7 @@ pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG /// Create a long option that is optional and takes an argument. pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -400,7 +400,7 @@ pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG /// Create a long option that is optional and does not take an argument. pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -415,7 +415,7 @@ pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup { /// take an argument. pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -429,7 +429,7 @@ pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup { /// Create a long option that is optional and takes an optional argument. pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -444,7 +444,7 @@ pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> /// multiple times. pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { let len = short_name.len(); - assert!(len == 1 || len == 0); + fail_unless!(len == 1 || len == 0); OptGroup { short_name: short_name.to_owned(), long_name: long_name.to_owned(), @@ -846,7 +846,7 @@ fn test_split_within() { fn t(s: &str, i: uint, u: &[~str]) { let mut v = ~[]; each_split_within(s, i, |s| { v.push(s.to_owned()); true }); - assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); + fail_unless!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); } t("", 0, []); t("", 15, []); @@ -866,11 +866,11 @@ mod tests { fn check_fail_type(f: Fail_, ft: FailType) { match f { - ArgumentMissing(_) => assert!(ft == ArgumentMissing_), - UnrecognizedOption(_) => assert!(ft == UnrecognizedOption_), - OptionMissing(_) => assert!(ft == OptionMissing_), - OptionDuplicated(_) => assert!(ft == OptionDuplicated_), - UnexpectedArgument(_) => assert!(ft == UnexpectedArgument_) + ArgumentMissing(_) => fail_unless!(ft == ArgumentMissing_), + UnrecognizedOption(_) => fail_unless!(ft == UnrecognizedOption_), + OptionMissing(_) => fail_unless!(ft == OptionMissing_), + OptionDuplicated(_) => fail_unless!(ft == OptionDuplicated_), + UnexpectedArgument(_) => fail_unless!(ft == UnexpectedArgument_) } } @@ -882,9 +882,9 @@ mod tests { let rs = getopts(long_args, opts); match rs { Ok(ref m) => { - assert!(m.opt_present("test")); + fail_unless!(m.opt_present("test")); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!(m.opt_present("t")); + fail_unless!(m.opt_present("t")); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => { fail!("test_reqopt failed (long arg)"); } @@ -892,9 +892,9 @@ mod tests { let short_args = ~[~"-t", ~"20"]; match getopts(short_args, opts) { Ok(ref m) => { - assert!((m.opt_present("test"))); + fail_unless!((m.opt_present("test"))); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!((m.opt_present("t"))); + fail_unless!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => { fail!("test_reqopt failed (short arg)"); } @@ -947,9 +947,9 @@ mod tests { let rs = getopts(long_args, opts); match rs { Ok(ref m) => { - assert!(m.opt_present("test")); + fail_unless!(m.opt_present("test")); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!((m.opt_present("t"))); + fail_unless!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() @@ -957,9 +957,9 @@ mod tests { let short_args = ~[~"-t", ~"20"]; match getopts(short_args, opts) { Ok(ref m) => { - assert!((m.opt_present("test"))); + fail_unless!((m.opt_present("test"))); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!((m.opt_present("t"))); + fail_unless!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() @@ -973,8 +973,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); + fail_unless!(!m.opt_present("test")); + fail_unless!(!m.opt_present("t")); } _ => fail!() } @@ -1015,16 +1015,16 @@ mod tests { let rs = getopts(long_args, opts); match rs { Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); + fail_unless!(m.opt_present("test")); + fail_unless!(m.opt_present("t")); } _ => fail!() } let short_args = ~[~"-t"]; match getopts(short_args, opts) { Ok(ref m) => { - assert!(m.opt_present("test")); - assert!(m.opt_present("t")); + fail_unless!(m.opt_present("test")); + fail_unless!(m.opt_present("t")); } _ => fail!() } @@ -1037,8 +1037,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); + fail_unless!(!m.opt_present("test")); + fail_unless!(!m.opt_present("t")); } _ => fail!() } @@ -1078,7 +1078,7 @@ mod tests { Ok(ref m) => { // The next variable after the flag is just a free argument - assert!(m.free[0] == ~"20"); + fail_unless!(m.free[0] == ~"20"); } _ => fail!() } @@ -1172,9 +1172,9 @@ mod tests { let rs = getopts(long_args, opts); match rs { Ok(ref m) => { - assert!((m.opt_present("test"))); + fail_unless!((m.opt_present("test"))); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!((m.opt_present("t"))); + fail_unless!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() @@ -1182,9 +1182,9 @@ mod tests { let short_args = ~[~"-t", ~"20"]; match getopts(short_args, opts) { Ok(ref m) => { - assert!((m.opt_present("test"))); + fail_unless!((m.opt_present("test"))); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!((m.opt_present("t"))); + fail_unless!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() @@ -1198,8 +1198,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!(!m.opt_present("test")); - assert!(!m.opt_present("t")); + fail_unless!(!m.opt_present("test")); + fail_unless!(!m.opt_present("t")); } _ => fail!() } @@ -1228,13 +1228,13 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!(m.opt_present("test")); + fail_unless!(m.opt_present("test")); assert_eq!(m.opt_str("test").unwrap(), ~"20"); - assert!(m.opt_present("t")); + fail_unless!(m.opt_present("t")); assert_eq!(m.opt_str("t").unwrap(), ~"20"); let pair = m.opt_strs("test"); - assert!(pair[0] == ~"20"); - assert!(pair[1] == ~"30"); + fail_unless!(pair[0] == ~"20"); + fail_unless!(pair[1] == ~"30"); } _ => fail!() } @@ -1273,20 +1273,20 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!(m.free[0] == ~"prog"); - assert!(m.free[1] == ~"free1"); + fail_unless!(m.free[0] == ~"prog"); + fail_unless!(m.free[1] == ~"free1"); assert_eq!(m.opt_str("s").unwrap(), ~"20"); - assert!(m.free[2] == ~"free2"); - assert!((m.opt_present("flag"))); + fail_unless!(m.free[2] == ~"free2"); + fail_unless!((m.opt_present("flag"))); assert_eq!(m.opt_str("long").unwrap(), ~"30"); - assert!((m.opt_present("f"))); + fail_unless!((m.opt_present("f"))); let pair = m.opt_strs("m"); - assert!(pair[0] == ~"40"); - assert!(pair[1] == ~"50"); + fail_unless!(pair[0] == ~"40"); + fail_unless!(pair[1] == ~"50"); let pair = m.opt_strs("n"); - assert!(pair[0] == ~"-A B"); - assert!(pair[1] == ~"-60 70"); - assert!((!m.opt_present("notpresent"))); + fail_unless!(pair[0] == ~"-A B"); + fail_unless!(pair[1] == ~"-60 70"); + fail_unless!((!m.opt_present("notpresent"))); } _ => fail!() } @@ -1303,12 +1303,12 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - assert!(matches_single.opts_present([~"e"])); - assert!(matches_single.opts_present([~"encrypt", ~"e"])); - assert!(matches_single.opts_present([~"e", ~"encrypt"])); - assert!(!matches_single.opts_present([~"encrypt"])); - assert!(!matches_single.opts_present([~"thing"])); - assert!(!matches_single.opts_present([])); + fail_unless!(matches_single.opts_present([~"e"])); + fail_unless!(matches_single.opts_present([~"encrypt", ~"e"])); + fail_unless!(matches_single.opts_present([~"e", ~"encrypt"])); + fail_unless!(!matches_single.opts_present([~"encrypt"])); + fail_unless!(!matches_single.opts_present([~"thing"])); + fail_unless!(!matches_single.opts_present([])); assert_eq!(matches_single.opts_str([~"e"]).unwrap(), ~"foo"); assert_eq!(matches_single.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo"); @@ -1319,13 +1319,13 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - assert!(matches_both.opts_present([~"e"])); - assert!(matches_both.opts_present([~"encrypt"])); - assert!(matches_both.opts_present([~"encrypt", ~"e"])); - assert!(matches_both.opts_present([~"e", ~"encrypt"])); - assert!(!matches_both.opts_present([~"f"])); - assert!(!matches_both.opts_present([~"thing"])); - assert!(!matches_both.opts_present([])); + fail_unless!(matches_both.opts_present([~"e"])); + fail_unless!(matches_both.opts_present([~"encrypt"])); + fail_unless!(matches_both.opts_present([~"encrypt", ~"e"])); + fail_unless!(matches_both.opts_present([~"e", ~"encrypt"])); + fail_unless!(!matches_both.opts_present([~"f"])); + fail_unless!(!matches_both.opts_present([~"thing"])); + fail_unless!(!matches_both.opts_present([])); assert_eq!(matches_both.opts_str([~"e"]).unwrap(), ~"foo"); assert_eq!(matches_both.opts_str([~"encrypt"]).unwrap(), ~"foo"); @@ -1342,9 +1342,9 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - assert!(matches.opts_present([~"L"])); + fail_unless!(matches.opts_present([~"L"])); assert_eq!(matches.opts_str([~"L"]).unwrap(), ~"foo"); - assert!(matches.opts_present([~"M"])); + fail_unless!(matches.opts_present([~"M"])); assert_eq!(matches.opts_str([~"M"]).unwrap(), ~"."); } @@ -1432,7 +1432,7 @@ Options: debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", usage); - assert!(usage == expected) + fail_unless!(usage == expected) } #[test] @@ -1459,7 +1459,7 @@ Options: debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", usage); - assert!(usage == expected) + fail_unless!(usage == expected) } #[test] diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 3a93b10ad29c8..29b26f09bc01a 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -304,9 +304,9 @@ impl Pattern { * ```rust * use glob::Pattern; * - * assert!(Pattern::new("c?t").matches("cat")); - * assert!(Pattern::new("k[!e]tteh").matches("kitteh")); - * assert!(Pattern::new("d*g").matches("doog")); + * fail_unless!(Pattern::new("c?t").matches("cat")); + * fail_unless!(Pattern::new("k[!e]tteh").matches("kitteh")); + * fail_unless!(Pattern::new("d*g").matches("doog")); * ``` */ pub fn matches(&self, str: &str) -> bool { @@ -549,28 +549,28 @@ mod test { #[test] fn test_absolute_pattern() { // assume that the filesystem is not empty! - assert!(glob("/*").next().is_some()); - assert!(glob("//").next().is_none()); + fail_unless!(glob("/*").next().is_some()); + fail_unless!(glob("//").next().is_none()); // check windows absolute paths with host/device components let root_with_device = os::getcwd().root_path().unwrap().join("*"); // FIXME (#9639): This needs to handle non-utf8 paths - assert!(glob(root_with_device.as_str().unwrap()).next().is_some()); + fail_unless!(glob(root_with_device.as_str().unwrap()).next().is_some()); } #[test] fn test_wildcard_optimizations() { - assert!(Pattern::new("a*b").matches("a___b")); - assert!(Pattern::new("a**b").matches("a___b")); - assert!(Pattern::new("a***b").matches("a___b")); - assert!(Pattern::new("a*b*c").matches("abc")); - assert!(!Pattern::new("a*b*c").matches("abcd")); - assert!(Pattern::new("a*b*c").matches("a_b_c")); - assert!(Pattern::new("a*b*c").matches("a___b___c")); - assert!(Pattern::new("abc*abc*abc").matches("abcabcabcabcabcabcabc")); - assert!(!Pattern::new("abc*abc*abc").matches("abcabcabcabcabcabcabca")); - assert!(Pattern::new("a*a*a*a*a*a*a*a*a").matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); - assert!(Pattern::new("a*b[xyz]c*d").matches("abxcdbxcddd")); + fail_unless!(Pattern::new("a*b").matches("a___b")); + fail_unless!(Pattern::new("a**b").matches("a___b")); + fail_unless!(Pattern::new("a***b").matches("a___b")); + fail_unless!(Pattern::new("a*b*c").matches("abc")); + fail_unless!(!Pattern::new("a*b*c").matches("abcd")); + fail_unless!(Pattern::new("a*b*c").matches("a_b_c")); + fail_unless!(Pattern::new("a*b*c").matches("a___b___c")); + fail_unless!(Pattern::new("abc*abc*abc").matches("abcabcabcabcabcabcabc")); + fail_unless!(!Pattern::new("abc*abc*abc").matches("abcabcabcabcabcabcabca")); + fail_unless!(Pattern::new("a*a*a*a*a*a*a*a*a").matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); + fail_unless!(Pattern::new("a*b[xyz]c*d").matches("abxcdbxcddd")); } #[test] @@ -584,85 +584,85 @@ mod test { let pat = Pattern::new("a[0-9]b"); for i in range(0, 10) { - assert!(pat.matches(format!("a{}b", i))); + fail_unless!(pat.matches(format!("a{}b", i))); } - assert!(!pat.matches("a_b")); + fail_unless!(!pat.matches("a_b")); let pat = Pattern::new("a[!0-9]b"); for i in range(0, 10) { - assert!(!pat.matches(format!("a{}b", i))); + fail_unless!(!pat.matches(format!("a{}b", i))); } - assert!(pat.matches("a_b")); + fail_unless!(pat.matches("a_b")); let pats = ["[a-z123]", "[1a-z23]", "[123a-z]"]; for &p in pats.iter() { let pat = Pattern::new(p); for c in "abcdefghijklmnopqrstuvwxyz".chars() { - assert!(pat.matches(c.to_str())); + fail_unless!(pat.matches(c.to_str())); } for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() { let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()}; - assert!(pat.matches_with(c.to_str(), options)); + fail_unless!(pat.matches_with(c.to_str(), options)); } - assert!(pat.matches("1")); - assert!(pat.matches("2")); - assert!(pat.matches("3")); + fail_unless!(pat.matches("1")); + fail_unless!(pat.matches("2")); + fail_unless!(pat.matches("3")); } let pats = ["[abc-]", "[-abc]", "[a-c-]"]; for &p in pats.iter() { let pat = Pattern::new(p); - assert!(pat.matches("a")); - assert!(pat.matches("b")); - assert!(pat.matches("c")); - assert!(pat.matches("-")); - assert!(!pat.matches("d")); + fail_unless!(pat.matches("a")); + fail_unless!(pat.matches("b")); + fail_unless!(pat.matches("c")); + fail_unless!(pat.matches("-")); + fail_unless!(!pat.matches("d")); } let pat = Pattern::new("[2-1]"); - assert!(!pat.matches("1")); - assert!(!pat.matches("2")); + fail_unless!(!pat.matches("1")); + fail_unless!(!pat.matches("2")); - assert!(Pattern::new("[-]").matches("-")); - assert!(!Pattern::new("[!-]").matches("-")); + fail_unless!(Pattern::new("[-]").matches("-")); + fail_unless!(!Pattern::new("[!-]").matches("-")); } #[test] fn test_unclosed_bracket() { // unclosed `[` should be treated literally - assert!(Pattern::new("abc[def").matches("abc[def")); - assert!(Pattern::new("abc[!def").matches("abc[!def")); - assert!(Pattern::new("abc[").matches("abc[")); - assert!(Pattern::new("abc[!").matches("abc[!")); - assert!(Pattern::new("abc[d").matches("abc[d")); - assert!(Pattern::new("abc[!d").matches("abc[!d")); - assert!(Pattern::new("abc[]").matches("abc[]")); - assert!(Pattern::new("abc[!]").matches("abc[!]")); + fail_unless!(Pattern::new("abc[def").matches("abc[def")); + fail_unless!(Pattern::new("abc[!def").matches("abc[!def")); + fail_unless!(Pattern::new("abc[").matches("abc[")); + fail_unless!(Pattern::new("abc[!").matches("abc[!")); + fail_unless!(Pattern::new("abc[d").matches("abc[d")); + fail_unless!(Pattern::new("abc[!d").matches("abc[!d")); + fail_unless!(Pattern::new("abc[]").matches("abc[]")); + fail_unless!(Pattern::new("abc[!]").matches("abc[!]")); } #[test] fn test_pattern_matches() { let txt_pat = Pattern::new("*hello.txt"); - assert!(txt_pat.matches("hello.txt")); - assert!(txt_pat.matches("gareth_says_hello.txt")); - assert!(txt_pat.matches("some/path/to/hello.txt")); - assert!(txt_pat.matches("some\\path\\to\\hello.txt")); - assert!(txt_pat.matches("/an/absolute/path/to/hello.txt")); - assert!(!txt_pat.matches("hello.txt-and-then-some")); - assert!(!txt_pat.matches("goodbye.txt")); + fail_unless!(txt_pat.matches("hello.txt")); + fail_unless!(txt_pat.matches("gareth_says_hello.txt")); + fail_unless!(txt_pat.matches("some/path/to/hello.txt")); + fail_unless!(txt_pat.matches("some\\path\\to\\hello.txt")); + fail_unless!(txt_pat.matches("/an/absolute/path/to/hello.txt")); + fail_unless!(!txt_pat.matches("hello.txt-and-then-some")); + fail_unless!(!txt_pat.matches("goodbye.txt")); let dir_pat = Pattern::new("*some/path/to/hello.txt"); - assert!(dir_pat.matches("some/path/to/hello.txt")); - assert!(dir_pat.matches("a/bigger/some/path/to/hello.txt")); - assert!(!dir_pat.matches("some/path/to/hello.txt-and-then-some")); - assert!(!dir_pat.matches("some/other/path/to/hello.txt")); + fail_unless!(dir_pat.matches("some/path/to/hello.txt")); + fail_unless!(dir_pat.matches("a/bigger/some/path/to/hello.txt")); + fail_unless!(!dir_pat.matches("some/path/to/hello.txt-and-then-some")); + fail_unless!(!dir_pat.matches("some/other/path/to/hello.txt")); } #[test] fn test_pattern_escape() { let s = "_[_]_?_*_!_"; assert_eq!(Pattern::escape(s), ~"_[[]_[]]_[?]_[*]_!_"); - assert!(Pattern::new(Pattern::escape(s)).matches(s)); + fail_unless!(Pattern::new(Pattern::escape(s)).matches(s)); } #[test] @@ -675,10 +675,10 @@ mod test { require_literal_leading_dot: false }; - assert!(pat.matches_with("aBcDeFg", options)); - assert!(pat.matches_with("abcdefg", options)); - assert!(pat.matches_with("ABCDEFG", options)); - assert!(pat.matches_with("AbCdEfG", options)); + fail_unless!(pat.matches_with("aBcDeFg", options)); + fail_unless!(pat.matches_with("abcdefg", options)); + fail_unless!(pat.matches_with("ABCDEFG", options)); + fail_unless!(pat.matches_with("AbCdEfG", options)); } #[test] @@ -698,13 +698,13 @@ mod test { require_literal_leading_dot: false }; - assert!(pat_within.matches_with("a", options_case_insensitive)); - assert!(pat_within.matches_with("A", options_case_insensitive)); - assert!(!pat_within.matches_with("A", options_case_sensitive)); + fail_unless!(pat_within.matches_with("a", options_case_insensitive)); + fail_unless!(pat_within.matches_with("A", options_case_insensitive)); + fail_unless!(!pat_within.matches_with("A", options_case_sensitive)); - assert!(!pat_except.matches_with("a", options_case_insensitive)); - assert!(!pat_except.matches_with("A", options_case_insensitive)); - assert!(pat_except.matches_with("A", options_case_sensitive)); + fail_unless!(!pat_except.matches_with("a", options_case_insensitive)); + fail_unless!(!pat_except.matches_with("A", options_case_insensitive)); + fail_unless!(pat_except.matches_with("A", options_case_sensitive)); } #[test] @@ -721,15 +721,15 @@ mod test { require_literal_leading_dot: false }; - assert!(Pattern::new("abc/def").matches_with("abc/def", options_require_literal)); - assert!(!Pattern::new("abc?def").matches_with("abc/def", options_require_literal)); - assert!(!Pattern::new("abc*def").matches_with("abc/def", options_require_literal)); - assert!(!Pattern::new("abc[/]def").matches_with("abc/def", options_require_literal)); + fail_unless!(Pattern::new("abc/def").matches_with("abc/def", options_require_literal)); + fail_unless!(!Pattern::new("abc?def").matches_with("abc/def", options_require_literal)); + fail_unless!(!Pattern::new("abc*def").matches_with("abc/def", options_require_literal)); + fail_unless!(!Pattern::new("abc[/]def").matches_with("abc/def", options_require_literal)); - assert!(Pattern::new("abc/def").matches_with("abc/def", options_not_require_literal)); - assert!(Pattern::new("abc?def").matches_with("abc/def", options_not_require_literal)); - assert!(Pattern::new("abc*def").matches_with("abc/def", options_not_require_literal)); - assert!(Pattern::new("abc[/]def").matches_with("abc/def", options_not_require_literal)); + fail_unless!(Pattern::new("abc/def").matches_with("abc/def", options_not_require_literal)); + fail_unless!(Pattern::new("abc?def").matches_with("abc/def", options_not_require_literal)); + fail_unless!(Pattern::new("abc*def").matches_with("abc/def", options_not_require_literal)); + fail_unless!(Pattern::new("abc[/]def").matches_with("abc/def", options_not_require_literal)); } #[test] @@ -747,38 +747,38 @@ mod test { }; let f = |options| Pattern::new("*.txt").matches_with(".hello.txt", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(!f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(!f(options_require_literal_leading_dot)); let f = |options| Pattern::new(".*.*").matches_with(".hello.txt", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(f(options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/*").matches_with("aaa/bbb/.ccc", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(!f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(!f(options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/*").matches_with("aaa/bbb/c.c.c.", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(f(options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/.*").matches_with("aaa/bbb/.ccc", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(f(options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/?bbb").matches_with("aaa/.bbb", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(!f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(!f(options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/[.]bbb").matches_with("aaa/.bbb", options); - assert!(f(options_not_require_literal_leading_dot)); - assert!(!f(options_require_literal_leading_dot)); + fail_unless!(f(options_not_require_literal_leading_dot)); + fail_unless!(!f(options_require_literal_leading_dot)); } #[test] fn test_matches_path() { // on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this // tests that / and \ are considered equivalent on windows - assert!(Pattern::new("a/b").matches_path(&Path::new("a/b"))); + fail_unless!(Pattern::new("a/b").matches_path(&Path::new("a/b"))); } } diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 8758eb1179ef9..ddf442f9284ae 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -331,7 +331,7 @@ impl SchedPool { event_loop_factory: factory } = config; let factory = factory.unwrap_or(default_event_loop_factory()); - assert!(nscheds > 0); + fail_unless!(nscheds > 0); // The pool of schedulers that will be returned from this function let (p, state) = TaskState::new(); diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index a966dff000ae0..a91440e844e13 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -272,7 +272,7 @@ impl Scheduler { fn run_sched_once(mut ~self, stask: ~GreenTask) { // Make sure that we're not lying in that the `stask` argument is indeed // the scheduler task for this scheduler. - assert!(self.sched_task.is_none()); + fail_unless!(self.sched_task.is_none()); // Assume that we need to continue idling unless we reach the // end of this function without performing an action. @@ -577,7 +577,7 @@ impl Scheduler { pub fn enqueue_task(&mut self, task: ~GreenTask) { // We push the task onto our local queue clone. - assert!(!task.is_sched()); + fail_unless!(!task.is_sched()); self.work_queue.push(task); match self.idle_callback { Some(ref mut idle) => idle.resume(), @@ -695,9 +695,9 @@ impl Scheduler { pub fn resume_task_immediately(~self, cur: ~GreenTask, next: ~GreenTask) -> (~Scheduler, ~GreenTask) { - assert!(cur.is_sched()); + fail_unless!(cur.is_sched()); let mut cur = self.change_task_context(cur, next, |sched, stask| { - assert!(sched.sched_task.is_none()); + fail_unless!(sched.sched_task.is_none()); sched.sched_task = Some(stask); }); (cur.sched.take_unwrap(), cur) @@ -777,7 +777,7 @@ impl Scheduler { next: ~GreenTask) -> (~Scheduler, ~GreenTask) { let mut cur = sched.change_task_context(cur, next, |sched, last_task| { if last_task.is_sched() { - assert!(sched.sched_task.is_none()); + fail_unless!(sched.sched_task.is_none()); sched.sched_task = Some(last_task); } else { sched.enqueue_task(last_task); @@ -823,7 +823,7 @@ impl Scheduler { // task, which eventually gets us to here. See comments in SchedRunner // for more info on this. if cur.is_sched() { - assert!(self.sched_task.is_none()); + fail_unless!(self.sched_task.is_none()); self.run_sched_once(cur); } else { self.yield_check_count = reset_yield_check(&mut self.rng); @@ -1039,7 +1039,7 @@ mod test { unsafe { *task_ran_ptr = true }; rtdebug!("executed from the new scheduler") }); - assert!(task_ran); + fail_unless!(task_ran); } #[test] @@ -1056,7 +1056,7 @@ mod test { }); } }); - assert!(task_run_count == total); + fail_unless!(task_run_count == total); } #[test] @@ -1074,7 +1074,7 @@ mod test { }) }) }); - assert!(task_run_count == 3); + fail_unless!(task_run_count == 3); } // A very simple test that confirms that a task executing on the diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs index 297c22e2cd6ce..be6c453dbf52b 100644 --- a/src/libgreen/simple.rs +++ b/src/libgreen/simple.rs @@ -29,7 +29,7 @@ impl Runtime for SimpleTask { // a simple number of cases. fn deschedule(mut ~self, times: uint, mut cur_task: ~Task, f: |BlockedTask| -> Result<(), BlockedTask>) { - assert!(times == 1); + fail_unless!(times == 1); let me = &mut *self as *mut SimpleTask; let cur_dupe = &*cur_task as *Task; diff --git a/src/libgreen/sleeper_list.rs b/src/libgreen/sleeper_list.rs index 5be260efdfaef..e6d2d1c71b32e 100644 --- a/src/libgreen/sleeper_list.rs +++ b/src/libgreen/sleeper_list.rs @@ -25,7 +25,7 @@ impl SleeperList { } pub fn push(&mut self, value: SchedHandle) { - assert!(self.q.push(value)) + fail_unless!(self.q.push(value)) } pub fn pop(&mut self) -> Option { diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index e139cfa1025a1..eb9d30ecc4180 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -274,13 +274,13 @@ impl GreenTask { // Runtime glue functions and helpers pub fn put_with_sched(mut ~self, sched: ~Scheduler) { - assert!(self.sched.is_none()); + fail_unless!(self.sched.is_none()); self.sched = Some(sched); self.put(); } pub fn put_task(&mut self, task: ~Task) { - assert!(self.task.is_none()); + fail_unless!(self.task.is_none()); self.task = Some(task); } @@ -291,7 +291,7 @@ impl GreenTask { } pub fn put(~self) { - assert!(self.sched.is_some()); + fail_unless!(self.sched.is_some()); Local::put(self.swap()); } @@ -393,7 +393,7 @@ impl Runtime for GreenTask { fn reawaken(mut ~self, to_wake: ~Task) { self.put_task(to_wake); - assert!(self.sched.is_none()); + fail_unless!(self.sched.is_none()); // Optimistically look for a local task, but if one's not available to // inspect (in order to see if it's in the same sched pool as we are), @@ -524,7 +524,7 @@ mod tests { let (p, c) = Chan::new(); opts.notify_chan = Some(c); spawn_opts(opts, proc() {}); - assert!(p.recv().is_ok()); + fail_unless!(p.recv().is_ok()); } #[test] @@ -533,7 +533,7 @@ mod tests { let (p, c) = Chan::new(); opts.notify_chan = Some(c); spawn_opts(opts, proc() { fail!() }); - assert!(p.recv().is_err()); + fail_unless!(p.recv().is_err()); } #[test] diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs index 5bdeaa17e745f..6a87ab111b67d 100644 --- a/src/libnative/io/addrinfo.rs +++ b/src/libnative/io/addrinfo.rs @@ -23,7 +23,7 @@ pub struct GetAddrInfoRequest; impl GetAddrInfoRequest { pub fn run(host: Option<&str>, servname: Option<&str>, hint: Option) -> Result<~[ai::Info], IoError> { - assert!(host.is_some() || servname.is_some()); + fail_unless!(host.is_some() || servname.is_some()); let c_host = host.map_or(unsafe { CString::new(null(), true) }, |x| x.to_c_str()); let c_serv = servname.map_or(unsafe { CString::new(null(), true) }, |x| x.to_c_str()); diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs index d1d2dba383d9d..0a3e66ff1aabd 100644 --- a/src/libnative/io/file.rs +++ b/src/libnative/io/file.rs @@ -580,7 +580,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { } more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE); } - assert!(FindClose(find_handle) != 0); + fail_unless!(FindClose(find_handle) != 0); free(wfd_ptr as *mut c_void); Ok(paths) } else { @@ -715,7 +715,7 @@ pub fn readlink(p: &CString) -> IoResult { Some(s) => Ok(Path::new(s)), None => Err(super::last_error()), }; - assert!(unsafe { libc::CloseHandle(handle) } != 0); + fail_unless!(unsafe { libc::CloseHandle(handle) } != 0); return ret; } @@ -734,7 +734,7 @@ pub fn readlink(p: &CString) -> IoResult { }) { -1 => Err(super::last_error()), n => { - assert!(n > 0); + fail_unless!(n > 0); unsafe { buf.set_len(n as uint); } Ok(Path::new(buf)) } @@ -965,8 +965,8 @@ mod tests { r => fail!("invalid read: {:?}", r) } - assert!(writer.inner_read(buf).is_err()); - assert!(reader.inner_write(buf).is_err()); + fail_unless!(writer.inner_read(buf).is_err()); + fail_unless!(reader.inner_write(buf).is_err()); } } @@ -975,7 +975,7 @@ mod tests { fn test_cfile() { unsafe { let f = libc::tmpfile(); - assert!(!f.is_null()); + fail_unless!(!f.is_null()); let mut file = CFile::new(f); file.write(bytes!("test")).unwrap(); diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index d58e4d54342c9..cd38405ce8d38 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -157,7 +157,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, len: uint) -> IoResult { match storage.ss_family as libc::c_int { libc::AF_INET => { - assert!(len as uint >= mem::size_of::()); + fail_unless!(len as uint >= mem::size_of::()); let storage: &libc::sockaddr_in = unsafe { cast::transmute(storage) }; @@ -172,7 +172,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, }) } libc::AF_INET6 => { - assert!(len as uint >= mem::size_of::()); + fail_unless!(len as uint >= mem::size_of::()); let storage: &libc::sockaddr_in6 = unsafe { cast::transmute(storage) }; diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index 64acdbf7f489f..1cefe88a72e68 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -29,7 +29,7 @@ fn unix_socket(ty: libc::c_int) -> IoResult { fn addr_to_sockaddr_un(addr: &CString) -> IoResult<(libc::sockaddr_storage, uint)> { // the sun_path length is limited to SUN_LEN (with null) - assert!(mem::size_of::() >= + fail_unless!(mem::size_of::() >= mem::size_of::()); let mut storage: libc::sockaddr_storage = unsafe { intrinsics::init() }; let s: &mut libc::sockaddr_un = unsafe { cast::transmute(&mut storage) }; @@ -56,7 +56,7 @@ fn sockaddr_to_unix(storage: &libc::sockaddr_storage, len: uint) -> IoResult { match storage.ss_family as libc::c_int { libc::AF_UNIX => { - assert!(len as uint <= mem::size_of::()); + fail_unless!(len as uint <= mem::size_of::()); let storage: &libc::sockaddr_un = unsafe { cast::transmute(storage) }; diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index fc4fc0fa7893d..8cf532ab5abee 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -469,7 +469,7 @@ impl UnixAcceptor { // If our disconnection fails, then there's not really a whole lot // that we can do, so fail the task. let err = unsafe { libc::DisconnectNamedPipe(handle) }; - assert!(err != 0); + fail_unless!(err != 0); return ret; } else { self.listener.handle = new_handle; diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index affa3ebf54456..c76ee8ca4bd10 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -269,9 +269,9 @@ fn spawn_process_os(config: p::ProcessConfig, }) }); - assert!(CloseHandle(si.hStdInput) != 0); - assert!(CloseHandle(si.hStdOutput) != 0); - assert!(CloseHandle(si.hStdError) != 0); + fail_unless!(CloseHandle(si.hStdInput) != 0); + fail_unless!(CloseHandle(si.hStdOutput) != 0); + fail_unless!(CloseHandle(si.hStdError) != 0); match create_err { Some(err) => return Err(err), @@ -283,7 +283,7 @@ fn spawn_process_os(config: p::ProcessConfig, // able to close it later. We don't close the process handle however // because std::we want the process id to stay valid at least until the // calling code closes the process handle. - assert!(CloseHandle(pi.hThread) != 0); + fail_unless!(CloseHandle(pi.hThread) != 0); Ok(SpawnProcessResult { pid: pi.dwProcessId as pid_t, @@ -442,7 +442,7 @@ fn spawn_process_os(config: p::ProcessConfig, Err(super::translate_error(errno, false)) } Err(e) => { - assert!(e.kind == io::BrokenPipe || + fail_unless!(e.kind == io::BrokenPipe || e.kind == io::EndOfFile, "unexpected error: {:?}", e); Ok(SpawnProcessResult { @@ -463,7 +463,7 @@ fn spawn_process_os(config: p::ProcessConfig, (errno << 8) as u8, (errno << 0) as u8, ]; - assert!(output.inner_write(bytes).is_ok()); + fail_unless!(output.inner_write(bytes).is_ok()); unsafe { libc::_exit(1) } } @@ -628,7 +628,7 @@ fn with_dirp(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T { #[cfg(windows)] fn free_handle(handle: *()) { - assert!(unsafe { + fail_unless!(unsafe { libc::CloseHandle(cast::transmute(handle)) != 0 }) } @@ -681,15 +681,15 @@ fn waitpid(pid: pid_t) -> p::ProcessExit { loop { let mut status = 0; if GetExitCodeProcess(process, &mut status) == FALSE { - assert!(CloseHandle(process) != 0); + fail_unless!(CloseHandle(process) != 0); fail!("failure in GetExitCodeProcess: {}", os::last_os_error()); } if status != STILL_ACTIVE { - assert!(CloseHandle(process) != 0); + fail_unless!(CloseHandle(process) != 0); return p::ExitStatus(status as int); } if WaitForSingleObject(process, INFINITE) == WAIT_FAILED { - assert!(CloseHandle(process) != 0); + fail_unless!(CloseHandle(process) != 0); fail!("failure in WaitForSingleObject: {}", os::last_os_error()); } } diff --git a/src/libnative/io/timer_helper.rs b/src/libnative/io/timer_helper.rs index 0f3ed1482294b..300adf7a91bee 100644 --- a/src/libnative/io/timer_helper.rs +++ b/src/libnative/io/timer_helper.rs @@ -65,7 +65,7 @@ pub fn boot(helper: fn(imp::signal, Port)) { pub fn send(req: Req) { unsafe { - assert!(!HELPER_CHAN.is_null()); + fail_unless!(!HELPER_CHAN.is_null()); (*HELPER_CHAN).send(req); imp::signal(HELPER_SIGNAL); } @@ -134,11 +134,11 @@ mod imp { } pub fn signal(handle: HANDLE) { - assert!(unsafe { SetEvent(handle) != 0 }); + fail_unless!(unsafe { SetEvent(handle) != 0 }); } pub fn close(handle: HANDLE) { - assert!(unsafe { CloseHandle(handle) != 0 }); + fail_unless!(unsafe { CloseHandle(handle) != 0 }); } extern "system" { diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs index 3a060194a69ac..5171f958cacad 100644 --- a/src/libnative/io/timer_other.rs +++ b/src/libnative/io/timer_other.rs @@ -165,7 +165,7 @@ fn helper(input: libc::c_int, messages: Port) { loop { match messages.try_recv() { Data(Shutdown) => { - assert!(active.len() == 0); + fail_unless!(active.len() == 0); break 'outer; } diff --git a/src/libnative/io/timer_timerfd.rs b/src/libnative/io/timer_timerfd.rs index b1ae582088801..47e927c87802c 100644 --- a/src/libnative/io/timer_timerfd.rs +++ b/src/libnative/io/timer_timerfd.rs @@ -148,7 +148,7 @@ fn helper(input: libc::c_int, messages: Port) { } Data(Shutdown) => { - assert!(map.len() == 0); + fail_unless!(map.len() == 0); break 'outer; } diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs index 6b472d2f46d59..4d8184c74e66d 100644 --- a/src/libnative/io/timer_win32.rs +++ b/src/libnative/io/timer_win32.rs @@ -173,7 +173,7 @@ impl rtio::RtioTimer for Timer { impl Drop for Timer { fn drop(&mut self) { self.remove(); - assert!(unsafe { libc::CloseHandle(self.obj) != 0 }); + fail_unless!(unsafe { libc::CloseHandle(self.obj) != 0 }); } } diff --git a/src/libnative/task.rs b/src/libnative/task.rs index b0f063ff06e19..56ded99345705 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -286,7 +286,7 @@ mod tests { let (p, c) = Chan::new(); opts.notify_chan = Some(c); spawn_opts(opts, proc() {}); - assert!(p.recv().is_ok()); + fail_unless!(p.recv().is_ok()); } #[test] @@ -295,7 +295,7 @@ mod tests { let (p, c) = Chan::new(); opts.notify_chan = Some(c); spawn_opts(opts, proc() { fail!() }); - assert!(p.recv().is_err()); + fail_unless!(p.recv().is_err()); } #[test] diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index 0418c61d361b4..838b10393b3bc 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -244,7 +244,7 @@ impl Sub for BigUint { lo }); - assert_eq!(borrow, 0); // <=> assert!((self >= other)); + assert_eq!(borrow, 0); // <=> fail_unless!((self >= other)); return BigUint::new(diff); } } @@ -371,7 +371,7 @@ impl Integer for BigUint { n <<= 1; shift += 1; } - assert!(shift < BigDigit::bits); + fail_unless!(shift < BigDigit::bits); let (d, m) = div_mod_floor_inner(self << shift, other << shift); return (d, m >> shift); @@ -421,7 +421,7 @@ impl Integer for BigUint { for elt in an.rev_iter() { let ai = BigDigit::to_uint(carry, *elt); let di = ai / (bn as uint); - assert!(di < BigDigit::base); + fail_unless!(di < BigDigit::base); carry = (ai % (bn as uint)) as BigDigit; d = ~[di as BigDigit] + d; } @@ -622,7 +622,7 @@ impl_to_biguint!(u64, FromPrimitive::from_u64) impl ToStrRadix for BigUint { fn to_str_radix(&self, radix: uint) -> ~str { - assert!(1 < radix && radix <= 16); + fail_unless!(1 < radix && radix <= 16); let (base, max_len) = get_radix_base(radix); if base == BigDigit::base { return fill_concat(self.data, radix, max_len) @@ -781,7 +781,7 @@ impl BigUint { #[cfg(target_word_size = "32")] #[inline] fn get_radix_base(radix: uint) -> (uint, uint) { - assert!(1 < radix && radix <= 16); + fail_unless!(1 < radix && radix <= 16); match radix { 2 => (65536, 16), 3 => (59049, 10), @@ -805,7 +805,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) { #[cfg(target_word_size = "64")] #[inline] fn get_radix_base(radix: uint) -> (uint, uint) { - assert!(1 < radix && radix <= 16); + fail_unless!(1 < radix && radix <= 16); match radix { 2 => (4294967296, 32), 3 => (3486784401, 20), @@ -1315,7 +1315,7 @@ impl RandBigInt for R { } fn gen_biguint_below(&mut self, bound: &BigUint) -> BigUint { - assert!(!bound.is_zero()); + fail_unless!(!bound.is_zero()); let bits = bound.bits(); loop { let n = self.gen_biguint(bits); @@ -1327,7 +1327,7 @@ impl RandBigInt for R { lbound: &BigUint, ubound: &BigUint) -> BigUint { - assert!(*lbound < *ubound); + fail_unless!(*lbound < *ubound); return *lbound + self.gen_biguint_below(&(*ubound - *lbound)); } @@ -1335,7 +1335,7 @@ impl RandBigInt for R { lbound: &BigInt, ubound: &BigInt) -> BigInt { - assert!(*lbound < *ubound); + fail_unless!(*lbound < *ubound); let delta = (*ubound - *lbound).to_biguint().unwrap(); return *lbound + self.gen_biguint_below(&delta).to_bigint().unwrap(); } @@ -1406,7 +1406,7 @@ mod biguint_tests { #[test] fn test_from_slice() { fn check(slice: &[BigDigit], data: &[BigDigit]) { - assert!(data == BigUint::from_slice(slice).data); + fail_unless!(data == BigUint::from_slice(slice).data); } check([1], [1]); check([0, 0, 0], []); @@ -1427,27 +1427,27 @@ mod biguint_tests { assert_eq!(ni.cmp(nj), Equal); assert_eq!(nj.cmp(ni), Equal); assert_eq!(ni, nj); - assert!(!(ni != nj)); - assert!(ni <= nj); - assert!(ni >= nj); - assert!(!(ni < nj)); - assert!(!(ni > nj)); + fail_unless!(!(ni != nj)); + fail_unless!(ni <= nj); + fail_unless!(ni >= nj); + fail_unless!(!(ni < nj)); + fail_unless!(!(ni > nj)); } else { assert_eq!(ni.cmp(nj), Less); assert_eq!(nj.cmp(ni), Greater); - assert!(!(ni == nj)); - assert!(ni != nj); + fail_unless!(!(ni == nj)); + fail_unless!(ni != nj); - assert!(ni <= nj); - assert!(!(ni >= nj)); - assert!(ni < nj); - assert!(!(ni > nj)); + fail_unless!(ni <= nj); + fail_unless!(!(ni >= nj)); + fail_unless!(ni < nj); + fail_unless!(!(ni > nj)); - assert!(!(nj <= ni)); - assert!(nj >= ni); - assert!(!(nj < ni)); - assert!(nj > ni); + fail_unless!(!(nj <= ni)); + fail_unless!(nj >= ni); + fail_unless!(!(nj < ni)); + fail_unless!(nj > ni); } } } @@ -1577,8 +1577,8 @@ mod biguint_tests { fn test_convert_i64() { fn check(b1: BigUint, i: i64) { let b2: BigUint = FromPrimitive::from_i64(i).unwrap(); - assert!(b1 == b2); - assert!(b1.to_i64().unwrap() == i); + fail_unless!(b1 == b2); + fail_unless!(b1.to_i64().unwrap() == i); } check(Zero::zero(), 0); @@ -1606,8 +1606,8 @@ mod biguint_tests { fn test_convert_i64() { fn check(b1: BigUint, i: i64) { let b2: BigUint = FromPrimitive::from_i64(i).unwrap(); - assert!(b1 == b2); - assert!(b1.to_i64().unwrap() == i); + fail_unless!(b1 == b2); + fail_unless!(b1.to_i64().unwrap() == i); } check(Zero::zero(), 0); @@ -1631,8 +1631,8 @@ mod biguint_tests { fn test_convert_u64() { fn check(b1: BigUint, u: u64) { let b2: BigUint = FromPrimitive::from_u64(u).unwrap(); - assert!(b1 == b2); - assert!(b1.to_u64().unwrap() == u); + fail_unless!(b1 == b2); + fail_unless!(b1.to_u64().unwrap() == u); } check(Zero::zero(), 0); @@ -1659,8 +1659,8 @@ mod biguint_tests { fn test_convert_u64() { fn check(b1: BigUint, u: u64) { let b2: BigUint = FromPrimitive::from_u64(u).unwrap(); - assert!(b1 == b2); - assert!(b1.to_u64().unwrap() == u); + fail_unless!(b1 == b2); + fail_unless!(b1.to_u64().unwrap() == u); } check(Zero::zero(), 0); @@ -1711,8 +1711,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - assert!(a + b == c); - assert!(b + a == c); + fail_unless!(a + b == c); + fail_unless!(b + a == c); } } @@ -1724,8 +1724,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - assert!(c - a == b); - assert!(c - b == a); + fail_unless!(c - a == b); + fail_unless!(c - b == a); } } @@ -1775,8 +1775,8 @@ mod biguint_tests { let b = BigUint::from_slice(bVec); let c = BigUint::from_slice(cVec); - assert!(a * b == c); - assert!(b * a == c); + fail_unless!(a * b == c); + fail_unless!(b * a == c); } for elm in div_rem_quadruples.iter() { @@ -1786,8 +1786,8 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - assert!(a == b * c + d); - assert!(a == c * b + d); + fail_unless!(a == b * c + d); + fail_unless!(a == c * b + d); } } @@ -1814,7 +1814,7 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); } + if !b.is_zero() { fail_unless!(a.div_rem(&b) == (c, d)); } } } @@ -1860,13 +1860,13 @@ mod biguint_tests { let thousand: BigUint = FromStr::from_str("1000").unwrap(); let big: BigUint = FromStr::from_str("1000000000000000000000").unwrap(); let bigger: BigUint = FromStr::from_str("1000000000000000000001").unwrap(); - assert!(one.is_odd()); - assert!(two.is_even()); - assert!(thousand.is_even()); - assert!(big.is_even()); - assert!(bigger.is_odd()); - assert!((one << 64).is_even()); - assert!(((one << 64) + one).is_odd()); + fail_unless!(one.is_odd()); + fail_unless!(two.is_even()); + fail_unless!(thousand.is_even()); + fail_unless!(big.is_even()); + fail_unless!(bigger.is_odd()); + fail_unless!((one << 64).is_even()); + fail_unless!(((one << 64) + one).is_odd()); } fn to_str_pairs() -> ~[ (BigUint, ~[(uint, ~str)]) ] { @@ -2003,7 +2003,7 @@ mod biguint_tests { fn test_rand() { let mut rng = task_rng(); let _n: BigUint = rng.gen_biguint(137); - assert!(rng.gen_biguint(0).is_zero()); + fail_unless!(rng.gen_biguint(0).is_zero()); } #[test] @@ -2020,11 +2020,11 @@ mod biguint_tests { let u = FromPrimitive::from_uint(403469000 + 3513).unwrap(); for _ in range(0, 1000) { let n: BigUint = rng.gen_biguint_below(&u); - assert!(n < u); + fail_unless!(n < u); let n: BigUint = rng.gen_biguint_range(&l, &u); - assert!(n >= l); - assert!(n < u); + fail_unless!(n >= l); + fail_unless!(n < u); } } @@ -2089,27 +2089,27 @@ mod bigint_tests { assert_eq!(ni.cmp(nj), Equal); assert_eq!(nj.cmp(ni), Equal); assert_eq!(ni, nj); - assert!(!(ni != nj)); - assert!(ni <= nj); - assert!(ni >= nj); - assert!(!(ni < nj)); - assert!(!(ni > nj)); + fail_unless!(!(ni != nj)); + fail_unless!(ni <= nj); + fail_unless!(ni >= nj); + fail_unless!(!(ni < nj)); + fail_unless!(!(ni > nj)); } else { assert_eq!(ni.cmp(nj), Less); assert_eq!(nj.cmp(ni), Greater); - assert!(!(ni == nj)); - assert!(ni != nj); + fail_unless!(!(ni == nj)); + fail_unless!(ni != nj); - assert!(ni <= nj); - assert!(!(ni >= nj)); - assert!(ni < nj); - assert!(!(ni > nj)); + fail_unless!(ni <= nj); + fail_unless!(!(ni >= nj)); + fail_unless!(ni < nj); + fail_unless!(!(ni > nj)); - assert!(!(nj <= ni)); - assert!(nj >= ni); - assert!(!(nj < ni)); - assert!(nj > ni); + fail_unless!(!(nj <= ni)); + fail_unless!(nj >= ni); + fail_unless!(!(nj < ni)); + fail_unless!(nj > ni); } } } @@ -2119,8 +2119,8 @@ mod bigint_tests { fn test_convert_i64() { fn check(b1: BigInt, i: i64) { let b2: BigInt = FromPrimitive::from_i64(i).unwrap(); - assert!(b1 == b2); - assert!(b1.to_i64().unwrap() == i); + fail_unless!(b1 == b2); + fail_unless!(b1.to_i64().unwrap() == i); } check(Zero::zero(), 0); @@ -2149,8 +2149,8 @@ mod bigint_tests { fn test_convert_u64() { fn check(b1: BigInt, u: u64) { let b2: BigInt = FromPrimitive::from_u64(u).unwrap(); - assert!(b1 == b2); - assert!(b1.to_u64().unwrap() == u); + fail_unless!(b1 == b2); + fail_unless!(b1.to_u64().unwrap() == u); } check(Zero::zero(), 0); @@ -2207,14 +2207,14 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - assert!(a + b == c); - assert!(b + a == c); - assert!(c + (-a) == b); - assert!(c + (-b) == a); - assert!(a + (-c) == (-b)); - assert!(b + (-c) == (-a)); - assert!((-a) + (-b) == (-c)) - assert!(a + (-a) == Zero::zero()); + fail_unless!(a + b == c); + fail_unless!(b + a == c); + fail_unless!(c + (-a) == b); + fail_unless!(c + (-b) == a); + fail_unless!(a + (-c) == (-b)); + fail_unless!(b + (-c) == (-a)); + fail_unless!((-a) + (-b) == (-c)) + fail_unless!(a + (-a) == Zero::zero()); } } @@ -2226,14 +2226,14 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - assert!(c - a == b); - assert!(c - b == a); - assert!((-b) - a == (-c)) - assert!((-a) - b == (-c)) - assert!(b - (-a) == c); - assert!(a - (-b) == c); - assert!((-c) - (-a) == (-b)); - assert!(a - a == Zero::zero()); + fail_unless!(c - a == b); + fail_unless!(c - b == a); + fail_unless!((-b) - a == (-c)) + fail_unless!((-a) - b == (-c)) + fail_unless!(b - (-a) == c); + fail_unless!(a - (-b) == c); + fail_unless!((-c) - (-a) == (-b)); + fail_unless!(a - a == Zero::zero()); } } @@ -2283,11 +2283,11 @@ mod bigint_tests { let b = BigInt::from_slice(Plus, bVec); let c = BigInt::from_slice(Plus, cVec); - assert!(a * b == c); - assert!(b * a == c); + fail_unless!(a * b == c); + fail_unless!(b * a == c); - assert!((-a) * b == -c); - assert!((-b) * a == -c); + fail_unless!((-a) * b == -c); + fail_unless!((-b) * a == -c); } for elm in div_rem_quadruples.iter() { @@ -2297,8 +2297,8 @@ mod bigint_tests { let c = BigInt::from_slice(Plus, cVec); let d = BigInt::from_slice(Plus, dVec); - assert!(a == b * c + d); - assert!(a == c * b + d); + fail_unless!(a == b * c + d); + fail_unless!(a == c * b + d); } } @@ -2309,10 +2309,10 @@ mod bigint_tests { if !m.is_zero() { assert_eq!(m.sign, b.sign); } - assert!(m.abs() <= b.abs()); - assert!(*a == b * d + m); - assert!(d == *ans_d); - assert!(m == *ans_m); + fail_unless!(m.abs() <= b.abs()); + fail_unless!(*a == b * d + m); + fail_unless!(d == *ans_d); + fail_unless!(m == *ans_m); } fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) { @@ -2360,10 +2360,10 @@ mod bigint_tests { if !r.is_zero() { assert_eq!(r.sign, a.sign); } - assert!(r.abs() <= b.abs()); - assert!(*a == b * q + r); - assert!(q == *ans_q); - assert!(r == *ans_r); + fail_unless!(r.abs() <= b.abs()); + fail_unless!(*a == b * q + r); + fail_unless!(q == *ans_q); + fail_unless!(r == *ans_r); } fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) { @@ -2455,7 +2455,7 @@ mod bigint_tests { fn test_to_str_radix() { fn check(n: int, ans: &str) { let n: BigInt = FromPrimitive::from_int(n).unwrap(); - assert!(ans == n.to_str_radix(10)); + fail_unless!(ans == n.to_str_radix(10)); } check(10, "10"); check(1, "1"); @@ -2490,9 +2490,9 @@ mod bigint_tests { #[test] fn test_neg() { - assert!(-BigInt::new(Plus, ~[1, 1, 1]) == + fail_unless!(-BigInt::new(Plus, ~[1, 1, 1]) == BigInt::new(Minus, ~[1, 1, 1])); - assert!(-BigInt::new(Minus, ~[1, 1, 1]) == + fail_unless!(-BigInt::new(Minus, ~[1, 1, 1]) == BigInt::new(Plus, ~[1, 1, 1])); let zero: BigInt = Zero::zero(); assert_eq!(-zero, zero); @@ -2502,7 +2502,7 @@ mod bigint_tests { fn test_rand() { let mut rng = task_rng(); let _n: BigInt = rng.gen_bigint(137); - assert!(rng.gen_bigint(0).is_zero()); + fail_unless!(rng.gen_bigint(0).is_zero()); } #[test] @@ -2519,8 +2519,8 @@ mod bigint_tests { let mut rng = task_rng(); for _ in range(0, 1000) { let n: BigInt = rng.gen_bigint_range(&l, &u); - assert!(n >= l); - assert!(n < u); + fail_unless!(n >= l); + fail_unless!(n < u); } } let l: BigInt = FromPrimitive::from_uint(403469000 + 2352).unwrap(); diff --git a/src/libnum/complex.rs b/src/libnum/complex.rs index 3755b2e43af1b..2dfe725ed80cd 100644 --- a/src/libnum/complex.rs +++ b/src/libnum/complex.rs @@ -267,7 +267,7 @@ mod test { #[test] fn test_arg() { fn test(c: Complex64, arg: f64) { - assert!((c.arg() - arg).abs() < 1.0e-6) + fail_unless!((c.arg() - arg).abs() < 1.0e-6) } test(_1_0i, 0.0); test(_1_1i, 0.25 * Float::pi()); @@ -279,7 +279,7 @@ mod test { fn test_polar_conv() { fn test(c: Complex64) { let (r, theta) = c.to_polar(); - assert!((c - Cmplx::from_polar(&r, &theta)).norm() < 1e-6); + fail_unless!((c - Cmplx::from_polar(&r, &theta)).norm() < 1e-6); } for &c in all_consts.iter() { test(c); } } diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index e9e93cc29d6fe..298b8de3144fa 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -36,15 +36,15 @@ pub trait Integer: Num + Ord /// /// ~~~ /// # use num::Integer; - /// assert!(( 8i).div_floor(& 3) == 2); - /// assert!(( 8i).div_floor(&-3) == -3); - /// assert!((-8i).div_floor(& 3) == -3); - /// assert!((-8i).div_floor(&-3) == 2); + /// fail_unless!(( 8i).div_floor(& 3) == 2); + /// fail_unless!(( 8i).div_floor(&-3) == -3); + /// fail_unless!((-8i).div_floor(& 3) == -3); + /// fail_unless!((-8i).div_floor(&-3) == 2); /// - /// assert!(( 1i).div_floor(& 2) == 0); - /// assert!(( 1i).div_floor(&-2) == -1); - /// assert!((-1i).div_floor(& 2) == -1); - /// assert!((-1i).div_floor(&-2) == 0); + /// fail_unless!(( 1i).div_floor(& 2) == 0); + /// fail_unless!(( 1i).div_floor(&-2) == -1); + /// fail_unless!((-1i).div_floor(& 2) == -1); + /// fail_unless!((-1i).div_floor(&-2) == 0); /// ~~~ fn div_floor(&self, other: &Self) -> Self; @@ -53,22 +53,22 @@ pub trait Integer: Num + Ord /// ~~~ /// # use num::Integer; /// # let n = 1i; let d = 1i; - /// assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n) + /// fail_unless!(n.div_floor(&d) * d + n.mod_floor(&d) == n) /// ~~~ /// /// # Examples /// /// ~~~ /// # use num::Integer; - /// assert!(( 8i).mod_floor(& 3) == 2); - /// assert!(( 8i).mod_floor(&-3) == -1); - /// assert!((-8i).mod_floor(& 3) == 1); - /// assert!((-8i).mod_floor(&-3) == -2); + /// fail_unless!(( 8i).mod_floor(& 3) == 2); + /// fail_unless!(( 8i).mod_floor(&-3) == -1); + /// fail_unless!((-8i).mod_floor(& 3) == 1); + /// fail_unless!((-8i).mod_floor(&-3) == -2); /// - /// assert!(( 1i).mod_floor(& 2) == 1); - /// assert!(( 1i).mod_floor(&-2) == -1); - /// assert!((-1i).mod_floor(& 2) == 1); - /// assert!((-1i).mod_floor(&-2) == -1); + /// fail_unless!(( 1i).mod_floor(& 2) == 1); + /// fail_unless!(( 1i).mod_floor(&-2) == -1); + /// fail_unless!((-1i).mod_floor(& 2) == 1); + /// fail_unless!((-1i).mod_floor(&-2) == -1); /// ~~~ fn mod_floor(&self, other: &Self) -> Self; @@ -389,9 +389,9 @@ macro_rules! impl_integer_for_uint { #[test] fn test_divides() { - assert!((6 as $T).divides(&(6 as $T))); - assert!((6 as $T).divides(&(3 as $T))); - assert!((6 as $T).divides(&(1 as $T))); + fail_unless!((6 as $T).divides(&(6 as $T))); + fail_unless!((6 as $T).divides(&(3 as $T))); + fail_unless!((6 as $T).divides(&(1 as $T))); } #[test] diff --git a/src/libnum/rational.rs b/src/libnum/rational.rs index 5f1868b48c519..41d6b5fc4b243 100644 --- a/src/libnum/rational.rs +++ b/src/libnum/rational.rs @@ -375,16 +375,16 @@ mod test { #[test] fn test_cmp() { - assert!(_0 == _0 && _1 == _1); - assert!(_0 != _1 && _1 != _0); - assert!(_0 < _1 && !(_1 < _0)); - assert!(_1 > _0 && !(_0 > _1)); + fail_unless!(_0 == _0 && _1 == _1); + fail_unless!(_0 != _1 && _1 != _0); + fail_unless!(_0 < _1 && !(_1 < _0)); + fail_unless!(_1 > _0 && !(_0 > _1)); - assert!(_0 <= _0 && _1 <= _1); - assert!(_0 <= _1 && !(_1 <= _0)); + fail_unless!(_0 <= _0 && _1 <= _1); + fail_unless!(_0 <= _1 && !(_1 <= _0)); - assert!(_0 >= _0 && _1 >= _1); - assert!(_1 >= _0 && !(_0 >= _1)); + fail_unless!(_0 >= _0 && _1 >= _1); + fail_unless!(_1 >= _0 && !(_0 >= _1)); } @@ -421,12 +421,12 @@ mod test { #[test] fn test_is_integer() { - assert!(_0.is_integer()); - assert!(_1.is_integer()); - assert!(_2.is_integer()); - assert!(!_1_2.is_integer()); - assert!(!_3_2.is_integer()); - assert!(!_neg1_2.is_integer()); + fail_unless!(_0.is_integer()); + fail_unless!(_1.is_integer()); + fail_unless!(_2.is_integer()); + fail_unless!(!_1_2.is_integer()); + fail_unless!(!_3_2.is_integer()); + fail_unless!(!_neg1_2.is_integer()); } diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs index d5d784cc2de32..34f2efd100121 100644 --- a/src/librustc/back/archive.rs +++ b/src/librustc/back/archive.rs @@ -81,7 +81,7 @@ impl Archive { /// Opens an existing static archive pub fn open(sess: Session, dst: Path) -> Archive { - assert!(dst.exists()); + fail_unless!(dst.exists()); Archive { sess: sess, dst: dst } } diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index a9d7d231cefd9..6246b5476f359 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -179,7 +179,7 @@ pub mod write { let addpass = |pass: &str| { pass.with_c_str(|s| llvm::LLVMRustAddPass(fpm, s)) }; - if !sess.no_verify() { assert!(addpass("verify")); } + if !sess.no_verify() { fail_unless!(addpass("verify")); } if !sess.opts.cg.no_prepopulate_passes { llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod); @@ -1364,7 +1364,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session, crates: ~[(ast::CrateNum, Path)]) { // If we're performing LTO, then it should have been previously required // that all upstream rust dependencies were available in an rlib format. - assert!(!sess.lto()); + fail_unless!(!sess.lto()); for (_, cratepath) in crates.move_iter() { // Just need to tell the linker about where the library lives and diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 43ecbccfd79dc..0dbb8fd8b0fc1 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -125,7 +125,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os, -> ~str { use std::os; - assert!(not_win32(os)); + fail_unless!(not_win32(os)); // Mac doesn't appear to support $ORIGIN let prefix = match os { @@ -203,13 +203,13 @@ mod test { debug!("test_prefix_path: {} vs. {}", res, d.display()); - assert!(res.as_bytes().ends_with(d.as_vec())); + fail_unless!(res.as_bytes().ends_with(d.as_vec())); } #[test] fn test_prefix_rpath_abs() { let res = get_install_prefix_rpath("triple"); - assert!(Path::new(res).is_absolute()); + fail_unless!(Path::new(res).is_absolute()); } #[test] diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index f2d82bfdf3c9b..c96bb5af7c2d4 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -1177,7 +1177,7 @@ mod test { let sessopts = build_session_options(matches); let sess = build_session(sessopts, None); let cfg = build_configuration(sess); - assert!((attr::contains_name(cfg, "test"))); + fail_unless!((attr::contains_name(cfg, "test"))); } // When the user supplies --test and --cfg test, don't implicitly add @@ -1196,7 +1196,7 @@ mod test { let sess = build_session(sessopts, None); let cfg = build_configuration(sess); let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test"))); - assert!(test_items.next().is_some()); - assert!(test_items.next().is_none()); + fail_unless!(test_items.next().is_some()); + fail_unless!(test_items.next().is_none()); } } diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index d565e378af431..cdbd5ef7fe18f 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1833,7 +1833,7 @@ impl TypeNames { pub fn associate_type(&self, s: &str, t: &Type) { let mut named_types = self.named_types.borrow_mut(); - assert!(named_types.get().insert(s.to_owned(), t.to_ref())); + fail_unless!(named_types.get().insert(s.to_owned(), t.to_ref())); } pub fn find_type(&self, s: &str) -> Option { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index d361ee569362c..f07f8f441af8d 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -100,7 +100,7 @@ fn warn_if_multiple_versions(e: &mut Env, let (matches, non_matches) = crate_cache.partitioned(|entry| name == entry.crateid.name); - assert!(!matches.is_empty()); + fail_unless!(!matches.is_empty()); if matches.len() != 1u { diag.handler().warn( diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 8c2c05b96cd01..6b940667c5149 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -153,7 +153,7 @@ impl CStore { pub fn add_used_library(&self, lib: ~str, kind: NativeLibaryKind) -> bool { - assert!(!lib.is_empty()); + fail_unless!(!lib.is_empty()); let mut used_libraries = self.used_libraries.borrow_mut(); if used_libraries.get().iter().any(|&(ref x, _)| x == &lib) { return false; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index d2b843cdcf7e9..54b12192dc961 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1075,7 +1075,7 @@ fn encode_info_for_item(ecx: &EncodeContext, match ty.node { ast::TyPath(ref path, ref bounds, _) if path.segments .len() == 1 => { - assert!(bounds.is_none()); + fail_unless!(bounds.is_none()); encode_impl_type_basename(ebml_w, ast_util::path_to_ident(path)); } _ => {} @@ -1411,7 +1411,7 @@ fn encode_index( ebml_w.start_tag(tag_index_buckets_bucket); for elt in (**bucket).iter() { ebml_w.start_tag(tag_index_buckets_bucket_elt); - assert!(elt.pos < 0xffff_ffff); + fail_unless!(elt.pos < 0xffff_ffff); { let wr: &mut MemWriter = ebml_w.writer; wr.write_be_u32(elt.pos as u32); @@ -1424,7 +1424,7 @@ fn encode_index( ebml_w.end_tag(); ebml_w.start_tag(tag_index_table); for pos in bucket_locs.iter() { - assert!(*pos < 0xffff_ffff); + fail_unless!(*pos < 0xffff_ffff); let wr: &mut MemWriter = ebml_w.writer; wr.write_be_u32(*pos as u32); } @@ -1434,7 +1434,7 @@ fn encode_index( fn write_i64(writer: &mut MemWriter, &n: &i64) { let wr: &mut MemWriter = writer; - assert!(n < 0x7fff_ffff); + fail_unless!(n < 0x7fff_ffff); wr.write_be_u32(n as u32); } @@ -1492,7 +1492,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext, krate: &Crate) -> ~[Attribute] { fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute { - assert!(!ecx.link_meta.crateid.name.is_empty()); + fail_unless!(!ecx.link_meta.crateid.name.is_empty()); attr::mk_attr( attr::mk_name_value_item_str( diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 42231ce1b4763..7cc74724aa0b0 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -141,7 +141,7 @@ impl FileSearch { pub fn relative_target_lib_path(target_triple: &str) -> Path { let mut p = Path::new(libdir()); - assert!(p.is_relative()); + fail_unless!(p.is_relative()); p.push(rustlibdir()); p.push(target_triple); p.push("lib"); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 8cc52627fcc93..95702a6d23be1 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -200,7 +200,7 @@ impl ExtendedDecodeContext { */ // from_id_range should be non-empty - assert!(!self.from_id_range.empty()); + fail_unless!(!self.from_id_range.empty()); (id - self.from_id_range.min + self.to_id_range.min) } pub fn tr_def_id(&self, did: ast::DefId) -> ast::DefId { @@ -1483,7 +1483,7 @@ fn test_simplification() { ).unwrap()); match (item_out, item_exp) { (ast::IIItem(item_out), ast::IIItem(item_exp)) => { - assert!(pprust::item_to_str(item_out) == pprust::item_to_str(item_exp)); + fail_unless!(pprust::item_to_str(item_out) == pprust::item_to_str(item_exp)); } _ => fail!() } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 590229a6652a2..bbf52dd580db9 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -194,7 +194,7 @@ impl<'a> CheckLoanCtxt<'a> { new_loan.repr(self.tcx())); // Should only be called for loans that are in scope at the same time. - assert!(self.tcx().region_maps.scopes_intersect(old_loan.kill_scope, + fail_unless!(self.tcx().region_maps.scopes_intersect(old_loan.kill_scope, new_loan.kill_scope)); self.report_error_if_loan_conflicts_with_restriction( @@ -405,7 +405,7 @@ impl<'a> CheckLoanCtxt<'a> { // For immutable local variables, assignments are legal // if they cannot already have been assigned if self.is_local_variable(cmt) { - assert!(cmt.mutbl.is_immutable()); // no "const" locals + fail_unless!(cmt.mutbl.is_immutable()); // no "const" locals let lp = opt_loan_path(cmt).unwrap(); self.move_data.each_assignment_of(expr.id, lp, |assign| { self.bccx.report_reassigned_immutable_variable( diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 15922d57ba83c..caedb469aff6b 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -769,7 +769,7 @@ impl<'a> GatherLoanCtxt<'a> { if rm.is_subscope_of(lexical_scope, loan_scope) { lexical_scope } else { - assert!(self.bccx.tcx.region_maps.is_subscope_of(loan_scope, lexical_scope)); + fail_unless!(self.bccx.tcx.region_maps.is_subscope_of(loan_scope, lexical_scope)); loan_scope } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index c7157ad1703a6..afd0f4897ee42 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -509,7 +509,7 @@ impl BorrowckCtxt { pat: @ast::Pat, op: |mc::cmt, &ast::Pat|) { let r = self.mc().cat_pattern(cmt, pat, |_,x,y| op(x,y)); - assert!(r.is_ok()); + fail_unless!(r.is_ok()); } pub fn report(&self, err: BckError) { diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 6ca779906e2d1..fc03461c7d200 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -458,7 +458,7 @@ impl CFGBuilder { } fn add_node(&mut self, id: ast::NodeId, preds: &[CFGIndex]) -> CFGIndex { - assert!(!self.exit_map.contains_key(&id)); + fail_unless!(!self.exit_map.contains_key(&id)); let node = self.graph.add_node(CFGNodeData {id: id}); self.exit_map.insert(id, node); for &pred in preds.iter() { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index c0789e0aa8536..2ffdcf4928f8c 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -167,7 +167,7 @@ fn raw_pat(p: @Pat) -> @Pat { } fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) { - assert!((!pats.is_empty())); + fail_unless!((!pats.is_empty())); let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) { not_useful => { // This is good, wildcard pattern isn't reachable diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index e8e05b0979a04..70d0d9b9ab871 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -220,10 +220,10 @@ impl DataFlowContext { let start = *n * self.words_per_id; let end = start + self.words_per_id; - assert!(start < self.gens.len()); - assert!(end <= self.gens.len()); - assert!(self.gens.len() == self.kills.len()); - assert!(self.gens.len() == self.on_entry.len()); + fail_unless!(start < self.gens.len()); + fail_unless!(end <= self.gens.len()); + fail_unless!(self.gens.len() == self.kills.len()); + fail_unless!(self.gens.len() == self.on_entry.len()); (start, end) } diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index a83e1f6012493..14f046e8ddb5a 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -354,7 +354,7 @@ mod test { let mut counter = 0; graph.each_incoming_edge(start_index, |edge_index, edge| { assert_eq!(graph.edge_data(edge_index), &edge.data); - assert!(counter < expected_incoming.len()); + fail_unless!(counter < expected_incoming.len()); debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", counter, expected_incoming[counter], edge_index, edge); match expected_incoming[counter] { @@ -372,7 +372,7 @@ mod test { let mut counter = 0; graph.each_outgoing_edge(start_index, |edge_index, edge| { assert_eq!(graph.edge_data(edge_index), &edge.data); - assert!(counter < expected_outgoing.len()); + fail_unless!(counter < expected_outgoing.len()); debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", counter, expected_outgoing[counter], edge_index, edge); match expected_outgoing[counter] { diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 9be0a1b0fd340..0954ec9e6835f 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -146,7 +146,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t if cx.tcx.lang_items.drop_trait() == Some(trait_def_id) { match self_type.node { TyPath(_, ref bounds, path_node_id) => { - assert!(bounds.is_none()); + fail_unless!(bounds.is_none()); let struct_def = def_map.get().get_copy(&path_node_id); let struct_did = ast_util::def_id_of_def(struct_def); check_struct_safe_for_destructor(cx, self_type.span, struct_did); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 28436093a3573..ca067d3a9527f 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -1099,7 +1099,7 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) { fn check_item_non_camel_case_types(cx: &Context, it: &ast::Item) { fn is_camel_case(ident: ast::Ident) -> bool { let ident = token::get_ident(ident); - assert!(!ident.get().is_empty()); + fail_unless!(!ident.get().is_empty()); let ident = ident.get().trim_chars(&'_'); // start with a non-lowercase letter rather than non-uppercase diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index efe88b7847f2a..b408fd7074337 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -680,7 +680,7 @@ impl Liveness { pub fn live_on_entry(&self, ln: LiveNode, var: Variable) -> Option { - assert!(ln.is_valid()); + fail_unless!(ln.is_valid()); let users = self.users.borrow(); let reader = users.get()[self.idx(ln, var)].reader; if reader.is_valid() {Some(self.ir.lnk(reader))} else {None} @@ -699,14 +699,14 @@ impl Liveness { } pub fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool { - assert!(ln.is_valid()); + fail_unless!(ln.is_valid()); let users = self.users.borrow(); users.get()[self.idx(ln, var)].used } pub fn assigned_on_entry(&self, ln: LiveNode, var: Variable) -> Option { - assert!(ln.is_valid()); + fail_unless!(ln.is_valid()); let users = self.users.borrow(); let writer = users.get()[self.idx(ln, var)].writer; if writer.is_valid() {Some(self.ir.lnk(writer))} else {None} @@ -1418,9 +1418,9 @@ impl Liveness { // repeat until fixed point is reached: while self.merge_from_succ(ln, body_ln, first_merge) { first_merge = false; - assert!(cond_ln == self.propagate_through_opt_expr(cond, + fail_unless!(cond_ln == self.propagate_through_opt_expr(cond, ln)); - assert!(body_ln == self.with_loop_nodes(expr.id, succ, ln, + fail_unless!(body_ln == self.with_loop_nodes(expr.id, succ, ln, || { self.propagate_through_block(body, cond_ln) })); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index dddd750544092..5c9a426a64b3d 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -450,7 +450,7 @@ impl MemCategorizationContext { ast::ExprField(base, f_name, _) => { // Method calls are now a special syntactic form, // so `a.b` should always be a field. - assert!(!self.typer.is_method_call(expr.id)); + fail_unless!(!self.typer.is_method_call(expr.id)); let base_cmt = if_ok!(self.cat_expr(base)); Ok(self.cat_field(expr, base_cmt, f_name, expr_ty)) diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 7578636b2b681..62258db107845 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -327,7 +327,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> { // crate module gets processed as well. if self.prev_exported { let exp_map2 = self.exp_map2.borrow(); - assert!(exp_map2.get().contains_key(&id), "wut {:?}", id); + fail_unless!(exp_map2.get().contains_key(&id), "wut {:?}", id); for export in exp_map2.get().get(&id).iter() { if is_local(export.def_id) { self.reexports.insert(export.def_id.node); @@ -773,7 +773,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> { // Method calls are now a special syntactic form, // so `a.b` should always be a field. let method_map = self.method_map.borrow(); - assert!(!method_map.get().contains_key(&expr.id)); + fail_unless!(!method_map.get().contains_key(&expr.id)); // With type_autoderef, make sure we don't // allow pointers to violate privacy diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index ee948f5453bab..acaff2fa77cc3 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -228,7 +228,7 @@ impl ReachableContext { let impl_did = tcx.map.get_parent_did(node_id); // Check the impl. If the generics on the self type of the // impl require inlining, this method does too. - assert!(impl_did.krate == ast::LOCAL_CRATE); + fail_unless!(impl_did.krate == ast::LOCAL_CRATE); match tcx.map.expect_item(impl_did.node).node { ast::ItemImpl(ref generics, _, _, _) => { generics_require_inlining(generics) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 9b1473cbd8ed4..0c3dd1538e773 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -117,7 +117,7 @@ impl RegionMaps { pub fn record_encl_scope(&self, sub: ast::NodeId, sup: ast::NodeId) { debug!("record_encl_scope(sub={}, sup={})", sub, sup); - assert!(sub != sup); + fail_unless!(sub != sup); let mut scope_map = self.scope_map.borrow_mut(); scope_map.get().insert(sub, sup); @@ -125,7 +125,7 @@ impl RegionMaps { pub fn record_var_scope(&self, var: ast::NodeId, lifetime: ast::NodeId) { debug!("record_var_scope(sub={}, sup={})", var, lifetime); - assert!(var != lifetime); + fail_unless!(var != lifetime); let mut var_map = self.var_map.borrow_mut(); var_map.get().insert(var, lifetime); @@ -133,7 +133,7 @@ impl RegionMaps { pub fn record_rvalue_scope(&self, var: ast::NodeId, lifetime: ast::NodeId) { debug!("record_rvalue_scope(sub={}, sup={})", var, lifetime); - assert!(var != lifetime); + fail_unless!(var != lifetime); let mut rvalue_scopes = self.rvalue_scopes.borrow_mut(); rvalue_scopes.get().insert(var, lifetime); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 066e4d2b313bc..8062e91259b1f 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1454,7 +1454,7 @@ impl Resolver { match view_path.node { ViewPathSimple(_, ref full_path, _) => { let path_len = full_path.segments.len(); - assert!(path_len != 0); + fail_unless!(path_len != 0); for (i, segment) in full_path.segments .iter() @@ -1926,7 +1926,7 @@ impl Resolver { if !module.populated.get() { self.populate_external_module(module) } - assert!(module.populated.get()) + fail_unless!(module.populated.get()) } /// Builds the reduced graph rooted at the 'use' directive for an external @@ -2221,7 +2221,7 @@ impl Resolver { // Decrement the count of unresolved imports. match resolution_result { Success(()) => { - assert!(self.unresolved_imports >= 1); + fail_unless!(self.unresolved_imports >= 1); self.unresolved_imports -= 1; } _ => { @@ -2237,7 +2237,7 @@ impl Resolver { if !resolution_result.indeterminate() { match *import_directive.subclass { GlobImport => { - assert!(module_.glob_count.get() >= 1); + fail_unless!(module_.glob_count.get() >= 1); module_.glob_count.set(module_.glob_count.get() - 1); } SingleImport(..) => { @@ -2431,7 +2431,7 @@ impl Resolver { // We've successfully resolved the import. Write the results in. let import_resolution = { let import_resolutions = module_.import_resolutions.borrow(); - assert!(import_resolutions.get().contains_key(&target.name)); + fail_unless!(import_resolutions.get().contains_key(&target.name)); import_resolutions.get().get_copy(&target.name) }; @@ -2475,7 +2475,7 @@ impl Resolver { let value_used_public = value_used_reexport || value_used_public; let type_used_public = type_used_reexport || type_used_public; - assert!(import_resolution.outstanding_references.get() >= 1); + fail_unless!(import_resolution.outstanding_references.get() >= 1); import_resolution.outstanding_references.set( import_resolution.outstanding_references.get() - 1); @@ -2807,7 +2807,7 @@ impl Resolver { name_search_type: NameSearchType) -> ResolveResult<(@Module, LastPrivate)> { let module_path_len = module_path.len(); - assert!(module_path_len > 0); + fail_unless!(module_path_len > 0); debug!("(resolving module path for import) processing `{}` rooted at \ `{}`", @@ -4619,7 +4619,7 @@ impl Resolver { self.record_def(pattern.id, (class_def, lp)); } Some(definition @ (DefStruct(class_id), _)) => { - assert!(self.structs.contains(&class_id)); + fail_unless!(self.structs.contains(&class_id)); self.record_def(pattern.id, definition); } Some(definition @ (DefVariant(_, variant_id, _), _)) @@ -5430,7 +5430,7 @@ impl Resolver { fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) { debug!("(recording def) recording {:?} for {:?}, last private {:?}", def, node_id, lp); - assert!(match lp {LastImport{..} => false, _ => true}, + fail_unless!(match lp {LastImport{..} => false, _ => true}, "Import should only be used for `use` directives"); self.last_private.insert(node_id, lp); let mut def_map = self.def_map.borrow_mut(); diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 0aa8393e79d5c..27e7179b790dd 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1457,7 +1457,7 @@ fn compile_submatch<'r, /* For an empty match, a fall-through case must exist */ - assert!((m.len() > 0u || chk.is_fallible())); + fail_unless!((m.len() > 0u || chk.is_fallible())); let _icx = push_ctxt("match::compile_submatch"); let mut bcx = bcx; if m.len() == 0u { @@ -1522,7 +1522,7 @@ fn compile_submatch_continue<'r, // If we are not matching against an `@T`, we should not be // required to root any values. - assert!(!pats_require_rooting(bcx, m, col)); + fail_unless!(!pats_require_rooting(bcx, m, col)); match collect_record_or_struct_fields(bcx, m, col) { Some(ref rec_fields) => { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 2c68914d21fb0..9d5201940bdb1 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -213,7 +213,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { } // The general case. - assert!((cases.len() - 1) as i64 >= 0); + fail_unless!((cases.len() - 1) as i64 >= 0); let bounds = IntBounds { ulo: 0, uhi: (cases.len() - 1) as u64, slo: 0, shi: (cases.len() - 1) as i64 }; let ity = range_to_inttype(cx, hint, &bounds); @@ -528,7 +528,7 @@ fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) let llty = ll_inttype(bcx.ccx(), ity); assert_eq!(val_ty(ptr), llty.ptr_to()); let bits = machine::llbitsize_of_real(bcx.ccx(), llty); - assert!(bits <= 64); + fail_unless!(bits <= 64); let mask = (-1u64 >> (64 - bits)) as Disr; if (max + 1) & mask == min & mask { // i.e., if the range is everything. The lo==hi case would be @@ -566,7 +566,7 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr) bcx.ccx().sess.bug("no cases for univariants or structs") } NullablePointer{ .. } => { - assert!(discr == 0 || discr == 1); + fail_unless!(discr == 0 || discr == 1); _match::single_result(rslt(bcx, C_i1(discr != 0))) } } @@ -608,8 +608,8 @@ pub fn trans_start_init(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr) { fn assert_discr_in_range(ity: IntType, min: Disr, max: Disr, discr: Disr) { match ity { - attr::UnsignedInt(_) => assert!(min <= discr && discr <= max), - attr::SignedInt(_) => assert!(min as i64 <= discr as i64 && discr as i64 <= max as i64) + attr::UnsignedInt(_) => fail_unless!(min <= discr && discr <= max), + attr::SignedInt(_) => fail_unless!(min as i64 <= discr as i64 && discr as i64 <= max as i64) } } @@ -642,7 +642,7 @@ pub fn deref_ty(ccx: &CrateContext, r: &Repr) -> ty::t { st.fields[0] } General(_, ref cases) => { - assert!(cases.len() == 1); + fail_unless!(cases.len() == 1); cases[0].fields[0] } NullablePointer{ .. } => { @@ -745,7 +745,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, C_struct(contents + &[padding(max_sz - case.size)], false) } Univariant(ref st, _dro) => { - assert!(discr == 0); + fail_unless!(discr == 0); let contents = build_const_struct(ccx, st, vals); C_struct(contents, st.packed) } @@ -793,7 +793,7 @@ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef]) } let val = if is_undef(vals[i]) { let wrapped = C_struct([vals[i]], false); - assert!(!is_undef(wrapped)); + fail_unless!(!is_undef(wrapped)); wrapped } else { vals[i] diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c7d09e31855b8..7d7d582e8ecba 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -420,7 +420,7 @@ pub fn malloc_general_dyn<'a>( heap: heap, size: ValueRef) -> MallocResult<'a> { - assert!(heap != heap_exchange); + fail_unless!(heap != heap_exchange); let _icx = push_ctxt("malloc_general"); let Result {bcx: bcx, val: llbox} = malloc_raw_dyn(bcx, t, heap, size); let body = GEPi(bcx, llbox, [0u, abi::box_field_body]); @@ -435,7 +435,7 @@ pub fn malloc_general_dyn<'a>( pub fn malloc_general<'a>(bcx: &'a Block<'a>, t: ty::t, heap: heap) -> MallocResult<'a> { let ty = type_of(bcx.ccx(), t); - assert!(heap != heap_exchange); + fail_unless!(heap != heap_exchange); malloc_general_dyn(bcx, t, heap, llsize_of(bcx.ccx(), ty)) } @@ -1128,7 +1128,7 @@ pub fn alloc_ty(bcx: &Block, t: ty::t, name: &str) -> ValueRef { let _icx = push_ctxt("alloc_ty"); let ccx = bcx.ccx(); let ty = type_of::type_of(ccx, t); - assert!(!ty::type_has_params(t)); + fail_unless!(!ty::type_has_params(t)); let val = alloca(bcx, ty, name); return val; } @@ -1484,7 +1484,7 @@ pub fn trans_closure<'a>(ccx: @CrateContext, let dest = match fcx.llretptr.get() { Some(e) => {expr::SaveIn(e)} None => { - assert!(type_is_zero_size(bcx.ccx(), block_ty)) + fail_unless!(type_is_zero_size(bcx.ccx(), block_ty)) expr::Ignore } }; @@ -1783,7 +1783,7 @@ fn register_fn(ccx: @CrateContext, -> ValueRef { let f = match ty::get(node_type).sty { ty::ty_bare_fn(ref f) => { - assert!(f.abis.is_rust() || f.abis.is_intrinsic()); + fail_unless!(f.abis.is_rust() || f.abis.is_intrinsic()); f } _ => fail!("expected bare rust fn or an intrinsic") @@ -2121,7 +2121,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { let llfn; match v.node.kind { ast::TupleVariantKind(ref args) => { - assert!(args.len() != 0u); + fail_unless!(args.len() != 0u); let ty = ty::node_id_to_type(ccx.tcx, id); let parent = ccx.tcx.map.get_parent(id); let enm = ccx.tcx.map.expect_item(parent); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index e8424bcde603c..c7735da747240 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -758,7 +758,7 @@ pub fn Trap(cx: &Block) { pub fn LandingPad(cx: &Block, Ty: Type, PersFn: ValueRef, NumClauses: uint) -> ValueRef { check_not_terminated(cx); - assert!(!cx.unreachable.get()); + fail_unless!(!cx.unreachable.get()); B(cx).landing_pad(Ty, PersFn, NumClauses) } diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index 9dd92fbc45c73..b4efba8dd738c 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -488,7 +488,7 @@ impl<'a> Builder<'a> { debug!("Store {} -> {}", self.ccx.tn.val_to_str(val), self.ccx.tn.val_to_str(ptr)); - assert!(self.llbuilder.is_not_null()); + fail_unless!(self.llbuilder.is_not_null()); self.count_insn("store"); unsafe { llvm::LLVMBuildStore(self.llbuilder, val, ptr); @@ -499,7 +499,7 @@ impl<'a> Builder<'a> { debug!("Store {} -> {}", self.ccx.tn.val_to_str(val), self.ccx.tn.val_to_str(ptr)); - assert!(self.llbuilder.is_not_null()); + fail_unless!(self.llbuilder.is_not_null()); self.count_insn("store.volatile"); unsafe { let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr); @@ -908,7 +908,7 @@ impl<'a> Builder<'a> { let T: ValueRef = "llvm.trap".with_c_str(|buf| { llvm::LLVMGetNamedFunction(M, buf) }); - assert!((T as int != 0)); + fail_unless!((T as int != 0)); let args: &[ValueRef] = []; self.count_insn("trap"); llvm::LLVMBuildCall( diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index cfba7f03fc9e9..77c63be718824 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -129,7 +129,7 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { } ast::DefVariant(tid, vid, _) => { // nullary variants are not callable - assert!(ty::enum_variant_with_id(bcx.tcx(), + fail_unless!(ty::enum_variant_with_id(bcx.tcx(), tid, vid).args.len() > 0u); fn_callee(bcx, trans_fn_ref(bcx, vid, ref_expr.id)) @@ -273,7 +273,7 @@ pub fn trans_fn_ref_with_vtables( type_params.repr(bcx.tcx()), vtables.repr(bcx.tcx())); - assert!(type_params.iter().all(|t| !ty::type_needs_infer(*t))); + fail_unless!(type_params.iter().all(|t| !ty::type_needs_infer(*t))); // Polytype of the function item (may have type params) let fn_tpt = ty::lookup_item_type(tcx, def_id); @@ -644,7 +644,7 @@ pub fn trans_call_inner<'a>( // not care about the result, just make a stack slot. let opt_llretslot = match dest { None => { - assert!(!type_of::return_uses_outptr(ccx, ret_ty)); + fail_unless!(!type_of::return_uses_outptr(ccx, ret_ty)); None } Some(expr::SaveIn(dst)) => Some(dst), @@ -731,7 +731,7 @@ pub fn trans_call_inner<'a>( } else { // Lang items are the only case where dest is None, and // they are always Rust fns. - assert!(dest.is_some()); + fail_unless!(dest.is_some()); let mut llargs = ~[]; bcx = trans_args(bcx, args, callee_ty, &mut llargs, @@ -749,7 +749,7 @@ pub fn trans_call_inner<'a>( // drop the temporary slot we made. match dest { None => { - assert!(!type_of::return_uses_outptr(bcx.ccx(), ret_ty)); + fail_unless!(!type_of::return_uses_outptr(bcx.ccx(), ret_ty)); } Some(expr::Ignore) => { // drop the value if it is not being saved. @@ -796,7 +796,7 @@ fn trans_args<'a>(cx: &'a Block<'a>, continue; } let arg_ty = if i >= num_formal_args { - assert!(variadic); + fail_unless!(variadic); expr_ty_adjusted(cx, *arg_expr) } else { arg_tys[i] @@ -809,7 +809,7 @@ fn trans_args<'a>(cx: &'a Block<'a>, } } ArgAutorefSecond(arg_expr, arg2) => { - assert!(!variadic); + fail_unless!(!variadic); llargs.push(unpack_result!(bcx, { trans_arg_expr(bcx, arg_tys[0], arg_expr, diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 5bbb9749a592a..267c1ec7adbd4 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -137,7 +137,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("pop_and_trans_ast_cleanup_scope({})", self.ccx.tcx.map.node_to_str(cleanup_scope)); - assert!(self.top_scope(|s| s.kind.is_ast_with_id(cleanup_scope))); + fail_unless!(self.top_scope(|s| s.kind.is_ast_with_id(cleanup_scope))); let scope = self.pop_scope(); self.trans_scope_cleanups(bcx, &scope) @@ -156,7 +156,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("pop_loop_cleanup_scope({})", self.ccx.tcx.map.node_to_str(cleanup_scope)); - assert!(self.top_scope(|s| s.kind.is_loop_with_id(cleanup_scope))); + fail_unless!(self.top_scope(|s| s.kind.is_loop_with_id(cleanup_scope))); let _ = self.pop_scope(); } @@ -170,7 +170,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ debug!("pop_custom_cleanup_scope({})", custom_scope.index); - assert!(self.is_valid_to_pop_custom_scope(custom_scope)); + fail_unless!(self.is_valid_to_pop_custom_scope(custom_scope)); let _ = self.pop_scope(); } @@ -185,7 +185,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ debug!("pop_and_trans_custom_cleanup_scope({:?})", custom_scope); - assert!(self.is_valid_to_pop_custom_scope(custom_scope)); + fail_unless!(self.is_valid_to_pop_custom_scope(custom_scope)); let scope = self.pop_scope(); self.trans_scope_cleanups(bcx, &scope) @@ -346,7 +346,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("schedule_clean_in_custom_scope(custom_scope={})", custom_scope.index); - assert!(self.is_valid_custom_scope(custom_scope)); + fail_unless!(self.is_valid_custom_scope(custom_scope)); let mut scopes = self.scopes.borrow_mut(); let scope = &mut scopes.get()[custom_scope.index]; @@ -376,7 +376,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { debug!("get_landing_pad"); let orig_scopes_len = self.scopes_len(); - assert!(orig_scopes_len > 0); + fail_unless!(orig_scopes_len > 0); // Remove any scopes that do not have cleanups on failure: let mut popped_scopes = opt_vec::Empty; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index d9e929c25019c..9121f5b7601b8 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -194,8 +194,8 @@ pub struct param_substs { impl param_substs { pub fn validate(&self) { - for t in self.tys.iter() { assert!(!ty::type_needs_infer(*t)); } - for t in self.self_ty.iter() { assert!(!ty::type_needs_infer(*t)); } + for t in self.tys.iter() { fail_unless!(!ty::type_needs_infer(*t)); } + for t in self.self_ty.iter() { fail_unless!(!ty::type_needs_infer(*t)); } } } @@ -298,7 +298,7 @@ impl<'a> FunctionContext<'a> { } pub fn out_arg_pos(&self) -> uint { - assert!(self.caller_expects_out_pointer); + fail_unless!(self.caller_expects_out_pointer); 0u } @@ -785,8 +785,8 @@ pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t { ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t) } _ => { - assert!(!ty::type_has_params(t)); - assert!(!ty::type_has_self(t)); + fail_unless!(!ty::type_has_params(t)); + fail_unless!(!ty::type_has_self(t)); t } } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index fc5e48a161f13..42f011a7e6d57 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -83,7 +83,7 @@ pub fn const_ptrcast(cx: &CrateContext, a: ValueRef, t: Type) -> ValueRef { unsafe { let b = llvm::LLVMConstPointerCast(a, t.ptr_to().to_ref()); let mut const_globals = cx.const_globals.borrow_mut(); - assert!(const_globals.get().insert(b as int, a)); + fail_unless!(const_globals.get().insert(b as int, a)); b } } @@ -137,7 +137,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool) -> (ValueRef, ty::t) { match ty::deref(t, explicit) { Some(ref mt) => { - assert!(mt.mutbl != ast::MutMutable); + fail_unless!(mt.mutbl != ast::MutMutable); let dv = match ty::get(t).sty { ty::ty_ptr(..) | ty::ty_rptr(..) => { const_deref_ptr(cx, v) @@ -245,11 +245,11 @@ pub fn const_expr(cx: @CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef match *autoref { ty::AutoUnsafe(m) | ty::AutoPtr(ty::ReStatic, m) => { - assert!(m != ast::MutMutable); + fail_unless!(m != ast::MutMutable); llconst = llptr; } ty::AutoBorrowVec(ty::ReStatic, m) => { - assert!(m != ast::MutMutable); + fail_unless!(m != ast::MutMutable); assert_eq!(abi::slice_elt_base, 0); assert_eq!(abi::slice_elt_len, 1); match ty::get(ty).sty { @@ -457,7 +457,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr, let len = llvm::LLVMConstIntGetZExtValue(len) as u64; let len = match ty::get(bt).sty { - ty::ty_str(..) => {assert!(len > 0); len - 1}, + ty::ty_str(..) => {fail_unless!(len > 0); len - 1}, _ => len }; if iv >= len { @@ -609,7 +609,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr, } ast::ExprPath(ref pth) => { // Assert that there are no type parameters in this path. - assert!(pth.segments.iter().all(|seg| seg.types.is_empty())); + fail_unless!(pth.segments.iter().all(|seg| seg.types.is_empty())); let tcx = cx.tcx; let opt_def = { @@ -622,7 +622,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr, let ty = csearch::get_type(cx.tcx, def_id).ty; (base::trans_external_path(cx, def_id, ty), true) } else { - assert!(ast_util::is_local(def_id)); + fail_unless!(ast_util::is_local(def_id)); (base::get_item_val(cx, def_id.node), true) } } diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 15f34ed2d196a..615b634cc72b2 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -98,7 +98,7 @@ pub fn trans_block<'a>(bcx: &'a Block<'a>, bcx = expr::trans_into(bcx, e, dest); } None => { - assert!(dest == expr::Ignore || bcx.unreachable.get()); + fail_unless!(dest == expr::Ignore || bcx.unreachable.get()); } } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 329301efa5ebb..bc570a453b1d6 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -626,7 +626,7 @@ impl Datum { * affine values (since they must never be duplicated). */ - assert!(!ty::type_moves_by_default(bcx.tcx(), self.ty)); + fail_unless!(!ty::type_moves_by_default(bcx.tcx(), self.ty)); let mut bcx = bcx; bcx = self.shallow_copy(bcx, dst); glue::take_ty(bcx, dst, self.ty) @@ -665,8 +665,8 @@ impl Datum { * value, and not by reference. */ - assert!(!ty::type_needs_drop(bcx.tcx(), self.ty)); - assert!(self.appropriate_rvalue_mode(bcx.ccx()) == ByValue); + fail_unless!(!ty::type_needs_drop(bcx.tcx(), self.ty)); + fail_unless!(self.appropriate_rvalue_mode(bcx.ccx()) == ByValue); if self.kind.is_by_ref() { load(bcx, self.val, self.ty) } else { @@ -675,7 +675,7 @@ impl Datum { } pub fn to_llbool<'a>(self, bcx: &'a Block<'a>) -> ValueRef { - assert!(ty::type_is_bool(self.ty) || ty::type_is_bot(self.ty)) + fail_unless!(ty::type_is_bool(self.ty) || ty::type_is_bot(self.ty)) let cond_val = self.to_llscalarish(bcx); bool_to_i1(bcx, cond_val) } @@ -689,7 +689,7 @@ impl<'a, K:KindOps> DatumBlock<'a, K> { impl<'a> DatumBlock<'a, Expr> { pub fn assert_by_ref(self) -> DatumBlock<'a, Expr> { - assert!(self.datum.kind.is_by_ref()); + fail_unless!(self.datum.kind.is_by_ref()); self } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 6a9ee514f8fe7..dd67093704191 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -996,7 +996,7 @@ fn declare_local(bcx: &Block, match variable_kind { ArgumentVariable(_) | CapturedVariable => { - assert!(!bcx.fcx + fail_unless!(!bcx.fcx .debug_context .get_ref(cx, span) .source_locations_enabled @@ -1503,7 +1503,7 @@ fn prepare_enum_metadata(cx: &CrateContext, FinalMetadata(discriminant_type_metadata(inttype)) } adt::Univariant(ref struct_def, _) => { - assert!(variants.len() == 1); + fail_unless!(variants.len() == 1); let (metadata_stub, variant_llvm_type, member_description_factory) = describe_enum_variant(cx, @@ -1738,7 +1738,7 @@ fn boxed_type_metadata(cx: &CrateContext, let box_llvm_type = Type::at_box(cx, content_llvm_type); let member_llvm_types = box_llvm_type.field_types(); - assert!(box_layout_is_correct(cx, member_llvm_types, content_llvm_type)); + fail_unless!(box_layout_is_correct(cx, member_llvm_types, content_llvm_type)); let int_type = ty::mk_int(); let nil_pointer_type = ty::mk_nil_ptr(cx.tcx); @@ -1876,7 +1876,7 @@ fn vec_metadata(cx: &CrateContext, } ]; - assert!(member_descriptions.len() == member_llvm_types.len()); + fail_unless!(member_descriptions.len() == member_llvm_types.len()); let loc = span_start(cx, span); let file_metadata = file_metadata(cx, loc.file.name); @@ -1903,7 +1903,7 @@ fn vec_slice_metadata(cx: &CrateContext, let slice_type_name = ppaux::ty_to_str(cx.tcx, vec_type); let member_llvm_types = slice_llvm_type.field_types(); - assert!(slice_layout_is_correct(cx, member_llvm_types, element_type)); + fail_unless!(slice_layout_is_correct(cx, member_llvm_types, element_type)); let data_ptr_type = ty::mk_ptr(cx.tcx, ty::mt { ty: element_type, mutbl: ast::MutImmutable }); @@ -1922,7 +1922,7 @@ fn vec_slice_metadata(cx: &CrateContext, }, ]; - assert!(member_descriptions.len() == member_llvm_types.len()); + fail_unless!(member_descriptions.len() == member_llvm_types.len()); let loc = span_start(cx, span); let file_metadata = file_metadata(cx, loc.file.name); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 99852e446cc8e..8825943ad98db 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -465,7 +465,7 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>, // if overloaded, would be RvalueDpsExpr { let method_map = bcx.ccx().maps.method_map.borrow(); - assert!(!method_map.get().contains_key(&expr.id)); + fail_unless!(!method_map.get().contains_key(&expr.id)); } trans_binary(bcx, expr, op, lhs, rhs) @@ -1178,12 +1178,12 @@ fn trans_unary_datum<'a>( let _icx = push_ctxt("trans_unary_datum"); // if deref, would be LvalueExpr - assert!(op != ast::UnDeref); + fail_unless!(op != ast::UnDeref); // if overloaded, would be RvalueDpsExpr { let method_map = bcx.ccx().maps.method_map.borrow(); - assert!(!method_map.get().contains_key(&un_expr.id)); + fail_unless!(!method_map.get().contains_key(&un_expr.id)); } let un_ty = expr_ty(bcx, un_expr); @@ -1677,14 +1677,14 @@ fn trans_assign_op<'a>( debug!("trans_assign_op(expr={})", bcx.expr_to_str(expr)); // User-defined operator methods cannot be used with `+=` etc right now - assert!({ + fail_unless!({ let method_map = bcx.ccx().maps.method_map.borrow(); !method_map.get().find(&expr.id).is_some() }); // Evaluate LHS (destination), which should be an lvalue let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, dst, "assign_op")); - assert!(!ty::type_needs_drop(bcx.tcx(), dst_datum.ty)); + fail_unless!(!ty::type_needs_drop(bcx.tcx(), dst_datum.ty)); let dst_ty = dst_datum.ty; let dst = Load(bcx, dst_datum.val); @@ -1804,7 +1804,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>, ty::ty_ptr(ty::mt { ty: content_ty, .. }) | ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => { - assert!(!ty::type_needs_drop(bcx.tcx(), datum.ty)); + fail_unless!(!ty::type_needs_drop(bcx.tcx(), datum.ty)); let ptr = datum.to_llscalarish(bcx); diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index d0eef924356ab..10e41ab38d63e 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -136,7 +136,7 @@ pub fn register_foreign_item_fn(ccx: @CrateContext, abis: AbiSet, // Make sure the calling convention is right for variadic functions // (should've been caught if not in typeck) if tys.fn_sig.variadic { - assert!(cc == lib::llvm::CCallConv); + fail_unless!(cc == lib::llvm::CCallConv); } // Create the LLVM value for the C extern fn @@ -451,7 +451,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, // normal Rust function. This will be the type of the wrappee fn. let f = match ty::get(t).sty { ty::ty_bare_fn(ref f) => { - assert!(!f.abis.is_rust() && !f.abis.is_intrinsic()); + fail_unless!(!f.abis.is_rust() && !f.abis.is_intrinsic()); f } _ => { @@ -610,7 +610,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, // bitcast the llforeign_arg pointer so it matches the types // Rust expects. if llforeign_arg_ty.cast.is_some() { - assert!(!foreign_indirect); + fail_unless!(!foreign_indirect); llforeign_arg = llvm::LLVMBuildBitCast( builder, llforeign_arg, llrust_ty.ptr_to().to_ref(), noname()); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 25d49bd789d87..f84719260f4e1 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -399,7 +399,7 @@ fn incr_refcnt_of_boxed<'a>(bcx: &'a Block<'a>, pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info { // If emit_tydescs already ran, then we shouldn't be creating any new // tydescs. - assert!(!ccx.finished_tydescs.get()); + fail_unless!(!ccx.finished_tydescs.get()); let llty = type_of(ccx, t); diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 4abc114fef667..49d5c6881b9e4 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -208,7 +208,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, // "atomic_[_], and no ordering means SeqCst if name.get().starts_with("atomic_") { let split: ~[&str] = name.get().split('_').collect(); - assert!(split.len() >= 2, "Atomic intrinsic not correct format"); + fail_unless!(split.len() >= 2, "Atomic intrinsic not correct format"); let order = if split.len() == 2 { lib::llvm::SequentiallyConsistent } else { diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 7fa116cafd094..7a89d40e9779f 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -199,7 +199,7 @@ pub fn trans_static_method_callee(bcx: &Block, match vtbls[bound_index][0] { typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => { - assert!(rcvr_substs.iter().all(|t| !ty::type_needs_infer(*t))); + fail_unless!(rcvr_substs.iter().all(|t| !ty::type_needs_infer(*t))); let mth_id = method_with_name(ccx, impl_did, mname); let (callee_substs, callee_origins) = @@ -367,7 +367,7 @@ fn trans_trait_callee<'a>(bcx: &'a Block<'a>, self_datum.add_clean(bcx.fcx, arg_cleanup_scope) } else { // We don't have to do anything about cleanups for &Trait and &mut Trait. - assert!(self_datum.kind.is_by_ref()); + fail_unless!(self_datum.kind.is_by_ref()); self_datum.val }; diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 7a9d93d89f2b3..16a6277c7459b 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -47,7 +47,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, self_vtables.repr(ccx.tcx), ref_id); - assert!(real_substs.tps.iter().all(|t| !ty::type_needs_infer(*t))); + fail_unless!(real_substs.tps.iter().all(|t| !ty::type_needs_infer(*t))); let _icx = push_ctxt("monomorphic_fn"); let mut must_cast = false; @@ -58,8 +58,8 @@ pub fn monomorphic_fn(ccx: @CrateContext, self_vtables: self_vtables }; - for s in real_substs.tps.iter() { assert!(!ty::type_has_params(*s)); } - for s in psubsts.tys.iter() { assert!(!ty::type_has_params(*s)); } + for s in real_substs.tps.iter() { fail_unless!(!ty::type_has_params(*s)); } + for s in psubsts.tys.iter() { fail_unless!(!ty::type_has_params(*s)); } let hash_id = make_mono_id(ccx, fn_id, &*psubsts); if hash_id.params.iter().any( @@ -156,7 +156,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, let f = match ty::get(mono_ty).sty { ty::ty_bare_fn(ref f) => { - assert!(f.abis.is_rust() || f.abis.is_intrinsic()); + fail_unless!(f.abis.is_rust() || f.abis.is_intrinsic()); f } _ => fail!("expected bare rust fn or an intrinsic") diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 4349872756642..642e6304e5c09 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -452,7 +452,7 @@ pub fn write_content<'a>( // cleanup since things would *probably* be broken at that point anyways. let elem = unpack_datum!(bcx, expr::trans(bcx, element)); - assert!(!ty::type_moves_by_default(bcx.tcx(), elem.ty)); + fail_unless!(!ty::type_moves_by_default(bcx.tcx(), elem.ty)); let bcx = iter_vec_loop(bcx, lldest, vt, C_uint(bcx.ccx(), count), |set_bcx, lleltptr, _| { @@ -538,14 +538,14 @@ pub fn get_base_and_byte_len(bcx: &Block, (base, len) } ty::vstore_slice(_) => { - assert!(!type_is_immediate(bcx.ccx(), vt.vec_ty)); + fail_unless!(!type_is_immediate(bcx.ccx(), vt.vec_ty)); let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base])); let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len])); let len = Mul(bcx, count, vt.llunit_size); (base, len) } ty::vstore_uniq => { - assert!(type_is_immediate(bcx.ccx(), vt.vec_ty)); + fail_unless!(type_is_immediate(bcx.ccx(), vt.vec_ty)); let body = Load(bcx, llval); (get_dataptr(bcx, body), get_fill(bcx, body)) } @@ -578,13 +578,13 @@ pub fn get_base_and_len(bcx: &Block, (base, C_uint(ccx, n)) } ty::vstore_slice(_) => { - assert!(!type_is_immediate(bcx.ccx(), vt.vec_ty)); + fail_unless!(!type_is_immediate(bcx.ccx(), vt.vec_ty)); let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base])); let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len])); (base, count) } ty::vstore_uniq => { - assert!(type_is_immediate(bcx.ccx(), vt.vec_ty)); + fail_unless!(type_is_immediate(bcx.ccx(), vt.vec_ty)); let body = Load(bcx, llval); (get_dataptr(bcx, body), UDiv(bcx, get_fill(bcx, body), vt.llunit_size)) } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 09c21d54c87a0..8af234878fba6 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3796,7 +3796,7 @@ pub fn trait_supertraits(cx: ctxt, id: ast::DefId) -> @~[@TraitRef] { // Not in the cache. It had better be in the metadata, which means it // shouldn't be local. - assert!(!is_local(id)); + fail_unless!(!is_local(id)); // Get the supertraits out of the metadata and create the // TraitRef for each. @@ -3981,7 +3981,7 @@ impl VariantInfo { let fields: &[StructField] = struct_def.fields; - assert!(fields.len() > 0); + fail_unless!(fields.len() > 0); let arg_tys = ty_fn_args(ctor_ty).map(|a| *a); let arg_names = fields.map(|field| { @@ -4218,7 +4218,7 @@ pub fn lookup_trait_def(cx: ctxt, did: ast::DefId) -> @ty::TraitDef { return trait_def; } None => { - assert!(did.krate != ast::LOCAL_CRATE); + fail_unless!(did.krate != ast::LOCAL_CRATE); let trait_def = @csearch::get_trait_def(cx, did); trait_defs.get().insert(did, trait_def); return trait_def; diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index fca89f3f91ca8..51300ed14b174 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -944,7 +944,7 @@ impl<'a> LookupContext<'a> { self.enforce_drop_trait_limitations(candidate); // static methods should never have gotten this far: - assert!(candidate.method_ty.explicit_self != SelfStatic); + fail_unless!(candidate.method_ty.explicit_self != SelfStatic); // Determine the values for the type parameters of the method. // If they were not explicitly supplied, just construct fresh diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 761a8b81a46ee..c54c965558208 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2384,7 +2384,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, if check_completeness && !error_happened { // Make sure the programmer specified all the fields. - assert!(fields_found <= field_types.len()); + fail_unless!(fields_found <= field_types.len()); if fields_found < field_types.len() { let mut missing_fields = ~[]; for class_field in field_types.iter() { @@ -3985,7 +3985,7 @@ pub fn check_intrinsic_type(ccx: @CrateCtxt, it: &ast::ForeignItem) { let name = token::get_ident(it.ident); let (n_tps, inputs, output) = if name.get().starts_with("atomic_") { let split : ~[&str] = name.get().split('_').collect(); - assert!(split.len() >= 2, "Atomic intrinsic not correct format"); + fail_unless!(split.len() >= 2, "Atomic intrinsic not correct format"); //We only care about the operation here match split[1] { diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 384007727780a..5831bfa3a0a63 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -631,7 +631,7 @@ fn check_expr_fn_block(rcx: &mut Rcx, // Identify the variable being closed over and its node-id. let def = freevar.def; let def_id = ast_util::def_id_of_def(def); - assert!(def_id.krate == ast::LOCAL_CRATE); + fail_unless!(def_id.krate == ast::LOCAL_CRATE); let upvar_id = ty::UpvarId { var_id: def_id.node, closure_expr_id: expr.id }; diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index ba4300b58a11a..ea7474b634811 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -239,7 +239,7 @@ fn lookup_vtable(vcx: &VtableContext, Some(ty) => ty, None => { // fixup_ty can only fail if this is early resolution - assert!(is_early); + fail_unless!(is_early); // The type has unconstrained type variables in it, so we can't // do early resolution on it. Return some completely bogus vtable // information: we aren't storing it anyways. @@ -436,7 +436,7 @@ fn search_for_vtable(vcx: &VtableContext, is_early) { Some(ref substs) => (*substs).clone(), None => { - assert!(is_early); + fail_unless!(is_early); // Bail out with a bogus answer return Some(vtable_param(param_self, 0)); } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index a9dffeb670fff..b78da2eeab6f1 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -662,7 +662,7 @@ impl CoherenceChecker { let associated_traits = get_impl_trait(tcx, implementation.did); // Do a sanity check. - assert!(associated_traits.is_some()); + fail_unless!(associated_traits.is_some()); // Record all the trait methods. for trait_ref in associated_traits.iter() { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index eff8680f27cbf..8b0d8e6da9b52 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -413,7 +413,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, // Supertraits are ensured at the same time. { let supertraits = tcx.supertraits.borrow(); - assert!(!supertraits.get().contains_key(&local_def(id))); + fail_unless!(!supertraits.get().contains_key(&local_def(id))); } let self_ty = ty::mk_self(ccx.tcx, local_def(id)); diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 4af6364642e8a..2bc3a2423c30f 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -171,7 +171,7 @@ impl<'f> Combine for Glb<'f> { b_vars: &[RegionVid], r0: ty::Region) -> ty::Region { if !is_var_in_set(new_vars, r0) { - assert!(!r0.is_bound()); + fail_unless!(!r0.is_bound()); return r0; } @@ -224,7 +224,7 @@ impl<'f> Combine for Glb<'f> { return rev_lookup(this, a_map, new_binder_id, a_r.unwrap()); } else if a_r.is_none() && b_r.is_none() { // Not related to bound variables from either fn: - assert!(!r0.is_bound()); + fail_unless!(!r0.is_bound()); return r0; } else { // Other: diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index dc6df33327693..267b6e9aba625 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -156,7 +156,7 @@ impl<'f> Combine for Lub<'f> { -> ty::Region { // Regions that pre-dated the LUB computation stay as they are. if !is_var_in_set(new_vars, r0) { - assert!(!r0.is_bound()); + fail_unless!(!r0.is_bound()); debug!("generalize_region(r0={:?}): not new variable", r0); return r0; } @@ -170,7 +170,7 @@ impl<'f> Combine for Lub<'f> { debug!("generalize_region(r0={:?}): \ non-new-variables found in {:?}", r0, tainted); - assert!(!r0.is_bound()); + fail_unless!(!r0.is_bound()); return r0; } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index abff3b683953d..6d75cf391fddd 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -554,7 +554,7 @@ impl InferCtxt { /// Execute `f` and commit the bindings if successful pub fn commit(&self, f: || -> Result) -> Result { - assert!(!self.in_snapshot()); + fail_unless!(!self.in_snapshot()); debug!("commit()"); indent(|| { diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index bbd9d8e1c4dcc..71a091440b6cf 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -248,7 +248,7 @@ impl RegionVarBindings { constraint: Constraint, origin: SubregionOrigin) { // cannot add constraints once regions are resolved - assert!(self.values_are_none()); + fail_unless!(self.values_are_none()); debug!("RegionVarBindings: add_constraint({:?})", constraint); @@ -268,7 +268,7 @@ impl RegionVarBindings { sub: Region, sup: Region) { // cannot add constraints once regions are resolved - assert!(self.values_are_none()); + fail_unless!(self.values_are_none()); debug!("RegionVarBindings: make_subregion({}, {}) due to {}", sub.repr(self.tcx), @@ -307,7 +307,7 @@ impl RegionVarBindings { b: Region) -> Region { // cannot add constraints once regions are resolved - assert!(self.values_are_none()); + fail_unless!(self.values_are_none()); debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b); match (a, b) { @@ -330,7 +330,7 @@ impl RegionVarBindings { b: Region) -> Region { // cannot add constraints once regions are resolved - assert!(self.values_are_none()); + fail_unless!(self.values_are_none()); debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b); match (a, b) { diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index fec6e357e5ac0..276340e6b72fb 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -126,9 +126,9 @@ impl<'a> ResolveState<'a> { // n.b. This is a hokey mess because the current fold doesn't // allow us to pass back errors in any useful way. - assert!(self.v_seen.is_empty()); + fail_unless!(self.v_seen.is_empty()); let rty = indent(|| self.resolve_type(typ) ); - assert!(self.v_seen.is_empty()); + fail_unless!(self.v_seen.is_empty()); match self.err { None => { debug!("Resolved to {} + {} (modes={:x})", diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 0a447a5f8e6fd..2cf212b2f49f7 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -105,7 +105,7 @@ impl Env { m: &ast::Mod, idx: uint, names: &[~str]) -> Option { - assert!(idx < names.len()); + fail_unless!(idx < names.len()); for item in m.items.iter() { if self.tcx.sess.str_of(item.ident) == names[idx] { return search(self, *item, idx+1, names); diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 4f2c8966c503e..9747476cac33c 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -223,7 +223,7 @@ pub struct CrateCtxt { // Functions that write types into the node type table pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::NodeId, ty: ty::t) { debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_str(tcx, ty)); - assert!(!ty::type_needs_infer(ty)); + fail_unless!(!ty::type_needs_infer(ty)); let mut node_types = tcx.node_types.borrow_mut(); node_types.get().insert(node_id as uint, ty); } @@ -233,7 +233,7 @@ pub fn write_substs_to_tcx(tcx: ty::ctxt, if substs.len() > 0u { debug!("write_substs_to_tcx({}, {:?})", node_id, substs.map(|t| ppaux::ty_to_str(tcx, *t))); - assert!(substs.iter().all(|t| !ty::type_needs_infer(*t))); + fail_unless!(substs.iter().all(|t| !ty::type_needs_infer(*t))); let mut node_type_substs = tcx.node_type_substs.borrow_mut(); node_type_substs.get().insert(node_id, substs); diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index b20312c2241c9..5db30f72b18b9 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -76,7 +76,7 @@ impl RegionScope for BindingRscope { pub fn bound_type_regions(defs: &[ty::RegionParameterDef]) -> OptVec { - assert!(defs.iter().all(|def| def.def_id.krate == ast::LOCAL_CRATE)); + fail_unless!(defs.iter().all(|def| def.def_id.krate == ast::LOCAL_CRATE)); defs.iter().enumerate().map( |(i, def)| ty::ReEarlyBound(def.def_id.node, i, def.ident)).collect() } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 57c7f6752a8c9..26c0f72a7bf92 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -310,7 +310,7 @@ impl<'a> TermsContext<'a> { param_id: param_id, term: term }); let newly_added = self.inferred_map.insert(param_id, inf_index); - assert!(newly_added); + fail_unless!(newly_added); debug!("add_inferred(item_id={}, \ kind={:?}, \ @@ -366,7 +366,7 @@ impl<'a> Visitor<()> for TermsContext<'a> { let newly_added = item_variance_map.get().insert( ast_util::local_def(item.id), self.empty_variances); - assert!(newly_added); + fail_unless!(newly_added); } visit::walk_item(self, item, ()); @@ -913,7 +913,7 @@ impl<'a> SolveContext<'a> { let info = &inferred_infos[index]; match info.kind { SelfParam => { - assert!(item_variances.self_param.is_none()); + fail_unless!(item_variances.self_param.is_none()); item_variances.self_param = Some(solutions[index]); } TypeParam => { @@ -942,7 +942,7 @@ impl<'a> SolveContext<'a> { let mut item_variance_map = tcx.item_variance_map.borrow_mut(); let newly_added = item_variance_map.get().insert(item_def_id, @item_variances); - assert!(newly_added); + fail_unless!(newly_added); } } diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index bd17f6b581483..704f2bb10fad2 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -23,7 +23,7 @@ use serialize::hex::ToHex; fn write_u32_be(dst: &mut[u8], input: u32) { use std::cast::transmute; use std::mem::to_be32; - assert!(dst.len() == 4); + fail_unless!(dst.len() == 4); unsafe { let x: *mut i32 = transmute(dst.unsafe_mut_ref(0)); *x = to_be32(input as i32); @@ -34,7 +34,7 @@ fn write_u32_be(dst: &mut[u8], input: u32) { fn read_u32v_be(dst: &mut[u32], input: &[u8]) { use std::cast::transmute; use std::mem::to_be32; - assert!(dst.len() * 4 == input.len()); + fail_unless!(dst.len() * 4 == input.len()); unsafe { let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0)); let mut y: *i32 = transmute(input.unsafe_ref(0)); @@ -171,7 +171,7 @@ impl FixedBuffer for FixedBuffer64 { } fn zero_until(&mut self, idx: uint) { - assert!(idx >= self.buffer_idx); + fail_unless!(idx >= self.buffer_idx); self.buffer.mut_slice(self.buffer_idx, idx).set_memory(0); self.buffer_idx = idx; } @@ -182,7 +182,7 @@ impl FixedBuffer for FixedBuffer64 { } fn full_buffer<'s>(&'s mut self) -> &'s [u8] { - assert!(self.buffer_idx == 64); + fail_unless!(self.buffer_idx == 64); self.buffer_idx = 0; return self.buffer.slice_to(64); } @@ -450,7 +450,7 @@ impl Engine256 { } fn input(&mut self, input: &[u8]) { - assert!(!self.finished) + fail_unless!(!self.finished) // Assumes that input.len() can be converted to u64 without overflow self.length_bits = add_bytes_to_bits(self.length_bits, input.len() as u64); let self_state = &mut self.state; @@ -534,7 +534,7 @@ mod tests { // A normal addition - no overflow occurs #[test] fn test_add_bytes_to_bits_ok() { - assert!(super::add_bytes_to_bits::(100, 10) == 180); + fail_unless!(super::add_bytes_to_bits::(100, 10) == 180); } // A simple failure case - adding 1 to the max value @@ -555,7 +555,7 @@ mod tests { sh.reset(); sh.input_str(t.input); let out_str = sh.result_str(); - assert!(out_str == t.output_str); + fail_unless!(out_str == t.output_str); } // Test that it works when accepting the message in pieces @@ -569,7 +569,7 @@ mod tests { left = left - take; } let out_str = sh.result_str(); - assert!(out_str == t.output_str); + fail_unless!(out_str == t.output_str); } } diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 4fc47d64e57e8..b8188e2a9a625 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -317,7 +317,7 @@ pub fn unindent(s: &str) -> ~str { if line.is_whitespace() { line } else { - assert!(line.len() >= min_indent); + fail_unless!(line.len() >= min_indent); line.slice_from(min_indent) } })); diff --git a/src/librustuv/access.rs b/src/librustuv/access.rs index 9d06593a6eafd..173ba44ba71fa 100644 --- a/src/librustuv/access.rs +++ b/src/librustuv/access.rs @@ -57,7 +57,7 @@ impl Access { inner.queue.push(task); Ok(()) }); - assert!(inner.held); + fail_unless!(inner.held); } else { inner.held = true; } @@ -77,7 +77,7 @@ impl<'a> Drop for Guard<'a> { fn drop(&mut self) { // This guard's homing missile is still armed, so we're guaranteed to be // on the same I/O event loop, so this unsafety should be ok. - assert!(self.missile.is_some()); + fail_unless!(self.missile.is_some()); let inner: &mut Inner = unsafe { cast::transmute(self.access.inner.get()) }; @@ -103,7 +103,7 @@ impl<'a> Drop for Guard<'a> { impl Drop for Inner { fn drop(&mut self) { - assert!(!self.held); + fail_unless!(!self.held); assert_eq!(self.queue.len(), 0); } } diff --git a/src/librustuv/addrinfo.rs b/src/librustuv/addrinfo.rs index 5d6af2969b8b3..3fcc0f718426e 100644 --- a/src/librustuv/addrinfo.rs +++ b/src/librustuv/addrinfo.rs @@ -34,7 +34,7 @@ pub struct GetAddrInfoRequest; impl GetAddrInfoRequest { pub fn run(loop_: &Loop, node: Option<&str>, service: Option<&str>, hints: Option) -> Result<~[ai::Info], UvError> { - assert!(node.is_some() || service.is_some()); + fail_unless!(node.is_some() || service.is_some()); let (_c_node, c_node_ptr) = match node { Some(n) => { let c_node = n.to_c_str(); @@ -103,7 +103,7 @@ impl GetAddrInfoRequest { status: c_int, res: *libc::addrinfo) { let req = Request::wrap(req); - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let cx: &mut Ctx = unsafe { req.get_data() }; cx.status = status; cx.addrinfo = Some(Addrinfo { handle: res }); diff --git a/src/librustuv/async.rs b/src/librustuv/async.rs index 5dc50beb85061..ff19c46582ed4 100644 --- a/src/librustuv/async.rs +++ b/src/librustuv/async.rs @@ -55,7 +55,7 @@ impl UvHandle for AsyncWatcher { } extern fn async_cb(handle: *uvll::uv_async_t, status: c_int) { - assert!(status == 0); + fail_unless!(status == 0); let payload: &mut Payload = unsafe { cast::transmute(uvll::get_data_for_uv_handle(handle)) }; diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index e66452041a531..b522c3d25be25 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -466,36 +466,36 @@ mod test { // open/create let result = FsRequest::open(local_loop(), &path_str.to_c_str(), create_flags as int, mode as int); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = result.unwrap(); let fd = result.fd; // write let result = FsRequest::write(l(), fd, "hello".as_bytes(), -1); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); } { // re-open let result = FsRequest::open(local_loop(), &path_str.to_c_str(), read_flags as int, 0); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = result.unwrap(); let fd = result.fd; // read let mut read_mem = vec::from_elem(1000, 0u8); let result = FsRequest::read(l(), fd, read_mem, 0); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let nread = result.unwrap(); - assert!(nread > 0); + fail_unless!(nread > 0); let read_str = str::from_utf8(read_mem.slice_to(nread as uint)).unwrap(); assert_eq!(read_str, "hello"); } // unlink let result = FsRequest::unlink(l(), &path_str.to_c_str()); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); } #[test] @@ -505,21 +505,21 @@ mod test { let mode = (S_IWUSR | S_IRUSR) as int; let result = FsRequest::open(local_loop(), path, create_flags, mode); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let file = result.unwrap(); let result = FsRequest::write(l(), file.fd, "hello".as_bytes(), 0); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = FsRequest::stat(l(), path); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); assert_eq!(result.unwrap().size, 5); fn free(_: T) {} free(file); let result = FsRequest::unlink(l(), path); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); } #[test] @@ -528,17 +528,17 @@ mod test { let mode = S_IWUSR | S_IRUSR; let result = FsRequest::mkdir(l(), path, mode); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = FsRequest::stat(l(), path); - assert!(result.is_ok()); - assert!(result.unwrap().kind == io::TypeDirectory); + fail_unless!(result.is_ok()); + fail_unless!(result.unwrap().kind == io::TypeDirectory); let result = FsRequest::rmdir(l(), path); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = FsRequest::stat(l(), path); - assert!(result.is_err()); + fail_unless!(result.is_err()); } #[test] @@ -547,19 +547,19 @@ mod test { let mode = S_IWUSR | S_IRUSR; let result = FsRequest::stat(l(), path); - assert!(result.is_err(), "{:?}", result); + fail_unless!(result.is_err(), "{:?}", result); let result = FsRequest::mkdir(l(), path, mode as c_int); - assert!(result.is_ok(), "{:?}", result); + fail_unless!(result.is_ok(), "{:?}", result); let result = FsRequest::mkdir(l(), path, mode as c_int); - assert!(result.is_err(), "{:?}", result); + fail_unless!(result.is_err(), "{:?}", result); let result = FsRequest::rmdir(l(), path); - assert!(result.is_ok(), "{:?}", result); + fail_unless!(result.is_ok(), "{:?}", result); } #[test] fn file_test_rmdir_chokes_on_nonexistant_path() { let path = &"./tmp/never_existed_dir".to_c_str(); let result = FsRequest::rmdir(l(), path); - assert!(result.is_err()); + fail_unless!(result.is_err()); } } diff --git a/src/librustuv/homing.rs b/src/librustuv/homing.rs index 25c929c995de7..92aba67647916 100644 --- a/src/librustuv/homing.rs +++ b/src/librustuv/homing.rs @@ -133,7 +133,7 @@ impl HomingMissile { /// Check at runtime that the task has *not* transplanted itself to a /// different I/O loop while executing. pub fn check(&self, msg: &'static str) { - assert!(local_id() == self.io_home, "{}", msg); + fail_unless!(local_id() == self.io_home, "{}", msg); } } diff --git a/src/librustuv/idle.rs b/src/librustuv/idle.rs index aae86b18512bf..dcdc82e505fc2 100644 --- a/src/librustuv/idle.rs +++ b/src/librustuv/idle.rs @@ -143,7 +143,7 @@ mod test { let mut slot = chan.borrow().borrow_mut(); match *slot.get() { (ref mut slot, _) => { - assert!(slot.is_none()); + fail_unless!(slot.is_none()); *slot = Some(task); } } diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index adbe4491886d4..4c381a67ae6d9 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -103,7 +103,7 @@ pub trait UvHandle { fn alloc(_: Option, ty: uvll::uv_handle_type) -> *T { unsafe { let handle = uvll::malloc_handle(ty); - assert!(!handle.is_null()); + fail_unless!(!handle.is_null()); handle as *T } } @@ -173,7 +173,7 @@ impl ForbidSwitch { impl Drop for ForbidSwitch { fn drop(&mut self) { - assert!(self.io == homing::local_id(), + fail_unless!(self.io == homing::local_id(), "didnt want a scheduler switch: {}", self.msg); } @@ -194,7 +194,7 @@ impl ForbidUnwind { impl Drop for ForbidUnwind { fn drop(&mut self) { - assert!(self.failing_before == task::failing(), + fail_unless!(self.failing_before == task::failing(), "didnt want an unwind during: {}", self.msg); } } @@ -204,7 +204,7 @@ fn wait_until_woken_after(slot: *mut Option, f: ||) { let _f = ForbidUnwind::new("wait_until_woken_after"); unsafe { - assert!((*slot).is_none()); + fail_unless!((*slot).is_none()); let task: ~Task = Local::take(); loop_.modify_blockers(1); task.deschedule(1, |task| { @@ -217,7 +217,7 @@ fn wait_until_woken_after(slot: *mut Option, } fn wakeup(slot: &mut Option) { - assert!(slot.is_some()); + fail_unless!(slot.is_some()); let _ = slot.take_unwrap().wake().map(|t| t.reawaken()); } @@ -245,7 +245,7 @@ impl Request { pub unsafe fn get_data(&self) -> &'static mut T { let data = uvll::get_data_for_req(self.handle); - assert!(data != null()); + fail_unless!(data != null()); cast::transmute(data) } @@ -280,7 +280,7 @@ pub struct Loop { impl Loop { pub fn new() -> Loop { let handle = unsafe { uvll::loop_new() }; - assert!(handle.is_not_null()); + fail_unless!(handle.is_not_null()); unsafe { uvll::set_data_for_uv_loop(handle, 0 as *c_void) } Loop::wrap(handle) } @@ -319,7 +319,7 @@ impl UvError { unsafe { let inner = match self { &UvError(a) => a }; let name_str = uvll::uv_err_name(inner); - assert!(name_str.is_not_null()); + fail_unless!(name_str.is_not_null()); from_c_str(name_str) } } @@ -328,7 +328,7 @@ impl UvError { unsafe { let inner = match self { &UvError(a) => a }; let desc_str = uvll::uv_strerror(inner); - assert!(desc_str.is_not_null()); + fail_unless!(desc_str.is_not_null()); from_c_str(desc_str) } } @@ -450,8 +450,8 @@ mod test { (*base.offset(1)) = 2; } - assert!(slice[0] == 1); - assert!(slice[1] == 2); + fail_unless!(slice[0] == 1); + fail_unless!(slice[1] == 2); } diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index a091829f297e8..b9856ef450981 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -39,7 +39,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, len: uint) -> ip::SocketAddr { match storage.ss_family as c_int { libc::AF_INET => { - assert!(len as uint >= mem::size_of::()); + fail_unless!(len as uint >= mem::size_of::()); let storage: &libc::sockaddr_in = unsafe { cast::transmute(storage) }; @@ -54,7 +54,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, } } libc::AF_INET6 => { - assert!(len as uint >= mem::size_of::()); + fail_unless!(len as uint >= mem::size_of::()); let storage: &libc::sockaddr_in6 = unsafe { cast::transmute(storage) }; @@ -229,7 +229,7 @@ impl TcpWatcher { extern fn connect_cb(req: *uvll::uv_connect_t, status: c_int) { let req = Request::wrap(req); - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let cx: &mut Ctx = unsafe { req.get_data() }; cx.status = status; wakeup(&mut cx.task); @@ -379,7 +379,7 @@ impl rtio::RtioTcpListener for TcpListener { } extern fn listen_cb(server: *uvll::uv_stream_t, status: c_int) { - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let tcp: &mut TcpListener = unsafe { UvHandle::from_uv_handle(&server) }; let msg = match status { 0 => { @@ -537,7 +537,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { extern fn recv_cb(handle: *uvll::uv_udp_t, nread: ssize_t, buf: *Buf, addr: *libc::sockaddr, _flags: c_uint) { - assert!(nread != uvll::ECANCELED as ssize_t); + fail_unless!(nread != uvll::ECANCELED as ssize_t); let cx: &mut Ctx = unsafe { cast::transmute(uvll::get_data_for_uv_handle(handle)) }; @@ -601,7 +601,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { extern fn send_cb(req: *uvll::uv_udp_send_t, status: c_int) { let req = Request::wrap(req); - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let cx: &mut Ctx = unsafe { req.get_data() }; cx.result = status; wakeup(&mut cx.task); @@ -889,7 +889,7 @@ mod test { let buf = [1, .. 2048]; let mut total_bytes_written = 0; while total_bytes_written < MAX { - assert!(stream.write(buf).is_ok()); + fail_unless!(stream.write(buf).is_ok()); uvdebug!("wrote bytes"); total_bytes_written += buf.len(); } @@ -919,8 +919,8 @@ mod test { spawn(proc() { let mut client = UdpWatcher::bind(local_loop(), client_addr).unwrap(); port.recv(); - assert!(client.sendto([1], server_addr).is_ok()); - assert!(client.sendto([2], server_addr).is_ok()); + fail_unless!(client.sendto([1], server_addr).is_ok()); + fail_unless!(client.sendto([2], server_addr).is_ok()); }); let mut server = UdpWatcher::bind(local_loop(), server_addr).unwrap(); @@ -960,16 +960,16 @@ mod test { let mut buf = [1]; while buf[0] == 1 { // send more data - assert!(server_out.sendto(msg, client_in_addr).is_ok()); + fail_unless!(server_out.sendto(msg, client_in_addr).is_ok()); total_bytes_sent += msg.len(); // check if the client has received enough let res = server_in.recvfrom(buf); - assert!(res.is_ok()); + fail_unless!(res.is_ok()); let (nread, src) = res.unwrap(); assert_eq!(nread, 1); assert_eq!(src, client_out_addr); } - assert!(total_bytes_sent >= MAX); + fail_unless!(total_bytes_sent >= MAX); }); let l = local_loop(); @@ -982,10 +982,10 @@ mod test { let mut buf = [0, .. 2048]; while total_bytes_recv < MAX { // ask for more - assert!(client_out.sendto([1], server_in_addr).is_ok()); + fail_unless!(client_out.sendto([1], server_in_addr).is_ok()); // wait for data let res = client_in.recvfrom(buf); - assert!(res.is_ok()); + fail_unless!(res.is_ok()); let (nread, src) = res.unwrap(); assert_eq!(src, server_out_addr); total_bytes_recv += nread; @@ -994,7 +994,7 @@ mod test { } } // tell the server we're done - assert!(client_out.sendto([0], server_in_addr).is_ok()); + fail_unless!(client_out.sendto([0], server_in_addr).is_ok()); } #[test] @@ -1037,7 +1037,7 @@ mod test { } // Make sure we had multiple reads - assert!(reads > 1); + fail_unless!(reads > 1); } #[test] diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs index 24ac17700cc27..37525c8317fca 100644 --- a/src/librustuv/pipe.rs +++ b/src/librustuv/pipe.rs @@ -59,7 +59,7 @@ impl PipeWatcher { pub fn new_home(loop_: &Loop, home: HomeHandle, ipc: bool) -> PipeWatcher { let handle = unsafe { let handle = uvll::malloc_handle(uvll::UV_NAMED_PIPE); - assert!(!handle.is_null()); + fail_unless!(!handle.is_null()); let ipc = ipc as libc::c_int; assert_eq!(uvll::uv_pipe_init(loop_.handle, handle, ipc), 0); handle @@ -109,7 +109,7 @@ impl PipeWatcher { extern fn connect_cb(req: *uvll::uv_connect_t, status: libc::c_int) {; let req = Request::wrap(req); - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let cx: &mut Ctx = unsafe { req.get_data() }; cx.result = status; wakeup(&mut cx.task); @@ -219,7 +219,7 @@ impl UvHandle for PipeListener { } extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) { - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); let pipe: &mut PipeListener = unsafe { UvHandle::from_uv_handle(&server) }; let msg = match status { @@ -307,15 +307,15 @@ mod tests { chan.send(()); let mut client = p.accept().unwrap(); let mut buf = [0]; - assert!(client.read(buf).unwrap() == 1); + fail_unless!(client.read(buf).unwrap() == 1); assert_eq!(buf[0], 1); - assert!(client.write([2]).is_ok()); + fail_unless!(client.write([2]).is_ok()); }); port.recv(); let mut c = PipeWatcher::connect(local_loop(), &path.to_c_str()).unwrap(); - assert!(c.write([1]).is_ok()); + fail_unless!(c.write([1]).is_ok()); let mut buf = [0]; - assert!(c.read(buf).unwrap() == 1); + fail_unless!(c.read(buf).unwrap() == 1); assert_eq!(buf[0], 2); } diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index a0623059bd716..7ec2ffe2de424 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -112,7 +112,7 @@ extern fn on_exit(handle: *uvll::uv_process_t, term_signal: libc::c_int) { let p: &mut Process = unsafe { UvHandle::from_uv_handle(&handle) }; - assert!(p.exit_status.is_none()); + fail_unless!(p.exit_status.is_none()); p.exit_status = Some(match term_signal { 0 => process::ExitStatus(exit_status as int), n => process::ExitSignal(n as int), @@ -222,7 +222,7 @@ impl RtioProcess for Process { // process's exit callback has yet to be invoked. We just // need to deschedule ourselves and wait to be reawoken. wait_until_woken_after(&mut self.to_wake, &self.uv_loop(), || {}); - assert!(self.exit_status.is_some()); + fail_unless!(self.exit_status.is_some()); } } @@ -233,7 +233,7 @@ impl RtioProcess for Process { impl Drop for Process { fn drop(&mut self) { let _m = self.fire_homing_missile(); - assert!(self.to_wake.is_none()); + fail_unless!(self.to_wake.is_none()); self.close(); } } diff --git a/src/librustuv/stream.rs b/src/librustuv/stream.rs index f7bf2f051eb90..e61dd249c7017 100644 --- a/src/librustuv/stream.rs +++ b/src/librustuv/stream.rs @@ -154,7 +154,7 @@ extern fn alloc_cb(stream: *uvll::uv_stream_t, _hint: size_t, buf: *mut Buf) { // return all the data read (even if it didn't fill the whole buffer). extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) { uvdebug!("read_cb {}", nread); - assert!(nread != uvll::ECANCELED as ssize_t); + fail_unless!(nread != uvll::ECANCELED as ssize_t); let rcx: &mut ReadContext = unsafe { cast::transmute(uvll::get_data_for_uv_handle(handle)) }; @@ -173,7 +173,7 @@ extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) { // away the error code as a result. extern fn write_cb(req: *uvll::uv_write_t, status: c_int) { let mut req = Request::wrap(req); - assert!(status != uvll::ECANCELED); + fail_unless!(status != uvll::ECANCELED); // Remember to not free the request because it is re-used between writes on // the same stream. let wcx: &mut WriteContext = unsafe { req.get_data() }; diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index c5ff5c60b80c9..baaf3d7bb7447 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -328,7 +328,7 @@ pub enum uv_membership { } pub unsafe fn malloc_handle(handle: uv_handle_type) -> *c_void { - assert!(handle != UV_UNKNOWN_HANDLE && handle != UV_HANDLE_TYPE_MAX); + fail_unless!(handle != UV_UNKNOWN_HANDLE && handle != UV_HANDLE_TYPE_MAX); let size = uv_handle_size(handle); malloc_raw(size as uint) as *c_void } @@ -338,7 +338,7 @@ pub unsafe fn free_handle(v: *c_void) { } pub unsafe fn malloc_req(req: uv_req_type) -> *c_void { - assert!(req != UV_UNKNOWN_REQ && req != UV_REQ_TYPE_MAX); + fail_unless!(req != UV_UNKNOWN_REQ && req != UV_REQ_TYPE_MAX); let size = uv_req_size(req); malloc_raw(size as uint) as *c_void } diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index d03d230d8bfd4..138bf1ac94b4e 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -288,63 +288,63 @@ fn test_parse() { assert_eq!(parse("a.b.c"), None); assert_eq!(parse("1.2.3 abc"), None); - assert!(parse("1.2.3") == Some(Version { + fail_unless!(parse("1.2.3") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[], })); - assert!(parse(" 1.2.3 ") == Some(Version { + fail_unless!(parse(" 1.2.3 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[], })); - assert!(parse("1.2.3-alpha1") == Some(Version { + fail_unless!(parse("1.2.3-alpha1") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[] })); - assert!(parse(" 1.2.3-alpha1 ") == Some(Version { + fail_unless!(parse(" 1.2.3-alpha1 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[] })); - assert!(parse("1.2.3+build5") == Some(Version { + fail_unless!(parse("1.2.3+build5") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[AlphaNumeric(~"build5")] })); - assert!(parse(" 1.2.3+build5 ") == Some(Version { + fail_unless!(parse(" 1.2.3+build5 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[], build: ~[AlphaNumeric(~"build5")] })); - assert!(parse("1.2.3-alpha1+build5") == Some(Version { + fail_unless!(parse("1.2.3-alpha1+build5") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[AlphaNumeric(~"build5")] })); - assert!(parse(" 1.2.3-alpha1+build5 ") == Some(Version { + fail_unless!(parse(" 1.2.3-alpha1+build5 ") == Some(Version { major: 1u, minor: 2u, patch: 3u, pre: ~[AlphaNumeric(~"alpha1")], build: ~[AlphaNumeric(~"build5")] })); - assert!(parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Some(Version { + fail_unless!(parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Some(Version { major: 1u, minor: 2u, patch: 3u, @@ -366,11 +366,11 @@ fn test_eq() { #[test] fn test_ne() { - assert!(parse("0.0.0") != parse("0.0.1")); - assert!(parse("0.0.0") != parse("0.1.0")); - assert!(parse("0.0.0") != parse("1.0.0")); - assert!(parse("1.2.3-alpha") != parse("1.2.3-beta")); - assert!(parse("1.2.3+23") != parse("1.2.3+42")); + fail_unless!(parse("0.0.0") != parse("0.0.1")); + fail_unless!(parse("0.0.0") != parse("0.1.0")); + fail_unless!(parse("0.0.0") != parse("1.0.0")); + fail_unless!(parse("1.2.3-alpha") != parse("1.2.3-beta")); + fail_unless!(parse("1.2.3+23") != parse("1.2.3+42")); } #[test] @@ -391,44 +391,44 @@ fn test_to_str() { #[test] fn test_lt() { - assert!(parse("0.0.0") < parse("1.2.3-alpha2")); - assert!(parse("1.0.0") < parse("1.2.3-alpha2")); - assert!(parse("1.2.0") < parse("1.2.3-alpha2")); - assert!(parse("1.2.3-alpha1") < parse("1.2.3")); - assert!(parse("1.2.3-alpha1") < parse("1.2.3-alpha2")); - assert!(!(parse("1.2.3-alpha2") < parse("1.2.3-alpha2"))); - assert!(!(parse("1.2.3+23") < parse("1.2.3+42"))); + fail_unless!(parse("0.0.0") < parse("1.2.3-alpha2")); + fail_unless!(parse("1.0.0") < parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.0") < parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.3-alpha1") < parse("1.2.3")); + fail_unless!(parse("1.2.3-alpha1") < parse("1.2.3-alpha2")); + fail_unless!(!(parse("1.2.3-alpha2") < parse("1.2.3-alpha2"))); + fail_unless!(!(parse("1.2.3+23") < parse("1.2.3+42"))); } #[test] fn test_le() { - assert!(parse("0.0.0") <= parse("1.2.3-alpha2")); - assert!(parse("1.0.0") <= parse("1.2.3-alpha2")); - assert!(parse("1.2.0") <= parse("1.2.3-alpha2")); - assert!(parse("1.2.3-alpha1") <= parse("1.2.3-alpha2")); - assert!(parse("1.2.3-alpha2") <= parse("1.2.3-alpha2")); - assert!(parse("1.2.3+23") <= parse("1.2.3+42")); + fail_unless!(parse("0.0.0") <= parse("1.2.3-alpha2")); + fail_unless!(parse("1.0.0") <= parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.0") <= parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.3-alpha1") <= parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.3-alpha2") <= parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.3+23") <= parse("1.2.3+42")); } #[test] fn test_gt() { - assert!(parse("1.2.3-alpha2") > parse("0.0.0")); - assert!(parse("1.2.3-alpha2") > parse("1.0.0")); - assert!(parse("1.2.3-alpha2") > parse("1.2.0")); - assert!(parse("1.2.3-alpha2") > parse("1.2.3-alpha1")); - assert!(parse("1.2.3") > parse("1.2.3-alpha2")); - assert!(!(parse("1.2.3-alpha2") > parse("1.2.3-alpha2"))); - assert!(!(parse("1.2.3+23") > parse("1.2.3+42"))); + fail_unless!(parse("1.2.3-alpha2") > parse("0.0.0")); + fail_unless!(parse("1.2.3-alpha2") > parse("1.0.0")); + fail_unless!(parse("1.2.3-alpha2") > parse("1.2.0")); + fail_unless!(parse("1.2.3-alpha2") > parse("1.2.3-alpha1")); + fail_unless!(parse("1.2.3") > parse("1.2.3-alpha2")); + fail_unless!(!(parse("1.2.3-alpha2") > parse("1.2.3-alpha2"))); + fail_unless!(!(parse("1.2.3+23") > parse("1.2.3+42"))); } #[test] fn test_ge() { - assert!(parse("1.2.3-alpha2") >= parse("0.0.0")); - assert!(parse("1.2.3-alpha2") >= parse("1.0.0")); - assert!(parse("1.2.3-alpha2") >= parse("1.2.0")); - assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha1")); - assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha2")); - assert!(parse("1.2.3+23") >= parse("1.2.3+42")); + fail_unless!(parse("1.2.3-alpha2") >= parse("0.0.0")); + fail_unless!(parse("1.2.3-alpha2") >= parse("1.0.0")); + fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.0")); + fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha1")); + fail_unless!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha2")); + fail_unless!(parse("1.2.3+23") >= parse("1.2.3+42")); } #[test] @@ -446,7 +446,7 @@ fn test_spec_order() { while i < vs.len() { let a = parse(vs[i-1]).unwrap(); let b = parse(vs[i]).unwrap(); - assert!(a < b); + fail_unless!(a < b); i += 1; } } diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 839450ce57cc3..6353204183389 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -278,7 +278,7 @@ mod tests { #[test] fn test_to_base64_line_break() { - assert!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD}) + fail_unless!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD}) .contains("\r\n")); assert_eq!("foobar".as_bytes().to_base64(Config {line_length: Some(4), ..STANDARD}), @@ -323,13 +323,13 @@ mod tests { #[test] fn test_from_base64_invalid_char() { - assert!("Zm$=".from_base64().is_err()) - assert!("Zg==$".from_base64().is_err()); + fail_unless!("Zm$=".from_base64().is_err()) + fail_unless!("Zg==$".from_base64().is_err()); } #[test] fn test_from_base64_invalid_padding() { - assert!("Z===".from_base64().is_err()); + fail_unless!("Z===".from_base64().is_err()); } #[test] diff --git a/src/libserialize/ebml.rs b/src/libserialize/ebml.rs index e65c21a6b5f86..316d14a93d11c 100644 --- a/src/libserialize/ebml.rs +++ b/src/libserialize/ebml.rs @@ -762,7 +762,7 @@ pub mod writer { impl<'a> Encoder<'a> { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) { - assert!(v <= 0xFFFF_FFFF_u); + fail_unless!(v <= 0xFFFF_FFFF_u); self.wr_tagged_u32(t as uint, v as u32); } diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 223a586a5a0dd..405fbad603b4f 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -158,13 +158,13 @@ mod tests { #[test] pub fn test_from_hex_odd_len() { - assert!("666".from_hex().is_err()); - assert!("66 6".from_hex().is_err()); + fail_unless!("666".from_hex().is_err()); + fail_unless!("66 6".from_hex().is_err()); } #[test] pub fn test_from_hex_invalid_char() { - assert!("66y6".from_hex().is_err()); + fail_unless!("66y6".from_hex().is_err()); } #[test] diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 3f14db14882ec..3ef7cf26a05c6 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -279,34 +279,34 @@ mod tests { fn any_referenced() { let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any); - assert!(a.is::()); - assert!(!b.is::()); - assert!(!c.is::()); + fail_unless!(a.is::()); + fail_unless!(!b.is::()); + fail_unless!(!c.is::()); - assert!(!a.is::<&'static str>()); - assert!(b.is::<&'static str>()); - assert!(!c.is::<&'static str>()); + fail_unless!(!a.is::<&'static str>()); + fail_unless!(b.is::<&'static str>()); + fail_unless!(!c.is::<&'static str>()); - assert!(!a.is::()); - assert!(!b.is::()); - assert!(c.is::()); + fail_unless!(!a.is::()); + fail_unless!(!b.is::()); + fail_unless!(c.is::()); } #[test] fn any_owning() { let (a, b, c) = (~5u as ~Any, ~TEST as ~Any, ~Test as ~Any); - assert!(a.is::()); - assert!(!b.is::()); - assert!(!c.is::()); + fail_unless!(a.is::()); + fail_unless!(!b.is::()); + fail_unless!(!c.is::()); - assert!(!a.is::<&'static str>()); - assert!(b.is::<&'static str>()); - assert!(!c.is::<&'static str>()); + fail_unless!(!a.is::<&'static str>()); + fail_unless!(b.is::<&'static str>()); + fail_unless!(!c.is::<&'static str>()); - assert!(!a.is::()); - assert!(!b.is::()); - assert!(c.is::()); + fail_unless!(!a.is::()); + fail_unless!(!b.is::()); + fail_unless!(c.is::()); } #[test] @@ -387,8 +387,8 @@ mod tests { let a = ~8u as ~Any; let b = ~Test as ~Any; - assert!(a.move::<~Test>().is_err()); - assert!(b.move::<~uint>().is_err()); + fail_unless!(a.move::<~Test>().is_err()); + fail_unless!(b.move::<~uint>().is_err()); } #[test] diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 651d364dd1b97..58e0a165159fe 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -146,7 +146,7 @@ pub trait AsciiCast { /// Convert to an ascii type, fail on non-ASCII input. #[inline] fn to_ascii(&self) -> T { - assert!(self.is_ascii()); + fail_unless!(self.is_ascii()); unsafe {self.to_ascii_nocheck()} } @@ -226,7 +226,7 @@ pub trait OwnedAsciiCast { /// Take ownership and cast to an ascii vector. Fail on non-ASCII input. #[inline] fn into_ascii(self) -> ~[Ascii] { - assert!(self.is_ascii()); + fail_unless!(self.is_ascii()); unsafe {self.into_ascii_nocheck()} } @@ -513,17 +513,17 @@ mod tests { assert_eq!('`'.to_ascii().to_upper().to_char(), '`'); assert_eq!('{'.to_ascii().to_upper().to_char(), '{'); - assert!('0'.to_ascii().is_digit()); - assert!('9'.to_ascii().is_digit()); - assert!(!'/'.to_ascii().is_digit()); - assert!(!':'.to_ascii().is_digit()); + fail_unless!('0'.to_ascii().is_digit()); + fail_unless!('9'.to_ascii().is_digit()); + fail_unless!(!'/'.to_ascii().is_digit()); + fail_unless!(!':'.to_ascii().is_digit()); - assert!((0x1fu8).to_ascii().is_control()); - assert!(!' '.to_ascii().is_control()); - assert!((0x7fu8).to_ascii().is_control()); + fail_unless!((0x1fu8).to_ascii().is_control()); + fail_unless!(!' '.to_ascii().is_control()); + fail_unless!((0x7fu8).to_ascii().is_control()); - assert!("banana".chars().all(|c| c.is_ascii())); - assert!(!"ประเทศไทย中华Việt Nam".chars().all(|c| c.is_ascii())); + fail_unless!("banana".chars().all(|c| c.is_ascii())); + fail_unless!(!"ประเทศไทย中华Việt Nam".chars().all(|c| c.is_ascii())); } #[test] @@ -543,11 +543,11 @@ mod tests { assert_eq!("YMCA".to_ascii().to_lower().into_str(), ~"ymca"); assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), ~"ABCDEFXYZ:.;"); - assert!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii())); + fail_unless!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii())); - assert!("".is_ascii()); - assert!("a".is_ascii()); - assert!(!"\u2009".is_ascii()); + fail_unless!("".is_ascii()); + fail_unless!("a".is_ascii()); + fail_unless!(!"\u2009".is_ascii()); } @@ -680,20 +680,20 @@ mod tests { #[test] fn test_eq_ignore_ascii_case() { - assert!("url()URL()uRl()Ürl".eq_ignore_ascii_case("url()url()url()Ürl")); - assert!(!"Ürl".eq_ignore_ascii_case("ürl")); + fail_unless!("url()URL()uRl()Ürl".eq_ignore_ascii_case("url()url()url()Ürl")); + fail_unless!(!"Ürl".eq_ignore_ascii_case("ürl")); // Dotted capital I, Kelvin sign, Sharp S. - assert!("HİKß".eq_ignore_ascii_case("hİKß")); - assert!(!"İ".eq_ignore_ascii_case("i")); - assert!(!"K".eq_ignore_ascii_case("k")); - assert!(!"ß".eq_ignore_ascii_case("s")); + fail_unless!("HİKß".eq_ignore_ascii_case("hİKß")); + fail_unless!(!"İ".eq_ignore_ascii_case("i")); + fail_unless!(!"K".eq_ignore_ascii_case("k")); + fail_unless!(!"ß".eq_ignore_ascii_case("s")); let mut i = 0; while i <= 500 { let c = i; let lower = if 'A' as u32 <= c && c <= 'Z' as u32 { c + 'a' as u32 - 'A' as u32 } else { c }; - assert!(from_char(from_u32(i).unwrap()). + fail_unless!(from_char(from_u32(i).unwrap()). eq_ignore_ascii_case(from_char(from_u32(lower).unwrap()))); i += 1; } diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index af745f94fb519..5cb0f0f3307d1 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -387,7 +387,7 @@ mod tests { #[test] fn test_bool_from_str() { all_values(|v| { - assert!(Some(v) == FromStr::from_str(v.to_str())) + fail_unless!(Some(v) == FromStr::from_str(v.to_str())) }); } @@ -408,21 +408,21 @@ mod tests { #[test] fn test_bool_ord() { - assert!(true > false); - assert!(!(false > true)); + fail_unless!(true > false); + fail_unless!(!(false > true)); - assert!(false < true); - assert!(!(true < false)); + fail_unless!(false < true); + fail_unless!(!(true < false)); - assert!(false <= false); - assert!(false >= false); - assert!(true <= true); - assert!(true >= true); + fail_unless!(false <= false); + fail_unless!(false >= false); + fail_unless!(true <= true); + fail_unless!(true >= true); - assert!(false <= true); - assert!(!(false >= true)); - assert!(true >= false); - assert!(!(true <= false)); + fail_unless!(false <= true); + fail_unless!(!(false >= true)); + fail_unless!(true >= false); + fail_unless!(!(true <= false)); } #[test] diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index e6b0958617e38..6589cfb6082e9 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -364,7 +364,7 @@ fn check_for_null(v: &[u8], buf: *mut libc::c_char) { for i in range(0, v.len()) { unsafe { let p = buf.offset(i as int); - assert!(*p != 0); + fail_unless!(*p != 0); } } } @@ -436,7 +436,7 @@ mod tests { assert_eq!(cbytes, it.next().unwrap().as_bytes()); }); assert_eq!(result, 2); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } } @@ -494,8 +494,8 @@ mod tests { #[test] fn test_is_null() { let c_str = unsafe { CString::new(ptr::null(), false) }; - assert!(c_str.is_null()); - assert!(!c_str.is_not_null()); + fail_unless!(c_str.is_null()); + fail_unless!(!c_str.is_not_null()); } #[test] @@ -508,8 +508,8 @@ mod tests { fn test_with_ref() { let c_str = "hello".to_c_str(); let len = unsafe { c_str.with_ref(|buf| libc::strlen(buf)) }; - assert!(!c_str.is_null()); - assert!(c_str.is_not_null()); + fail_unless!(!c_str.is_null()); + fail_unless!(c_str.is_not_null()); assert_eq!(len, 5); } @@ -539,7 +539,7 @@ mod tests { #[test] fn test_to_c_str_fail() { use task; - assert!(task::try(proc() { "he\x00llo".to_c_str() }).is_err()); + fail_unless!(task::try(proc() { "he\x00llo".to_c_str() }).is_err()); } #[test] @@ -627,7 +627,7 @@ mod tests { fn test_clone() { let a = "hello".to_c_str(); let b = a.clone(); - assert!(a == b); + fail_unless!(a == b); } #[test] @@ -658,7 +658,7 @@ mod tests { fn test_clone_eq_null() { let x = unsafe { CString::new(ptr::null(), false) }; let y = x.clone(); - assert!(x == y); + fail_unless!(x == y); } } diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index ffdd70a6c144a..07dc9693d2697 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -51,7 +51,7 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } * use std::cast; * * let v: &[u8] = unsafe { cast::transmute("L") }; - * assert!(v == [76u8]); + * fail_unless!(v == [76u8]); * ``` */ #[inline] @@ -128,8 +128,8 @@ mod tests { let ptr: *int = transmute(managed); // refcount 2 let _box1: @~str = ::cast::transmute_copy(&ptr); let _box2: @~str = ::cast::transmute_copy(&ptr); - assert!(*_box1 == ~"box box box"); - assert!(*_box2 == ~"box box box"); + fail_unless!(*_box1 == ~"box box box"); + fail_unless!(*_box2 == ~"box box box"); // Will destroy _box1 and _box2. Without the bump, this would // use-after-free. With too many bumps, it would leak. } @@ -140,7 +140,7 @@ mod tests { unsafe { let x = @100u8; let x: *raw::Box = transmute(x); - assert!((*x).data == 100); + fail_unless!((*x).data == 100); let _x: @int = transmute(x); } } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 0a3c87f405893..0ee5895df5a89 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -84,7 +84,7 @@ impl RefCell { /// Consumes the `RefCell`, returning the wrapped value. pub fn unwrap(self) -> T { - assert!(self.borrow == UNUSED); + fail_unless!(self.borrow == UNUSED); self.value } @@ -232,7 +232,7 @@ pub struct Ref<'b, T> { #[unsafe_destructor] impl<'b, T> Drop for Ref<'b, T> { fn drop(&mut self) { - assert!(self.parent.borrow != WRITING && self.parent.borrow != UNUSED); + fail_unless!(self.parent.borrow != WRITING && self.parent.borrow != UNUSED); unsafe { self.parent.as_mut().borrow -= 1; } } } @@ -253,7 +253,7 @@ pub struct RefMut<'b, T> { #[unsafe_destructor] impl<'b, T> Drop for RefMut<'b, T> { fn drop(&mut self) { - assert!(self.parent.borrow == WRITING); + fail_unless!(self.parent.borrow == WRITING); self.parent.borrow = UNUSED; } } @@ -292,21 +292,21 @@ mod test { fn no_mut_then_imm_borrow() { let x = RefCell::new(0); let _b1 = x.borrow_mut(); - assert!(x.try_borrow().is_none()); + fail_unless!(x.try_borrow().is_none()); } #[test] fn no_imm_then_borrow_mut() { let x = RefCell::new(0); let _b1 = x.borrow(); - assert!(x.try_borrow_mut().is_none()); + fail_unless!(x.try_borrow_mut().is_none()); } #[test] fn no_double_borrow_mut() { let x = RefCell::new(0); let _b1 = x.borrow_mut(); - assert!(x.try_borrow_mut().is_none()); + fail_unless!(x.try_borrow_mut().is_none()); } #[test] @@ -334,7 +334,7 @@ mod test { { let _b2 = x.borrow(); } - assert!(x.try_borrow_mut().is_none()); + fail_unless!(x.try_borrow_mut().is_none()); } #[test] diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 71a297d71765e..23ae516506180 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -450,31 +450,31 @@ impl Default for char { #[test] fn test_is_lowercase() { - assert!('a'.is_lowercase()); - assert!('ö'.is_lowercase()); - assert!('ß'.is_lowercase()); - assert!(!'Ü'.is_lowercase()); - assert!(!'P'.is_lowercase()); + fail_unless!('a'.is_lowercase()); + fail_unless!('ö'.is_lowercase()); + fail_unless!('ß'.is_lowercase()); + fail_unless!(!'Ü'.is_lowercase()); + fail_unless!(!'P'.is_lowercase()); } #[test] fn test_is_uppercase() { - assert!(!'h'.is_uppercase()); - assert!(!'ä'.is_uppercase()); - assert!(!'ß'.is_uppercase()); - assert!('Ö'.is_uppercase()); - assert!('T'.is_uppercase()); + fail_unless!(!'h'.is_uppercase()); + fail_unless!(!'ä'.is_uppercase()); + fail_unless!(!'ß'.is_uppercase()); + fail_unless!('Ö'.is_uppercase()); + fail_unless!('T'.is_uppercase()); } #[test] fn test_is_whitespace() { - assert!(' '.is_whitespace()); - assert!('\u2007'.is_whitespace()); - assert!('\t'.is_whitespace()); - assert!('\n'.is_whitespace()); - assert!(!'a'.is_whitespace()); - assert!(!'_'.is_whitespace()); - assert!(!'\u0000'.is_whitespace()); + fail_unless!(' '.is_whitespace()); + fail_unless!('\u2007'.is_whitespace()); + fail_unless!('\t'.is_whitespace()); + fail_unless!('\n'.is_whitespace()); + fail_unless!(!'a'.is_whitespace()); + fail_unless!(!'_'.is_whitespace()); + fail_unless!(!'\u0000'.is_whitespace()); } #[test] @@ -495,25 +495,25 @@ fn test_to_digit() { #[test] fn test_is_control() { - assert!('\u0000'.is_control()); - assert!('\u0003'.is_control()); - assert!('\u0006'.is_control()); - assert!('\u0009'.is_control()); - assert!('\u007f'.is_control()); - assert!('\u0092'.is_control()); - assert!(!'\u0020'.is_control()); - assert!(!'\u0055'.is_control()); - assert!(!'\u0068'.is_control()); + fail_unless!('\u0000'.is_control()); + fail_unless!('\u0003'.is_control()); + fail_unless!('\u0006'.is_control()); + fail_unless!('\u0009'.is_control()); + fail_unless!('\u007f'.is_control()); + fail_unless!('\u0092'.is_control()); + fail_unless!(!'\u0020'.is_control()); + fail_unless!(!'\u0055'.is_control()); + fail_unless!(!'\u0068'.is_control()); } #[test] fn test_is_digit() { - assert!('2'.is_digit()); - assert!('7'.is_digit()); - assert!(!'c'.is_digit()); - assert!(!'i'.is_digit()); - assert!(!'z'.is_digit()); - assert!(!'Q'.is_digit()); + fail_unless!('2'.is_digit()); + fail_unless!('7'.is_digit()); + fail_unless!(!'c'.is_digit()); + fail_unless!(!'i'.is_digit()); + fail_unless!(!'z'.is_digit()); + fail_unless!(!'Q'.is_digit()); } #[test] diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index de9f836ca5eb6..52b553c22b589 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -214,13 +214,13 @@ mod test { #[test] fn test_int_totaleq() { - assert!(5.equals(&5)); - assert!(!2.equals(&17)); + fail_unless!(5.equals(&5)); + fail_unless!(!2.equals(&17)); } #[test] fn test_ordering_order() { - assert!(Less < Equal); + fail_unless!(Less < Equal); assert_eq!(Greater.cmp(&Less), Greater); } diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 145bee50a2036..3b290c34c3499 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -75,7 +75,7 @@ //! //! for _ in range(0, 10) { //! let j = port.recv(); -//! assert!(0 <= j && j < 10); +//! fail_unless!(0 <= j && j < 10); //! } //! //! // The call to recv() will fail!() because the channel has already hung @@ -943,37 +943,37 @@ mod test { port.recv(); }); // What is our res? - assert!(res.is_err()); + fail_unless!(res.is_err()); }) test!(fn oneshot_single_thread_send_then_recv() { let (port, chan) = Chan::<~int>::new(); chan.send(~10); - assert!(port.recv() == ~10); + fail_unless!(port.recv() == ~10); }) test!(fn oneshot_single_thread_try_send_open() { let (port, chan) = Chan::::new(); - assert!(chan.try_send(10)); - assert!(port.recv() == 10); + fail_unless!(chan.try_send(10)); + fail_unless!(port.recv() == 10); }) test!(fn oneshot_single_thread_try_send_closed() { let (port, chan) = Chan::::new(); { let _p = port; } - assert!(!chan.try_send(10)); + fail_unless!(!chan.try_send(10)); }) test!(fn oneshot_single_thread_try_recv_open() { let (port, chan) = Chan::::new(); chan.send(10); - assert!(port.recv_opt() == Some(10)); + fail_unless!(port.recv_opt() == Some(10)); }) test!(fn oneshot_single_thread_try_recv_closed() { let (port, chan) = Chan::::new(); { let _c = chan; } - assert!(port.recv_opt() == None); + fail_unless!(port.recv_opt() == None); }) test!(fn oneshot_single_thread_peek_data() { @@ -998,7 +998,7 @@ mod test { test!(fn oneshot_multi_task_recv_then_send() { let (port, chan) = Chan::<~int>::new(); spawn(proc() { - assert!(port.recv() == ~10); + fail_unless!(port.recv() == ~10); }); chan.send(~10); @@ -1010,9 +1010,9 @@ mod test { let _chan = chan; }); let res = task::try(proc() { - assert!(port.recv() == ~10); + fail_unless!(port.recv() == ~10); }); - assert!(res.is_err()); + fail_unless!(res.is_err()); }) test!(fn oneshot_multi_thread_close_stress() { @@ -1045,7 +1045,7 @@ mod test { let res = task::try(proc() { port.recv(); }); - assert!(res.is_err()); + fail_unless!(res.is_err()); }); spawn(proc() { let chan = chan; @@ -1063,7 +1063,7 @@ mod test { chan.send(~10); }); spawn(proc() { - assert!(port.recv() == ~10); + fail_unless!(port.recv() == ~10); }); } }) @@ -1088,7 +1088,7 @@ mod test { if i == 10 { return } spawn(proc() { - assert!(port.recv() == ~i); + fail_unless!(port.recv() == ~i); recv(port, i + 1); }); } diff --git a/src/libstd/comm/oneshot.rs b/src/libstd/comm/oneshot.rs index 9deccfeb87566..7ab25b7f94308 100644 --- a/src/libstd/comm/oneshot.rs +++ b/src/libstd/comm/oneshot.rs @@ -96,7 +96,7 @@ impl Packet { NothingSent => {} _ => fail!("sending on a oneshot that's already sent on "), } - assert!(self.data.is_none()); + fail_unless!(self.data.is_none()); self.data = Some(t); self.upgrade = SendUsed; @@ -343,7 +343,7 @@ impl Packet { // requested, and if so, the other end needs to have its selection // aborted. DISCONNECTED => { - assert!(self.data.is_none()); + fail_unless!(self.data.is_none()); match mem::replace(&mut self.upgrade, SendUsed) { GoUp(port) => Err(port), _ => Ok(true), diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index 02066086ad773..d6cd478d45b78 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -184,7 +184,7 @@ impl Select { return (*p).id; } } - assert!(amt > 0); + fail_unless!(amt > 0); let mut ready_index = amt; let mut ready_id = uint::MAX; @@ -234,7 +234,7 @@ impl Select { } } - assert!(ready_id != uint::MAX); + fail_unless!(ready_id != uint::MAX); return ready_id; } } @@ -271,7 +271,7 @@ impl<'port, T: Send> Handle<'port, T> { selector.tail = me; } else { (*me).prev = selector.tail; - assert!((*me).next.is_null()); + fail_unless!((*me).next.is_null()); (*selector.tail).next = me; selector.tail = me; } @@ -310,8 +310,8 @@ impl<'port, T: Send> Handle<'port, T> { #[unsafe_destructor] impl Drop for Select { fn drop(&mut self) { - assert!(self.head.is_null()); - assert!(self.tail.is_null()); + fail_unless!(self.head.is_null()); + fail_unless!(self.tail.is_null()); } } @@ -458,8 +458,8 @@ mod test { for i in range(0, AMT) { select! ( - i1 = p1.recv() => { assert!(i % 2 == 0 && i == i1); }, - i2 = p2.recv() => { assert!(i % 2 == 1 && i == i2); } + i1 = p1.recv() => { fail_unless!(i % 2 == 0 && i == i1); }, + i2 = p2.recv() => { fail_unless!(i % 2 == 1 && i == i2); } ) c3.send(()); } diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs index 444f2d14dba20..a42e4b26d72ea 100644 --- a/src/libstd/comm/shared.rs +++ b/src/libstd/comm/shared.rs @@ -249,7 +249,7 @@ impl Packet { // If we factor in our steals and notice that the channel has no // data, we successfully sleep n => { - assert!(n >= 0); + fail_unless!(n >= 0); if n - steals <= 0 { return Ok(()) } } } @@ -316,7 +316,7 @@ impl Packet { self.bump(n - m); } } - assert!(self.steals >= 0); + fail_unless!(self.steals >= 0); } self.steals += 1; Ok(data) @@ -359,7 +359,7 @@ impl Packet { match self.cnt.swap(DISCONNECTED, atomics::SeqCst) { -1 => { self.take_to_wake().wake().map(|t| t.reawaken()); } DISCONNECTED => {} - n => { assert!(n >= 0); } + n => { fail_unless!(n >= 0); } } } @@ -388,7 +388,7 @@ impl Packet { fn take_to_wake(&mut self) -> BlockedTask { let task = self.to_wake.load(atomics::SeqCst); self.to_wake.store(0, atomics::SeqCst); - assert!(task != 0); + fail_unless!(task != 0); unsafe { BlockedTask::cast_from_uint(task) } } @@ -428,7 +428,7 @@ impl Packet { Ok(()) => Ok(()), Err(task) => { let prev = self.bump(1); - assert!(prev == DISCONNECTED || prev >= 0); + fail_unless!(prev == DISCONNECTED || prev >= 0); return Err(task); } } @@ -465,7 +465,7 @@ impl Packet { true } else { let cur = prev + steals + 1; - assert!(cur >= 0); + fail_unless!(cur >= 0); if prev < 0 { self.take_to_wake().trash(); } else { @@ -476,7 +476,7 @@ impl Packet { // if the number of steals is -1, it was the pre-emptive -1 steal // count from when we inherited a blocker. This is fine because // we're just going to overwrite it with a real value. - assert!(self.steals == 0 || self.steals == -1); + fail_unless!(self.steals == 0 || self.steals == -1); self.steals = steals; prev >= 0 } diff --git a/src/libstd/comm/stream.rs b/src/libstd/comm/stream.rs index 4eac22b813dbe..d279fcb18c84a 100644 --- a/src/libstd/comm/stream.rs +++ b/src/libstd/comm/stream.rs @@ -124,7 +124,7 @@ impl Packet { self.cnt.store(DISCONNECTED, atomics::SeqCst); let first = self.queue.pop(); let second = self.queue.pop(); - assert!(second.is_none()); + fail_unless!(second.is_none()); match first { Some(..) => UpSuccess, // we failed to send the data @@ -134,7 +134,7 @@ impl Packet { // Otherwise we just sent some data on a non-waiting queue, so just // make sure the world is sane and carry on! - n => { assert!(n >= 0); UpSuccess } + n => { fail_unless!(n >= 0); UpSuccess } } } @@ -142,7 +142,7 @@ impl Packet { fn take_to_wake(&mut self) -> BlockedTask { let task = self.to_wake.load(atomics::SeqCst); self.to_wake.store(0, atomics::SeqCst); - assert!(task != 0); + fail_unless!(task != 0); unsafe { BlockedTask::cast_from_uint(task) } } @@ -162,7 +162,7 @@ impl Packet { // If we factor in our steals and notice that the channel has no // data, we successfully sleep n => { - assert!(n >= 0); + fail_unless!(n >= 0); if n - steals <= 0 { return Ok(()) } } } @@ -224,7 +224,7 @@ impl Packet { self.bump(n - m); } } - assert!(self.steals >= 0); + fail_unless!(self.steals >= 0); } self.steals += 1; match data { @@ -266,7 +266,7 @@ impl Packet { match self.cnt.swap(DISCONNECTED, atomics::SeqCst) { -1 => { self.take_to_wake().wake().map(|t| t.reawaken()); } DISCONNECTED => {} - n => { assert!(n >= 0); } + n => { fail_unless!(n >= 0); } } } @@ -376,7 +376,7 @@ impl Packet { // Undo our decrement above, and we should be guaranteed that the // previous value is positive because we're not going to sleep let prev = self.bump(1); - assert!(prev == DISCONNECTED || prev >= 0); + fail_unless!(prev == DISCONNECTED || prev >= 0); return ret; } } @@ -417,7 +417,7 @@ impl Packet { true // there is data, that data is that we're disconnected } else { let cur = prev + steals + 1; - assert!(cur >= 0); + fail_unless!(cur >= 0); // If the previous count was negative, then we just made things go // positive, hence we passed the -1 boundary and we're responsible diff --git a/src/libstd/fmt/num.rs b/src/libstd/fmt/num.rs index 681d0678ed495..47d2cc6342040 100644 --- a/src/libstd/fmt/num.rs +++ b/src/libstd/fmt/num.rs @@ -113,7 +113,7 @@ pub struct Radix { impl Radix { fn new(base: u8) -> Radix { - assert!(2 <= base && base <= 36, "the base must be in the range of 0..36: {}", base); + fail_unless!(2 <= base && base <= 36, "the base must be in the range of 0..36: {}", base); Radix { base: base } } } diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 555fe29bed004..3fc13a9721e6a 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -674,7 +674,7 @@ mod tests { fn musterr(s: &str) { let mut p = Parser::new(s); p.next(); - assert!(p.errors.len() != 0); + fail_unless!(p.errors.len() != 0); } #[test] diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index fa7c94ac9948a..5171cf931fd09 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -133,9 +133,9 @@ mod tests { let x = Gc::new(5); let y = x.clone(); let z = Gc::new(7); - assert!(x.ptr_eq(&x)); - assert!(x.ptr_eq(&y)); - assert!(!x.ptr_eq(&z)); + fail_unless!(x.ptr_eq(&x)); + fail_unless!(x.ptr_eq(&y)); + fail_unless!(!x.ptr_eq(&z)); } #[test] diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index 432e27257f355..f8fc3ad8b31c4 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -409,7 +409,7 @@ mod tests { let v = to_hex_str(&vecs[t]); debug!("{}: ({}) => inc={} full={}", t, v, i, f); - assert!(f == i && f == v); + fail_unless!(f == i && f == v); buf.push(t as u8); stream_inc.input([t as u8]); @@ -421,19 +421,19 @@ mod tests { #[test] #[cfg(target_arch = "arm")] fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert!((val as u64).hash() != (val as uint).hash()); + fail_unless!((val as u64).hash() != (val as uint).hash()); assert_eq!((val as u32).hash(), (val as uint).hash()); } #[test] #[cfg(target_arch = "x86_64")] fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; assert_eq!((val as u64).hash(), (val as uint).hash()); - assert!((val as u32).hash() != (val as uint).hash()); + fail_unless!((val as u32).hash() != (val as uint).hash()); } #[test] #[cfg(target_arch = "x86")] fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert!((val as u64).hash() != (val as uint).hash()); + fail_unless!((val as u64).hash() != (val as uint).hash()); assert_eq!((val as u32).hash(), (val as uint).hash()); } @@ -449,17 +449,17 @@ mod tests { fn test_hash_no_bytes_dropped_64() { let val = 0xdeadbeef_deadbeef_u64; - assert!(val.hash() != zero_byte(val, 0).hash()); - assert!(val.hash() != zero_byte(val, 1).hash()); - assert!(val.hash() != zero_byte(val, 2).hash()); - assert!(val.hash() != zero_byte(val, 3).hash()); - assert!(val.hash() != zero_byte(val, 4).hash()); - assert!(val.hash() != zero_byte(val, 5).hash()); - assert!(val.hash() != zero_byte(val, 6).hash()); - assert!(val.hash() != zero_byte(val, 7).hash()); + fail_unless!(val.hash() != zero_byte(val, 0).hash()); + fail_unless!(val.hash() != zero_byte(val, 1).hash()); + fail_unless!(val.hash() != zero_byte(val, 2).hash()); + fail_unless!(val.hash() != zero_byte(val, 3).hash()); + fail_unless!(val.hash() != zero_byte(val, 4).hash()); + fail_unless!(val.hash() != zero_byte(val, 5).hash()); + fail_unless!(val.hash() != zero_byte(val, 6).hash()); + fail_unless!(val.hash() != zero_byte(val, 7).hash()); fn zero_byte(val: u64, byte: uint) -> u64 { - assert!(byte < 8); + fail_unless!(byte < 8); val & !(0xff << (byte * 8)) } } @@ -468,21 +468,21 @@ mod tests { fn test_hash_no_bytes_dropped_32() { let val = 0xdeadbeef_u32; - assert!(val.hash() != zero_byte(val, 0).hash()); - assert!(val.hash() != zero_byte(val, 1).hash()); - assert!(val.hash() != zero_byte(val, 2).hash()); - assert!(val.hash() != zero_byte(val, 3).hash()); + fail_unless!(val.hash() != zero_byte(val, 0).hash()); + fail_unless!(val.hash() != zero_byte(val, 1).hash()); + fail_unless!(val.hash() != zero_byte(val, 2).hash()); + fail_unless!(val.hash() != zero_byte(val, 3).hash()); fn zero_byte(val: u32, byte: uint) -> u32 { - assert!(byte < 4); + fail_unless!(byte < 4); val & !(0xff << (byte * 8)) } } #[test] fn test_float_hashes_differ() { - assert!(0.0.hash() != 1.0.hash()); - assert!(1.0.hash() != (-1.0).hash()); + fail_unless!(0.0.hash() != 1.0.hash()); + fail_unless!(1.0.hash() != (-1.0).hash()); } #[test] @@ -499,8 +499,8 @@ mod tests { let v = (&[1u8], &[0u8, 0], &[0u8]); let w = (&[1u8, 0, 0, 0], &[], &[]); - assert!(v != w); - assert!(s.hash() != t.hash() && s.hash() != u.hash()); - assert!(v.hash() != w.hash()); + fail_unless!(v != w); + fail_unless!(s.hash() != t.hash() && s.hash() != u.hash()); + fail_unless!(v.hash() != w.hash()); } } diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 5d4db10672844..992df8df63af0 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -929,14 +929,14 @@ mod test_map { #[test] fn test_create_capacity_zero() { let mut m = HashMap::with_capacity(0); - assert!(m.insert(1, 1)); + fail_unless!(m.insert(1, 1)); } #[test] fn test_insert() { let mut m = HashMap::new(); - assert!(m.insert(1, 2)); - assert!(m.insert(2, 4)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(2, 4)); assert_eq!(*m.get(&1), 2); assert_eq!(*m.get(&2), 4); } @@ -944,9 +944,9 @@ mod test_map { #[test] fn test_find_mut() { let mut m = HashMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + fail_unless!(m.insert(1, 12)); + fail_unless!(m.insert(2, 8)); + fail_unless!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -957,18 +957,18 @@ mod test_map { #[test] fn test_insert_overwrite() { let mut m = HashMap::new(); - assert!(m.insert(1, 2)); + fail_unless!(m.insert(1, 2)); assert_eq!(*m.get(&1), 2); - assert!(!m.insert(1, 3)); + fail_unless!(!m.insert(1, 3)); assert_eq!(*m.get(&1), 3); } #[test] fn test_insert_conflicts() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); - assert!(m.insert(5, 3)); - assert!(m.insert(9, 4)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 4)); assert_eq!(*m.get(&9), 4); assert_eq!(*m.get(&5), 3); assert_eq!(*m.get(&1), 2); @@ -977,10 +977,10 @@ mod test_map { #[test] fn test_conflict_remove() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); - assert!(m.insert(5, 3)); - assert!(m.insert(9, 4)); - assert!(m.remove(&1)); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 4)); + fail_unless!(m.remove(&1)); assert_eq!(*m.get(&9), 4); assert_eq!(*m.get(&5), 3); } @@ -988,10 +988,10 @@ mod test_map { #[test] fn test_is_empty() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); - assert!(!m.is_empty()); - assert!(m.remove(&1)); - assert!(m.is_empty()); + fail_unless!(m.insert(1, 2)); + fail_unless!(!m.is_empty()); + fail_unless!(m.remove(&1)); + fail_unless!(m.is_empty()); } #[test] @@ -1043,14 +1043,14 @@ mod test_map { }; let v = hm.move_iter().collect::<~[(char, int)]>(); - assert!([('a', 1), ('b', 2)] == v || [('b', 2), ('a', 1)] == v); + fail_unless!([('a', 1), ('b', 2)] == v || [('b', 2), ('a', 1)] == v); } #[test] fn test_iterate() { let mut m = HashMap::with_capacity(4); for i in range(0u, 32) { - assert!(m.insert(i, i*2)); + fail_unless!(m.insert(i, i*2)); } let mut observed = 0; for (k, v) in m.iter() { @@ -1066,9 +1066,9 @@ mod test_map { let map = vec.move_iter().collect::>(); let keys = map.keys().map(|&k| k).collect::<~[int]>(); assert_eq!(keys.len(), 3); - assert!(keys.contains(&1)); - assert!(keys.contains(&2)); - assert!(keys.contains(&3)); + fail_unless!(keys.contains(&1)); + fail_unless!(keys.contains(&2)); + fail_unless!(keys.contains(&3)); } #[test] @@ -1077,19 +1077,19 @@ mod test_map { let map = vec.move_iter().collect::>(); let values = map.values().map(|&v| v).collect::<~[char]>(); assert_eq!(values.len(), 3); - assert!(values.contains(&'a')); - assert!(values.contains(&'b')); - assert!(values.contains(&'c')); + fail_unless!(values.contains(&'a')); + fail_unless!(values.contains(&'b')); + fail_unless!(values.contains(&'c')); } #[test] fn test_find() { let mut m = HashMap::new(); - assert!(m.find(&1).is_none()); + fail_unless!(m.find(&1).is_none()); m.insert(1, 2); match m.find(&1) { None => fail!(), - Some(v) => assert!(*v == 2) + Some(v) => fail_unless!(*v == 2) } } @@ -1104,7 +1104,7 @@ mod test_map { m2.insert(1, 2); m2.insert(2, 3); - assert!(m1 != m2); + fail_unless!(m1 != m2); m2.insert(3, 4); @@ -1116,7 +1116,7 @@ mod test_map { let mut m = HashMap::new(); assert_eq!(m.len(), 0); - assert!(m.is_empty()); + fail_unless!(m.is_empty()); let mut i = 0u; let old_resize_at = m.resize_at; @@ -1126,7 +1126,7 @@ mod test_map { } assert_eq!(m.len(), i); - assert!(!m.is_empty()); + fail_unless!(!m.is_empty()); } #[test] @@ -1177,7 +1177,7 @@ mod test_map { let table_str = format!("{}", table); - assert!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); + fail_unless!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); assert_eq!(format!("{}", empty), ~"{}"); } } @@ -1193,58 +1193,58 @@ mod test_set { fn test_disjoint() { let mut xs = HashSet::new(); let mut ys = HashSet::new(); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(5)); - assert!(ys.insert(11)); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(7)); - assert!(xs.insert(19)); - assert!(xs.insert(4)); - assert!(ys.insert(2)); - assert!(ys.insert(-11)); - assert!(xs.is_disjoint(&ys)); - assert!(ys.is_disjoint(&xs)); - assert!(ys.insert(7)); - assert!(!xs.is_disjoint(&ys)); - assert!(!ys.is_disjoint(&xs)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(xs.insert(5)); + fail_unless!(ys.insert(11)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(xs.insert(7)); + fail_unless!(xs.insert(19)); + fail_unless!(xs.insert(4)); + fail_unless!(ys.insert(2)); + fail_unless!(ys.insert(-11)); + fail_unless!(xs.is_disjoint(&ys)); + fail_unless!(ys.is_disjoint(&xs)); + fail_unless!(ys.insert(7)); + fail_unless!(!xs.is_disjoint(&ys)); + fail_unless!(!ys.is_disjoint(&xs)); } #[test] fn test_subset_and_superset() { let mut a = HashSet::new(); - assert!(a.insert(0)); - assert!(a.insert(5)); - assert!(a.insert(11)); - assert!(a.insert(7)); + fail_unless!(a.insert(0)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(7)); let mut b = HashSet::new(); - assert!(b.insert(0)); - assert!(b.insert(7)); - assert!(b.insert(19)); - assert!(b.insert(250)); - assert!(b.insert(11)); - assert!(b.insert(200)); + fail_unless!(b.insert(0)); + fail_unless!(b.insert(7)); + fail_unless!(b.insert(19)); + fail_unless!(b.insert(250)); + fail_unless!(b.insert(11)); + fail_unless!(b.insert(200)); - assert!(!a.is_subset(&b)); - assert!(!a.is_superset(&b)); - assert!(!b.is_subset(&a)); - assert!(!b.is_superset(&a)); + fail_unless!(!a.is_subset(&b)); + fail_unless!(!a.is_superset(&b)); + fail_unless!(!b.is_subset(&a)); + fail_unless!(!b.is_superset(&a)); - assert!(b.insert(5)); + fail_unless!(b.insert(5)); - assert!(a.is_subset(&b)); - assert!(!a.is_superset(&b)); - assert!(!b.is_subset(&a)); - assert!(b.is_superset(&a)); + fail_unless!(a.is_subset(&b)); + fail_unless!(!a.is_superset(&b)); + fail_unless!(!b.is_subset(&a)); + fail_unless!(b.is_superset(&a)); } #[test] fn test_iterate() { let mut a = HashSet::new(); for i in range(0u, 32) { - assert!(a.insert(i)); + fail_unless!(a.insert(i)); } let mut observed = 0; for k in a.iter() { @@ -1258,26 +1258,26 @@ mod test_set { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(11)); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(77)); - assert!(a.insert(103)); - assert!(a.insert(5)); - assert!(a.insert(-5)); - - assert!(b.insert(2)); - assert!(b.insert(11)); - assert!(b.insert(77)); - assert!(b.insert(-9)); - assert!(b.insert(-42)); - assert!(b.insert(5)); - assert!(b.insert(3)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(77)); + fail_unless!(a.insert(103)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(-5)); + + fail_unless!(b.insert(2)); + fail_unless!(b.insert(11)); + fail_unless!(b.insert(77)); + fail_unless!(b.insert(-9)); + fail_unless!(b.insert(-42)); + fail_unless!(b.insert(5)); + fail_unless!(b.insert(3)); let mut i = 0; let expected = [3, 5, 11, 77]; for x in a.intersection(&b) { - assert!(expected.contains(x)); + fail_unless!(expected.contains(x)); i += 1 } assert_eq!(i, expected.len()); @@ -1288,19 +1288,19 @@ mod test_set { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(9)); - assert!(a.insert(11)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(9)); + fail_unless!(a.insert(11)); - assert!(b.insert(3)); - assert!(b.insert(9)); + fail_unless!(b.insert(3)); + fail_unless!(b.insert(9)); let mut i = 0; let expected = [1, 5, 11]; for x in a.difference(&b) { - assert!(expected.contains(x)); + fail_unless!(expected.contains(x)); i += 1 } assert_eq!(i, expected.len()); @@ -1311,22 +1311,22 @@ mod test_set { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(9)); - assert!(a.insert(11)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(9)); + fail_unless!(a.insert(11)); - assert!(b.insert(-2)); - assert!(b.insert(3)); - assert!(b.insert(9)); - assert!(b.insert(14)); - assert!(b.insert(22)); + fail_unless!(b.insert(-2)); + fail_unless!(b.insert(3)); + fail_unless!(b.insert(9)); + fail_unless!(b.insert(14)); + fail_unless!(b.insert(22)); let mut i = 0; let expected = [-2, 1, 5, 11, 14, 22]; for x in a.symmetric_difference(&b) { - assert!(expected.contains(x)); + fail_unless!(expected.contains(x)); i += 1 } assert_eq!(i, expected.len()); @@ -1337,26 +1337,26 @@ mod test_set { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); - assert!(a.insert(3)); - assert!(a.insert(5)); - assert!(a.insert(9)); - assert!(a.insert(11)); - assert!(a.insert(16)); - assert!(a.insert(19)); - assert!(a.insert(24)); - - assert!(b.insert(-2)); - assert!(b.insert(1)); - assert!(b.insert(5)); - assert!(b.insert(9)); - assert!(b.insert(13)); - assert!(b.insert(19)); + fail_unless!(a.insert(1)); + fail_unless!(a.insert(3)); + fail_unless!(a.insert(5)); + fail_unless!(a.insert(9)); + fail_unless!(a.insert(11)); + fail_unless!(a.insert(16)); + fail_unless!(a.insert(19)); + fail_unless!(a.insert(24)); + + fail_unless!(b.insert(-2)); + fail_unless!(b.insert(1)); + fail_unless!(b.insert(5)); + fail_unless!(b.insert(9)); + fail_unless!(b.insert(13)); + fail_unless!(b.insert(19)); let mut i = 0; let expected = [-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]; for x in a.union(&b) { - assert!(expected.contains(x)); + fail_unless!(expected.contains(x)); i += 1 } assert_eq!(i, expected.len()); @@ -1369,7 +1369,7 @@ mod test_set { let set: HashSet = xs.iter().map(|&x| x).collect(); for x in xs.iter() { - assert!(set.contains(x)); + fail_unless!(set.contains(x)); } } @@ -1385,7 +1385,7 @@ mod test_set { }; let v = hs.move_iter().collect::<~[char]>(); - assert!(['a', 'b'] == v || ['b', 'a'] == v); + fail_unless!(['a', 'b'] == v || ['b', 'a'] == v); } #[test] @@ -1399,7 +1399,7 @@ mod test_set { s2.insert(1); s2.insert(2); - assert!(s1 != s2); + fail_unless!(s1 != s2); s2.insert(3); @@ -1416,7 +1416,7 @@ mod test_set { let set_str = format!("{}", set); - assert!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); + fail_unless!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); assert_eq!(format!("{}", empty), ~"{}"); } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index df2a800c2920d..8b6cf959cd80d 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -96,7 +96,7 @@ impl Buffer for BufferedReader { fn consume(&mut self, amt: uint) { self.pos += amt; - assert!(self.pos <= self.cap); + fail_unless!(self.pos <= self.cap); } } @@ -407,7 +407,7 @@ mod test { assert_eq!(Ok(1), nread); assert_eq!([4, 0, 0], buf); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); } #[test] @@ -475,7 +475,7 @@ mod test { let mut stream = BufferedStream::new(S); let mut buf = []; - assert!(stream.read(buf).is_err()); + fail_unless!(stream.read(buf).is_err()); stream.write(buf).unwrap(); stream.flush().unwrap(); } @@ -488,7 +488,7 @@ mod test { assert_eq!(reader.read_until(2), Ok(~[1, 2])); assert_eq!(reader.read_until(1), Ok(~[1])); assert_eq!(reader.read_until(8), Ok(~[0])); - assert!(reader.read_until(9).is_err()); + fail_unless!(reader.read_until(9).is_err()); } #[test] @@ -518,7 +518,7 @@ mod test { assert_eq!(reader.read_line(), Ok(~"a\n")); assert_eq!(reader.read_line(), Ok(~"b\n")); assert_eq!(reader.read_line(), Ok(~"c")); - assert!(reader.read_line().is_err()); + fail_unless!(reader.read_line().is_err()); } #[test] @@ -543,7 +543,7 @@ mod test { assert_eq!(reader.read(buf), Ok(0)); assert_eq!(reader.read(buf), Ok(1)); assert_eq!(reader.read(buf), Ok(0)); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); } #[test] diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index ee366e96f23c5..8e6e488f832b1 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -56,7 +56,7 @@ pub fn u64_to_le_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { use cast::transmute; // LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics - assert!(size <= 8u); + fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), 2u => f(unsafe { transmute::(to_le16(n as i16)) }), @@ -82,7 +82,7 @@ pub fn u64_to_be_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { use cast::transmute; // LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics - assert!(size <= 8u); + fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), 2u => f(unsafe { transmute::(to_be16(n as i16)) }), @@ -109,7 +109,7 @@ pub fn u64_from_be_bytes(data: &[u8], use mem::from_be64; use vec::MutableVector; - assert!(size <= 8u); + fail_unless!(size <= 8u); if data.len() - start < size { fail!("index out of bounds"); @@ -223,7 +223,7 @@ mod test { fn read_byte() { let mut reader = MemReader::new(~[10]); let byte = reader.read_byte(); - assert!(byte == Ok(10)); + fail_unless!(byte == Ok(10)); } #[test] @@ -232,21 +232,21 @@ mod test { count: 0, }; let byte = reader.read_byte(); - assert!(byte == Ok(10)); + fail_unless!(byte == Ok(10)); } #[test] fn read_byte_eof() { let mut reader = EofReader; let byte = reader.read_byte(); - assert!(byte.is_err()); + fail_unless!(byte.is_err()); } #[test] fn read_byte_error() { let mut reader = ErroringReader; let byte = reader.read_byte(); - assert!(byte.is_err()); + fail_unless!(byte.is_err()); } #[test] @@ -255,14 +255,14 @@ mod test { count: 0, }; let byte = reader.bytes().next(); - assert!(byte == Some(10)); + fail_unless!(byte == Some(10)); } #[test] fn bytes_eof() { let mut reader = EofReader; let byte = reader.bytes().next(); - assert!(byte.is_none()); + fail_unless!(byte.is_none()); } #[test] @@ -270,14 +270,14 @@ mod test { let mut reader = ErroringReader; let mut it = reader.bytes(); let byte = it.next(); - assert!(byte.is_none()); + fail_unless!(byte.is_none()); } #[test] fn read_bytes() { let mut reader = MemReader::new(~[10, 11, 12, 13]); let bytes = reader.read_bytes(4).unwrap(); - assert!(bytes == ~[10, 11, 12, 13]); + fail_unless!(bytes == ~[10, 11, 12, 13]); } #[test] @@ -286,13 +286,13 @@ mod test { count: 0, }; let bytes = reader.read_bytes(4).unwrap(); - assert!(bytes == ~[10, 11, 12, 13]); + fail_unless!(bytes == ~[10, 11, 12, 13]); } #[test] fn read_bytes_eof() { let mut reader = MemReader::new(~[10, 11]); - assert!(reader.read_bytes(4).is_err()); + fail_unless!(reader.read_bytes(4).is_err()); } #[test] @@ -300,7 +300,7 @@ mod test { let mut reader = MemReader::new(~[10, 11, 12, 13]); let mut buf = ~[8, 9]; reader.push_bytes(&mut buf, 4).unwrap(); - assert!(buf == ~[8, 9, 10, 11, 12, 13]); + fail_unless!(buf == ~[8, 9, 10, 11, 12, 13]); } #[test] @@ -310,15 +310,15 @@ mod test { }; let mut buf = ~[8, 9]; reader.push_bytes(&mut buf, 4).unwrap(); - assert!(buf == ~[8, 9, 10, 11, 12, 13]); + fail_unless!(buf == ~[8, 9, 10, 11, 12, 13]); } #[test] fn push_bytes_eof() { let mut reader = MemReader::new(~[10, 11]); let mut buf = ~[8, 9]; - assert!(reader.push_bytes(&mut buf, 4).is_err()); - assert!(buf == ~[8, 9, 10, 11]); + fail_unless!(reader.push_bytes(&mut buf, 4).is_err()); + fail_unless!(buf == ~[8, 9, 10, 11]); } #[test] @@ -327,8 +327,8 @@ mod test { count: 0, }; let mut buf = ~[8, 9]; - assert!(reader.push_bytes(&mut buf, 4).is_err()); - assert!(buf == ~[8, 9, 10]); + fail_unless!(reader.push_bytes(&mut buf, 4).is_err()); + fail_unless!(buf == ~[8, 9, 10]); } #[test] @@ -337,7 +337,7 @@ mod test { count: 0, }; let buf = reader.read_to_end().unwrap(); - assert!(buf == ~[10, 11, 12, 13]); + fail_unless!(buf == ~[10, 11, 12, 13]); } #[test] @@ -347,7 +347,7 @@ mod test { count: 0, }; let buf = reader.read_to_end().unwrap(); - assert!(buf == ~[10, 11]); + fail_unless!(buf == ~[10, 11]); } #[test] @@ -361,7 +361,7 @@ mod test { let mut reader = MemReader::new(writer.unwrap()); for i in uints.iter() { - assert!(reader.read_le_u64().unwrap() == *i); + fail_unless!(reader.read_le_u64().unwrap() == *i); } } @@ -377,7 +377,7 @@ mod test { let mut reader = MemReader::new(writer.unwrap()); for i in uints.iter() { - assert!(reader.read_be_u64().unwrap() == *i); + fail_unless!(reader.read_be_u64().unwrap() == *i); } } @@ -394,7 +394,7 @@ mod test { for i in ints.iter() { // this tests that the sign extension is working // (comparing the values as i32 would not test this) - assert!(reader.read_be_int_n(4).unwrap() == *i as i64); + fail_unless!(reader.read_be_int_n(4).unwrap() == *i as i64); } } @@ -408,7 +408,7 @@ mod test { let mut reader = MemReader::new(writer.unwrap()); let f = reader.read_be_f32().unwrap(); - assert!(f == 8.1250); + fail_unless!(f == 8.1250); } #[test] @@ -420,8 +420,8 @@ mod test { writer.write_le_f32(f).unwrap(); let mut reader = MemReader::new(writer.unwrap()); - assert!(reader.read_be_f32().unwrap() == 8.1250); - assert!(reader.read_le_f32().unwrap() == 8.1250); + fail_unless!(reader.read_be_f32().unwrap() == 8.1250); + fail_unless!(reader.read_le_f32().unwrap() == 8.1250); } #[test] diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 7f2af92b07812..471c868303868 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -718,13 +718,13 @@ mod test { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_that_does_not_exist.txt"); let result = File::open_mode(filename, Open, Read); - assert!(result.is_err()); + fail_unless!(result.is_err()); }) iotest!(fn file_test_iounlinking_invalid_path_should_raise_condition() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_another_file_that_does_not_exist.txt"); - assert!(unlink(filename).is_err()); + fail_unless!(unlink(filename).is_err()); }) iotest!(fn file_test_io_non_positional_read() { @@ -798,7 +798,7 @@ mod test { } unlink(filename).unwrap(); let read_str = str::from_utf8(read_mem).unwrap(); - assert!(read_str == final_msg.to_owned()); + fail_unless!(read_str == final_msg.to_owned()); }) iotest!(fn file_test_io_seek_shakedown() { @@ -850,7 +850,7 @@ mod test { let filename = &tmpdir.join("file_stat_correct_on_is_dir"); mkdir(filename, io::UserRWX).unwrap(); let stat_res = filename.stat().unwrap(); - assert!(stat_res.kind == io::TypeDirectory); + fail_unless!(stat_res.kind == io::TypeDirectory); rmdir(filename).unwrap(); }) @@ -858,7 +858,7 @@ mod test { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); mkdir(dir, io::UserRWX).unwrap(); - assert!(dir.is_file() == false); + fail_unless!(dir.is_file() == false); rmdir(dir).unwrap(); }) @@ -866,20 +866,20 @@ mod test { let tmpdir = tmpdir(); let file = &tmpdir.join("fileinfo_check_exists_b_and_a.txt"); File::create(file).write(bytes!("foo")).unwrap(); - assert!(file.exists()); + fail_unless!(file.exists()); unlink(file).unwrap(); - assert!(!file.exists()); + fail_unless!(!file.exists()); }) iotest!(fn file_test_directoryinfo_check_exists_before_and_after_mkdir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); - assert!(!dir.exists()); + fail_unless!(!dir.exists()); mkdir(dir, io::UserRWX).unwrap(); - assert!(dir.exists()); - assert!(dir.is_dir()); + fail_unless!(dir.exists()); + fail_unless!(dir.is_dir()); rmdir(dir).unwrap(); - assert!(!dir.exists()); + fail_unless!(!dir.exists()); }) iotest!(fn file_test_directoryinfo_readdir() { @@ -918,33 +918,33 @@ mod test { }) iotest!(fn unicode_path_is_dir() { - assert!(Path::new(".").is_dir()); - assert!(!Path::new("test/stdtest/fs.rs").is_dir()); + fail_unless!(Path::new(".").is_dir()); + fail_unless!(!Path::new("test/stdtest/fs.rs").is_dir()); let tmpdir = tmpdir(); let mut dirpath = tmpdir.path().clone(); dirpath.push(format!("test-가一ー你好")); mkdir(&dirpath, io::UserRWX).unwrap(); - assert!(dirpath.is_dir()); + fail_unless!(dirpath.is_dir()); let mut filepath = dirpath; filepath.push("unicode-file-\uac00\u4e00\u30fc\u4f60\u597d.rs"); File::create(&filepath).unwrap(); // ignore return; touch only - assert!(!filepath.is_dir()); - assert!(filepath.exists()); + fail_unless!(!filepath.is_dir()); + fail_unless!(filepath.exists()); }) iotest!(fn unicode_path_exists() { - assert!(Path::new(".").exists()); - assert!(!Path::new("test/nonexistent-bogus-path").exists()); + fail_unless!(Path::new(".").exists()); + fail_unless!(!Path::new("test/nonexistent-bogus-path").exists()); let tmpdir = tmpdir(); let unicode = tmpdir.path(); let unicode = unicode.join(format!("test-각丁ー再见")); mkdir(&unicode, io::UserRWX).unwrap(); - assert!(unicode.exists()); - assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); + fail_unless!(unicode.exists()); + fail_unless!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); }) iotest!(fn copy_file_does_not_exist() { @@ -953,8 +953,8 @@ mod test { match copy(&from, &to) { Ok(..) => fail!(), Err(..) => { - assert!(!from.exists()); - assert!(!to.exists()); + fail_unless!(!from.exists()); + fail_unless!(!to.exists()); } } }) @@ -1002,7 +1002,7 @@ mod test { match copy(tmpdir.path(), &out) { Ok(..) => fail!(), Err(..) => {} } - assert!(!out.exists()); + fail_unless!(!out.exists()); }) iotest!(fn copy_file_preserves_perm_bits() { @@ -1013,7 +1013,7 @@ mod test { File::create(&input).unwrap(); chmod(&input, io::UserRead).unwrap(); copy(&input, &out).unwrap(); - assert!(out.stat().unwrap().perm & io::UserWrite == 0); + fail_unless!(out.stat().unwrap().perm & io::UserWrite == 0); chmod(&input, io::UserFile).unwrap(); chmod(&out, io::UserFile).unwrap(); @@ -1040,7 +1040,7 @@ mod test { let tmpdir = tmpdir(); // symlinks can point to things that don't exist symlink(&tmpdir.join("foo"), &tmpdir.join("bar")).unwrap(); - assert!(readlink(&tmpdir.join("bar")).unwrap() == tmpdir.join("foo")); + fail_unless!(readlink(&tmpdir.join("bar")).unwrap() == tmpdir.join("foo")); }) iotest!(fn readlink_not_symlink() { @@ -1083,9 +1083,9 @@ mod test { let file = tmpdir.join("in.txt"); File::create(&file).unwrap(); - assert!(stat(&file).unwrap().perm & io::UserWrite == io::UserWrite); + fail_unless!(stat(&file).unwrap().perm & io::UserWrite == io::UserWrite); chmod(&file, io::UserRead).unwrap(); - assert!(stat(&file).unwrap().perm & io::UserWrite == 0); + fail_unless!(stat(&file).unwrap().perm & io::UserWrite == 0); match chmod(&tmpdir.join("foo"), io::UserRWX) { Ok(..) => fail!("wanted a failure"), diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 49c37b4520f4e..1ce98bb597266 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -174,7 +174,7 @@ impl Reader for MemReader { vec::bytes::copy_memory(output, input); } self.pos += write_len; - assert!(self.pos <= self.buf.len()); + fail_unless!(self.pos <= self.buf.len()); return Ok(write_len); } @@ -304,7 +304,7 @@ impl<'a> Reader for BufReader<'a> { vec::bytes::copy_memory(output, input); } self.pos += write_len; - assert!(self.pos <= self.buf.len()); + fail_unless!(self.pos <= self.buf.len()); return Ok(write_len); } @@ -437,11 +437,11 @@ mod test { assert_eq!(buf, [1, 2, 3, 4]); assert_eq!(reader.read(buf), Ok(3)); assert_eq!(buf.slice(0, 3), [5, 6, 7]); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]); assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); } #[test] @@ -461,11 +461,11 @@ mod test { assert_eq!(buf, [1, 2, 3, 4]); assert_eq!(reader.read(buf), Ok(3)); assert_eq!(buf.slice(0, 3), [5, 6, 7]); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); let mut reader = BufReader::new(in_buf); assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); - assert!(reader.read(buf).is_err()); + fail_unless!(reader.read(buf).is_err()); } #[test] @@ -476,14 +476,14 @@ mod test { assert_eq!(r.read_char(), Ok('i')); assert_eq!(r.read_char(), Ok('ệ')); assert_eq!(r.read_char(), Ok('t')); - assert!(r.read_char().is_err()); + fail_unless!(r.read_char().is_err()); } #[test] fn test_read_bad_char() { let b = bytes!(0x80); let mut r = BufReader::new(b); - assert!(r.read_char().is_err()); + fail_unless!(r.read_char().is_err()); } #[test] @@ -521,36 +521,36 @@ mod test { let buf = [0xff]; let mut r = BufReader::new(buf); r.seek(10, SeekSet).unwrap(); - assert!(r.read(&mut []).is_err()); + fail_unless!(r.read(&mut []).is_err()); let mut r = MemReader::new(~[10]); r.seek(10, SeekSet).unwrap(); - assert!(r.read(&mut []).is_err()); + fail_unless!(r.read(&mut []).is_err()); let mut r = MemWriter::new(); r.seek(10, SeekSet).unwrap(); - assert!(r.write([3]).is_ok()); + fail_unless!(r.write([3]).is_ok()); let mut buf = [0]; let mut r = BufWriter::new(buf); r.seek(10, SeekSet).unwrap(); - assert!(r.write([3]).is_err()); + fail_unless!(r.write([3]).is_err()); } #[test] fn seek_before_0() { let buf = [0xff]; let mut r = BufReader::new(buf); - assert!(r.seek(-1, SeekSet).is_err()); + fail_unless!(r.seek(-1, SeekSet).is_err()); let mut r = MemReader::new(~[10]); - assert!(r.seek(-1, SeekSet).is_err()); + fail_unless!(r.seek(-1, SeekSet).is_err()); let mut r = MemWriter::new(); - assert!(r.seek(-1, SeekSet).is_err()); + fail_unless!(r.seek(-1, SeekSet).is_err()); let mut buf = [0]; let mut r = BufWriter::new(buf); - assert!(r.seek(-1, SeekSet).is_err()); + fail_unless!(r.seek(-1, SeekSet).is_err()); } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index f09dc3da9bfe9..bfcc4efea376e 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -575,7 +575,7 @@ pub trait Reader { /// /// `n` must be between 1 and 8, inclusive. fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult { - assert!(nbytes > 0 && nbytes <= 8); + fail_unless!(nbytes > 0 && nbytes <= 8); let mut val = 0u64; let mut pos = 0; @@ -599,7 +599,7 @@ pub trait Reader { /// /// `n` must be between 1 and 8, inclusive. fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult { - assert!(nbytes > 0 && nbytes <= 8); + fail_unless!(nbytes > 0 && nbytes <= 8); let mut val = 0u64; let mut i = nbytes; diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index e9ffe97f1c356..bf6a5e21fb3fb 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -102,7 +102,7 @@ mod test { for addr in ipaddrs.iter() { found_local = found_local || addr == local_addr; } - assert!(found_local); + fail_unless!(found_local); }) iotest!(fn issue_10663() { diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index f042661117ea3..ef91ae191a552 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -224,7 +224,7 @@ impl<'a> Parser<'a> { fn read_ipv6_addr_impl(&mut self) -> Option { fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr { - assert!(head.len() + tail.len() <= 8); + fail_unless!(head.len() + tail.len() <= 8); let mut gs = [0u16, ..8]; gs.copy_from(head); gs.mut_slice(8 - tail.len(), 8).copy_from(tail); @@ -439,7 +439,7 @@ mod test { #[test] fn ipv6_addr_to_str() { let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280); - assert!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128"); + fail_unless!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128"); assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), ~"8:9:a:b:c:d:e:f"); } diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 53129f3df9b6f..976762166976a 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -208,7 +208,7 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == 99); + fail_unless!(buf[0] == 99); }) iotest!(fn smoke_test_ip6() { @@ -226,7 +226,7 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == 99); + fail_unless!(buf[0] == 99); }) iotest!(fn read_eof_ip4() { @@ -244,7 +244,7 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; let nread = stream.read(buf); - assert!(nread.is_err()); + fail_unless!(nread.is_err()); }) iotest!(fn read_eof_ip6() { @@ -262,7 +262,7 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; let nread = stream.read(buf); - assert!(nread.is_err()); + fail_unless!(nread.is_err()); }) iotest!(fn read_eof_twice_ip4() { @@ -280,12 +280,12 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; let nread = stream.read(buf); - assert!(nread.is_err()); + fail_unless!(nread.is_err()); match stream.read(buf) { Ok(..) => fail!(), Err(ref e) => { - assert!(e.kind == NotConnected || e.kind == EndOfFile, + fail_unless!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {:?}", e.kind); } } @@ -306,12 +306,12 @@ mod test { let mut stream = acceptor.accept(); let mut buf = [0]; let nread = stream.read(buf); - assert!(nread.is_err()); + fail_unless!(nread.is_err()); match stream.read(buf) { Ok(..) => fail!(), Err(ref e) => { - assert!(e.kind == NotConnected || e.kind == EndOfFile, + fail_unless!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {:?}", e.kind); } } @@ -335,7 +335,7 @@ mod test { match stream.write(buf) { Ok(..) => {} Err(e) => { - assert!(e.kind == ConnectionReset || + fail_unless!(e.kind == ConnectionReset || e.kind == BrokenPipe || e.kind == ConnectionAborted, "unknown error: {:?}", e); @@ -363,7 +363,7 @@ mod test { match stream.write(buf) { Ok(..) => {} Err(e) => { - assert!(e.kind == ConnectionReset || + fail_unless!(e.kind == ConnectionReset || e.kind == BrokenPipe || e.kind == ConnectionAborted, "unknown error: {:?}", e); @@ -431,7 +431,7 @@ mod test { let mut stream = stream; let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == i as u8); + fail_unless!(buf[0] == i as u8); debug!("read"); }); } @@ -468,7 +468,7 @@ mod test { let mut stream = stream; let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == i as u8); + fail_unless!(buf[0] == i as u8); debug!("read"); }); } @@ -505,7 +505,7 @@ mod test { let mut stream = stream; let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == 99); + fail_unless!(buf[0] == 99); debug!("read"); }); } @@ -542,7 +542,7 @@ mod test { let mut stream = stream; let mut buf = [0]; stream.read(buf).unwrap(); - assert!(buf[0] == 99); + fail_unless!(buf[0] == 99); debug!("read"); }); } @@ -571,7 +571,7 @@ mod test { // Make sure socket_name gives // us the socket we binded to. let so_name = listener.socket_name(); - assert!(so_name.is_ok()); + fail_unless!(so_name.is_ok()); assert_eq!(addr, so_name.unwrap()); } @@ -587,14 +587,14 @@ mod test { port.recv(); let stream = TcpStream::connect(addr); - assert!(stream.is_ok()); + fail_unless!(stream.is_ok()); let mut stream = stream.unwrap(); // Make sure peer_name gives us the // address/port of the peer we've // connected to. let peer_name = stream.peer_name(); - assert!(peer_name.is_ok()); + fail_unless!(peer_name.is_ok()); assert_eq!(addr, peer_name.unwrap()); } @@ -633,11 +633,11 @@ mod test { iotest!(fn double_bind() { let addr = next_test_ip4(); let listener = TcpListener::bind(addr).unwrap().listen(); - assert!(listener.is_ok()); + fail_unless!(listener.is_ok()); match TcpListener::bind(addr).listen() { Ok(..) => fail!(), Err(e) => { - assert!(e.kind == ConnectionRefused || e.kind == OtherIoError); + fail_unless!(e.kind == ConnectionRefused || e.kind == OtherIoError); } } }) diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index f779d80976f6b..8899c7a973c59 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -248,13 +248,13 @@ mod test { pub fn socket_name(addr: SocketAddr) { let server = UdpSocket::bind(addr); - assert!(server.is_ok()); + fail_unless!(server.is_ok()); let mut server = server.unwrap(); // Make sure socket_name gives // us the socket we binded to. let so_name = server.socket_name(); - assert!(so_name.is_ok()); + fail_unless!(so_name.is_ok()); assert_eq!(addr, so_name.unwrap()); } diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index a1f3cbbe32643..7ada3044c69a0 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -154,7 +154,7 @@ mod tests { match UnixListener::bind(&path) { Ok(..) => fail!(), Err(e) => { - assert!(e.kind == PermissionDenied || e.kind == FileNotFound || + fail_unless!(e.kind == PermissionDenied || e.kind == FileNotFound || e.kind == InvalidInput); } } @@ -169,7 +169,7 @@ mod tests { match UnixStream::connect(&path) { Ok(..) => fail!(), Err(e) => { - assert!(e.kind == FileNotFound || e.kind == OtherIoError); + fail_unless!(e.kind == FileNotFound || e.kind == OtherIoError); } } }) @@ -178,7 +178,7 @@ mod tests { smalltest(proc(mut server) { let mut buf = [0]; server.read(buf).unwrap(); - assert!(buf[0] == 99); + fail_unless!(buf[0] == 99); }, proc(mut client) { client.write([99]).unwrap(); }) @@ -187,8 +187,8 @@ mod tests { iotest!(fn read_eof() { smalltest(proc(mut server) { let mut buf = [0]; - assert!(server.read(buf).is_err()); - assert!(server.read(buf).is_err()); + fail_unless!(server.read(buf).is_err()); + fail_unless!(server.read(buf).is_err()); }, proc(_client) { // drop the client }) @@ -201,7 +201,7 @@ mod tests { match server.write(buf) { Ok(..) => {} Err(e) => { - assert!(e.kind == BrokenPipe || + fail_unless!(e.kind == BrokenPipe || e.kind == NotConnected || e.kind == ConnectionReset, "unknown error {:?}", e); @@ -251,7 +251,7 @@ mod tests { iotest!(fn path_exists() { let path = next_test_unix(); let _acceptor = UnixListener::bind(&path).listen(); - assert!(path.exists()); + fail_unless!(path.exists()); }) iotest!(fn unix_clone_smoke() { diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 6540fcd85d3fd..87d6c75860ae4 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -225,9 +225,9 @@ mod tests { .. ProcessConfig::new() }; let p = Process::new(args); - assert!(p.is_ok()); + fail_unless!(p.is_ok()); let mut p = p.unwrap(); - assert!(p.wait().success()); + fail_unless!(p.wait().success()); }) // FIXME(#10380) @@ -252,9 +252,9 @@ mod tests { .. ProcessConfig::new() }; let p = Process::new(args); - assert!(p.is_ok()); + fail_unless!(p.is_ok()); let mut p = p.unwrap(); - assert!(p.wait().matches_exit_status(1)); + fail_unless!(p.wait().matches_exit_status(1)); }) #[cfg(unix, not(target_os="android"))] @@ -265,7 +265,7 @@ mod tests { .. ProcessConfig::new() }; let p = Process::new(args); - assert!(p.is_ok()); + fail_unless!(p.is_ok()); let mut p = p.unwrap(); match p.wait() { process::ExitSignal(1) => {}, @@ -279,12 +279,12 @@ mod tests { pub fn run_output(args: ProcessConfig) -> ~str { let p = Process::new(args); - assert!(p.is_ok()); + fail_unless!(p.is_ok()); let mut p = p.unwrap(); - assert!(p.io[0].is_none()); - assert!(p.io[1].is_some()); + fail_unless!(p.io[0].is_none()); + fail_unless!(p.io[1].is_some()); let ret = read_all(p.io[1].get_mut_ref() as &mut Reader); - assert!(p.wait().success()); + fail_unless!(p.wait().success()); return ret; } @@ -331,7 +331,7 @@ mod tests { p.io[0].get_mut_ref().write("foobar".as_bytes()).unwrap(); p.io[0] = None; // close stdin; let out = read_all(p.io[1].get_mut_ref() as &mut Reader); - assert!(p.wait().success()); + fail_unless!(p.wait().success()); assert_eq!(out, ~"foobar\n"); }) @@ -345,7 +345,7 @@ mod tests { .. ProcessConfig::new() }; let mut p = Process::new(args).unwrap(); - assert!(p.wait().success()); + fail_unless!(p.wait().success()); }) #[cfg(windows)] @@ -355,7 +355,7 @@ mod tests { uid: Some(10), .. ProcessConfig::new() }; - assert!(Process::new(args).is_err()); + fail_unless!(Process::new(args).is_err()); }) // FIXME(#10380) @@ -370,7 +370,7 @@ mod tests { .. ProcessConfig::new() }; let mut p = Process::new(args).unwrap(); - assert!(p.wait().success()); + fail_unless!(p.wait().success()); }) // FIXME(#10380) @@ -387,6 +387,6 @@ mod tests { gid: Some(0), .. ProcessConfig::new() }; - assert!(Process::new(args).is_err()); + fail_unless!(Process::new(args).is_err()); }) } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 2cc0c67ff6aba..c2d1f56823849 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -372,6 +372,6 @@ mod tests { fail!("my special message"); }); let s = r.read_to_str().unwrap(); - assert!(s.contains("my special message")); + fail_unless!(s.contains("my special message")); }) } diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 692aaa7afd05e..fb6862484e62a 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -150,11 +150,11 @@ mod test { let port = timer.oneshot(1); port.recv(); - assert!(port.recv_opt().is_none()); + fail_unless!(port.recv_opt().is_none()); let port = timer.oneshot(1); port.recv(); - assert!(port.recv_opt().is_none()); + fail_unless!(port.recv_opt().is_none()); }) iotest!(fn override() { diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index acaffd00665bf..19cf69bb26912 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -250,7 +250,7 @@ mod test { fn test_null_reader() { let mut r = NullReader; let mut buf = ~[0]; - assert!(r.read(buf).is_err()); + fail_unless!(r.read(buf).is_err()); } #[test] diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 5e919e4ac0a4d..0a3f308e623c1 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -117,7 +117,7 @@ pub trait Iterator { /// let mut it = a.iter().chain(b.iter()); /// assert_eq!(it.next().unwrap(), &0); /// assert_eq!(it.next().unwrap(), &1); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn chain>(self, other: U) -> Chain { @@ -136,7 +136,7 @@ pub trait Iterator { /// let b = [1]; /// let mut it = a.iter().zip(b.iter()); /// assert_eq!(it.next().unwrap(), (&0, &1)); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn zip>(self, other: U) -> Zip { @@ -153,7 +153,7 @@ pub trait Iterator { /// let mut it = a.iter().map(|&x| 2 * x); /// assert_eq!(it.next().unwrap(), 2); /// assert_eq!(it.next().unwrap(), 4); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn map<'r, B>(self, f: 'r |A| -> B) -> Map<'r, A, B, Self> { @@ -170,7 +170,7 @@ pub trait Iterator { /// let a = [1, 2]; /// let mut it = a.iter().filter(|&x| *x > 1); /// assert_eq!(it.next().unwrap(), &2); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn filter<'r>(self, predicate: 'r |&A| -> bool) -> Filter<'r, A, Self> { @@ -187,7 +187,7 @@ pub trait Iterator { /// let a = [1, 2]; /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None}); /// assert_eq!(it.next().unwrap(), 4); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn filter_map<'r, B>(self, f: 'r |A| -> Option) -> FilterMap<'r, A, B, Self> { @@ -204,7 +204,7 @@ pub trait Iterator { /// let mut it = a.iter().enumerate(); /// assert_eq!(it.next().unwrap(), (0, &100)); /// assert_eq!(it.next().unwrap(), (1, &200)); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn enumerate(self) -> Enumerate { @@ -226,8 +226,8 @@ pub trait Iterator { /// assert_eq!(it.peek().unwrap(), &300); /// assert_eq!(it.peek().unwrap(), &300); /// assert_eq!(it.next().unwrap(), 300); - /// assert!(it.peek().is_none()); - /// assert!(it.next().is_none()); + /// fail_unless!(it.peek().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn peekable(self) -> Peekable { @@ -246,7 +246,7 @@ pub trait Iterator { /// assert_eq!(it.next().unwrap(), &3); /// assert_eq!(it.next().unwrap(), &2); /// assert_eq!(it.next().unwrap(), &1); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn skip_while<'r>(self, predicate: 'r |&A| -> bool) -> SkipWhile<'r, A, Self> { @@ -264,7 +264,7 @@ pub trait Iterator { /// let mut it = a.iter().take_while(|&a| *a < 3); /// assert_eq!(it.next().unwrap(), &1); /// assert_eq!(it.next().unwrap(), &2); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn take_while<'r>(self, predicate: 'r |&A| -> bool) -> TakeWhile<'r, A, Self> { @@ -281,7 +281,7 @@ pub trait Iterator { /// let mut it = a.iter().skip(3); /// assert_eq!(it.next().unwrap(), &4); /// assert_eq!(it.next().unwrap(), &5); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn skip(self, n: uint) -> Skip { @@ -299,7 +299,7 @@ pub trait Iterator { /// assert_eq!(it.next().unwrap(), &1); /// assert_eq!(it.next().unwrap(), &2); /// assert_eq!(it.next().unwrap(), &3); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn take(self, n: uint) -> Take { @@ -324,7 +324,7 @@ pub trait Iterator { /// assert_eq!(it.next().unwrap(), 6); /// assert_eq!(it.next().unwrap(), 24); /// assert_eq!(it.next().unwrap(), 120); - /// assert!(it.next().is_none()); + /// fail_unless!(it.next().is_none()); /// ``` #[inline] fn scan<'r, St, B>(self, initial_state: St, f: 'r |&mut St, A| -> Option) @@ -420,9 +420,9 @@ pub trait Iterator { /// let mut xs = range(0, 10); /// // sum the first five values /// let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b); - /// assert!(partial_sum == 10); + /// fail_unless!(partial_sum == 10); /// // xs.next() is now `5` - /// assert!(xs.next() == Some(5)); + /// fail_unless!(xs.next() == Some(5)); /// ``` fn by_ref<'r>(&'r mut self) -> ByRef<'r, Self> { ByRef{iter: self} @@ -456,7 +456,7 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let b: ~[int] = a.iter().map(|&x| x).collect(); - /// assert!(a == b); + /// fail_unless!(a == b); /// ``` #[inline] fn collect>(&mut self) -> B { @@ -471,7 +471,7 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let b: ~[int] = a.iter().map(|&x| x).to_owned_vec(); - /// assert!(a == b); + /// fail_unless!(a == b); /// ``` #[inline] fn to_owned_vec(&mut self) -> ~[A] { @@ -486,8 +486,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert!(it.nth(2).unwrap() == &3); - /// assert!(it.nth(2) == None); + /// fail_unless!(it.nth(2).unwrap() == &3); + /// fail_unless!(it.nth(2) == None); /// ``` #[inline] fn nth(&mut self, mut n: uint) -> Option { @@ -507,7 +507,7 @@ pub trait Iterator { /// /// ```rust /// let a = [1, 2, 3, 4, 5]; - /// assert!(a.iter().last().unwrap() == &5); + /// fail_unless!(a.iter().last().unwrap() == &5); /// ``` #[inline] fn last(&mut self) -> Option { @@ -523,7 +523,7 @@ pub trait Iterator { /// /// ```rust /// let a = [1, 2, 3, 4, 5]; - /// assert!(a.iter().fold(0, |a, &b| a + b) == 15); + /// fail_unless!(a.iter().fold(0, |a, &b| a + b) == 15); /// ``` #[inline] fn fold(&mut self, init: B, f: |B, A| -> B) -> B { @@ -544,8 +544,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert!(it.len() == 5); - /// assert!(it.len() == 0); + /// fail_unless!(it.len() == 5); + /// fail_unless!(it.len() == 0); /// ``` #[inline] fn len(&mut self) -> uint { @@ -558,8 +558,8 @@ pub trait Iterator { /// /// ```rust /// let a = [1, 2, 3, 4, 5]; - /// assert!(a.iter().all(|x| *x > 0)); - /// assert!(!a.iter().all(|x| *x > 2)); + /// fail_unless!(a.iter().all(|x| *x > 0)); + /// fail_unless!(!a.iter().all(|x| *x > 2)); /// ``` #[inline] fn all(&mut self, f: |A| -> bool) -> bool { @@ -575,8 +575,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert!(it.any(|x| *x == 3)); - /// assert!(!it.any(|x| *x == 3)); + /// fail_unless!(it.any(|x| *x == 3)); + /// fail_unless!(!it.any(|x| *x == 3)); /// ``` #[inline] fn any(&mut self, f: |A| -> bool) -> bool { @@ -735,7 +735,7 @@ pub trait ExactSize : DoubleEndedIterator { #[inline] fn rposition(&mut self, predicate: |A| -> bool) -> Option { let (lower, upper) = self.size_hint(); - assert!(upper == Some(lower)); + fail_unless!(upper == Some(lower)); let mut i = lower; loop { match self.next_back() { @@ -819,7 +819,7 @@ pub trait AdditiveIterator { /// /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().map(|&x| x); - /// assert!(it.sum() == 15); + /// fail_unless!(it.sum() == 15); /// ``` fn sum(&mut self) -> A; } @@ -845,9 +845,9 @@ pub trait MultiplicativeIterator { /// fn factorial(n: uint) -> uint { /// count(1u, 1).take_while(|&i| i <= n).product() /// } - /// assert!(factorial(0) == 1); - /// assert!(factorial(1) == 1); - /// assert!(factorial(5) == 120); + /// fail_unless!(factorial(0) == 1); + /// fail_unless!(factorial(1) == 1); + /// fail_unless!(factorial(5) == 120); /// ``` fn product(&mut self) -> A; } @@ -869,7 +869,7 @@ pub trait OrdIterator { /// /// ```rust /// let a = [1, 2, 3, 4, 5]; - /// assert!(a.iter().max().unwrap() == &5); + /// fail_unless!(a.iter().max().unwrap() == &5); /// ``` fn max(&mut self) -> Option; @@ -879,7 +879,7 @@ pub trait OrdIterator { /// /// ```rust /// let a = [1, 2, 3, 4, 5]; - /// assert!(a.iter().min().unwrap() == &1); + /// fail_unless!(a.iter().min().unwrap() == &1); /// ``` fn min(&mut self) -> Option; @@ -903,16 +903,16 @@ pub trait OrdIterator { /// assert_eq!(v.iter().min_max(), NoElements); /// /// let v = [1i]; - /// assert!(v.iter().min_max() == OneElement(&1)); + /// fail_unless!(v.iter().min_max() == OneElement(&1)); /// /// let v = [1i, 2, 3, 4, 5]; - /// assert!(v.iter().min_max() == MinMax(&1, &5)); + /// fail_unless!(v.iter().min_max() == MinMax(&1, &5)); /// /// let v = [1i, 2, 3, 4, 5, 6]; - /// assert!(v.iter().min_max() == MinMax(&1, &6)); + /// fail_unless!(v.iter().min_max() == MinMax(&1, &6)); /// /// let v = [1i, 1, 1, 1]; - /// assert!(v.iter().min_max() == MinMax(&1, &1)); + /// fail_unless!(v.iter().min_max() == MinMax(&1, &1)); /// ``` fn min_max(&mut self) -> MinMaxResult; } @@ -1211,8 +1211,8 @@ for Zip { fn next_back(&mut self) -> Option<(A, B)> { let (a_sz, a_upper) = self.a.size_hint(); let (b_sz, b_upper) = self.b.size_hint(); - assert!(a_upper == Some(a_sz)); - assert!(b_upper == Some(b_sz)); + fail_unless!(a_upper == Some(a_sz)); + fail_unless!(b_upper == Some(b_sz)); if a_sz < b_sz { for _ in range(0, b_sz - a_sz) { self.b.next_back(); } } else if a_sz > b_sz { @@ -1220,7 +1220,7 @@ for Zip { } let (a_sz, _) = self.a.size_hint(); let (b_sz, _) = self.b.size_hint(); - assert!(a_sz == b_sz); + fail_unless!(a_sz == b_sz); match (self.a.next_back(), self.b.next_back()) { (Some(x), Some(y)) => Some((x, y)), _ => None @@ -1415,7 +1415,7 @@ impl> DoubleEndedIterator<(uint, A)> for Enumerate { match self.iter.next_back() { Some(a) => { let (lower, upper) = self.iter.size_hint(); - assert!(upper == Some(lower)); + fail_unless!(upper == Some(lower)); Some((self.count + lower, a)) } _ => None @@ -2299,43 +2299,43 @@ pub mod order { let xs = [1,2,3]; let ys = [1,2,0]; - assert!(!lt(xs.iter(), ys.iter())); - assert!(!le(xs.iter(), ys.iter())); - assert!( gt(xs.iter(), ys.iter())); - assert!( ge(xs.iter(), ys.iter())); + fail_unless!(!lt(xs.iter(), ys.iter())); + fail_unless!(!le(xs.iter(), ys.iter())); + fail_unless!( gt(xs.iter(), ys.iter())); + fail_unless!( ge(xs.iter(), ys.iter())); - assert!( lt(ys.iter(), xs.iter())); - assert!( le(ys.iter(), xs.iter())); - assert!(!gt(ys.iter(), xs.iter())); - assert!(!ge(ys.iter(), xs.iter())); + fail_unless!( lt(ys.iter(), xs.iter())); + fail_unless!( le(ys.iter(), xs.iter())); + fail_unless!(!gt(ys.iter(), xs.iter())); + fail_unless!(!ge(ys.iter(), xs.iter())); - assert!( lt(empty.iter(), xs.iter())); - assert!( le(empty.iter(), xs.iter())); - assert!(!gt(empty.iter(), xs.iter())); - assert!(!ge(empty.iter(), xs.iter())); + fail_unless!( lt(empty.iter(), xs.iter())); + fail_unless!( le(empty.iter(), xs.iter())); + fail_unless!(!gt(empty.iter(), xs.iter())); + fail_unless!(!ge(empty.iter(), xs.iter())); // Sequence with NaN let u = [1.0, 2.0]; let v = [0.0/0.0, 3.0]; - assert!(!lt(u.iter(), v.iter())); - assert!(!le(u.iter(), v.iter())); - assert!(!gt(u.iter(), v.iter())); - assert!(!ge(u.iter(), v.iter())); + fail_unless!(!lt(u.iter(), v.iter())); + fail_unless!(!le(u.iter(), v.iter())); + fail_unless!(!gt(u.iter(), v.iter())); + fail_unless!(!ge(u.iter(), v.iter())); let a = [0.0/0.0]; let b = [1.0]; let c = [2.0]; - assert!(lt(a.iter(), b.iter()) == (a[0] < b[0])); - assert!(le(a.iter(), b.iter()) == (a[0] <= b[0])); - assert!(gt(a.iter(), b.iter()) == (a[0] > b[0])); - assert!(ge(a.iter(), b.iter()) == (a[0] >= b[0])); + fail_unless!(lt(a.iter(), b.iter()) == (a[0] < b[0])); + fail_unless!(le(a.iter(), b.iter()) == (a[0] <= b[0])); + fail_unless!(gt(a.iter(), b.iter()) == (a[0] > b[0])); + fail_unless!(ge(a.iter(), b.iter()) == (a[0] >= b[0])); - assert!(lt(c.iter(), b.iter()) == (c[0] < b[0])); - assert!(le(c.iter(), b.iter()) == (c[0] <= b[0])); - assert!(gt(c.iter(), b.iter()) == (c[0] > b[0])); - assert!(ge(c.iter(), b.iter()) == (c[0] >= b[0])); + fail_unless!(lt(c.iter(), b.iter()) == (c[0] < b[0])); + fail_unless!(le(c.iter(), b.iter()) == (c[0] <= b[0])); + fail_unless!(gt(c.iter(), b.iter()) == (c[0] > b[0])); + fail_unless!(ge(c.iter(), b.iter()) == (c[0] >= b[0])); } } @@ -2408,8 +2408,8 @@ mod tests { assert_eq!(it.next().unwrap(), 4); assert_eq!(it.peek().unwrap(), &5); assert_eq!(it.next().unwrap(), 5); - assert!(it.peek().is_none()); - assert!(it.next().is_none()); + fail_unless!(it.peek().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -2647,19 +2647,19 @@ mod tests { #[test] fn test_all() { let v: ~&[int] = ~&[1, 2, 3, 4, 5]; - assert!(v.iter().all(|&x| x < 10)); - assert!(!v.iter().all(|&x| x % 2 == 0)); - assert!(!v.iter().all(|&x| x > 100)); - assert!(v.slice(0, 0).iter().all(|_| fail!())); + fail_unless!(v.iter().all(|&x| x < 10)); + fail_unless!(!v.iter().all(|&x| x % 2 == 0)); + fail_unless!(!v.iter().all(|&x| x > 100)); + fail_unless!(v.slice(0, 0).iter().all(|_| fail!())); } #[test] fn test_any() { let v: ~&[int] = ~&[1, 2, 3, 4, 5]; - assert!(v.iter().any(|&x| x < 10)); - assert!(v.iter().any(|&x| x % 2 == 0)); - assert!(!v.iter().any(|&x| x > 100)); - assert!(!v.slice(0, 0).iter().any(|_| fail!())); + fail_unless!(v.iter().any(|&x| x < 10)); + fail_unless!(v.iter().any(|&x| x % 2 == 0)); + fail_unless!(!v.iter().any(|&x| x > 100)); + fail_unless!(!v.slice(0, 0).iter().any(|_| fail!())); } #[test] @@ -2667,7 +2667,7 @@ mod tests { let v: &[int] = &[1, 3, 9, 27, 103, 14, 11]; assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14); assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3); - assert!(v.iter().find(|x| *x % 12 == 0).is_none()); + fail_unless!(v.iter().find(|x| *x % 12 == 0).is_none()); } #[test] @@ -2675,7 +2675,7 @@ mod tests { let v = &[1, 3, 9, 27, 103, 14, 11]; assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5); assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1); - assert!(v.iter().position(|x| *x % 12 == 0).is_none()); + fail_unless!(v.iter().position(|x| *x % 12 == 0).is_none()); } #[test] @@ -2799,7 +2799,7 @@ mod tests { let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; assert_eq!(v.iter().rposition(f), Some(3u)); - assert!(v.iter().rposition(g).is_none()); + fail_unless!(v.iter().rposition(g).is_none()); } #[test] @@ -2862,7 +2862,7 @@ mod tests { assert_eq!(it.idx(0).unwrap(), &1); assert_eq!(it.idx(5).unwrap(), &7); assert_eq!(it.idx(7).unwrap(), &11); - assert!(it.idx(8).is_none()); + fail_unless!(it.idx(8).is_none()); it.next(); it.next(); @@ -2870,7 +2870,7 @@ mod tests { assert_eq!(it.idx(0).unwrap(), &3); assert_eq!(it.idx(4).unwrap(), &9); - assert!(it.idx(6).is_none()); + fail_unless!(it.idx(6).is_none()); check_randacc_iter(it, xs.len() + ys.len() - 3); } @@ -3058,9 +3058,9 @@ mod tests { fn test_peekable_is_empty() { let a = [1]; let mut it = a.iter().peekable(); - assert!( !it.is_empty() ); + fail_unless!( !it.is_empty() ); it.next(); - assert!( it.is_empty() ); + fail_unless!( it.is_empty() ); } #[test] @@ -3069,16 +3069,16 @@ mod tests { assert_eq!(v.iter().min_max(), NoElements); let v = [1i]; - assert!(v.iter().min_max() == OneElement(&1)); + fail_unless!(v.iter().min_max() == OneElement(&1)); let v = [1i, 2, 3, 4, 5]; - assert!(v.iter().min_max() == MinMax(&1, &5)); + fail_unless!(v.iter().min_max() == MinMax(&1, &5)); let v = [1i, 2, 3, 4, 5, 6]; - assert!(v.iter().min_max() == MinMax(&1, &6)); + fail_unless!(v.iter().min_max() == MinMax(&1, &6)); let v = [1i, 1, 1, 1]; - assert!(v.iter().min_max() == MinMax(&1, &1)); + fail_unless!(v.iter().min_max() == MinMax(&1, &1)); } #[test] diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 043da46ba5e2c..7596039a6b02a 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -359,16 +359,16 @@ mod tests { set(my_key, ~"parent data"); task::spawn(proc() { // TLS shouldn't carry over. - assert!(get(my_key, |k| k.map(|k| (*k).clone())).is_none()); + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).is_none()); set(my_key, ~"child data"); - assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"child data"); // should be cleaned up for us }); // Must work multiple times - assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); - assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); - assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data"); } #[test] @@ -376,16 +376,16 @@ mod tests { static my_key: Key<~str> = &Key; set(my_key, ~"first data"); set(my_key, ~"next data"); // Shouldn't leak. - assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"next data"); + fail_unless!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"next data"); } #[test] fn test_tls_pop() { static my_key: Key<~str> = &Key; set(my_key, ~"weasel"); - assert!(pop(my_key).unwrap() == ~"weasel"); + fail_unless!(pop(my_key).unwrap() == ~"weasel"); // Pop must remove the data from the map. - assert!(pop(my_key).is_none()); + fail_unless!(pop(my_key).is_none()); } #[test] @@ -404,7 +404,7 @@ mod tests { None => fail!("missing value") } }); - assert!(pop(my_key).unwrap() == ~"next data"); + fail_unless!(pop(my_key).unwrap() == ~"next data"); } #[test] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index ef70882d73359..88e706b3c9270 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -259,7 +259,7 @@ macro_rules! debug_assert_eq { /// struct Item { weight: uint } /// /// fn choose_weighted_item(v: &[Item]) -> Item { -/// assert!(!v.is_empty()); +/// fail_unless!(!v.is_empty()); /// let mut so_far = 0u; /// for item in v.iter() { /// so_far += item.weight; diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 63196cd4f162e..164e3e02fc14e 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -61,10 +61,10 @@ impl TotalEq for @T { fn test() { let x = @3; let y = @3; - assert!((ptr_eq::(x, x))); - assert!((ptr_eq::(y, y))); - assert!((!ptr_eq::(x, y))); - assert!((!ptr_eq::(y, x))); + fail_unless!((ptr_eq::(x, x))); + fail_unless!((ptr_eq::(y, y))); + fail_unless!((!ptr_eq::(x, y))); + fail_unless!((!ptr_eq::(y, x))); } #[test] diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs index 11053f01ded09..f35372e93e658 100644 --- a/src/libstd/mem.rs +++ b/src/libstd/mem.rs @@ -259,8 +259,8 @@ mod tests { fn test_replace() { let mut x = Some(~"test"); let y = replace(&mut x, None); - assert!(x.is_none()); - assert!(y.is_some()); + fail_unless!(x.is_none()); + fail_unless!(y.is_some()); } } diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index da3f2c1636fe0..e4a1f14ad95bb 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -294,7 +294,7 @@ impl Round for f32 { /// /// ```rust /// let x = 1.65f32; - /// assert!(x == x.trunc() + x.fract()) + /// fail_unless!(x == x.trunc() + x.fract()) /// ``` #[inline] fn fract(&self) -> f32 { *self - self.trunc() } @@ -953,7 +953,7 @@ mod tests { let nan: f32 = Float::nan(); assert_eq!(inf.asinh(), inf); assert_eq!(neg_inf.asinh(), neg_inf); - assert!(nan.asinh().is_nan()); + fail_unless!(nan.asinh().is_nan()); assert_approx_eq!(2.0f32.asinh(), 1.443635475178810342493276740273105f32); assert_approx_eq!((-2.0f32).asinh(), -1.443635475178810342493276740273105f32); } @@ -961,14 +961,14 @@ mod tests { #[test] fn test_acosh() { assert_eq!(1.0f32.acosh(), 0.0f32); - assert!(0.999f32.acosh().is_nan()); + fail_unless!(0.999f32.acosh().is_nan()); let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); assert_eq!(inf.acosh(), inf); - assert!(neg_inf.acosh().is_nan()); - assert!(nan.acosh().is_nan()); + fail_unless!(neg_inf.acosh().is_nan()); + fail_unless!(nan.acosh().is_nan()); assert_approx_eq!(2.0f32.acosh(), 1.31695789692481670862504634730796844f32); assert_approx_eq!(3.0f32.acosh(), 1.76274717403908605046521864995958461f32); } @@ -983,15 +983,15 @@ mod tests { assert_eq!(1.0f32.atanh(), inf32); assert_eq!((-1.0f32).atanh(), neg_inf32); - assert!(2f64.atanh().atanh().is_nan()); - assert!((-2f64).atanh().atanh().is_nan()); + fail_unless!(2f64.atanh().atanh().is_nan()); + fail_unless!((-2f64).atanh().atanh().is_nan()); let inf64: f32 = Float::infinity(); let neg_inf64: f32 = Float::neg_infinity(); let nan32: f32 = Float::nan(); - assert!(inf64.atanh().is_nan()); - assert!(neg_inf64.atanh().is_nan()); - assert!(nan32.atanh().is_nan()); + fail_unless!(inf64.atanh().is_nan()); + fail_unless!(neg_inf64.atanh().is_nan()); + fail_unless!(nan32.atanh().is_nan()); assert_approx_eq!(0.5f32.atanh(), 0.54930614433405484569762261846126285f32); assert_approx_eq!((-0.5f32).atanh(), -0.54930614433405484569762261846126285f32); @@ -1043,7 +1043,7 @@ mod tests { assert_eq!((-1f32).abs(), 1f32); assert_eq!(NEG_INFINITY.abs(), INFINITY); assert_eq!((1f32/NEG_INFINITY).abs(), 0f32); - assert!(NAN.abs().is_nan()); + fail_unless!(NAN.abs().is_nan()); } #[test] @@ -1060,8 +1060,8 @@ mod tests { #[test] #[ignore(cfg(windows))] // FIXME #8663 fn test_abs_sub_nowin() { - assert!(NAN.abs_sub(&-1f32).is_nan()); - assert!(1f32.abs_sub(&NAN).is_nan()); + fail_unless!(NAN.abs_sub(&-1f32).is_nan()); + fail_unless!(1f32.abs_sub(&NAN).is_nan()); } #[test] @@ -1073,31 +1073,31 @@ mod tests { assert_eq!((-1f32).signum(), -1f32); assert_eq!(NEG_INFINITY.signum(), -1f32); assert_eq!((1f32/NEG_INFINITY).signum(), -1f32); - assert!(NAN.signum().is_nan()); + fail_unless!(NAN.signum().is_nan()); } #[test] fn test_is_positive() { - assert!(INFINITY.is_positive()); - assert!(1f32.is_positive()); - assert!(0f32.is_positive()); - assert!(!(-0f32).is_positive()); - assert!(!(-1f32).is_positive()); - assert!(!NEG_INFINITY.is_positive()); - assert!(!(1f32/NEG_INFINITY).is_positive()); - assert!(!NAN.is_positive()); + fail_unless!(INFINITY.is_positive()); + fail_unless!(1f32.is_positive()); + fail_unless!(0f32.is_positive()); + fail_unless!(!(-0f32).is_positive()); + fail_unless!(!(-1f32).is_positive()); + fail_unless!(!NEG_INFINITY.is_positive()); + fail_unless!(!(1f32/NEG_INFINITY).is_positive()); + fail_unless!(!NAN.is_positive()); } #[test] fn test_is_negative() { - assert!(!INFINITY.is_negative()); - assert!(!1f32.is_negative()); - assert!(!0f32.is_negative()); - assert!((-0f32).is_negative()); - assert!((-1f32).is_negative()); - assert!(NEG_INFINITY.is_negative()); - assert!((1f32/NEG_INFINITY).is_negative()); - assert!(!NAN.is_negative()); + fail_unless!(!INFINITY.is_negative()); + fail_unless!(!1f32.is_negative()); + fail_unless!(!0f32.is_negative()); + fail_unless!((-0f32).is_negative()); + fail_unless!((-1f32).is_negative()); + fail_unless!(NEG_INFINITY.is_negative()); + fail_unless!((1f32/NEG_INFINITY).is_negative()); + fail_unless!(!NAN.is_negative()); } #[test] @@ -1107,14 +1107,14 @@ mod tests { let neg_inf: f32 = Float::neg_infinity(); let zero: f32 = Zero::zero(); let neg_zero: f32 = Float::neg_zero(); - assert!(!nan.is_normal()); - assert!(!inf.is_normal()); - assert!(!neg_inf.is_normal()); - assert!(!zero.is_normal()); - assert!(!neg_zero.is_normal()); - assert!(1f32.is_normal()); - assert!(1e-37f32.is_normal()); - assert!(!1e-38f32.is_normal()); + fail_unless!(!nan.is_normal()); + fail_unless!(!inf.is_normal()); + fail_unless!(!neg_inf.is_normal()); + fail_unless!(!zero.is_normal()); + fail_unless!(!neg_zero.is_normal()); + fail_unless!(1f32.is_normal()); + fail_unless!(1e-37f32.is_normal()); + fail_unless!(!1e-38f32.is_normal()); } #[test] @@ -1151,7 +1151,7 @@ mod tests { let nan: f32 = Float::nan(); assert_eq!(Float::ldexp(inf, -123), inf); assert_eq!(Float::ldexp(neg_inf, -123), neg_inf); - assert!(Float::ldexp(nan, -123).is_nan()); + fail_unless!(Float::ldexp(nan, -123).is_nan()); } #[test] @@ -1178,7 +1178,7 @@ mod tests { let nan: f32 = Float::nan(); assert_eq!(match inf.frexp() { (x, _) => x }, inf) assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) - assert!(match nan.frexp() { (x, _) => x.is_nan() }) + fail_unless!(match nan.frexp() { (x, _) => x.is_nan() }) } #[test] diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 24165cbef50b9..c94676c60b81d 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -296,7 +296,7 @@ impl Round for f64 { /// /// ```rust /// let x = 1.65f64; - /// assert!(x == x.trunc() + x.fract()) + /// fail_unless!(x == x.trunc() + x.fract()) /// ``` #[inline] fn fract(&self) -> f64 { *self - self.trunc() } @@ -955,7 +955,7 @@ mod tests { let nan: f64 = Float::nan(); assert_eq!(inf.asinh(), inf); assert_eq!(neg_inf.asinh(), neg_inf); - assert!(nan.asinh().is_nan()); + fail_unless!(nan.asinh().is_nan()); assert_approx_eq!(2.0f64.asinh(), 1.443635475178810342493276740273105f64); assert_approx_eq!((-2.0f64).asinh(), -1.443635475178810342493276740273105f64); } @@ -963,14 +963,14 @@ mod tests { #[test] fn test_acosh() { assert_eq!(1.0f64.acosh(), 0.0f64); - assert!(0.999f64.acosh().is_nan()); + fail_unless!(0.999f64.acosh().is_nan()); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); assert_eq!(inf.acosh(), inf); - assert!(neg_inf.acosh().is_nan()); - assert!(nan.acosh().is_nan()); + fail_unless!(neg_inf.acosh().is_nan()); + fail_unless!(nan.acosh().is_nan()); assert_approx_eq!(2.0f64.acosh(), 1.31695789692481670862504634730796844f64); assert_approx_eq!(3.0f64.acosh(), 1.76274717403908605046521864995958461f64); } @@ -985,11 +985,11 @@ mod tests { let nan: f64 = Float::nan(); assert_eq!(1.0f64.atanh(), inf); assert_eq!((-1.0f64).atanh(), neg_inf); - assert!(2f64.atanh().atanh().is_nan()); - assert!((-2f64).atanh().atanh().is_nan()); - assert!(inf.atanh().is_nan()); - assert!(neg_inf.atanh().is_nan()); - assert!(nan.atanh().is_nan()); + fail_unless!(2f64.atanh().atanh().is_nan()); + fail_unless!((-2f64).atanh().atanh().is_nan()); + fail_unless!(inf.atanh().is_nan()); + fail_unless!(neg_inf.atanh().is_nan()); + fail_unless!(nan.atanh().is_nan()); assert_approx_eq!(0.5f64.atanh(), 0.54930614433405484569762261846126285f64); assert_approx_eq!((-0.5f64).atanh(), -0.54930614433405484569762261846126285f64); } @@ -1040,7 +1040,7 @@ mod tests { assert_eq!((-1f64).abs(), 1f64); assert_eq!(NEG_INFINITY.abs(), INFINITY); assert_eq!((1f64/NEG_INFINITY).abs(), 0f64); - assert!(NAN.abs().is_nan()); + fail_unless!(NAN.abs().is_nan()); } #[test] @@ -1057,8 +1057,8 @@ mod tests { #[test] #[ignore(cfg(windows))] // FIXME #8663 fn test_abs_sub_nowin() { - assert!(NAN.abs_sub(&-1f64).is_nan()); - assert!(1f64.abs_sub(&NAN).is_nan()); + fail_unless!(NAN.abs_sub(&-1f64).is_nan()); + fail_unless!(1f64.abs_sub(&NAN).is_nan()); } #[test] @@ -1070,31 +1070,31 @@ mod tests { assert_eq!((-1f64).signum(), -1f64); assert_eq!(NEG_INFINITY.signum(), -1f64); assert_eq!((1f64/NEG_INFINITY).signum(), -1f64); - assert!(NAN.signum().is_nan()); + fail_unless!(NAN.signum().is_nan()); } #[test] fn test_is_positive() { - assert!(INFINITY.is_positive()); - assert!(1f64.is_positive()); - assert!(0f64.is_positive()); - assert!(!(-0f64).is_positive()); - assert!(!(-1f64).is_positive()); - assert!(!NEG_INFINITY.is_positive()); - assert!(!(1f64/NEG_INFINITY).is_positive()); - assert!(!NAN.is_positive()); + fail_unless!(INFINITY.is_positive()); + fail_unless!(1f64.is_positive()); + fail_unless!(0f64.is_positive()); + fail_unless!(!(-0f64).is_positive()); + fail_unless!(!(-1f64).is_positive()); + fail_unless!(!NEG_INFINITY.is_positive()); + fail_unless!(!(1f64/NEG_INFINITY).is_positive()); + fail_unless!(!NAN.is_positive()); } #[test] fn test_is_negative() { - assert!(!INFINITY.is_negative()); - assert!(!1f64.is_negative()); - assert!(!0f64.is_negative()); - assert!((-0f64).is_negative()); - assert!((-1f64).is_negative()); - assert!(NEG_INFINITY.is_negative()); - assert!((1f64/NEG_INFINITY).is_negative()); - assert!(!NAN.is_negative()); + fail_unless!(!INFINITY.is_negative()); + fail_unless!(!1f64.is_negative()); + fail_unless!(!0f64.is_negative()); + fail_unless!((-0f64).is_negative()); + fail_unless!((-1f64).is_negative()); + fail_unless!(NEG_INFINITY.is_negative()); + fail_unless!((1f64/NEG_INFINITY).is_negative()); + fail_unless!(!NAN.is_negative()); } #[test] @@ -1104,14 +1104,14 @@ mod tests { let neg_inf: f64 = Float::neg_infinity(); let zero: f64 = Zero::zero(); let neg_zero: f64 = Float::neg_zero(); - assert!(!nan.is_normal()); - assert!(!inf.is_normal()); - assert!(!neg_inf.is_normal()); - assert!(!zero.is_normal()); - assert!(!neg_zero.is_normal()); - assert!(1f64.is_normal()); - assert!(1e-307f64.is_normal()); - assert!(!1e-308f64.is_normal()); + fail_unless!(!nan.is_normal()); + fail_unless!(!inf.is_normal()); + fail_unless!(!neg_inf.is_normal()); + fail_unless!(!zero.is_normal()); + fail_unless!(!neg_zero.is_normal()); + fail_unless!(1f64.is_normal()); + fail_unless!(1e-307f64.is_normal()); + fail_unless!(!1e-308f64.is_normal()); } #[test] @@ -1147,7 +1147,7 @@ mod tests { let nan: f64 = Float::nan(); assert_eq!(Float::ldexp(inf, -123), inf); assert_eq!(Float::ldexp(neg_inf, -123), neg_inf); - assert!(Float::ldexp(nan, -123).is_nan()); + fail_unless!(Float::ldexp(nan, -123).is_nan()); } #[test] @@ -1174,7 +1174,7 @@ mod tests { let nan: f64 = Float::nan(); assert_eq!(match inf.frexp() { (x, _) => x }, inf) assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) - assert!(match nan.frexp() { (x, _) => x.is_nan() }) + fail_unless!(match nan.frexp() { (x, _) => x.is_nan() }) } #[test] diff --git a/src/libstd/num/float_macros.rs b/src/libstd/num/float_macros.rs index 7c93602af118c..d601069b04c7f 100644 --- a/src/libstd/num/float_macros.rs +++ b/src/libstd/num/float_macros.rs @@ -14,7 +14,7 @@ macro_rules! assert_approx_eq( ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, + fail_unless!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) ) diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 43a7019081207..cbd7bfc29d745 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -96,15 +96,15 @@ impl Div<$T,$T> for $T { /// # Examples /// /// ~~~ - /// assert!( 8 / 3 == 2); - /// assert!( 8 / -3 == -2); - /// assert!(-8 / 3 == -2); - /// assert!(-8 / -3 == 2); + /// fail_unless!( 8 / 3 == 2); + /// fail_unless!( 8 / -3 == -2); + /// fail_unless!(-8 / 3 == -2); + /// fail_unless!(-8 / -3 == 2); /// - /// assert!( 1 / 2 == 0); - /// assert!( 1 / -2 == 0); - /// assert!(-1 / 2 == 0); - /// assert!(-1 / -2 == 0); + /// fail_unless!( 1 / 2 == 0); + /// fail_unless!( 1 / -2 == 0); + /// fail_unless!(-1 / 2 == 0); + /// fail_unless!(-1 / -2 == 0); /// ~~~ #[inline] fn div(&self, other: &$T) -> $T { *self / *other } @@ -117,21 +117,21 @@ impl Rem<$T,$T> for $T { /// ~~~ /// # let n = 1; /// # let d = 2; - /// assert!((n / d) * d + (n % d) == n) + /// fail_unless!((n / d) * d + (n % d) == n) /// ~~~ /// /// # Examples /// /// ~~~ - /// assert!( 8 % 3 == 2); - /// assert!( 8 % -3 == 2); - /// assert!(-8 % 3 == -2); - /// assert!(-8 % -3 == -2); + /// fail_unless!( 8 % 3 == 2); + /// fail_unless!( 8 % -3 == 2); + /// fail_unless!(-8 % 3 == -2); + /// fail_unless!(-8 % -3 == -2); /// - /// assert!( 1 % 2 == 1); - /// assert!( 1 % -2 == 1); - /// assert!(-1 % 2 == -1); - /// assert!(-1 % -2 == -1); + /// fail_unless!( 1 % 2 == 1); + /// fail_unless!( 1 % -2 == 1); + /// fail_unless!(-1 % 2 == -1); + /// fail_unless!(-1 % -2 == -1); /// ~~~ #[inline] fn rem(&self, other: &$T) -> $T { *self % *other } @@ -308,8 +308,8 @@ mod tests { #[test] fn test_overflows() { - assert!(MAX > 0); - assert!(MIN <= 0); + fail_unless!(MAX > 0); + fail_unless!(MIN <= 0); assert_eq!(MIN + MAX + 1, 0); } @@ -343,18 +343,18 @@ mod tests { #[test] fn test_is_positive() { - assert!((1 as $T).is_positive()); - assert!(!(0 as $T).is_positive()); - assert!(!(-0 as $T).is_positive()); - assert!(!(-1 as $T).is_positive()); + fail_unless!((1 as $T).is_positive()); + fail_unless!(!(0 as $T).is_positive()); + fail_unless!(!(-0 as $T).is_positive()); + fail_unless!(!(-1 as $T).is_positive()); } #[test] fn test_is_negative() { - assert!(!(1 as $T).is_negative()); - assert!(!(0 as $T).is_negative()); - assert!(!(-0 as $T).is_negative()); - assert!((-1 as $T).is_negative()); + fail_unless!(!(1 as $T).is_negative()); + fail_unless!(!(0 as $T).is_negative()); + fail_unless!(!(-0 as $T).is_negative()); + fail_unless!((-1 as $T).is_negative()); } #[test] @@ -395,8 +395,8 @@ mod tests { assert_eq!(from_str::("-123456789"), Some(-123456789 as i32)); assert_eq!(from_str::<$T>("-00100"), Some(-100 as $T)); - assert!(from_str::<$T>(" ").is_none()); - assert!(from_str::<$T>("x").is_none()); + fail_unless!(from_str::<$T>(" ").is_none()); + fail_unless!(from_str::<$T>("x").is_none()); } #[test] @@ -420,8 +420,8 @@ mod tests { assert_eq!(parse_bytes("-z".as_bytes(), 36u), Some(-35 as $T)); assert_eq!(parse_bytes("-Z".as_bytes(), 36u), Some(-35 as $T)); - assert!(parse_bytes("Z".as_bytes(), 35u).is_none()); - assert!(parse_bytes("-9".as_bytes(), 2u).is_none()); + fail_unless!(parse_bytes("Z".as_bytes(), 35u).is_none()); + fail_unless!(parse_bytes("-9".as_bytes(), 2u).is_none()); } #[test] @@ -465,35 +465,35 @@ mod tests { fn test_int_from_str_overflow() { let mut i8_val: i8 = 127_i8; assert_eq!(from_str::("127"), Some(i8_val)); - assert!(from_str::("128").is_none()); + fail_unless!(from_str::("128").is_none()); i8_val += 1 as i8; assert_eq!(from_str::("-128"), Some(i8_val)); - assert!(from_str::("-129").is_none()); + fail_unless!(from_str::("-129").is_none()); let mut i16_val: i16 = 32_767_i16; assert_eq!(from_str::("32767"), Some(i16_val)); - assert!(from_str::("32768").is_none()); + fail_unless!(from_str::("32768").is_none()); i16_val += 1 as i16; assert_eq!(from_str::("-32768"), Some(i16_val)); - assert!(from_str::("-32769").is_none()); + fail_unless!(from_str::("-32769").is_none()); let mut i32_val: i32 = 2_147_483_647_i32; assert_eq!(from_str::("2147483647"), Some(i32_val)); - assert!(from_str::("2147483648").is_none()); + fail_unless!(from_str::("2147483648").is_none()); i32_val += 1 as i32; assert_eq!(from_str::("-2147483648"), Some(i32_val)); - assert!(from_str::("-2147483649").is_none()); + fail_unless!(from_str::("-2147483649").is_none()); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; assert_eq!(from_str::("9223372036854775807"), Some(i64_val)); - assert!(from_str::("9223372036854775808").is_none()); + fail_unless!(from_str::("9223372036854775808").is_none()); i64_val += 1 as i64; assert_eq!(from_str::("-9223372036854775808"), Some(i64_val)); - assert!(from_str::("-9223372036854775809").is_none()); + fail_unless!(from_str::("-9223372036854775809").is_none()); } #[test] diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index b23e42ad1c689..ef4cf9d4b29e8 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1637,7 +1637,7 @@ mod tests { assert_eq!(checked_next_power_of_two(i), Some(next_power)); if i == next_power { next_power *= 2 } } - assert!(checked_next_power_of_two::<$T>($T::MAX / 2).is_some()); + fail_unless!(checked_next_power_of_two::<$T>($T::MAX / 2).is_some()); assert_eq!(checked_next_power_of_two::<$T>($T::MAX - 1), None); assert_eq!(checked_next_power_of_two::<$T>($T::MAX), None); } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 153c042c6a8c1..cd07024d280d0 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -134,7 +134,7 @@ static NAN_BUF: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8]; * - Fails if `radix` < 2 or `radix` > 36. */ pub fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, f: |u8|) { - assert!(2 <= radix && radix <= 36); + fail_unless!(2 <= radix && radix <= 36); let _0: T = Zero::zero(); @@ -240,7 +240,7 @@ pub fn float_to_str_bytes_common (~[u8], bool) { - assert!(2 <= radix && radix <= 36); + fail_unless!(2 <= radix && radix <= 36); match exp_format { ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' => fail!("float_to_str_bytes_common: radix {} incompatible with \ diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index d60b523544601..5d45aa0f335e3 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -245,8 +245,8 @@ mod tests { #[test] fn test_overflows() { - assert!(MAX > 0); - assert!(MIN <= 0); + fail_unless!(MAX > 0); + fail_unless!(MIN <= 0); assert_eq!(MIN + MAX + 1, 0); } @@ -298,9 +298,9 @@ mod tests { assert_eq!(from_str::("123456789"), Some(123456789 as u32)); assert_eq!(from_str::<$T>("00100"), Some(100u as $T)); - assert!(from_str::<$T>("").is_none()); - assert!(from_str::<$T>(" ").is_none()); - assert!(from_str::<$T>("x").is_none()); + fail_unless!(from_str::<$T>("").is_none()); + fail_unless!(from_str::<$T>(" ").is_none()); + fail_unless!(from_str::<$T>("x").is_none()); } #[test] @@ -313,8 +313,8 @@ mod tests { assert_eq!(u16::parse_bytes("ffff".as_bytes(), 16u), Some(65535u as u16)); assert_eq!(parse_bytes("z".as_bytes(), 36u), Some(35u as $T)); - assert!(parse_bytes("Z".as_bytes(), 10u).is_none()); - assert!(parse_bytes("_".as_bytes(), 2u).is_none()); + fail_unless!(parse_bytes("Z".as_bytes(), 10u).is_none()); + fail_unless!(parse_bytes("_".as_bytes(), 2u).is_none()); } #[test] @@ -348,35 +348,35 @@ mod tests { fn test_uint_from_str_overflow() { let mut u8_val: u8 = 255_u8; assert_eq!(from_str::("255"), Some(u8_val)); - assert!(from_str::("256").is_none()); + fail_unless!(from_str::("256").is_none()); u8_val += 1 as u8; assert_eq!(from_str::("0"), Some(u8_val)); - assert!(from_str::("-1").is_none()); + fail_unless!(from_str::("-1").is_none()); let mut u16_val: u16 = 65_535_u16; assert_eq!(from_str::("65535"), Some(u16_val)); - assert!(from_str::("65536").is_none()); + fail_unless!(from_str::("65536").is_none()); u16_val += 1 as u16; assert_eq!(from_str::("0"), Some(u16_val)); - assert!(from_str::("-1").is_none()); + fail_unless!(from_str::("-1").is_none()); let mut u32_val: u32 = 4_294_967_295_u32; assert_eq!(from_str::("4294967295"), Some(u32_val)); - assert!(from_str::("4294967296").is_none()); + fail_unless!(from_str::("4294967296").is_none()); u32_val += 1 as u32; assert_eq!(from_str::("0"), Some(u32_val)); - assert!(from_str::("-1").is_none()); + fail_unless!(from_str::("-1").is_none()); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; assert_eq!(from_str::("18446744073709551615"), Some(u64_val)); - assert!(from_str::("18446744073709551616").is_none()); + fail_unless!(from_str::("18446744073709551616").is_none()); u64_val += 1 as u64; assert_eq!(from_str::("0"), Some(u64_val)); - assert!(from_str::("-1").is_none()); + fail_unless!(from_str::("-1").is_none()); } #[test] diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 44d78be93d624..83fd360a108c5 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -446,7 +446,7 @@ impl ExactSize for Item {} /// } /// let v = [1u, 2, 3]; /// let res = collect(v.iter().map(|&x| inc_conditionally(x))); -/// assert!(res == Some(~[2u, 3, 4])); +/// fail_unless!(res == Some(~[2u, 3, 4])); #[inline] pub fn collect>, V: FromIterator>(iter: Iter) -> Option { // FIXME(#11084): This should be twice as fast once this bug is closed. @@ -546,7 +546,7 @@ mod tests { y2 = y.take_unwrap(); } assert_eq!(y2, 5); - assert!(y.is_none()); + fail_unless!(y.is_none()); } #[test] #[should_fail] @@ -657,7 +657,7 @@ mod tests { let some_stuff = Some(42); let modified_stuff = some_stuff.filtered(|&x| {x < 10}); assert_eq!(some_stuff.unwrap(), 42); - assert!(modified_stuff.is_none()); + fail_unless!(modified_stuff.is_none()); } #[test] @@ -670,7 +670,7 @@ mod tests { assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(it.next(), Some(&val)); assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -689,11 +689,11 @@ mod tests { assert_eq!(*interior, val); *interior = new_val; } - None => assert!(false), + None => fail_unless!(false), } assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } assert_eq!(x, Some(new_val)); } @@ -703,24 +703,24 @@ mod tests { let small = Some(1.0); let big = Some(5.0); let nan = Some(0.0/0.0); - assert!(!(nan < big)); - assert!(!(nan > big)); - assert!(small < big); - assert!(None < big); - assert!(big > None); + fail_unless!(!(nan < big)); + fail_unless!(!(nan > big)); + fail_unless!(small < big); + fail_unless!(None < big); + fail_unless!(big > None); } #[test] fn test_mutate() { let mut x = Some(3i); - assert!(x.mutate(|i| i+1)); + fail_unless!(x.mutate(|i| i+1)); assert_eq!(x, Some(4i)); - assert!(x.mutate_or_set(0, |i| i+1)); + fail_unless!(x.mutate_or_set(0, |i| i+1)); assert_eq!(x, Some(5i)); x = None; - assert!(!x.mutate(|i| i+1)); + fail_unless!(!x.mutate(|i| i+1)); assert_eq!(x, None); - assert!(!x.mutate_or_set(0i, |i| i+1)); + fail_unless!(!x.mutate_or_set(0i, |i| i+1)); assert_eq!(x, Some(0i)); } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 458e31fd86f5f..ba35a317537af 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -392,8 +392,8 @@ pub fn pipe() -> Pipe { let res = libc::pipe(&mut fds.input, 1024 as ::libc::c_uint, (libc::O_BINARY | libc::O_NOINHERIT) as c_int); assert_eq!(res, 0); - assert!((fds.input != -1 && fds.input != 0 )); - assert!((fds.out != -1 && fds.input != 0)); + fail_unless!((fds.input != -1 && fds.input != 0 )); + fail_unless!((fds.out != -1 && fds.input != 0)); return Pipe {input: fds.input, out: fds.out}; } } @@ -1405,13 +1405,13 @@ mod tests { #[test] pub fn test_args() { let a = args(); - assert!(a.len() >= 1); + fail_unless!(a.len() >= 1); } fn make_rand_name() -> ~str { let mut rng = rand::rng(); let n = ~"TEST" + rng.gen_ascii_str(10u); - assert!(getenv(n).is_none()); + fail_unless!(getenv(n).is_none()); n } @@ -1461,30 +1461,30 @@ mod tests { #[test] fn test_self_exe_name() { let path = os::self_exe_name(); - assert!(path.is_some()); + fail_unless!(path.is_some()); let path = path.unwrap(); debug!("{:?}", path.clone()); // Hard to test this function - assert!(path.is_absolute()); + fail_unless!(path.is_absolute()); } #[test] fn test_self_exe_path() { let path = os::self_exe_path(); - assert!(path.is_some()); + fail_unless!(path.is_some()); let path = path.unwrap(); debug!("{:?}", path.clone()); // Hard to test this function - assert!(path.is_absolute()); + fail_unless!(path.is_absolute()); } #[test] #[ignore] fn test_env_getenv() { let e = env(); - assert!(e.len() > 0u); + fail_unless!(e.len() > 0u); for p in e.iter() { let (n, v) = (*p).clone(); debug!("{:?}", n.clone()); @@ -1492,7 +1492,7 @@ mod tests { // MingW seems to set some funky environment variables like // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned // from env() but not visible from getenv(). - assert!(v2.is_none() || v2 == option::Some(v)); + fail_unless!(v2.is_none() || v2 == option::Some(v)); } } @@ -1512,15 +1512,15 @@ mod tests { let mut e = env(); setenv(n, "VALUE"); - assert!(!e.contains(&(n.clone(), ~"VALUE"))); + fail_unless!(!e.contains(&(n.clone(), ~"VALUE"))); e = env(); - assert!(e.contains(&(n, ~"VALUE"))); + fail_unless!(e.contains(&(n, ~"VALUE"))); } #[test] fn test() { - assert!((!Path::new("test-path").is_absolute())); + fail_unless!((!Path::new("test-path").is_absolute())); let cwd = getcwd(); debug!("Current working directory: {}", cwd.display()); @@ -1538,7 +1538,7 @@ mod tests { assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); setenv("HOME", ""); - assert!(os::homedir().is_none()); + fail_unless!(os::homedir().is_none()); for s in oldhome.iter() { setenv("HOME", *s) } } @@ -1553,7 +1553,7 @@ mod tests { setenv("HOME", ""); setenv("USERPROFILE", ""); - assert!(os::homedir().is_none()); + fail_unless!(os::homedir().is_none()); setenv("HOME", "/home/MountainView"); assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); @@ -1582,11 +1582,11 @@ mod tests { Ok(chunk) => chunk, Err(msg) => fail!("{}", msg) }; - assert!(chunk.len >= 16); + fail_unless!(chunk.len >= 16); unsafe { *chunk.data = 0xBE; - assert!(*chunk.data == 0xBE); + fail_unless!(*chunk.data == 0xBE); } } @@ -1600,13 +1600,13 @@ mod tests { #[cfg(unix)] fn lseek_(fd: c_int, size: uint) { unsafe { - assert!(lseek(fd, size as off_t, SEEK_SET) == size as off_t); + fail_unless!(lseek(fd, size as off_t, SEEK_SET) == size as off_t); } } #[cfg(windows)] fn lseek_(fd: c_int, size: uint) { unsafe { - assert!(lseek(fd, size as c_long, SEEK_SET) == size as c_long); + fail_unless!(lseek(fd, size as c_long, SEEK_SET) == size as c_long); } } @@ -1619,7 +1619,7 @@ mod tests { open(path, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR) }); lseek_(fd, size); - "x".with_c_str(|x| assert!(write(fd, x as *c_void, 1) == 1)); + "x".with_c_str(|x| fail_unless!(write(fd, x as *c_void, 1) == 1)); fd }; let chunk = match MemoryMap::new(size / 2, [ @@ -1631,11 +1631,11 @@ mod tests { Ok(chunk) => chunk, Err(msg) => fail!("{}", msg) }; - assert!(chunk.len > 0); + fail_unless!(chunk.len > 0); unsafe { *chunk.data = 0xbe; - assert!(*chunk.data == 0xbe); + fail_unless!(*chunk.data == 0xbe); close(fd); } drop(chunk); diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 13496033fd0e5..a2ae35b920972 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -159,7 +159,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// See individual Path impls for additional restrictions. #[inline] fn new(path: T) -> Self { - assert!(!contains_nul(path.container_as_bytes())); + fail_unless!(!contains_nul(path.container_as_bytes())); unsafe { GenericPathUnsafe::new_unchecked(path) } } @@ -275,7 +275,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Fails the task if the filename contains a NUL. #[inline] fn set_filename(&mut self, filename: T) { - assert!(!contains_nul(filename.container_as_bytes())); + fail_unless!(!contains_nul(filename.container_as_bytes())); unsafe { self.set_filename_unchecked(filename) } } /// Replaces the extension with the given byte vector or string. @@ -287,7 +287,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// Fails the task if the extension contains a NUL. fn set_extension(&mut self, extension: T) { - assert!(!contains_nul(extension.container_as_bytes())); + fail_unless!(!contains_nul(extension.container_as_bytes())); // borrowck causes problems here too let val = { match self.filename() { @@ -377,7 +377,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// Fails the task if the path contains a NUL. #[inline] fn push(&mut self, path: T) { - assert!(!contains_nul(path.container_as_bytes())); + fail_unless!(!contains_nul(path.container_as_bytes())); unsafe { self.push_unchecked(path) } } /// Pushes multiple paths (as byte vectors or strings) onto `self`. diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 9aaa86c4cfe21..a994a8094c1a4 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -116,7 +116,7 @@ impl<'a> BytesContainer for &'a Path { impl GenericPathUnsafe for Path { unsafe fn new_unchecked(path: T) -> Path { let path = Path::normalize(path.container_as_bytes()); - assert!(!path.is_empty()); + fail_unless!(!path.is_empty()); let idx = path.rposition_elem(&SEP_BYTE); Path{ repr: path, sepidx: idx } } @@ -531,17 +531,17 @@ mod tests { let result = task::try(proc() { Path::new(b!("foo/bar", 0)) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { Path::new("test").set_filename(b!("f", 0, "o")) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { Path::new("test").push(b!("f", 0, "o")); }); - assert!(result.is_err()); + fail_unless!(result.is_err()); } #[test] @@ -969,19 +969,19 @@ mod tests { { let path = $path; let filename = $filename; - assert!(path.filename_str() == filename, + fail_unless!(path.filename_str() == filename, "{}.filename_str(): Expected `{:?}`, found {:?}", path.as_str().unwrap(), filename, path.filename_str()); let dirname = $dirname; - assert!(path.dirname_str() == dirname, + fail_unless!(path.dirname_str() == dirname, "`{}`.dirname_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), dirname, path.dirname_str()); let filestem = $filestem; - assert!(path.filestem_str() == filestem, + fail_unless!(path.filestem_str() == filestem, "`{}`.filestem_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), filestem, path.filestem_str()); let ext = $ext; - assert!(path.extension_str() == ext, + fail_unless!(path.extension_str() == ext, "`{}`.extension_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), ext, path.extension_str()); } @@ -1180,11 +1180,11 @@ mod tests { let comps = path.components().to_owned_vec(); let exp: &[&str] = $exp; let exps = exp.iter().map(|x| x.as_bytes()).to_owned_vec(); - assert!(comps == exps, "components: Expected {:?}, found {:?}", + fail_unless!(comps == exps, "components: Expected {:?}, found {:?}", comps, exps); let comps = path.rev_components().to_owned_vec(); let exps = exps.move_rev_iter().to_owned_vec(); - assert!(comps == exps, "rev_components: Expected {:?}, found {:?}", + fail_unless!(comps == exps, "rev_components: Expected {:?}, found {:?}", comps, exps); } ); @@ -1193,11 +1193,11 @@ mod tests { let path = Path::new(b!($($arg),+)); let comps = path.components().to_owned_vec(); let exp: &[&[u8]] = [$(b!($($exp),*)),*]; - assert!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}", + fail_unless!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}", comps.as_slice(), exp); let comps = path.rev_components().to_owned_vec(); let exp = exp.rev_iter().map(|&x|x).to_owned_vec(); - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "rev_components: Expected {:?}, found {:?}", comps.as_slice(), exp); } @@ -1228,12 +1228,12 @@ mod tests { let path = Path::new(b!($($arg),+)); let comps = path.str_components().to_owned_vec(); let exp: &[Option<&str>] = $exp; - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); let comps = path.rev_str_components().to_owned_vec(); let exp = exp.rev_iter().map(|&x|x).to_owned_vec(); - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "rev_str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 972b7d178a111..0d222869cd0ad 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -158,7 +158,7 @@ impl GenericPathUnsafe for Path { #[inline] unsafe fn new_unchecked(path: T) -> Path { let (prefix, path) = Path::normalize_(path.container_as_str().unwrap()); - assert!(!path.is_empty()); + fail_unless!(!path.is_empty()); let mut ret = Path{ repr: path, prefix: prefix, sepidx: None }; ret.update_sepidx(); ret @@ -1094,7 +1094,7 @@ mod tests { let path = $path; let exp = $exp; let res = parse_prefix(path); - assert!(res == exp, + fail_unless!(res == exp, "parse_prefix(\"{}\"): expected {:?}, found {:?}", path, exp, res); } ) @@ -1252,17 +1252,17 @@ mod tests { let result = task::try(proc() { Path::new(b!("foo/bar", 0)) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { Path::new("test").set_filename(b!("f", 0, "o")) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { Path::new("test").push(b!("f", 0, "o")); }); - assert!(result.is_err()); + fail_unless!(result.is_err()); } #[test] @@ -1552,7 +1552,7 @@ mod tests { let mut p = Path::new(pstr); let result = p.pop(); let left = $left; - assert!(p.as_str() == Some(left), + fail_unless!(p.as_str() == Some(left), "`{}`.pop() failed; expected remainder `{}`, found `{}`", pstr, left, p.as_str().unwrap()); assert_eq!(result, $right); @@ -1692,7 +1692,7 @@ mod tests { let arg = $arg; let res = path.$op(arg); let exp = $res; - assert!(res.as_str() == Some(exp), + fail_unless!(res.as_str() == Some(exp), "`{}`.{}(\"{}\"): Expected `{}`, found `{}`", pstr, stringify!($op), arg, exp, res.as_str().unwrap()); } @@ -1819,19 +1819,19 @@ mod tests { { let path = $path; let filename = $filename; - assert!(path.filename_str() == filename, + fail_unless!(path.filename_str() == filename, "`{}`.filename_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), filename, path.filename_str()); let dirname = $dirname; - assert!(path.dirname_str() == dirname, + fail_unless!(path.dirname_str() == dirname, "`{}`.dirname_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), dirname, path.dirname_str()); let filestem = $filestem; - assert!(path.filestem_str() == filestem, + fail_unless!(path.filestem_str() == filestem, "`{}`.filestem_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), filestem, path.filestem_str()); let ext = $ext; - assert!(path.extension_str() == ext, + fail_unless!(path.extension_str() == ext, "`{}`.extension_str(): Expected `{:?}`, found `{:?}`", path.as_str().unwrap(), ext, path.extension_str()); } @@ -1886,16 +1886,16 @@ mod tests { let path = Path::new($path); let (abs, vol, cwd, rel) = ($abs, $vol, $cwd, $rel); let b = path.is_absolute(); - assert!(b == abs, "Path '{}'.is_absolute(): expected {:?}, found {:?}", + fail_unless!(b == abs, "Path '{}'.is_absolute(): expected {:?}, found {:?}", path.as_str().unwrap(), abs, b); let b = is_vol_relative(&path); - assert!(b == vol, "is_vol_relative('{}'): expected {:?}, found {:?}", + fail_unless!(b == vol, "is_vol_relative('{}'): expected {:?}, found {:?}", path.as_str().unwrap(), vol, b); let b = is_cwd_relative(&path); - assert!(b == cwd, "is_cwd_relative('{}'): expected {:?}, found {:?}", + fail_unless!(b == cwd, "is_cwd_relative('{}'): expected {:?}, found {:?}", path.as_str().unwrap(), cwd, b); let b = path.is_relative(); - assert!(b == rel, "Path '{}'.is_relativf(): expected {:?}, found {:?}", + fail_unless!(b == rel, "Path '{}'.is_relativf(): expected {:?}, found {:?}", path.as_str().unwrap(), rel, b); } ) @@ -1927,7 +1927,7 @@ mod tests { let dest = Path::new($dest); let exp = $exp; let res = path.is_ancestor_of(&dest); - assert!(res == exp, + fail_unless!(res == exp, "`{}`.is_ancestor_of(`{}`): Expected {:?}, found {:?}", path.as_str().unwrap(), dest.as_str().unwrap(), exp, res); } @@ -2062,7 +2062,7 @@ mod tests { let other = Path::new($other); let res = path.path_relative_from(&other); let exp = $exp; - assert!(res.as_ref().and_then(|x| x.as_str()) == exp, + fail_unless!(res.as_ref().and_then(|x| x.as_str()) == exp, "`{}`.path_relative_from(`{}`): Expected {:?}, got {:?}", path.as_str().unwrap(), other.as_str().unwrap(), exp, res.as_ref().and_then(|x| x.as_str())); @@ -2195,12 +2195,12 @@ mod tests { let path = Path::new($path); let comps = path.str_components().map(|x|x.unwrap()).to_owned_vec(); let exp: &[&str] = $exp; - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); let comps = path.rev_str_components().map(|x|x.unwrap()).to_owned_vec(); let exp = exp.rev_iter().map(|&x|x).to_owned_vec(); - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "rev_str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); } @@ -2210,12 +2210,12 @@ mod tests { let path = Path::new(b!($($arg),+)); let comps = path.str_components().map(|x|x.unwrap()).to_owned_vec(); let exp: &[&str] = $exp; - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); let comps = path.rev_str_components().map(|x|x.unwrap()).to_owned_vec(); let exp = exp.rev_iter().map(|&x|x).to_owned_vec(); - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "rev_str_components: Expected {:?}, found {:?}", comps.as_slice(), exp); } @@ -2270,11 +2270,11 @@ mod tests { let path = Path::new($path); let comps = path.components().to_owned_vec(); let exp: &[&[u8]] = $exp; - assert!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}", + fail_unless!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}", comps.as_slice(), exp); let comps = path.rev_components().to_owned_vec(); let exp = exp.rev_iter().map(|&x|x).to_owned_vec(); - assert!(comps.as_slice() == exp, + fail_unless!(comps.as_slice() == exp, "rev_components: Expected {:?}, found {:?}", comps.as_slice(), exp); } diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 193e9ea7052f0..cdc7d2ad4f2f9 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -418,14 +418,14 @@ pub mod ptr_tests { copy_memory(v1.as_mut_ptr().offset(1), v0.as_ptr().offset(1), 1); - assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); + fail_unless!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); copy_memory(v1.as_mut_ptr(), v0.as_ptr().offset(2), 1); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && + fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16)); copy_memory(v1.as_mut_ptr().offset(2), v0.as_ptr(), 1u); - assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && + fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16)); } } @@ -436,9 +436,9 @@ pub mod ptr_tests { "hello".with_c_str(|p| { unsafe { - assert!(2u == position(p, |c| *c == 'l' as c_char)); - assert!(4u == position(p, |c| *c == 'o' as c_char)); - assert!(5u == position(p, |c| *c == 0 as c_char)); + fail_unless!(2u == position(p, |c| *c == 'l' as c_char)); + fail_unless!(4u == position(p, |c| *c == 'o' as c_char)); + fail_unless!(5u == position(p, |c| *c == 0 as c_char)); } }) } @@ -460,20 +460,20 @@ pub mod ptr_tests { #[test] fn test_is_null() { let p: *int = null(); - assert!(p.is_null()); - assert!(!p.is_not_null()); + fail_unless!(p.is_null()); + fail_unless!(!p.is_not_null()); let q = unsafe { p.offset(1) }; - assert!(!q.is_null()); - assert!(q.is_not_null()); + fail_unless!(!q.is_null()); + fail_unless!(q.is_not_null()); let mp: *mut int = mut_null(); - assert!(mp.is_null()); - assert!(!mp.is_not_null()); + fail_unless!(mp.is_null()); + fail_unless!(!mp.is_not_null()); let mq = unsafe { mp.offset(1) }; - assert!(!mq.is_null()); - assert!(mq.is_not_null()); + fail_unless!(!mq.is_null()); + fail_unless!(mq.is_not_null()); } #[test] diff --git a/src/libstd/rand/distributions/exponential.rs b/src/libstd/rand/distributions/exponential.rs index 2fa9cf8bd48b2..af041372eef67 100644 --- a/src/libstd/rand/distributions/exponential.rs +++ b/src/libstd/rand/distributions/exponential.rs @@ -74,7 +74,7 @@ impl Exp { /// Construct a new `Exp` with the given shape parameter /// `lambda`. Fails if `lambda <= 0`. pub fn new(lambda: f64) -> Exp { - assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); + fail_unless!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); Exp { lambda_inverse: 1.0 / lambda } } } @@ -101,8 +101,8 @@ mod test { let mut exp = Exp::new(10.0); let mut rng = task_rng(); for _ in range(0, 1000) { - assert!(exp.sample(&mut rng) >= 0.0); - assert!(exp.ind_sample(&mut rng) >= 0.0); + fail_unless!(exp.sample(&mut rng) >= 0.0); + fail_unless!(exp.ind_sample(&mut rng) >= 0.0); } } #[test] diff --git a/src/libstd/rand/distributions/gamma.rs b/src/libstd/rand/distributions/gamma.rs index b9702ccd48da2..a469620b0baca 100644 --- a/src/libstd/rand/distributions/gamma.rs +++ b/src/libstd/rand/distributions/gamma.rs @@ -89,8 +89,8 @@ impl Gamma { /// /// Fails if `shape <= 0` or `scale <= 0`. pub fn new(shape: f64, scale: f64) -> Gamma { - assert!(shape > 0.0, "Gamma::new called with shape <= 0"); - assert!(scale > 0.0, "Gamma::new called with scale <= 0"); + fail_unless!(shape > 0.0, "Gamma::new called with shape <= 0"); + fail_unless!(scale > 0.0, "Gamma::new called with scale <= 0"); match shape { 1.0 => One(Exp::new(1.0 / scale)), @@ -201,7 +201,7 @@ impl ChiSquared { if k == 1.0 { DoFExactlyOne } else { - assert!(k > 0.0, "ChiSquared::new called with `k` < 0"); + fail_unless!(k > 0.0, "ChiSquared::new called with `k` < 0"); DoFAnythingElse(Gamma::new(0.5 * k, 2.0)) } } @@ -250,8 +250,8 @@ impl FisherF { /// Create a new `FisherF` distribution, with the given /// parameter. Fails if either `m` or `n` are not positive. pub fn new(m: f64, n: f64) -> FisherF { - assert!(m > 0.0, "FisherF::new called with `m < 0`"); - assert!(n > 0.0, "FisherF::new called with `n < 0`"); + fail_unless!(m > 0.0, "FisherF::new called with `m < 0`"); + fail_unless!(n > 0.0, "FisherF::new called with `n < 0`"); FisherF { numer: ChiSquared::new(m), @@ -291,7 +291,7 @@ impl StudentT { /// Create a new Student t distribution with `n` degrees of /// freedom. Fails if `n <= 0`. pub fn new(n: f64) -> StudentT { - assert!(n > 0.0, "StudentT::new called with `n <= 0`"); + fail_unless!(n > 0.0, "StudentT::new called with `n <= 0`"); StudentT { chi: ChiSquared::new(n), dof: n diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index 140323110df68..b34f2dde5bc69 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -120,7 +120,7 @@ impl WeightedChoice { /// - the total weight is larger than a `uint` can contain. pub fn new(mut items: ~[Weighted]) -> WeightedChoice { // strictly speaking, this is subsumed by the total weight == 0 case - assert!(!items.is_empty(), "WeightedChoice::new called with no items"); + fail_unless!(!items.is_empty(), "WeightedChoice::new called with no items"); let mut running_total = 0u; @@ -134,7 +134,7 @@ impl WeightedChoice { item.weight = running_total; } - assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0"); + fail_unless!(running_total != 0, "WeightedChoice::new called with a total weight of 0"); WeightedChoice { items: items, diff --git a/src/libstd/rand/distributions/normal.rs b/src/libstd/rand/distributions/normal.rs index b2f952e2a4c98..ab65860378b58 100644 --- a/src/libstd/rand/distributions/normal.rs +++ b/src/libstd/rand/distributions/normal.rs @@ -91,7 +91,7 @@ impl Normal { /// Construct a new `Normal` distribution with the given mean and /// standard deviation. Fails if `std_dev < 0`. pub fn new(mean: f64, std_dev: f64) -> Normal { - assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); + fail_unless!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); Normal { mean: mean, std_dev: std_dev @@ -133,7 +133,7 @@ impl LogNormal { /// Construct a new `LogNormal` distribution with the given mean /// and standard deviation. Fails if `std_dev < 0`. pub fn new(mean: f64, std_dev: f64) -> LogNormal { - assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); + fail_unless!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); LogNormal { norm: Normal::new(mean, std_dev) } } } diff --git a/src/libstd/rand/distributions/range.rs b/src/libstd/rand/distributions/range.rs index 8141b3d3e896f..537fda764f614 100644 --- a/src/libstd/rand/distributions/range.rs +++ b/src/libstd/rand/distributions/range.rs @@ -57,7 +57,7 @@ impl Range { /// Create a new `Range` instance that samples uniformly from /// `[low, high)`. Fails if `low >= high`. pub fn new(low: X, high: X) -> Range { - assert!(low < high, "Range::new called with `low >= high`"); + fail_unless!(low < high, "Range::new called with `low >= high`"); SampleRange::construct_range(low, high) } } @@ -193,9 +193,9 @@ mod tests { let mut sampler: Range<$ty> = Range::new(low, high); for _ in range(0, 1000) { let v = sampler.sample(&mut rng); - assert!(low <= v && v < high); + fail_unless!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); - assert!(low <= v && v < high); + fail_unless!(low <= v && v < high); } } )* @@ -219,9 +219,9 @@ mod tests { let mut sampler: Range<$ty> = Range::new(low, high); for _ in range(0, 1000) { let v = sampler.sample(&mut rng); - assert!(low <= v && v < high); + fail_unless!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); - assert!(low <= v && v < high); + fail_unless!(low <= v && v < high); } } )* diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 7218f83d66203..261ea11000dcf 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -219,7 +219,7 @@ pub trait Rng { /// println!("{}", m); /// ``` fn gen_range(&mut self, low: T, high: T) -> T { - assert!(low < high, "Rng.gen_range called with low >= high"); + fail_unless!(low < high, "Rng.gen_range called with low >= high"); Range::new(low, high).ind_sample(self) } @@ -493,7 +493,7 @@ impl Rng for XorShiftRng { impl SeedableRng<[u32, .. 4]> for XorShiftRng { /// Reseed an XorShiftRng. This will fail if `seed` is entirely 0. fn reseed(&mut self, seed: [u32, .. 4]) { - assert!(!seed.iter().all(|&x| x == 0), + fail_unless!(!seed.iter().all(|&x| x == 0), "XorShiftRng.reseed called with an all zero seed."); self.x = seed[0]; @@ -504,7 +504,7 @@ impl SeedableRng<[u32, .. 4]> for XorShiftRng { /// Create a new XorShiftRng. This will fail if `seed` is entirely 0. fn from_seed(seed: [u32, .. 4]) -> XorShiftRng { - assert!(!seed.iter().all(|&x| x == 0), + fail_unless!(!seed.iter().all(|&x| x == 0), "XorShiftRng::from_seed called with an all zero seed."); XorShiftRng { @@ -694,14 +694,14 @@ mod test { let mut r = rng(); for _ in range(0, 1000) { let a = r.gen_range(-3i, 42); - assert!(a >= -3 && a < 42); + fail_unless!(a >= -3 && a < 42); assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(-12, -11), -12); } for _ in range(0, 1000) { let a = r.gen_range(10, 42); - assert!(a >= 10 && a < 42); + fail_unless!(a >= 10 && a < 42); assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(3_000_000u, 3_000_001), 3_000_000); } @@ -766,7 +766,7 @@ mod test { fn test_choose_option() { let mut r = rng(); let v: &[int] = &[]; - assert!(r.choose_option(v).is_none()); + fail_unless!(r.choose_option(v).is_none()); let i = 1; let v = [1,1,1]; @@ -814,7 +814,7 @@ mod test { assert_eq!(small_sample.len(), 5); assert_eq!(large_sample.len(), vals.len()); - assert!(small_sample.iter().all(|e| { + fail_unless!(small_sample.iter().all(|e| { **e >= MIN_VAL && **e <= MAX_VAL })); } diff --git a/src/libstd/rand/rand_impls.rs b/src/libstd/rand/rand_impls.rs index 8f4752b3c44c7..81653144b3494 100644 --- a/src/libstd/rand/rand_impls.rs +++ b/src/libstd/rand/rand_impls.rs @@ -244,8 +244,8 @@ mod tests { #[test] fn floating_point_edge_cases() { // the test for exact equality is correct here. - assert!(ConstantRng(0xffff_ffff).gen::() != 1.0) - assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::() != 1.0) + fail_unless!(ConstantRng(0xffff_ffff).gen::() != 1.0) + fail_unless!(ConstantRng(0xffff_ffff_ffff_ffff).gen::() != 1.0) } #[test] @@ -256,10 +256,10 @@ mod tests { for _ in range(0, 1_000) { // strict inequalities let Open01(f) = rng.gen::>(); - assert!(0.0 < f && f < 1.0); + fail_unless!(0.0 < f && f < 1.0); let Open01(f) = rng.gen::>(); - assert!(0.0 < f && f < 1.0); + fail_unless!(0.0 < f && f < 1.0); } } @@ -269,10 +269,10 @@ mod tests { for _ in range(0, 1_000) { // strict inequalities let Closed01(f) = rng.gen::>(); - assert!(0.0 <= f && f <= 1.0); + fail_unless!(0.0 <= f && f <= 1.0); let Closed01(f) = rng.gen::>(); - assert!(0.0 <= f && f <= 1.0); + fail_unless!(0.0 <= f && f <= 1.0); } } } diff --git a/src/libstd/rand/reseeding.rs b/src/libstd/rand/reseeding.rs index 758ca22e5c3ec..395af27debc8c 100644 --- a/src/libstd/rand/reseeding.rs +++ b/src/libstd/rand/reseeding.rs @@ -218,6 +218,6 @@ mod test { for &x in v.iter() { sum += x as f64; } - assert!(sum / v.len() as f64 != 0.0); + fail_unless!(sum / v.len() as f64 != 0.0); } } diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index ea3d5e0edac01..ff45c94a288ce 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -236,7 +236,7 @@ mod tests { fn test_live() { let x = Rc::new(5); let y = x.downgrade(); - assert!(y.upgrade().is_some()); + fail_unless!(y.upgrade().is_some()); } #[test] @@ -244,7 +244,7 @@ mod tests { let x = Rc::new(5); let y = x.downgrade(); drop(x); - assert!(y.upgrade().is_none()); + fail_unless!(y.upgrade().is_none()); } #[test] @@ -252,7 +252,7 @@ mod tests { // see issue #11532 use gc::Gc; let a = Rc::new(RefCell::new(Gc::new(1))); - assert!(a.borrow().try_borrow_mut().is_some()); + fail_unless!(a.borrow().try_borrow_mut().is_some()); } #[test] diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 39e8b6ad6c1d2..0cfe338ac32d8 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -233,7 +233,7 @@ impl fmt::Show for Result { /// } /// let v = [1u, 2, 3]; /// let res = collect(v.iter().map(|&x| inc_conditionally(x))); -/// assert!(res == Ok(~[2u, 3, 4])); +/// fail_unless!(res == Ok(~[2u, 3, 4])); #[inline] pub fn collect>, V: FromIterator>(iter: Iter) -> Result { // FIXME(#11084): This should be twice as fast once this bug is closed. diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 6f73265978bf4..ff4805e592361 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -147,9 +147,9 @@ mod imp { let expected = ~[bytes!("happy").to_owned(), bytes!("today?").to_owned()]; put(expected.clone()); - assert!(clone() == Some(expected.clone())); - assert!(take() == Some(expected.clone())); - assert!(take() == None); + fail_unless!(clone() == Some(expected.clone())); + fail_unless!(take() == Some(expected.clone())); + fail_unless!(take() == None); (|| { }).finally(|| { diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs index 8567f0e025161..068e85ed3059d 100644 --- a/src/libstd/rt/crate_map.rs +++ b/src/libstd/rt/crate_map.rs @@ -144,10 +144,10 @@ mod tests { let mut cnt = 0; unsafe { iter_crate_map(&root_crate, |entry| { - assert!(*entry.log_level == 3); + fail_unless!(*entry.log_level == 3); cnt += 1; }); - assert!(cnt == 1); + fail_unless!(cnt == 1); } } @@ -186,10 +186,10 @@ mod tests { let mut cnt = 0; unsafe { iter_crate_map(&root_crate, |entry| { - assert!(*entry.log_level == cnt); + fail_unless!(*entry.log_level == cnt); cnt += 1; }); - assert!(cnt == 4); + fail_unless!(cnt == 4); } } } diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 8128bb021487d..b416945ec7cd6 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -25,7 +25,7 @@ pub fn get_box_size(body_size: uint, body_align: uint) -> uint { // of two. #[inline] fn align_to(size: uint, align: uint) -> uint { - assert!(align != 0); + fail_unless!(align != 0); (size + align - 1) & !(align - 1) } diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs index 76a672b79cada..53d9bd9300cc0 100644 --- a/src/libstd/rt/local.rs +++ b/src/libstd/rt/local.rs @@ -116,7 +116,7 @@ mod test { let t: ~Task = Local::try_take().unwrap(); let u: Option<~Task> = Local::try_take(); - assert!(u.is_none()); + fail_unless!(u.is_none()); cleanup_task(t); }); diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 8a42cd7356544..3a3220fc48399 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -122,7 +122,7 @@ impl LocalHeap { impl Drop for LocalHeap { fn drop(&mut self) { - assert!(self.live_allocs.is_null()); + fail_unless!(self.live_allocs.is_null()); } } diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index b86a9612d7061..9140bc900a751 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -199,13 +199,13 @@ pub fn init() { fn parse_logging_spec_valid() { let dirs = parse_logging_spec(~"crate1::mod1=1,crate1::mod2,crate2=4"); assert_eq!(dirs.len(), 3); - assert!(dirs[0].name == Some(~"crate1::mod1")); + fail_unless!(dirs[0].name == Some(~"crate1::mod1")); assert_eq!(dirs[0].level, 1); - assert!(dirs[1].name == Some(~"crate1::mod2")); + fail_unless!(dirs[1].name == Some(~"crate1::mod2")); assert_eq!(dirs[1].level, MAX_LOG_LEVEL); - assert!(dirs[2].name == Some(~"crate2")); + fail_unless!(dirs[2].name == Some(~"crate2")); assert_eq!(dirs[2].level, 4); } @@ -214,7 +214,7 @@ fn parse_logging_spec_invalid_crate() { // test parse_logging_spec with multiple = in specification let dirs = parse_logging_spec(~"crate1::mod1=1=2,crate2=4"); assert_eq!(dirs.len(), 1); - assert!(dirs[0].name == Some(~"crate2")); + fail_unless!(dirs[0].name == Some(~"crate2")); assert_eq!(dirs[0].level, 4); } @@ -223,7 +223,7 @@ fn parse_logging_spec_invalid_log_level() { // test parse_logging_spec with 'noNumber' as log level let dirs = parse_logging_spec(~"crate1::mod1=noNumber,crate2=4"); assert_eq!(dirs.len(), 1); - assert!(dirs[0].name == Some(~"crate2")); + fail_unless!(dirs[0].name == Some(~"crate2")); assert_eq!(dirs[0].level, 4); } @@ -232,7 +232,7 @@ fn parse_logging_spec_string_log_level() { // test parse_logging_spec with 'warn' as log level let dirs = parse_logging_spec(~"crate1::mod1=wrong,crate2=warn"); assert_eq!(dirs.len(), 1); - assert!(dirs[0].name == Some(~"crate2")); + fail_unless!(dirs[0].name == Some(~"crate2")); assert_eq!(dirs[0].level, 2); } @@ -241,9 +241,9 @@ fn parse_logging_spec_global() { // test parse_logging_spec with no crate let dirs = parse_logging_spec(~"warn,crate2=4"); assert_eq!(dirs.len(), 2); - assert!(dirs[0].name == None); + fail_unless!(dirs[0].name == None); assert_eq!(dirs[0].level, 2); - assert!(dirs[1].name == Some(~"crate2")); + fail_unless!(dirs[1].name == Some(~"crate2")); assert_eq!(dirs[1].level, 4); } @@ -256,8 +256,8 @@ fn update_entry_match_full_path() { unsafe { let entry= &ModEntry {name:"crate1::mod1", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == 2); - assert!(m == 1); + fail_unless!(*entry.log_level == 2); + fail_unless!(m == 1); } } @@ -269,8 +269,8 @@ fn update_entry_no_match() { unsafe { let entry= &ModEntry {name: "crate3::mod1", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == DEFAULT_LOG_LEVEL); - assert!(m == 0); + fail_unless!(*entry.log_level == DEFAULT_LOG_LEVEL); + fail_unless!(m == 0); } } @@ -282,8 +282,8 @@ fn update_entry_match_beginning() { unsafe { let entry= &ModEntry {name: "crate2::mod1", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == 3); - assert!(m == 1); + fail_unless!(*entry.log_level == 3); + fail_unless!(m == 1); } } @@ -296,8 +296,8 @@ fn update_entry_match_beginning_longest_match() { unsafe { let entry = &ModEntry {name: "crate2::mod1", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == 4); - assert!(m == 1); + fail_unless!(*entry.log_level == 4); + fail_unless!(m == 1); } } @@ -310,11 +310,11 @@ fn update_entry_match_default() { unsafe { let entry= &ModEntry {name: "crate1::mod1", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == 2); - assert!(m == 1); + fail_unless!(*entry.log_level == 2); + fail_unless!(m == 1); let entry= &ModEntry {name: "crate2::mod2", log_level: level}; let m = update_entry(dirs, transmute(entry)); - assert!(*entry.log_level == 3); - assert!(m == 1); + fail_unless!(*entry.log_level == 3); + fail_unless!(m == 1); } } diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 72ba98eab4f7d..81feddab3f1a8 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -201,7 +201,7 @@ impl Task { /// task. It is illegal to replace a previous runtime object in this task /// with this argument. pub fn put_runtime(&mut self, ops: ~Runtime) { - assert!(self.imp.is_none()); + fail_unless!(self.imp.is_none()); self.imp = Some(ops); } @@ -328,7 +328,7 @@ impl BlockedTask { // This assertion has two flavours because the wake involves an atomic op. // In the faster version, destructors will fail dramatically instead. #[cfg(not(test))] pub fn trash(self) { } - #[cfg(test)] pub fn trash(self) { assert!(self.wake().is_none()); } + #[cfg(test)] pub fn trash(self) { fail_unless!(self.wake().is_none()); } /// Create a blocked task, unless the task was already killed. pub fn block(task: ~Task) -> BlockedTask { @@ -411,8 +411,8 @@ mod test { fn local_heap() { let a = @5; let b = a; - assert!(*a == 5); - assert!(*b == 5); + fail_unless!(*a == 5); + fail_unless!(*b == 5); } #[test] @@ -420,20 +420,20 @@ mod test { use local_data; local_data_key!(key: @~str) local_data::set(key, @~"data"); - assert!(*local_data::get(key, |k| k.map(|k| *k)).unwrap() == ~"data"); + fail_unless!(*local_data::get(key, |k| k.map(|k| *k)).unwrap() == ~"data"); local_data_key!(key2: @~str) local_data::set(key2, @~"data"); - assert!(*local_data::get(key2, |k| k.map(|k| *k)).unwrap() == ~"data"); + fail_unless!(*local_data::get(key2, |k| k.map(|k| *k)).unwrap() == ~"data"); } #[test] fn unwind() { let result = task::try(proc()()); rtdebug!("trying first assert"); - assert!(result.is_ok()); + fail_unless!(result.is_ok()); let result = task::try::<()>(proc() fail!()); rtdebug!("trying second assert"); - assert!(result.is_err()); + fail_unless!(result.is_err()); } #[test] @@ -452,14 +452,14 @@ mod test { fn comm_stream() { let (port, chan) = Chan::new(); chan.send(10); - assert!(port.recv() == 10); + fail_unless!(port.recv() == 10); } #[test] fn comm_shared_chan() { let (port, chan) = Chan::new(); chan.send(10); - assert!(port.recv() == 10); + fail_unless!(port.recv() == 10); } #[test] diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index b443182c157a3..89ca08d739795 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -123,10 +123,10 @@ impl Thread { /// Wait for this thread to finish, returning the result of the thread's /// calculation. pub fn join(mut self) -> T { - assert!(!self.joined); + fail_unless!(!self.joined); unsafe { imp::join(self.native) }; self.joined = true; - assert!(self.packet.is_some()); + fail_unless!(self.packet.is_some()); self.packet.take_unwrap() } } @@ -177,7 +177,7 @@ mod imp { } pub unsafe fn detach(native: rust_thread) { - assert!(libc::CloseHandle(native) != 0); + fail_unless!(libc::CloseHandle(native) != 0); } pub unsafe fn yield_now() { diff --git a/src/libstd/rt/thread_local_storage.rs b/src/libstd/rt/thread_local_storage.rs index 40d9523cf3aac..18f07607f6804 100644 --- a/src/libstd/rt/thread_local_storage.rs +++ b/src/libstd/rt/thread_local_storage.rs @@ -65,12 +65,12 @@ pub type Key = DWORD; pub unsafe fn create(key: &mut Key) { static TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF; *key = TlsAlloc(); - assert!(*key != TLS_OUT_OF_INDEXES); + fail_unless!(*key != TLS_OUT_OF_INDEXES); } #[cfg(windows)] pub unsafe fn set(key: Key, value: *mut u8) { - assert!(0 != TlsSetValue(key, value as *mut ::libc::c_void)) + fail_unless!(0 != TlsSetValue(key, value as *mut ::libc::c_void)) } #[cfg(windows)] @@ -80,7 +80,7 @@ pub unsafe fn get(key: Key) -> *mut u8 { #[cfg(windows)] pub unsafe fn destroy(key: Key) { - assert!(TlsFree(key) != 0); + fail_unless!(TlsFree(key) != 0); } #[cfg(windows)] diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index ef8bd94c89766..ad3c02a5143d3 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -412,7 +412,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file: &'static str, line: uint) -> begin_unwind_inner(~fmt::format(msg), file, line) } -/// This is the entry point of unwinding for fail!() and assert!(). +/// This is the entry point of unwinding for fail!() and fail_unless!(). #[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible pub fn begin_unwind(msg: M, file: &'static str, line: uint) -> ! { // Note that this should be the only allocation performed in this code path. diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 9ea8f6447dd6a..7dabba9eebc13 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -366,10 +366,10 @@ mod tests { #[cfg(not(target_os="android"))] // FIXME(#10380) fn test_process_status() { let mut status = run::process_status("false", []).unwrap(); - assert!(status.matches_exit_status(1)); + fail_unless!(status.matches_exit_status(1)); status = run::process_status("true", []).unwrap(); - assert!(status.success()); + fail_unless!(status.success()); } #[test] @@ -388,7 +388,7 @@ mod tests { = run::process_output("echo", [~"hello"]).unwrap(); let output_str = str::from_utf8_owned(output).unwrap(); - assert!(status.success()); + fail_unless!(status.success()); assert_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { @@ -403,9 +403,9 @@ mod tests { let run::ProcessOutput {status, output, error} = run::process_output("mkdir", [~"."]).unwrap(); - assert!(status.matches_exit_status(1)); + fail_unless!(status.matches_exit_status(1)); assert_eq!(output, ~[]); - assert!(!error.is_empty()); + fail_unless!(!error.is_empty()); } #[test] @@ -451,7 +451,7 @@ mod tests { fn test_finish_once() { let mut prog = run::Process::new("false", [], run::ProcessOptions::new()) .unwrap(); - assert!(prog.finish().matches_exit_status(1)); + fail_unless!(prog.finish().matches_exit_status(1)); } #[test] @@ -459,8 +459,8 @@ mod tests { fn test_finish_twice() { let mut prog = run::Process::new("false", [], run::ProcessOptions::new()) .unwrap(); - assert!(prog.finish().matches_exit_status(1)); - assert!(prog.finish().matches_exit_status(1)); + fail_unless!(prog.finish().matches_exit_status(1)); + fail_unless!(prog.finish().matches_exit_status(1)); } #[test] @@ -473,7 +473,7 @@ mod tests { = prog.finish_with_output(); let output_str = str::from_utf8_owned(output).unwrap(); - assert!(status.success()); + fail_unless!(status.success()); assert_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { @@ -492,7 +492,7 @@ mod tests { let output_str = str::from_utf8_owned(output).unwrap(); - assert!(status.success()); + fail_unless!(status.success()); assert_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { @@ -502,7 +502,7 @@ mod tests { let run::ProcessOutput {status, output, error} = prog.finish_with_output(); - assert!(status.success()); + fail_unless!(status.success()); assert_eq!(output, ~[]); // FIXME #7224 if !running_on_valgrind() { @@ -599,7 +599,7 @@ mod tests { let r = os::env(); for &(ref k, ref v) in r.iter() { // don't check windows magical empty-named variables - assert!(k.is_empty() || output.contains(format!("{}={}", *k, *v))); + fail_unless!(k.is_empty() || output.contains(format!("{}={}", *k, *v))); } } #[test] @@ -614,7 +614,7 @@ mod tests { for &(ref k, ref v) in r.iter() { // don't check android RANDOM variables if *k != ~"RANDOM" { - assert!(output.contains(format!("{}={}", *k, *v)) || + fail_unless!(output.contains(format!("{}={}", *k, *v)) || output.contains(format!("{}=\'{}\'", *k, *v))); } } @@ -629,6 +629,6 @@ mod tests { let mut prog = run_env(Some(new_env)); let output = str::from_utf8_owned(prog.finish_with_output().output).unwrap(); - assert!(output.contains("RUN_TEST_NEW_ENV=123")); + fail_unless!(output.contains("RUN_TEST_NEW_ENV=123")); } } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 123b4957599f5..4233e364d9993 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -153,7 +153,7 @@ impl<'a> ToStr for &'a str { /// /// Fails if invalid UTF-8 pub fn from_byte(b: u8) -> ~str { - assert!(b < 128u8); + fail_unless!(b < 128u8); unsafe { ::cast::transmute(~[b]) } } @@ -1394,7 +1394,7 @@ pub mod raw { ptr::copy_memory(v.as_mut_ptr(), buf, len); v.set_len(len); - assert!(is_utf8(v)); + fail_unless!(is_utf8(v)); ::cast::transmute(v) } @@ -1445,7 +1445,7 @@ pub mod raw { curr = s.offset(len as int); } let v = Slice { data: s, len: len }; - assert!(is_utf8(::cast::transmute(v))); + fail_unless!(is_utf8(::cast::transmute(v))); ::cast::transmute(v) } @@ -1459,8 +1459,8 @@ pub mod raw { /// If end is greater than the length of the string. #[inline] pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { - assert!(begin <= end); - assert!(end <= s.len()); + fail_unless!(begin <= end); + fail_unless!(end <= s.len()); slice_unchecked(s, begin, end) } @@ -1495,7 +1495,7 @@ pub mod raw { /// The caller must preserve the valid UTF-8 property. pub unsafe fn pop_byte(s: &mut ~str) -> u8 { let len = s.len(); - assert!((len > 0u)); + fail_unless!((len > 0u)); let b = s[len - 1u]; s.set_len(len - 1); return b; @@ -1505,7 +1505,7 @@ pub mod raw { /// The caller must preserve the valid UTF-8 property. pub unsafe fn shift_byte(s: &mut ~str) -> u8 { let len = s.len(); - assert!((len > 0u)); + fail_unless!((len > 0u)); let b = s[0]; *s = s.slice(1, len).to_owned(); return b; @@ -1899,10 +1899,10 @@ pub trait StrSlice<'a> { /// # Example /// /// ```rust - /// assert!(" \t\n".is_whitespace()); - /// assert!("".is_whitespace()); + /// fail_unless!(" \t\n".is_whitespace()); + /// fail_unless!("".is_whitespace()); /// - /// assert!( !"abc".is_whitespace()); + /// fail_unless!( !"abc".is_whitespace()); /// ``` fn is_whitespace(&self) -> bool; @@ -1914,10 +1914,10 @@ pub trait StrSlice<'a> { /// # Example /// /// ```rust - /// assert!("Löwe老虎Léopard123".is_alphanumeric()); - /// assert!("".is_alphanumeric()); + /// fail_unless!("Löwe老虎Léopard123".is_alphanumeric()); + /// fail_unless!("".is_alphanumeric()); /// - /// assert!( !" &*~".is_alphanumeric()); + /// fail_unless!( !" &*~".is_alphanumeric()); /// ``` fn is_alphanumeric(&self) -> bool; @@ -2142,16 +2142,16 @@ pub trait StrSlice<'a> { /// /// ```rust /// let s = "Löwe 老虎 Léopard"; - /// assert!(s.is_char_boundary(0)); + /// fail_unless!(s.is_char_boundary(0)); /// // start of `老` - /// assert!(s.is_char_boundary(6)); - /// assert!(s.is_char_boundary(s.len())); + /// fail_unless!(s.is_char_boundary(6)); + /// fail_unless!(s.is_char_boundary(s.len())); /// /// // second byte of `ö` - /// assert!(!s.is_char_boundary(2)); + /// fail_unless!(!s.is_char_boundary(2)); /// /// // third byte of `老` - /// assert!(!s.is_char_boundary(8)); + /// fail_unless!(!s.is_char_boundary(8)); /// ``` fn is_char_boundary(&self, index: uint) -> bool; @@ -2334,9 +2334,9 @@ pub trait StrSlice<'a> { /// let string = "a\nb\nc"; /// let lines: ~[&str] = string.lines().collect(); /// - /// assert!(string.subslice_offset(lines[0]) == 0); // &"a" - /// assert!(string.subslice_offset(lines[1]) == 2); // &"b" - /// assert!(string.subslice_offset(lines[2]) == 4); // &"c" + /// fail_unless!(string.subslice_offset(lines[0]) == 0); // &"a" + /// fail_unless!(string.subslice_offset(lines[1]) == 2); // &"b" + /// fail_unless!(string.subslice_offset(lines[2]) == 4); // &"c" /// ``` fn subslice_offset(&self, inner: &str) -> uint; @@ -2436,7 +2436,7 @@ impl<'a> StrSlice<'a> for &'a str { #[inline] fn match_indices(&self, sep: &'a str) -> MatchIndices<'a> { - assert!(!sep.is_empty()) + fail_unless!(!sep.is_empty()) MatchIndices { haystack: *self, needle: sep, @@ -2502,7 +2502,7 @@ impl<'a> StrSlice<'a> for &'a str { #[inline] fn slice(&self, begin: uint, end: uint) -> &'a str { - assert!(self.is_char_boundary(begin) && self.is_char_boundary(end)); + fail_unless!(self.is_char_boundary(begin) && self.is_char_boundary(end)); unsafe { raw::slice_bytes(*self, begin, end) } } @@ -2513,12 +2513,12 @@ impl<'a> StrSlice<'a> for &'a str { #[inline] fn slice_to(&self, end: uint) -> &'a str { - assert!(self.is_char_boundary(end)); + fail_unless!(self.is_char_boundary(end)); unsafe { raw::slice_bytes(*self, 0, end) } } fn slice_chars(&self, begin: uint, end: uint) -> &'a str { - assert!(begin <= end); + fail_unless!(begin <= end); let mut count = 0; let mut begin_byte = None; let mut end_byte = None; @@ -2640,11 +2640,11 @@ impl<'a> StrSlice<'a> for &'a str { if (ch & 0xFFFF_u32) == ch { // The BMP falls through (assuming non-surrogate, as it // should) - assert!(ch <= 0xD7FF_u32 || ch >= 0xE000_u32); + fail_unless!(ch <= 0xD7FF_u32 || ch >= 0xE000_u32); u.push(ch as u16) } else { // Supplementary planes break into surrogates. - assert!(ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32); + fail_unless!(ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32); ch -= 0x1_0000_u32; let w1 = 0xD800_u16 | ((ch >> 10) as u16); let w2 = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16); @@ -2671,7 +2671,7 @@ impl<'a> StrSlice<'a> for &'a str { fn multibyte_char_range_at(s: &str, i: uint) -> CharRange { let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; - assert!((w != 0)); + fail_unless!((w != 0)); val = utf8_first_byte!(val, w); val = utf8_acc_cont_byte!(val, s[i + 1]); @@ -2703,7 +2703,7 @@ impl<'a> StrSlice<'a> for &'a str { let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; - assert!((w != 0)); + fail_unless!((w != 0)); val = utf8_first_byte!(val, w); val = utf8_acc_cont_byte!(val, s[i + 1]); @@ -2816,8 +2816,8 @@ impl<'a> StrSlice<'a> for &'a str { let b_start = inner.as_ptr() as uint; let b_end = b_start + inner.len(); - assert!(a_start <= b_start); - assert!(b_end <= a_end); + fail_unless!(a_start <= b_start); + fail_unless!(b_end <= a_end); b_start - a_start } @@ -2955,7 +2955,7 @@ impl OwnedStr for ~str { #[inline] fn pop_char(&mut self) -> char { let end = self.len(); - assert!(end > 0u); + fail_unless!(end > 0u); let CharRange {ch, next} = self.char_range_at_reverse(end); unsafe { self.set_len(next); } return ch; @@ -3026,8 +3026,8 @@ impl OwnedStr for ~str { #[inline] fn truncate(&mut self, len: uint) { - assert!(len <= self.len()); - assert!(self.is_char_boundary(len)); + fail_unless!(len <= self.len()); + fail_unless!(self.is_char_boundary(len)); unsafe { self.set_len(len); } } @@ -3095,24 +3095,24 @@ mod tests { #[test] fn test_eq() { - assert!((eq(&~"", &~""))); - assert!((eq(&~"foo", &~"foo"))); - assert!((!eq(&~"foo", &~"bar"))); + fail_unless!((eq(&~"", &~""))); + fail_unless!((eq(&~"foo", &~"foo"))); + fail_unless!((!eq(&~"foo", &~"bar"))); } #[test] fn test_eq_slice() { - assert!((eq_slice("foobar".slice(0, 3), "foo"))); - assert!((eq_slice("barfoo".slice(3, 6), "foo"))); - assert!((!eq_slice("foo1", "foo2"))); + fail_unless!((eq_slice("foobar".slice(0, 3), "foo"))); + fail_unless!((eq_slice("barfoo".slice(3, 6), "foo"))); + fail_unless!((!eq_slice("foo1", "foo2"))); } #[test] fn test_le() { - assert!("" <= ""); - assert!("" <= "foo"); - assert!("foo" <= "foo"); - assert!("foo" != "bar"); + fail_unless!("" <= ""); + fail_unless!("" <= "foo"); + fail_unless!("foo" <= "foo"); + fail_unless!("foo" != "bar"); } #[test] @@ -3139,8 +3139,8 @@ mod tests { fn test_find() { assert_eq!("hello".find('l'), Some(2u)); assert_eq!("hello".find(|c:char| c == 'o'), Some(4u)); - assert!("hello".find('x').is_none()); - assert!("hello".find(|c:char| c == 'x').is_none()); + fail_unless!("hello".find('x').is_none()); + fail_unless!("hello".find(|c:char| c == 'x').is_none()); assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u)); assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u)); } @@ -3149,8 +3149,8 @@ mod tests { fn test_rfind() { assert_eq!("hello".rfind('l'), Some(3u)); assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u)); - assert!("hello".rfind('x').is_none()); - assert!("hello".rfind(|c:char| c == 'x').is_none()); + fail_unless!("hello".rfind('x').is_none()); + fail_unless!("hello".rfind(|c:char| c == 'x').is_none()); assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u)); assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u)); } @@ -3283,16 +3283,16 @@ mod tests { fn test_find_str() { // byte positions assert_eq!("".find_str(""), Some(0u)); - assert!("banana".find_str("apple pie").is_none()); + fail_unless!("banana".find_str("apple pie").is_none()); let data = "abcabc"; assert_eq!(data.slice(0u, 6u).find_str("ab"), Some(0u)); assert_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u - 2u)); - assert!(data.slice(2u, 4u).find_str("ab").is_none()); + fail_unless!(data.slice(2u, 4u).find_str("ab").is_none()); let mut data = ~"ประเทศไทย中华Việt Nam"; data = data + data; - assert!(data.find_str("ไท华").is_none()); + fail_unless!(data.find_str("ไท华").is_none()); assert_eq!(data.slice(0u, 43u).find_str(""), Some(0u)); assert_eq!(data.slice(6u, 43u).find_str(""), Some(6u - 6u)); @@ -3394,36 +3394,36 @@ mod tests { rs } let letters = a_million_letter_a(); - assert!(half_a_million_letter_a() == + fail_unless!(half_a_million_letter_a() == unsafe {raw::slice_bytes(letters, 0u, 500000)}.to_owned()); } #[test] fn test_starts_with() { - assert!(("".starts_with(""))); - assert!(("abc".starts_with(""))); - assert!(("abc".starts_with("a"))); - assert!((!"a".starts_with("abc"))); - assert!((!"".starts_with("abc"))); - assert!((!"ödd".starts_with("-"))); - assert!(("ödd".starts_with("öd"))); + fail_unless!(("".starts_with(""))); + fail_unless!(("abc".starts_with(""))); + fail_unless!(("abc".starts_with("a"))); + fail_unless!((!"a".starts_with("abc"))); + fail_unless!((!"".starts_with("abc"))); + fail_unless!((!"ödd".starts_with("-"))); + fail_unless!(("ödd".starts_with("öd"))); } #[test] fn test_ends_with() { - assert!(("".ends_with(""))); - assert!(("abc".ends_with(""))); - assert!(("abc".ends_with("c"))); - assert!((!"a".ends_with("abc"))); - assert!((!"".ends_with("abc"))); - assert!((!"ddö".ends_with("-"))); - assert!(("ddö".ends_with("dö"))); + fail_unless!(("".ends_with(""))); + fail_unless!(("abc".ends_with(""))); + fail_unless!(("abc".ends_with("c"))); + fail_unless!((!"a".ends_with("abc"))); + fail_unless!((!"".ends_with("abc"))); + fail_unless!((!"ddö".ends_with("-"))); + fail_unless!(("ddö".ends_with("dö"))); } #[test] fn test_is_empty() { - assert!("".is_empty()); - assert!(!"a".is_empty()); + fail_unless!("".is_empty()); + fail_unless!(!"a".is_empty()); } #[test] @@ -3433,7 +3433,7 @@ mod tests { assert_eq!("a".replace(a, "b"), ~"b"); assert_eq!("ab".replace(a, "b"), ~"bb"); let test = "test"; - assert!(" test test ".replace(test, "toast") == + fail_unless!(" test test ".replace(test, "toast") == ~" toast toast "); assert_eq!(" test test ".replace(test, ""), ~" "); } @@ -3506,7 +3506,7 @@ mod tests { rs } let letters = a_million_letter_X(); - assert!(half_a_million_letter_X() == + fail_unless!(half_a_million_letter_X() == letters.slice(0u, 3u * 500000u).to_owned()); } @@ -3626,11 +3626,11 @@ mod tests { #[test] fn test_is_whitespace() { - assert!("".is_whitespace()); - assert!(" ".is_whitespace()); - assert!("\u2009".is_whitespace()); // Thin space - assert!(" \n\t ".is_whitespace()); - assert!(!" _ ".is_whitespace()); + fail_unless!("".is_whitespace()); + fail_unless!(" ".is_whitespace()); + fail_unless!("\u2009".is_whitespace()); // Thin space + fail_unless!(" \n\t ".is_whitespace()); + fail_unless!(!" _ ".is_whitespace()); } #[test] @@ -3659,31 +3659,31 @@ mod tests { #[test] fn test_is_utf8() { // deny overlong encodings - assert!(!is_utf8([0xc0, 0x80])); - assert!(!is_utf8([0xc0, 0xae])); - assert!(!is_utf8([0xe0, 0x80, 0x80])); - assert!(!is_utf8([0xe0, 0x80, 0xaf])); - assert!(!is_utf8([0xe0, 0x81, 0x81])); - assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac])); - assert!(!is_utf8([0xf4, 0x90, 0x80, 0x80])); + fail_unless!(!is_utf8([0xc0, 0x80])); + fail_unless!(!is_utf8([0xc0, 0xae])); + fail_unless!(!is_utf8([0xe0, 0x80, 0x80])); + fail_unless!(!is_utf8([0xe0, 0x80, 0xaf])); + fail_unless!(!is_utf8([0xe0, 0x81, 0x81])); + fail_unless!(!is_utf8([0xf0, 0x82, 0x82, 0xac])); + fail_unless!(!is_utf8([0xf4, 0x90, 0x80, 0x80])); // deny surrogates - assert!(!is_utf8([0xED, 0xA0, 0x80])); - assert!(!is_utf8([0xED, 0xBF, 0xBF])); + fail_unless!(!is_utf8([0xED, 0xA0, 0x80])); + fail_unless!(!is_utf8([0xED, 0xBF, 0xBF])); - assert!(is_utf8([0xC2, 0x80])); - assert!(is_utf8([0xDF, 0xBF])); - assert!(is_utf8([0xE0, 0xA0, 0x80])); - assert!(is_utf8([0xED, 0x9F, 0xBF])); - assert!(is_utf8([0xEE, 0x80, 0x80])); - assert!(is_utf8([0xEF, 0xBF, 0xBF])); - assert!(is_utf8([0xF0, 0x90, 0x80, 0x80])); - assert!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF])); + fail_unless!(is_utf8([0xC2, 0x80])); + fail_unless!(is_utf8([0xDF, 0xBF])); + fail_unless!(is_utf8([0xE0, 0xA0, 0x80])); + fail_unless!(is_utf8([0xED, 0x9F, 0xBF])); + fail_unless!(is_utf8([0xEE, 0x80, 0x80])); + fail_unless!(is_utf8([0xEF, 0xBF, 0xBF])); + fail_unless!(is_utf8([0xF0, 0x90, 0x80, 0x80])); + fail_unless!(is_utf8([0xF4, 0x8F, 0xBF, 0xBF])); } #[test] fn test_is_utf16() { - macro_rules! pos ( ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }); + macro_rules! pos ( ($($e:expr),*) => { { $(fail_unless!(is_utf16($e));)* } }); // non-surrogates pos!([0x0000], @@ -3703,7 +3703,7 @@ mod tests { [0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]); // negative tests - macro_rules! neg ( ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }); + macro_rules! neg ( ($($e:expr),*) => { { $(fail_unless!(!is_utf16($e));)* } }); neg!( // surrogate + regular unit @@ -3831,27 +3831,27 @@ mod tests { #[test] fn test_contains() { - assert!("abcde".contains("bcd")); - assert!("abcde".contains("abcd")); - assert!("abcde".contains("bcde")); - assert!("abcde".contains("")); - assert!("".contains("")); - assert!(!"abcde".contains("def")); - assert!(!"".contains("a")); + fail_unless!("abcde".contains("bcd")); + fail_unless!("abcde".contains("abcd")); + fail_unless!("abcde".contains("bcde")); + fail_unless!("abcde".contains("")); + fail_unless!("".contains("")); + fail_unless!(!"abcde".contains("def")); + fail_unless!(!"".contains("a")); let data = ~"ประเทศไทย中华Việt Nam"; - assert!(data.contains("ประเ")); - assert!(data.contains("ะเ")); - assert!(data.contains("中华")); - assert!(!data.contains("ไท华")); + fail_unless!(data.contains("ประเ")); + fail_unless!(data.contains("ะเ")); + fail_unless!(data.contains("中华")); + fail_unless!(!data.contains("ไท华")); } #[test] fn test_contains_char() { - assert!("abc".contains_char('b')); - assert!("a".contains_char('a')); - assert!(!"abc".contains_char('d')); - assert!(!"".contains_char('a')); + fail_unless!("abc".contains_char('b')); + fail_unless!("a".contains_char('a')); + fail_unless!(!"abc".contains_char('d')); + fail_unless!(!"".contains_char('a')); } #[test] @@ -3898,7 +3898,7 @@ mod tests { for p in pairs.iter() { let (s, u) = (*p).clone(); - assert!(is_utf16(u)); + fail_unless!(is_utf16(u)); assert_eq!(s.to_utf16(), u); assert_eq!(from_utf16(u).unwrap(), s); @@ -3963,7 +3963,7 @@ mod tests { let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let mut pos = 0; for ch in v.iter() { - assert!(s.char_at(pos) == *ch); + fail_unless!(s.char_at(pos) == *ch); pos += from_char(*ch).len(); } } @@ -3974,7 +3974,7 @@ mod tests { let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let mut pos = s.len(); for ch in v.rev_iter() { - assert!(s.char_at_reverse(pos) == *ch); + fail_unless!(s.char_at_reverse(pos) == *ch); pos -= from_char(*ch).len(); } } @@ -4087,7 +4087,7 @@ mod tests { let s = "ศไทย中华Việt Nam"; let mut it = s.chars(); it.next(); - assert!(it.zip(it.clone()).all(|(x,y)| x == y)); + fail_unless!(it.zip(it.clone()).all(|(x,y)| x == y)); } #[test] @@ -4448,7 +4448,7 @@ mod tests { assert_eq!(s.as_slice(), "abcde"); assert_eq!(s.to_str(), ~"abcde"); assert_eq!(format!("{}", s), ~"abcde"); - assert!(s.lt(&Owned(~"bcdef"))); + fail_unless!(s.lt(&Owned(~"bcdef"))); assert_eq!(Slice(""), Default::default()); let o = Owned(~"abcde"); @@ -4456,27 +4456,27 @@ mod tests { assert_eq!(o.as_slice(), "abcde"); assert_eq!(o.to_str(), ~"abcde"); assert_eq!(format!("{}", o), ~"abcde"); - assert!(o.lt(&Slice("bcdef"))); + fail_unless!(o.lt(&Slice("bcdef"))); assert_eq!(Owned(~""), Default::default()); assert_eq!(s.cmp(&o), Equal); - assert!(s.equals(&o)); - assert!(s.equiv(&o)); + fail_unless!(s.equals(&o)); + fail_unless!(s.equiv(&o)); assert_eq!(o.cmp(&s), Equal); - assert!(o.equals(&s)); - assert!(o.equiv(&s)); + fail_unless!(o.equals(&s)); + fail_unless!(o.equiv(&s)); } #[test] fn test_maybe_owned_methods() { let s = Slice("abcde"); - assert!(s.is_slice()); - assert!(!s.is_owned()); + fail_unless!(s.is_slice()); + fail_unless!(!s.is_owned()); let o = Owned(~"abcde"); - assert!(!o.is_slice()); - assert!(o.is_owned()); + fail_unless!(!o.is_slice()); + fail_unless!(o.is_owned()); } #[test] diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs index 5c452018b9b7e..e9d5c72b7a263 100644 --- a/src/libstd/sync/arc.rs +++ b/src/libstd/sync/arc.rs @@ -80,7 +80,7 @@ impl UnsafeArc { #[inline] pub fn get(&self) -> *mut T { unsafe { - assert!((*self.data).count.load(Relaxed) > 0); + fail_unless!((*self.data).count.load(Relaxed) > 0); return &mut (*self.data).data as *mut T; } } @@ -90,7 +90,7 @@ impl UnsafeArc { #[inline] pub fn get_immut(&self) -> *T { unsafe { - assert!((*self.data).count.load(Relaxed) > 0); + fail_unless!((*self.data).count.load(Relaxed) > 0); return &(*self.data).data as *T; } } @@ -109,7 +109,7 @@ impl Clone for UnsafeArc { unsafe { // This barrier might be unnecessary, but I'm not sure... let old_count = (*self.data).count.fetch_add(1, Acquire); - assert!(old_count >= 1); + fail_unless!(old_count >= 1); return UnsafeArc { data: self.data }; } } @@ -127,7 +127,7 @@ impl Drop for UnsafeArc{ // Must be acquire+release, not just release, to make sure this // doesn't get reordered to after the unwrapper pointer load. let old_count = (*self.data).count.fetch_sub(1, SeqCst); - assert!(old_count >= 1); + fail_unless!(old_count >= 1); if old_count == 1 { let _: ~ArcData = cast::transmute(self.data); } diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index 00ce07d747f94..2c4296092cf92 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -537,17 +537,17 @@ mod test { #[test] fn flag() { let mut flg = AtomicFlag::new(); - assert!(!flg.test_and_set(SeqCst)); - assert!(flg.test_and_set(SeqCst)); + fail_unless!(!flg.test_and_set(SeqCst)); + fail_unless!(flg.test_and_set(SeqCst)); flg.clear(SeqCst); - assert!(!flg.test_and_set(SeqCst)); + fail_unless!(!flg.test_and_set(SeqCst)); } #[test] fn option_empty() { let mut option: AtomicOption<()> = AtomicOption::empty(); - assert!(option.is_empty(SeqCst)); + fail_unless!(option.is_empty(SeqCst)); } #[test] @@ -577,10 +577,10 @@ mod test { #[test] fn option_fill() { let mut p = AtomicOption::new(~1); - assert!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak! + fail_unless!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak! assert_eq!(p.take(SeqCst), Some(~1)); - assert!(p.fill(~2, SeqCst).is_none()); // shouldn't fail + fail_unless!(p.fill(~2, SeqCst).is_none()); // shouldn't fail assert_eq!(p.take(SeqCst), Some(~2)); } @@ -599,10 +599,10 @@ mod test { #[test] fn static_init() { unsafe { - assert!(!S_FLAG.test_and_set(SeqCst)); - assert!(!S_BOOL.load(SeqCst)); - assert!(S_INT.load(SeqCst) == 0); - assert!(S_UINT.load(SeqCst) == 0); + fail_unless!(!S_FLAG.test_and_set(SeqCst)); + fail_unless!(!S_BOOL.load(SeqCst)); + fail_unless!(S_INT.load(SeqCst) == 0); + fail_unless!(S_UINT.load(SeqCst) == 0); } } diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index 7ce760040e65e..9a2650231df63 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -346,7 +346,7 @@ impl Buffer { unsafe fn new(log_size: int) -> Buffer { let size = (1 << log_size) * mem::size_of::(); let buffer = libc::malloc(size as libc::size_t); - assert!(!buffer.is_null()); + fail_unless!(!buffer.is_null()); Buffer { storage: buffer as *T, log_size: log_size, diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs index 44825a1ef945b..df6a78eda3e6c 100644 --- a/src/libstd/sync/mpmc_bounded_queue.rs +++ b/src/libstd/sync/mpmc_bounded_queue.rs @@ -180,7 +180,7 @@ mod tests { native::task::spawn(proc() { let mut q = q; for i in range(0, nmsgs) { - assert!(q.push(i)); + fail_unless!(q.push(i)); } chan.send(()); }); diff --git a/src/libstd/sync/mpsc_queue.rs b/src/libstd/sync/mpsc_queue.rs index 2dc63380cb890..6268e639b331d 100644 --- a/src/libstd/sync/mpsc_queue.rs +++ b/src/libstd/sync/mpsc_queue.rs @@ -117,8 +117,8 @@ impl Queue { if !next.is_null() { self.tail = next; - assert!((*tail).value.is_none()); - assert!((*next).value.is_some()); + fail_unless!((*tail).value.is_none()); + fail_unless!((*next).value.is_some()); let ret = (*next).value.take_unwrap(); let _: ~Node = cast::transmute(tail); return Data(ret); diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs index a2c61a2b13579..7be75ceccf078 100644 --- a/src/libstd/sync/spsc_queue.rs +++ b/src/libstd/sync/spsc_queue.rs @@ -118,7 +118,7 @@ impl Queue { // Acquire a node (which either uses a cached one or allocates a new // one), and then append this to the 'head' node. let n = self.alloc(); - assert!((*n).value.is_none()); + fail_unless!((*n).value.is_none()); (*n).value = Some(t); (*n).next.store(0 as *mut Node, Relaxed); (*self.head).next.store(n, Release); @@ -168,7 +168,7 @@ impl Queue { let tail = self.tail; let next = (*tail).next.load(Acquire); if next.is_null() { return None } - assert!((*next).value.is_some()); + fail_unless!((*next).value.is_some()); let ret = (*next).value.take(); self.tail = next; diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 1de5322b157ed..6b2bf57e89e31 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -306,7 +306,7 @@ pub fn failing() -> bool { fn test_unnamed_task() { spawn(proc() { with_task_name(|name| { - assert!(name.is_none()); + fail_unless!(name.is_none()); }) }) } @@ -315,7 +315,7 @@ fn test_unnamed_task() { fn test_owned_named_task() { task().named(~"ada lovelace").spawn(proc() { with_task_name(|name| { - assert!(name.unwrap() == "ada lovelace"); + fail_unless!(name.unwrap() == "ada lovelace"); }) }) } @@ -324,7 +324,7 @@ fn test_owned_named_task() { fn test_static_named_task() { task().named("ada lovelace").spawn(proc() { with_task_name(|name| { - assert!(name.unwrap() == "ada lovelace"); + fail_unless!(name.unwrap() == "ada lovelace"); }) }) } @@ -333,7 +333,7 @@ fn test_static_named_task() { fn test_send_named_task() { task().named("ada lovelace".into_maybe_owned()).spawn(proc() { with_task_name(|name| { - assert!(name.unwrap() == "ada lovelace"); + fail_unless!(name.unwrap() == "ada lovelace"); }) }) } @@ -366,14 +366,14 @@ fn test_future_result() { let mut builder = task(); let result = builder.future_result(); builder.spawn(proc() {}); - assert!(result.recv().is_ok()); + fail_unless!(result.recv().is_ok()); let mut builder = task(); let result = builder.future_result(); builder.spawn(proc() { fail!(); }); - assert!(result.recv().is_err()); + fail_unless!(result.recv().is_err()); } #[test] #[should_fail] @@ -507,7 +507,7 @@ fn test_try_fail_message_static_str() { }) { Err(e) => { type T = &'static str; - assert!(e.is::()); + fail_unless!(e.is::()); assert_eq!(*e.move::().unwrap(), "static string"); } Ok(()) => fail!() @@ -521,7 +521,7 @@ fn test_try_fail_message_owned_str() { }) { Err(e) => { type T = ~str; - assert!(e.is::()); + fail_unless!(e.is::()); assert_eq!(*e.move::().unwrap(), ~"owned string"); } Ok(()) => fail!() @@ -535,9 +535,9 @@ fn test_try_fail_message_any() { }) { Err(e) => { type T = ~Any; - assert!(e.is::()); + fail_unless!(e.is::()); let any = e.move::().unwrap(); - assert!(any.is::()); + fail_unless!(any.is::()); assert_eq!(*any.move::().unwrap(), 413u16); } Ok(()) => fail!() diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index ab14e9f566778..a75340c4ae606 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -143,7 +143,7 @@ mod tests { assert_eq!(x.to_str(), ~"[]"); assert_eq!((~[1]).to_str(), ~"[1]"); assert_eq!((~[1, 2, 3]).to_str(), ~"[1, 2, 3]"); - assert!((~[~[], ~[1], ~[1, 1]]).to_str() == + fail_unless!((~[~[], ~[1], ~[1, 1]]).to_str() == ~"[[], [1], [1, 1]]"); } @@ -167,7 +167,7 @@ mod tests { let table_str = table.to_str(); - assert!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); + fail_unless!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); assert_eq!(empty.to_str(), ~"{}"); } @@ -181,7 +181,7 @@ mod tests { let set_str = set.to_str(); - assert!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); + fail_unless!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); assert_eq!(empty_set.to_str(), ~"{}"); } } diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index d17d59f8665e9..59ef20771a72f 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -624,7 +624,7 @@ impl<'a> Iterator for SetItems<'a> { #[cfg(test)] pub fn check_integrity(trie: &TrieNode) { - assert!(trie.count != 0); + fail_unless!(trie.count != 0); let mut sum = 0; @@ -652,9 +652,9 @@ mod test_map { #[test] fn test_find_mut() { let mut m = TrieMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + fail_unless!(m.insert(1, 12)); + fail_unless!(m.insert(2, 8)); + fail_unless!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -665,11 +665,11 @@ mod test_map { #[test] fn test_find_mut_missing() { let mut m = TrieMap::new(); - assert!(m.find_mut(&0).is_none()); - assert!(m.insert(1, 12)); - assert!(m.find_mut(&0).is_none()); - assert!(m.insert(2, 8)); - assert!(m.find_mut(&0).is_none()); + fail_unless!(m.find_mut(&0).is_none()); + fail_unless!(m.insert(1, 12)); + fail_unless!(m.find_mut(&0).is_none()); + fail_unless!(m.insert(2, 8)); + fail_unless!(m.find_mut(&0).is_none()); } #[test] @@ -678,32 +678,32 @@ mod test_map { let n = 300u; for x in range_step(1u, n, 2) { - assert!(trie.insert(x, x + 1)); - assert!(trie.contains_key(&x)); + fail_unless!(trie.insert(x, x + 1)); + fail_unless!(trie.contains_key(&x)); check_integrity(&trie.root); } for x in range_step(0u, n, 2) { - assert!(!trie.contains_key(&x)); - assert!(trie.insert(x, x + 1)); + fail_unless!(!trie.contains_key(&x)); + fail_unless!(trie.insert(x, x + 1)); check_integrity(&trie.root); } for x in range(0u, n) { - assert!(trie.contains_key(&x)); - assert!(!trie.insert(x, x + 1)); + fail_unless!(trie.contains_key(&x)); + fail_unless!(!trie.insert(x, x + 1)); check_integrity(&trie.root); } for x in range_step(1u, n, 2) { - assert!(trie.remove(&x)); - assert!(!trie.contains_key(&x)); + fail_unless!(trie.remove(&x)); + fail_unless!(!trie.contains_key(&x)); check_integrity(&trie.root); } for x in range_step(0u, n, 2) { - assert!(trie.contains_key(&x)); - assert!(!trie.insert(x, x + 1)); + fail_unless!(trie.contains_key(&x)); + fail_unless!(!trie.insert(x, x + 1)); check_integrity(&trie.root); } } @@ -712,11 +712,11 @@ mod test_map { fn test_each_reverse() { let mut m = TrieMap::new(); - assert!(m.insert(3, 6)); - assert!(m.insert(0, 0)); - assert!(m.insert(4, 8)); - assert!(m.insert(2, 4)); - assert!(m.insert(1, 2)); + fail_unless!(m.insert(3, 6)); + fail_unless!(m.insert(0, 0)); + fail_unless!(m.insert(4, 8)); + fail_unless!(m.insert(2, 4)); + fail_unless!(m.insert(1, 2)); let mut n = 4; m.each_reverse(|k, v| { @@ -738,7 +738,7 @@ mod test_map { let mut n = uint::MAX - 1; m.each_reverse(|k, v| { if n == uint::MAX - 5000 { false } else { - assert!(n > uint::MAX - 5000); + fail_unless!(n > uint::MAX - 5000); assert_eq!(*k, n); assert_eq!(*v, n / 2); @@ -800,7 +800,7 @@ mod test_map { #[test] fn test_mut_iter() { let mut empty_map : TrieMap = TrieMap::new(); - assert!(empty_map.mut_iter().next().is_none()); + fail_unless!(empty_map.mut_iter().next().is_none()); let first = uint::MAX - 10000; let last = uint::MAX; @@ -818,7 +818,7 @@ mod test_map { } assert_eq!(i, last - first); - assert!(map.iter().all(|(_, &v)| v == 0)); + fail_unless!(map.iter().all(|(_, &v)| v == 0)); } #[test] @@ -833,7 +833,7 @@ mod test_map { let mut map : TrieMap = TrieMap::new(); for x in range_step(0u, last, step) { - assert!(x % step == 0); + fail_unless!(x % step == 0); map.insert(x, value); } @@ -892,11 +892,11 @@ mod test_map { *v -= k; } - assert!(m_lower.mut_lower_bound(199).next().is_none()); - assert!(m_upper.mut_upper_bound(198).next().is_none()); + fail_unless!(m_lower.mut_lower_bound(199).next().is_none()); + fail_unless!(m_upper.mut_upper_bound(198).next().is_none()); - assert!(m_lower.iter().all(|(_, &x)| x == 0)); - assert!(m_upper.iter().all(|(_, &x)| x == 0)); + fail_unless!(m_lower.iter().all(|(_, &x)| x == 0)); + fail_unless!(m_upper.iter().all(|(_, &x)| x == 0)); } } @@ -1022,8 +1022,8 @@ mod test_set { let mut trie = TrieSet::new(); - assert!(trie.insert(x)); - assert!(trie.insert(y)); + fail_unless!(trie.insert(x)); + fail_unless!(trie.insert(y)); assert_eq!(trie.len(), 2); @@ -1041,7 +1041,7 @@ mod test_set { let set: TrieSet = xs.iter().map(|&x| x).collect(); for x in xs.iter() { - assert!(set.contains(x)); + fail_unless!(set.contains(x)); } } } diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index b0d51cba103d4..c1887ef004b96 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -321,35 +321,35 @@ mod tests { // Eq assert_eq!(small, small); assert_eq!(big, big); - assert!(small != big); - assert!(big != small); + fail_unless!(small != big); + fail_unless!(big != small); // Ord - assert!(small < big); - assert!(!(small < small)); - assert!(!(big < small)); - assert!(!(big < big)); - - assert!(small <= small); - assert!(big <= big); - - assert!(big > small); - assert!(small >= small); - assert!(big >= small); - assert!(big >= big); - - assert!(!((1.0, 2.0) < (nan, 3.0))); - assert!(!((1.0, 2.0) <= (nan, 3.0))); - assert!(!((1.0, 2.0) > (nan, 3.0))); - assert!(!((1.0, 2.0) >= (nan, 3.0))); - assert!(((1.0, 2.0) < (2.0, nan))); - assert!(!((2.0, 2.0) < (2.0, nan))); + fail_unless!(small < big); + fail_unless!(!(small < small)); + fail_unless!(!(big < small)); + fail_unless!(!(big < big)); + + fail_unless!(small <= small); + fail_unless!(big <= big); + + fail_unless!(big > small); + fail_unless!(small >= small); + fail_unless!(big >= small); + fail_unless!(big >= big); + + fail_unless!(!((1.0, 2.0) < (nan, 3.0))); + fail_unless!(!((1.0, 2.0) <= (nan, 3.0))); + fail_unless!(!((1.0, 2.0) > (nan, 3.0))); + fail_unless!(!((1.0, 2.0) >= (nan, 3.0))); + fail_unless!(((1.0, 2.0) < (2.0, nan))); + fail_unless!(!((2.0, 2.0) < (2.0, nan))); // TotalEq - assert!(small.equals(&small)); - assert!(big.equals(&big)); - assert!(!small.equals(&big)); - assert!(!big.equals(&small)); + fail_unless!(small.equals(&small)); + fail_unless!(big.equals(&big)); + fail_unless!(!small.equals(&big)); + fail_unless!(!big.equals(&small)); // TotalOrd assert_eq!(small.cmp(&small), Equal); diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 6fb8981b681c3..8195e4a737f2a 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -121,7 +121,7 @@ fn test_success() { *i = 10; }, |i| { - assert!(!failing()); + fail_unless!(!failing()); assert_eq!(*i, 10); *i = 20; }); @@ -139,7 +139,7 @@ fn test_fail() { fail!(); }, |i| { - assert!(failing()); + fail_unless!(failing()); assert_eq!(*i, 10); }) } diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 87870ef033142..18a088893cd81 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -51,7 +51,7 @@ fn test_run_in_bare_thread_exchange() { // Does the exchange heap work without the runtime? let i = ~100; run_in_bare_thread(proc() { - assert!(i == ~100); + fail_unless!(i == ~100); }); } diff --git a/src/libstd/unstable/mutex.rs b/src/libstd/unstable/mutex.rs index 34ddee46d350e..645b239c2f516 100644 --- a/src/libstd/unstable/mutex.rs +++ b/src/libstd/unstable/mutex.rs @@ -467,7 +467,7 @@ mod imp { } pub unsafe fn signal(&mut self) { - assert!(SetEvent(self.getcond() as HANDLE) != 0); + fail_unless!(SetEvent(self.getcond() as HANDLE) != 0); } /// This function is especially unsafe because there are no guarantees made diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index 93322977bc121..85a18a0eb0758 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -137,7 +137,7 @@ mod tests { for f in futures.mut_iter() { f.recv() } - total.with(|total| assert!(**total == num_tasks * count)); + total.with(|total| fail_unless!(**total == num_tasks * count)); } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 0adc6083f6b81..b0ef974209726 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -988,8 +988,8 @@ pub trait ImmutableVector<'a, T> { impl<'a,T> ImmutableVector<'a, T> for &'a [T] { #[inline] fn slice(&self, start: uint, end: uint) -> &'a [T] { - assert!(start <= end); - assert!(end <= self.len()); + fail_unless!(start <= end); + fail_unless!(end <= self.len()); unsafe { transmute(Slice { data: self.as_ptr().offset(start as int), @@ -1061,13 +1061,13 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { #[inline] fn windows(self, size: uint) -> Windows<'a, T> { - assert!(size != 0); + fail_unless!(size != 0); Windows { v: self, size: size } } #[inline] fn chunks(self, size: uint) -> Chunks<'a, T> { - assert!(size != 0); + fail_unless!(size != 0); Chunks { v: self, size: size } } @@ -1338,7 +1338,7 @@ pub trait OwnedVector { /// ```rust /// let mut a = ~[~1]; /// a.push_all_move(~[~2, ~3, ~4]); - /// assert!(a == ~[~1, ~2, ~3, ~4]); + /// fail_unless!(a == ~[~1, ~2, ~3, ~4]); /// ``` fn push_all_move(&mut self, rhs: ~[T]); /// Remove the last element from a vector and return it, or `None` if it is empty @@ -1543,7 +1543,7 @@ impl OwnedVector for ~[T] { fn insert(&mut self, i: uint, x: T) { let len = self.len(); - assert!(i <= len); + fail_unless!(i <= len); // space for the new element self.reserve_additional(1); @@ -1592,7 +1592,7 @@ impl OwnedVector for ~[T] { } fn truncate(&mut self, newlen: uint) { let oldlen = self.len(); - assert!(newlen <= oldlen); + fail_unless!(newlen <= oldlen); unsafe { let p = self.as_mut_ptr(); @@ -1668,7 +1668,7 @@ pub trait OwnedCloneableVector { /// ```rust /// let mut a = ~[1]; /// a.push_all([2, 3, 4]); - /// assert!(a == ~[1, 2, 3, 4]); + /// fail_unless!(a == ~[1, 2, 3, 4]); /// ``` fn push_all(&mut self, rhs: &[T]); @@ -2266,8 +2266,8 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { fn as_mut_slice(self) -> &'a mut [T] { self } fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { - assert!(start <= end); - assert!(end <= self.len()); + fail_unless!(start <= end); + fail_unless!(end <= self.len()); unsafe { transmute(Slice { data: self.as_mut_ptr().offset(start as int) as *T, @@ -2331,7 +2331,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { #[inline] fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T> { - assert!(chunk_size > 0); + fail_unless!(chunk_size > 0); MutChunks { v: self, chunk_size: chunk_size } } @@ -2406,7 +2406,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { #[inline] unsafe fn copy_memory(self, src: &[T]) { let len_src = src.len(); - assert!(self.len() >= len_src); + fail_unless!(self.len() >= len_src); ptr::copy_nonoverlapping_memory(self.as_mut_ptr(), src.as_ptr(), len_src) } } @@ -3027,8 +3027,8 @@ mod tests { #[test] fn test_is_empty() { let xs: [int, ..0] = []; - assert!(xs.is_empty()); - assert!(![0].is_empty()); + fail_unless!(xs.is_empty()); + fail_unless!(![0].is_empty()); } #[test] @@ -3430,13 +3430,13 @@ mod tests { #[test] fn test_position_elem() { - assert!([].position_elem(&1).is_none()); + fail_unless!([].position_elem(&1).is_none()); let v1 = ~[1, 2, 3, 3, 2, 5]; assert_eq!(v1.position_elem(&1), Some(0u)); assert_eq!(v1.position_elem(&2), Some(1u)); assert_eq!(v1.position_elem(&5), Some(5u)); - assert!(v1.position_elem(&4).is_none()); + fail_unless!(v1.position_elem(&4).is_none()); } #[test] @@ -3474,10 +3474,10 @@ mod tests { assert_eq!([].bsearch_elem(&1), None); assert_eq!([].bsearch_elem(&5), None); - assert!([1,1,1,1,1].bsearch_elem(&1) != None); - assert!([1,1,1,1,2].bsearch_elem(&1) != None); - assert!([1,1,1,2,2].bsearch_elem(&1) != None); - assert!([1,1,2,2,2].bsearch_elem(&1) != None); + fail_unless!([1,1,1,1,1].bsearch_elem(&1) != None); + fail_unless!([1,1,1,1,2].bsearch_elem(&1) != None); + fail_unless!([1,1,1,2,2].bsearch_elem(&1) != None); + fail_unless!([1,1,2,2,2].bsearch_elem(&1) != None); assert_eq!([1,2,2,2,2].bsearch_elem(&1), Some(0)); assert_eq!([1,2,3,4,5].bsearch_elem(&6), None); @@ -3495,7 +3495,7 @@ mod tests { let mut v3: ~[int] = ~[]; v3.reverse(); - assert!(v3.is_empty()); + fail_unless!(v3.is_empty()); } #[test] @@ -3506,13 +3506,13 @@ mod tests { let mut v1 = v.clone(); v.sort(); - assert!(v.windows(2).all(|w| w[0] <= w[1])); + fail_unless!(v.windows(2).all(|w| w[0] <= w[1])); v1.sort_by(|a, b| a.cmp(b)); - assert!(v1.windows(2).all(|w| w[0] <= w[1])); + fail_unless!(v1.windows(2).all(|w| w[0] <= w[1])); v1.sort_by(|a, b| b.cmp(a)); - assert!(v1.windows(2).all(|w| w[0] >= w[1])); + fail_unless!(v1.windows(2).all(|w| w[0] >= w[1])); } } @@ -3551,7 +3551,7 @@ mod tests { // will need to be ordered with increasing // counts... i.e. exactly asserting that this sort is // stable. - assert!(v.windows(2).all(|w| w[0] <= w[1])); + fail_unless!(v.windows(2).all(|w| w[0] <= w[1])); } } } @@ -3818,7 +3818,7 @@ mod tests { assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(it.next().unwrap(), &11); assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -3831,18 +3831,18 @@ mod tests { assert_eq!(it.idx(0).unwrap(), &1); assert_eq!(it.idx(2).unwrap(), &5); assert_eq!(it.idx(4).unwrap(), &11); - assert!(it.idx(5).is_none()); + fail_unless!(it.idx(5).is_none()); assert_eq!(it.next().unwrap(), &1); assert_eq!(it.indexable(), 4); assert_eq!(it.idx(0).unwrap(), &2); assert_eq!(it.idx(3).unwrap(), &11); - assert!(it.idx(4).is_none()); + fail_unless!(it.idx(4).is_none()); assert_eq!(it.next().unwrap(), &2); assert_eq!(it.indexable(), 3); assert_eq!(it.idx(1).unwrap(), &10); - assert!(it.idx(3).is_none()); + fail_unless!(it.idx(3).is_none()); assert_eq!(it.next().unwrap(), &5); assert_eq!(it.indexable(), 2); @@ -3851,13 +3851,13 @@ mod tests { assert_eq!(it.next().unwrap(), &10); assert_eq!(it.indexable(), 1); assert_eq!(it.idx(0).unwrap(), &11); - assert!(it.idx(1).is_none()); + fail_unless!(it.idx(1).is_none()); assert_eq!(it.next().unwrap(), &11); assert_eq!(it.indexable(), 0); - assert!(it.idx(0).is_none()); + fail_unless!(it.idx(0).is_none()); - assert!(it.next().is_none()); + fail_unless!(it.next().is_none()); } #[test] @@ -4001,7 +4001,7 @@ mod tests { assert_eq!(v.windows(2).collect::<~[&[int]]>(), ~[&[1,2], &[2,3], &[3,4]]); assert_eq!(v.windows(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[2,3,4]]); - assert!(v.windows(6).next().is_none()); + fail_unless!(v.windows(6).next().is_none()); } #[test] @@ -4096,7 +4096,7 @@ mod tests { macro_rules! t ( ($ty:ty) => {{ let v: $ty = Default::default(); - assert!(v.is_empty()); + fail_unless!(v.is_empty()); }} ); @@ -4161,25 +4161,25 @@ mod tests { let mut cnt = 0; for f in v.iter() { - assert!(*f == Foo); + fail_unless!(*f == Foo); cnt += 1; } assert_eq!(cnt, 3); for f in v.slice(1, 3).iter() { - assert!(*f == Foo); + fail_unless!(*f == Foo); cnt += 1; } assert_eq!(cnt, 5); for f in v.mut_iter() { - assert!(*f == Foo); + fail_unless!(*f == Foo); cnt += 1; } assert_eq!(cnt, 8); for f in v.move_iter() { - assert!(f == Foo); + fail_unless!(f == Foo); cnt += 1; } assert_eq!(cnt, 11); @@ -4193,10 +4193,10 @@ mod tests { ~"~[vec::tests::Foo, vec::tests::Foo]"); cnt = 0; for f in xs.iter() { - assert!(*f == Foo); + fail_unless!(*f == Foo); cnt += 1; } - assert!(cnt == 3); + fail_unless!(cnt == 3); } #[test] @@ -4213,30 +4213,30 @@ mod tests { #[test] fn test_starts_with() { - assert!(bytes!("foobar").starts_with(bytes!("foo"))); - assert!(!bytes!("foobar").starts_with(bytes!("oob"))); - assert!(!bytes!("foobar").starts_with(bytes!("bar"))); - assert!(!bytes!("foo").starts_with(bytes!("foobar"))); - assert!(!bytes!("bar").starts_with(bytes!("foobar"))); - assert!(bytes!("foobar").starts_with(bytes!("foobar"))); + fail_unless!(bytes!("foobar").starts_with(bytes!("foo"))); + fail_unless!(!bytes!("foobar").starts_with(bytes!("oob"))); + fail_unless!(!bytes!("foobar").starts_with(bytes!("bar"))); + fail_unless!(!bytes!("foo").starts_with(bytes!("foobar"))); + fail_unless!(!bytes!("bar").starts_with(bytes!("foobar"))); + fail_unless!(bytes!("foobar").starts_with(bytes!("foobar"))); let empty: &[u8] = []; - assert!(empty.starts_with(empty)); - assert!(!empty.starts_with(bytes!("foo"))); - assert!(bytes!("foobar").starts_with(empty)); + fail_unless!(empty.starts_with(empty)); + fail_unless!(!empty.starts_with(bytes!("foo"))); + fail_unless!(bytes!("foobar").starts_with(empty)); } #[test] fn test_ends_with() { - assert!(bytes!("foobar").ends_with(bytes!("bar"))); - assert!(!bytes!("foobar").ends_with(bytes!("oba"))); - assert!(!bytes!("foobar").ends_with(bytes!("foo"))); - assert!(!bytes!("foo").ends_with(bytes!("foobar"))); - assert!(!bytes!("bar").ends_with(bytes!("foobar"))); - assert!(bytes!("foobar").ends_with(bytes!("foobar"))); + fail_unless!(bytes!("foobar").ends_with(bytes!("bar"))); + fail_unless!(!bytes!("foobar").ends_with(bytes!("oba"))); + fail_unless!(!bytes!("foobar").ends_with(bytes!("foo"))); + fail_unless!(!bytes!("foo").ends_with(bytes!("foobar"))); + fail_unless!(!bytes!("bar").ends_with(bytes!("foobar"))); + fail_unless!(bytes!("foobar").ends_with(bytes!("foobar"))); let empty: &[u8] = []; - assert!(empty.ends_with(empty)); - assert!(!empty.ends_with(bytes!("foo"))); - assert!(bytes!("foobar").ends_with(empty)); + fail_unless!(empty.ends_with(empty)); + fail_unless!(!empty.ends_with(bytes!("foo"))); + fail_unless!(bytes!("foobar").ends_with(empty)); } #[test] @@ -4262,7 +4262,7 @@ mod tests { assert_eq!(x[3], 4); let mut y: &[int] = []; - assert!(y.pop_ref().is_none()); + fail_unless!(y.pop_ref().is_none()); } #[test] @@ -4331,7 +4331,7 @@ mod tests { assert_eq!(x[3], 5); let mut y: &mut [int] = []; - assert!(y.mut_shift_ref().is_none()); + fail_unless!(y.mut_shift_ref().is_none()); } #[test] @@ -4344,7 +4344,7 @@ mod tests { assert_eq!(x[3], 4); let mut y: &mut [int] = []; - assert!(y.mut_pop_ref().is_none()); + fail_unless!(y.mut_pop_ref().is_none()); } #[test] @@ -4354,7 +4354,7 @@ mod tests { assert_eq!(*h.unwrap(), 5); let y: &mut [int] = []; - assert!(y.mut_last().is_none()); + fail_unless!(y.mut_last().is_none()); } } diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs index 114f34963e2c7..729684d334cf1 100644 --- a/src/libstd/vec_ng.rs +++ b/src/libstd/vec_ng.rs @@ -295,7 +295,7 @@ impl Vec { pub fn insert(&mut self, index: uint, element: T) { let len = self.len(); - assert!(index <= len); + fail_unless!(index <= len); // space for the new element self.reserve_exact(len + 1); diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index db4260a30ee11..2bf1f584c4baf 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -69,7 +69,7 @@ impl<'a> Condvar<'a> { */ #[inline] pub fn wait_on(&self, condvar_id: uint) { - assert!(!*self.failed); + fail_unless!(!*self.failed); self.cond.wait_on(condvar_id); // This is why we need to wrap sync::condvar. check_poison(self.is_mutex, *self.failed); @@ -85,7 +85,7 @@ impl<'a> Condvar<'a> { */ #[inline] pub fn signal_on(&self, condvar_id: uint) -> bool { - assert!(!*self.failed); + fail_unless!(!*self.failed); self.cond.signal_on(condvar_id) } @@ -99,7 +99,7 @@ impl<'a> Condvar<'a> { */ #[inline] pub fn broadcast_on(&self, condvar_id: uint) -> uint { - assert!(!*self.failed); + fail_unless!(!*self.failed); self.cond.broadcast_on(condvar_id) } } @@ -256,7 +256,7 @@ struct PoisonOnFail { impl Drop for PoisonOnFail { fn drop(&mut self) { unsafe { - /* assert!(!*self.failed); + /* fail_unless!(!*self.failed); -- might be false in case of cond.wait() */ if !self.failed && task::failing() { *self.flag = true; @@ -434,7 +434,7 @@ impl RWArc { // of this cast is removing the mutability.) let new_data = data; // Downgrade ensured the token belonged to us. Just a sanity check. - assert!((&(*state).data as *T as uint) == (new_data as *mut T as uint)); + fail_unless!((&(*state).data as *T as uint) == (new_data as *mut T as uint)); // Produce new token RWReadMode { data: new_data, @@ -610,7 +610,7 @@ mod tests { arc.access_cond(|state, cond| { c.send(()); - assert!(!*state); + fail_unless!(!*state); while !*state { cond.wait(); } @@ -663,7 +663,7 @@ mod tests { task::spawn(proc() { (*arc2).access(|mutex| { (*mutex).access(|one| { - assert!(*one == 1); + fail_unless!(*one == 1); }) }) }); @@ -798,7 +798,7 @@ mod tests { children.push(builder.future_result()); builder.spawn(proc() { arc3.read(|num| { - assert!(*num >= 0); + fail_unless!(*num >= 0); }) }); } @@ -937,7 +937,7 @@ mod tests { x.write_downgrade(|mut write_mode| { write_mode.write_cond(|state, c| { - assert!(*state); + fail_unless!(*state); // make writer contend in the cond-reacquire path c.signal(); }); @@ -956,7 +956,7 @@ mod tests { // before we assert on it for _ in range(0, 5) { task::deschedule(); } // make sure writer didn't get in. - assert!(*state); + fail_unless!(*state); }) }); } @@ -976,12 +976,12 @@ mod tests { let cow1 = cow0.clone(); let cow2 = cow1.clone(); - assert!(75 == *cow0.get()); - assert!(75 == *cow1.get()); - assert!(75 == *cow2.get()); + fail_unless!(75 == *cow0.get()); + fail_unless!(75 == *cow1.get()); + fail_unless!(75 == *cow2.get()); - assert!(cow0.get() == cow1.get()); - assert!(cow0.get() == cow2.get()); + fail_unless!(cow0.get() == cow1.get()); + fail_unless!(cow0.get() == cow2.get()); } #[test] @@ -991,22 +991,22 @@ mod tests { let mut cow1 = cow0.clone(); let mut cow2 = cow1.clone(); - assert!(75 == *cow0.get_mut()); - assert!(75 == *cow1.get_mut()); - assert!(75 == *cow2.get_mut()); + fail_unless!(75 == *cow0.get_mut()); + fail_unless!(75 == *cow1.get_mut()); + fail_unless!(75 == *cow2.get_mut()); *cow0.get_mut() += 1; *cow1.get_mut() += 2; *cow2.get_mut() += 3; - assert!(76 == *cow0.get()); - assert!(77 == *cow1.get()); - assert!(78 == *cow2.get()); + fail_unless!(76 == *cow0.get()); + fail_unless!(77 == *cow1.get()); + fail_unless!(78 == *cow2.get()); // none should point to the same backing memory - assert!(cow0.get() != cow1.get()); - assert!(cow0.get() != cow2.get()); - assert!(cow1.get() != cow2.get()); + fail_unless!(cow0.get() != cow1.get()); + fail_unless!(cow0.get() != cow2.get()); + fail_unless!(cow1.get() != cow2.get()); } #[test] @@ -1016,20 +1016,20 @@ mod tests { let cow1 = cow0.clone(); let cow2 = cow1.clone(); - assert!(75 == *cow0.get()); - assert!(75 == *cow1.get()); - assert!(75 == *cow2.get()); + fail_unless!(75 == *cow0.get()); + fail_unless!(75 == *cow1.get()); + fail_unless!(75 == *cow2.get()); *cow0.get_mut() += 1; - assert!(76 == *cow0.get()); - assert!(75 == *cow1.get()); - assert!(75 == *cow2.get()); + fail_unless!(76 == *cow0.get()); + fail_unless!(75 == *cow1.get()); + fail_unless!(75 == *cow2.get()); // cow1 and cow2 should share the same contents // cow0 should have a unique reference - assert!(cow0.get() != cow1.get()); - assert!(cow0.get() != cow2.get()); - assert!(cow1.get() == cow2.get()); + fail_unless!(cow0.get() != cow1.get()); + fail_unless!(cow0.get() != cow2.get()); + fail_unless!(cow1.get() == cow2.get()); } } diff --git a/src/libsync/comm.rs b/src/libsync/comm.rs index c7d550762540a..1f991ba757aad 100644 --- a/src/libsync/comm.rs +++ b/src/libsync/comm.rs @@ -57,7 +57,7 @@ pub struct SyncPort { priv duplex_stream: DuplexStream<(), T> } impl SyncChan { pub fn send(&self, val: T) { - assert!(self.try_send(val), "SyncChan.send: receiving port closed"); + fail_unless!(self.try_send(val), "SyncChan.send: receiving port closed"); } /// Sends a message, or report if the receiver has closed the connection @@ -107,8 +107,8 @@ mod test { left.send(~"abc"); right.send(123); - assert!(left.recv() == 123); - assert!(right.recv() == ~"abc"); + fail_unless!(left.recv() == 123); + fail_unless!(right.recv() == ~"abc"); } #[test] @@ -119,7 +119,7 @@ mod test { chan.send("abc"); }); - assert!(port.recv() == "abc"); + fail_unless!(port.recv() == "abc"); } #[test] diff --git a/src/libsync/sync/mod.rs b/src/libsync/sync/mod.rs index 7078f01945e96..336ede7072f43 100644 --- a/src/libsync/sync/mod.rs +++ b/src/libsync/sync/mod.rs @@ -84,7 +84,7 @@ impl WaitQueue { fn wait_end(&self) -> WaitEnd { let (wait_end, signal_end) = Chan::new(); - assert!(self.tail.try_send(signal_end)); + fail_unless!(self.tail.try_send(signal_end)); wait_end } } @@ -509,9 +509,9 @@ impl RWLock { blk() }).finally(|| { let state = &mut *self.state.get(); - assert!(state.read_mode); + fail_unless!(state.read_mode); let old_count = state.read_count.fetch_sub(1, atomics::Release); - assert!(old_count > 0); + fail_unless!(old_count > 0); if old_count == 1 { state.read_mode = false; // Note: this release used to be outside of a locked access @@ -617,7 +617,7 @@ impl RWLock { if state.read_mode { // Releasing from read mode. let old_count = state.read_count.fetch_sub(1, atomics::Release); - assert!(old_count > 0); + fail_unless!(old_count > 0); // Check if other readers remain. if old_count == 1 { // Case 1: Writer downgraded & was the last reader @@ -646,7 +646,7 @@ impl RWLock { } unsafe { let state = &mut *self.state.get(); - assert!(!state.read_mode); + fail_unless!(!state.read_mode); state.read_mode = true; // If a reader attempts to enter at this point, both the // downgrader and reader will set the mode flag. This is fine. @@ -906,7 +906,7 @@ mod tests { task::spawn(proc() { m2.lock_cond(|cond| { let woken = cond.signal(); - assert!(woken); + fail_unless!(woken); }) }); cond.wait(); @@ -924,7 +924,7 @@ mod tests { let _ = port.recv(); // Wait until child gets in the mutex m.lock_cond(|cond| { let woken = cond.signal(); - assert!(woken); + fail_unless!(woken); }); let _ = port.recv(); // Wait until child wakes up } @@ -971,7 +971,7 @@ mod tests { m.lock_cond(|_x| { }) }); m2.lock_cond(|cond| { - assert!(!cond.signal()); + fail_unless!(!cond.signal()); }) } #[test] @@ -985,7 +985,7 @@ mod tests { fail!(); }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); // child task must have finished by the time try returns m.lock(|| { }) } @@ -1009,11 +1009,11 @@ mod tests { cond.wait(); // block forever }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); // child task must have finished by the time try returns m.lock_cond(|cond| { let woken = cond.signal(); - assert!(!woken); + fail_unless!(!woken); }) } #[ignore(reason = "linked failure")] @@ -1052,7 +1052,7 @@ mod tests { c.send(sibling_convos); // let parent wait on all children fail!(); }); - assert!(result.is_err()); + fail_unless!(result.is_err()); // child task must have finished by the time try returns let mut r = p.recv(); for p in r.mut_iter() { p.recv(); } // wait on all its siblings @@ -1095,7 +1095,7 @@ mod tests { } }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); } #[test] fn test_mutex_no_condvars() { @@ -1103,17 +1103,17 @@ mod tests { let m = Mutex::new_with_condvars(0); m.lock_cond(|cond| { cond.wait(); }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { let m = Mutex::new_with_condvars(0); m.lock_cond(|cond| { cond.signal(); }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); let result = task::try(proc() { let m = Mutex::new_with_condvars(0); m.lock_cond(|cond| { cond.broadcast(); }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); } /************************************************************************ * Reader/writer lock tests @@ -1253,7 +1253,7 @@ mod tests { task::spawn(proc() { x2.write_cond(|cond| { let woken = cond.signal(); - assert!(woken); + fail_unless!(woken); }) }); cond.wait(); @@ -1272,7 +1272,7 @@ mod tests { x.read(|| { }); // Must be able to get in as a reader in the meantime x.write_cond(|cond| { // Or as another writer let woken = cond.signal(); - assert!(woken); + fail_unless!(woken); }); let _ = port.recv(); // Wait until child wakes up x.read(|| { }); // Just for good measure @@ -1338,7 +1338,7 @@ mod tests { fail!(); }) }); - assert!(result.is_err()); + fail_unless!(result.is_err()); // child task must have finished by the time try returns lock_rwlock_in_mode(&x, mode2, || { }) } @@ -1406,7 +1406,7 @@ mod tests { // At this point, all spawned tasks should be blocked, // so we shouldn't get anything from the port - assert!(match port.try_recv() { + fail_unless!(match port.try_recv() { Empty => true, _ => false, }); diff --git a/src/libsync/sync/mutex.rs b/src/libsync/sync/mutex.rs index 923f12ed1d19a..a9de7b667aa76 100644 --- a/src/libsync/sync/mutex.rs +++ b/src/libsync/sync/mutex.rs @@ -174,7 +174,7 @@ impl StaticMutex { // FIXME: this can mess up the fairness of the mutex, seems bad match self.state.compare_and_swap(0, LOCKED, atomics::SeqCst) { 0 => { - assert!(self.flavor == Unlocked); + fail_unless!(self.flavor == Unlocked); self.flavor = TryLockAcquisition; Some(Guard::new(self)) } @@ -191,7 +191,7 @@ impl StaticMutex { // FIXME: this can mess up the fairness of the mutex, seems bad match self.state.compare_and_swap(0, LOCKED, atomics::SeqCst) { 0 => { - assert!(self.flavor == Unlocked); + fail_unless!(self.flavor == Unlocked); self.flavor = TryLockAcquisition; return Guard::new(self) } @@ -358,7 +358,7 @@ impl StaticMutex { let mut unlocked = false; let task; loop { - assert!(state & LOCKED != 0); + fail_unless!(state & LOCKED != 0); if state & GREEN_BLOCKED != 0 { self.unset(state, GREEN_BLOCKED); task = unsafe { @@ -407,7 +407,7 @@ impl StaticMutex { /// Loops around a CAS to unset the `bit` in `state` fn unset(&mut self, mut state: uint, bit: uint) { loop { - assert!(state & bit != 0); + fail_unless!(state & bit != 0); let new = state ^ bit; match self.state.compare_and_swap(state, new, atomics::SeqCst) { n if n == state => break, @@ -470,8 +470,8 @@ impl Mutex { impl<'a> Guard<'a> { fn new<'b>(lock: &'b mut StaticMutex) -> Guard<'b> { if cfg!(debug) { - assert!(lock.flavor != Unlocked); - assert!(lock.state.load(atomics::SeqCst) & LOCKED != 0); + fail_unless!(lock.flavor != Unlocked); + fail_unless!(lock.state.load(atomics::SeqCst) & LOCKED != 0); } Guard { lock: lock } } @@ -553,6 +553,6 @@ mod test { #[test] fn trylock() { let mut m = Mutex::new(); - assert!(m.try_lock().is_some()); + fail_unless!(m.try_lock().is_some()); } } diff --git a/src/libsync/sync/one.rs b/src/libsync/sync/one.rs index a651f3b9d4c3e..50c04a21c874c 100644 --- a/src/libsync/sync/one.rs +++ b/src/libsync/sync/one.rs @@ -144,10 +144,10 @@ mod test { for _ in range(0, 4) { task::deschedule() } unsafe { o.doit(|| { - assert!(!run); + fail_unless!(!run); run = true; }); - assert!(run); + fail_unless!(run); } c.send(()); }); @@ -155,10 +155,10 @@ mod test { unsafe { o.doit(|| { - assert!(!run); + fail_unless!(!run); run = true; }); - assert!(run); + fail_unless!(run); } for _ in range(0, 10) { diff --git a/src/libsync/task_pool.rs b/src/libsync/task_pool.rs index 0d8cccfe2b9ae..257d99e16f5a0 100644 --- a/src/libsync/task_pool.rs +++ b/src/libsync/task_pool.rs @@ -45,7 +45,7 @@ impl TaskPool { pub fn new(n_tasks: uint, init_fn_factory: || -> proc(uint) -> T) -> TaskPool { - assert!(n_tasks >= 1); + fail_unless!(n_tasks >= 1); let channels = vec::from_fn(n_tasks, |i| { let (port, chan) = Chan::>::new(); diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 6b0f2c6e516c6..2dc6b0048e2d2 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -297,19 +297,19 @@ impl ToStr for AbiSet { #[test] fn lookup_Rust() { let abi = lookup("Rust"); - assert!(abi.is_some() && abi.unwrap().data().name == "Rust"); + fail_unless!(abi.is_some() && abi.unwrap().data().name == "Rust"); } #[test] fn lookup_cdecl() { let abi = lookup("cdecl"); - assert!(abi.is_some() && abi.unwrap().data().name == "cdecl"); + fail_unless!(abi.is_some() && abi.unwrap().data().name == "cdecl"); } #[test] fn lookup_baz() { let abi = lookup("baz"); - assert!(abi.is_none()); + fail_unless!(abi.is_none()); } #[cfg(test)] @@ -319,7 +319,7 @@ fn cannot_combine(n: Abi, m: Abi) { set.add(m); match set.check_valid() { Some((a, b)) => { - assert!((n == a && m == b) || + fail_unless!((n == a && m == b) || (m == a && n == b)); } None => { @@ -381,7 +381,7 @@ fn abi_to_str_stdcall_aaps() { let mut set = AbiSet::empty(); set.add(Aapcs); set.add(Stdcall); - assert!(set.to_str() == ~"\"stdcall aapcs\""); + fail_unless!(set.to_str() == ~"\"stdcall aapcs\""); } #[test] @@ -390,7 +390,7 @@ fn abi_to_str_c_aaps() { set.add(Aapcs); set.add(C); debug!("set = {}", set.to_str()); - assert!(set.to_str() == ~"\"aapcs C\""); + fail_unless!(set.to_str() == ~"\"aapcs C\""); } #[test] @@ -398,7 +398,7 @@ fn abi_to_str_rust() { let mut set = AbiSet::empty(); set.add(Rust); debug!("set = {}", set.to_str()); - assert!(set.to_str() == ~"\"Rust\""); + fail_unless!(set.to_str() == ~"\"Rust\""); } #[test] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 790f3927352a6..1e186eea78ce0 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -973,11 +973,11 @@ mod test { } #[test] fn idents_name_eq_test() { - assert!(segments_name_eq([Ident{name:3,ctxt:4}, + fail_unless!(segments_name_eq([Ident{name:3,ctxt:4}, Ident{name:78,ctxt:82}].map(ident_to_segment), [Ident{name:3,ctxt:104}, Ident{name:78,ctxt:182}].map(ident_to_segment))); - assert!(!segments_name_eq([Ident{name:3,ctxt:4}, + fail_unless!(!segments_name_eq([Ident{name:3,ctxt:4}, Ident{name:78,ctxt:82}].map(ident_to_segment), [Ident{name:3,ctxt:104}, Ident{name:77,ctxt:182}].map(ident_to_segment))); diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 486a25fa775c9..b0c82965060ff 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -225,7 +225,7 @@ impl FileMap { // the new charpos must be > the last one (or it's the first one). let mut lines = self.lines.borrow_mut();; let line_len = lines.get().len(); - assert!(line_len == 0 || (lines.get()[line_len - 1] < pos)) + fail_unless!(line_len == 0 || (lines.get()[line_len - 1] < pos)) lines.get().push(pos); } @@ -242,7 +242,7 @@ impl FileMap { } pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) { - assert!(bytes >=2 && bytes <= 4); + fail_unless!(bytes >=2 && bytes <= 4); let mbc = MultiByteChar { pos: pos, bytes: bytes, @@ -429,7 +429,7 @@ impl CodeMap { debug!("codemap: char pos {:?} is on the line at char pos {:?}", chpos, linechpos); debug!("codemap: byte is on line: {:?}", line); - assert!(chpos >= linechpos); + fail_unless!(chpos >= linechpos); return Loc { file: f, line: line, @@ -463,7 +463,7 @@ impl CodeMap { total_extra_bytes += mbc.bytes; // We should never see a byte position in the middle of a // character - assert!(bpos == mbc.pos || + fail_unless!(bpos == mbc.pos || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes); } else { break; diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index 0831f319ce7b9..a6fc365757cd4 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -122,7 +122,7 @@ fn bare_name_single_char() { #[test] fn empty_crateid() { let crateid: Option = from_str(""); - assert!(crateid.is_none()); + fail_unless!(crateid.is_none()); } #[test] @@ -144,13 +144,13 @@ fn simple_version() { #[test] fn absolute_path() { let crateid: Option = from_str("/foo/bar"); - assert!(crateid.is_none()); + fail_unless!(crateid.is_none()); } #[test] fn path_ends_with_slash() { let crateid: Option = from_str("foo/bar/"); - assert!(crateid.is_none()); + fail_unless!(crateid.is_none()); } #[test] diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e6fffe8b53f48..a818ee1a5fce3 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -525,7 +525,7 @@ impl SyntaxEnv { } pub fn pop_frame(&mut self) { - assert!(self.chain.len() > 1, "too many pops on MapChain!"); + fail_unless!(self.chain.len() > 1, "too many pops on MapChain!"); self.chain.pop(); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1e0bfb0d3e9f0..b37699b80ba02 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1125,7 +1125,7 @@ mod test { let binding_name = mtwt_resolve(bindings[binding_idx]); let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,invalid_name); // shouldmatch can't name varrefs that don't exist: - assert!((shouldmatch.len() == 0) || + fail_unless!((shouldmatch.len() == 0) || (varrefs.len() > *shouldmatch.iter().max().unwrap())); for (idx,varref) in varrefs.iter().enumerate() { if shouldmatch.contains(&idx) { @@ -1165,7 +1165,7 @@ mod test { println!("binding: {:?}", bindings[binding_idx]); ast_util::display_sctable(get_sctable()); } - assert!(!fail); + fail_unless!(!fail); } } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index c2d005da74ebe..28f83cfae9c18 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -406,7 +406,7 @@ pub fn parse(sess: @ParseSess, } } - assert!(cur_eis.len() > 0u); + fail_unless!(cur_eis.len() > 0u); } } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 21f05fa684a84..e3d5dd6c24e45 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -105,7 +105,7 @@ impl OptVec { match *self { Empty => { fail!("index out of bounds"); } Vec(ref mut v) => { - assert!(index < v.len()); + fail_unless!(index < v.len()); v.swap_remove(index); } } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index c9bea78d02db5..e0778290a1f15 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -70,7 +70,7 @@ impl ParserAttr for Parser { permit_inner, self.token); let (span, value) = match self.token { INTERPOLATED(token::NtAttr(attr)) => { - assert!(attr.node.style == ast::AttrOuter); + fail_unless!(attr.node.style == ast::AttrOuter); self.bump(); (attr.span, attr.node.value) } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index e0ae9ce281214..df14daccc1094 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -44,7 +44,7 @@ pub fn is_doc_comment(s: &str) -> bool { } pub fn doc_comment_style(comment: &str) -> ast::AttrStyle { - assert!(is_doc_comment(comment)); + fail_unless!(is_doc_comment(comment)); if comment.starts_with("//!") || comment.starts_with("/*!") { ast::AttrInner } else { @@ -145,7 +145,7 @@ fn read_to_eol(rdr: &StringReader) -> ~str { fn read_one_line_comment(rdr: &StringReader) -> ~str { let val = read_to_eol(rdr); - assert!((val[0] == '/' as u8 && val[1] == '/' as u8) || + fail_unless!((val[0] == '/' as u8 && val[1] == '/' as u8) || (val[0] == '#' as u8 && val[1] == '!' as u8)); return val; } @@ -271,7 +271,7 @@ fn read_block_comment(rdr: &StringReader, bump(rdr); } if !is_block_non_doc_comment(curr_line) { return; } - assert!(!curr_line.contains_char('\n')); + fail_unless!(!curr_line.contains_char('\n')); lines.push(curr_line); } else { let mut level: int = 1; diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index b711e95bc943b..1c0d863420706 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -251,7 +251,7 @@ pub fn bump(rdr: &StringReader) { rdr.last_pos.set(rdr.pos.get()); let current_byte_offset = byte_offset(rdr, rdr.pos.get()).to_uint(); if current_byte_offset < (rdr.filemap.src).len() { - assert!(rdr.curr.get().is_some()); + fail_unless!(rdr.curr.get().is_some()); let last_char = rdr.curr.get().unwrap(); let next = rdr.filemap.src.char_range_at(current_byte_offset); let byte_offset_diff = next.next - current_byte_offset; @@ -1127,9 +1127,9 @@ mod test { } #[test] fn line_doc_comments() { - assert!(!is_line_non_doc_comment("///")); - assert!(!is_line_non_doc_comment("/// blah")); - assert!(is_line_non_doc_comment("////")); + fail_unless!(!is_line_non_doc_comment("///")); + fail_unless!(!is_line_non_doc_comment("/// blah")); + fail_unless!(is_line_non_doc_comment("////")); } #[test] fn nested_block_comments() { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6cde22fad107c..9d2f4f4ee050d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4294,7 +4294,7 @@ impl Parser { self.span_err(self.last_span, "expected item after attributes"); } - assert!(self.token == token::RBRACE); + fail_unless!(self.token == token::RBRACE); ast::ForeignMod { abis: abis, view_items: view_items, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b264e8d7467ba..75951e90f4811 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -722,9 +722,9 @@ mod test { } #[test] fn mtwt_token_eq_test() { - assert!(mtwt_token_eq(>,>)); + fail_unless!(mtwt_token_eq(>,>)); let a = str_to_ident("bac"); let a1 = mark_ident(a,92); - assert!(mtwt_token_eq(&IDENT(a,true),&IDENT(a1,false))); + fail_unless!(mtwt_token_eq(&IDENT(a,true),&IDENT(a1,false))); } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 14d8c662aae0e..302881472263f 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -391,12 +391,12 @@ impl Printer { } else { self.top += 1u; self.top %= self.buf_len; - assert!((self.top != self.bottom)); + fail_unless!((self.top != self.bottom)); } self.scan_stack[self.top] = x; } pub fn scan_pop(&mut self) -> uint { - assert!((!self.scan_stack_empty)); + fail_unless!((!self.scan_stack_empty)); let x = self.scan_stack[self.top]; if self.top == self.bottom { self.scan_stack_empty = true; @@ -404,11 +404,11 @@ impl Printer { return x; } pub fn scan_top(&mut self) -> uint { - assert!((!self.scan_stack_empty)); + fail_unless!((!self.scan_stack_empty)); return self.scan_stack[self.top]; } pub fn scan_pop_bottom(&mut self) -> uint { - assert!((!self.scan_stack_empty)); + fail_unless!((!self.scan_stack_empty)); let x = self.scan_stack[self.bottom]; if self.top == self.bottom { self.scan_stack_empty = true; @@ -418,7 +418,7 @@ impl Printer { pub fn advance_right(&mut self) { self.right += 1u; self.right %= self.buf_len; - assert!((self.right != self.left)); + fail_unless!((self.right != self.left)); } pub fn advance_left(&mut self, x: Token, L: int) -> io::IoResult<()> { debug!("advnce_left ~[{},{}], sizeof({})={}", self.left, self.right, @@ -525,7 +525,7 @@ impl Printer { End => { debug!("print End -> pop End"); let print_stack = &mut self.print_stack; - assert!((print_stack.len() != 0u)); + fail_unless!((print_stack.len() != 0u)); print_stack.pop().unwrap(); Ok(()) } @@ -565,7 +565,7 @@ impl Printer { String(s, len) => { debug!("print String({})", s); assert_eq!(L, len); - // assert!(L <= space); + // fail_unless!(L <= space); self.space -= len; self.print_str(s) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3b1386021d232..ffe73852597ef 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1384,8 +1384,8 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { try!(print_fn_block_args(s, decl)); try!(space(&mut s.s)); // } - assert!(body.stmts.is_empty()); - assert!(body.expr.is_some()); + fail_unless!(body.stmts.is_empty()); + fail_unless!(body.expr.is_some()); // we extract the block, so as not to create another set of boxes match body.expr.unwrap().node { ast::ExprBlock(blk) => { @@ -1411,8 +1411,8 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { try!(print_proc_args(s, decl)); try!(space(&mut s.s)); // } - assert!(body.stmts.is_empty()); - assert!(body.expr.is_some()); + fail_unless!(body.stmts.is_empty()); + fail_unless!(body.expr.is_some()); // we extract the block, so as not to create another set of boxes match body.expr.unwrap().node { ast::ExprBlock(blk) => { diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index 948e79b448105..a9a7f6909b3d1 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -494,7 +494,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { s_.push_all_move(s); s = s_; } - assert!(!s.is_empty(), "string conversion produced empty result"); + fail_unless!(!s.is_empty(), "string conversion produced empty result"); match op { FormatDigit => { if flags.space && !(s[0] == '-' as u8 || s[0] == '+' as u8) { @@ -587,30 +587,30 @@ mod test { let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"]; for cap in caps.iter() { let res = expand(cap.as_bytes(), [], vars); - assert!(res.is_err(), + fail_unless!(res.is_err(), "Op {} succeeded incorrectly with 0 stack entries", *cap); let p = if *cap == "%s" || *cap == "%l" { String(~"foo") } else { Number(97) }; let res = expand((bytes!("%p1")).to_owned() + cap.as_bytes(), [p], vars); - assert!(res.is_ok(), + fail_unless!(res.is_ok(), "Op {} failed with 1 stack entry: {}", *cap, res.unwrap_err()); } let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"]; for cap in caps.iter() { let res = expand(cap.as_bytes(), [], vars); - assert!(res.is_err(), + fail_unless!(res.is_err(), "Binop {} succeeded incorrectly with 0 stack entries", *cap); let res = expand((bytes!("%{1}")).to_owned() + cap.as_bytes(), [], vars); - assert!(res.is_err(), + fail_unless!(res.is_err(), "Binop {} succeeded incorrectly with 1 stack entry", *cap); let res = expand((bytes!("%{1}%{2}")).to_owned() + cap.as_bytes(), [], vars); - assert!(res.is_ok(), + fail_unless!(res.is_ok(), "Binop {} failed with 2 stack entries: {}", *cap, res.unwrap_err()); } } #[test] fn test_push_bad_param() { - assert!(expand(bytes!("%pa"), [], &mut Variables::new()).is_err()); + fail_unless!(expand(bytes!("%pa"), [], &mut Variables::new()).is_err()); } #[test] @@ -619,15 +619,15 @@ mod test { for &(op, bs) in v.iter() { let s = format!("%\\{1\\}%\\{2\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), ~['0' as u8 + bs[0]]); let s = format!("%\\{1\\}%\\{1\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), ~['0' as u8 + bs[1]]); let s = format!("%\\{2\\}%\\{1\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), ~['0' as u8 + bs[2]]); } } @@ -637,13 +637,13 @@ mod test { let mut vars = Variables::new(); let s = bytes!("\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"); let res = expand(s, [Number(1)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), bytes!("\\E[31m").to_owned()); let res = expand(s, [Number(8)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), bytes!("\\E[90m").to_owned()); let res = expand(s, [Number(42)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + fail_unless!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), bytes!("\\E[38;5;42m").to_owned()); } diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index b2d06d3b7d823..684bb6409d00e 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -193,7 +193,7 @@ pub fn parse(file: &mut io::Reader, let string_offsets_count = try!(file.read_le_i16()) as int; let string_table_bytes = try!(file.read_le_i16()) as int; - assert!(names_bytes > 0); + fail_unless!(names_bytes > 0); debug!("names_bytes = {}", names_bytes); debug!("bools_bytes = {}", bools_bytes); diff --git a/src/libterm/terminfo/searcher.rs b/src/libterm/terminfo/searcher.rs index 5b536d9aafa91..81e1da930bb19 100644 --- a/src/libterm/terminfo/searcher.rs +++ b/src/libterm/terminfo/searcher.rs @@ -96,10 +96,10 @@ fn test_get_dbpath_for_term() { let p = get_dbpath_for_term(t).expect("no terminfo entry found"); p.as_str().unwrap().to_owned() }; - assert!(x("screen") == ~"/usr/share/terminfo/s/screen"); - assert!(get_dbpath_for_term("") == None); + fail_unless!(x("screen") == ~"/usr/share/terminfo/s/screen"); + fail_unless!(get_dbpath_for_term("") == None); setenv("TERMINFO_DIRS", ":"); - assert!(x("screen") == ~"/usr/share/terminfo/s/screen"); + fail_unless!(x("screen") == ~"/usr/share/terminfo/s/screen"); unsetenv("TERMINFO_DIRS"); } @@ -108,5 +108,5 @@ fn test_get_dbpath_for_term() { fn test_open() { open("screen").unwrap(); let t = open("nonexistent terminal that hopefully does not exist"); - assert!(t.is_err()); + fail_unless!(t.is_err()); } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 19c2f80cdbd56..2074302ea71da 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -604,7 +604,7 @@ impl ConsoleTestState { pub fn write_run_finish(&mut self, ratchet_metrics: &Option, ratchet_pct: Option) -> io::IoResult { - assert!(self.passed + self.failed + self.ignored + self.measured == self.total); + fail_unless!(self.passed + self.failed + self.ignored + self.measured == self.total); let ratchet_success = match *ratchet_metrics { None => true, @@ -774,7 +774,7 @@ fn should_sort_failures_before_printing_them() { let apos = s.as_slice().find_str("a").unwrap(); let bpos = s.as_slice().find_str("b").unwrap(); - assert!(apos < bpos); + fail_unless!(apos < bpos); } fn use_color() -> bool { return get_concurrency() == 1; } @@ -1018,7 +1018,7 @@ impl MetricMap { /// This function will fail if the path does not exist or the path does not /// contain a valid metric map. pub fn load(p: &Path) -> MetricMap { - assert!(p.exists()); + fail_unless!(p.exists()); let mut f = File::open(p).unwrap(); let value = json::from_reader(&mut f as &mut io::Reader).unwrap(); let mut decoder = json::Decoder::new(value); @@ -1310,7 +1310,7 @@ mod tests { let (p, ch) = Chan::new(); run_test(false, desc, ch); let (_, res, _) = p.recv(); - assert!(res != TrOk); + fail_unless!(res != TrOk); } #[test] @@ -1371,7 +1371,7 @@ mod tests { Some(Ok(o)) => o, _ => fail!("Malformed arg in first_free_arg_should_be_a_filter") }; - assert!("filter" == opts.filter.clone().unwrap()); + fail_unless!("filter" == opts.filter.clone().unwrap()); } #[test] @@ -1381,7 +1381,7 @@ mod tests { Some(Ok(o)) => o, _ => fail!("Malformed arg in parse_ignored_flag") }; - assert!((opts.run_ignored)); + fail_unless!((opts.run_ignored)); } #[test] @@ -1423,7 +1423,7 @@ mod tests { assert_eq!(filtered.len(), 1); assert_eq!(filtered[0].desc.name.to_str(), ~"1"); - assert!(filtered[0].desc.ignore == false); + fail_unless!(filtered[0].desc.ignore == false); } #[test] @@ -1476,7 +1476,7 @@ mod tests { ~"test::sort_tests"]; for (a, b) in expected.iter().zip(filtered.iter()) { - assert!(*a == b.desc.name.to_str()); + fail_unless!(*a == b.desc.name.to_str()); } } diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 1f0a0686658f2..0898db9a4b498 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -76,7 +76,7 @@ pub struct Timespec { sec: i64, nsec: i32 } */ impl Timespec { pub fn new(sec: i64, nsec: i32) -> Timespec { - assert!(nsec >= 0 && nsec < NSEC_PER_SEC); + fail_unless!(nsec >= 0 && nsec < NSEC_PER_SEC); Timespec { sec: sec, nsec: nsec } } } @@ -1082,34 +1082,34 @@ mod tests { let tv1 = get_time(); debug!("tv1={:?} sec + {:?} nsec", tv1.sec as uint, tv1.nsec as uint); - assert!(tv1.sec > SOME_RECENT_DATE); - assert!(tv1.nsec < 1000000000i32); + fail_unless!(tv1.sec > SOME_RECENT_DATE); + fail_unless!(tv1.nsec < 1000000000i32); let tv2 = get_time(); debug!("tv2={:?} sec + {:?} nsec", tv2.sec as uint, tv2.nsec as uint); - assert!(tv2.sec >= tv1.sec); - assert!(tv2.sec < SOME_FUTURE_DATE); - assert!(tv2.nsec < 1000000000i32); + fail_unless!(tv2.sec >= tv1.sec); + fail_unless!(tv2.sec < SOME_FUTURE_DATE); + fail_unless!(tv2.nsec < 1000000000i32); if tv2.sec == tv1.sec { - assert!(tv2.nsec >= tv1.nsec); + fail_unless!(tv2.nsec >= tv1.nsec); } } fn test_precise_time() { let s0 = precise_time_s(); debug!("s0={} sec", f64::to_str_digits(s0, 9u)); - assert!(s0 > 0.); + fail_unless!(s0 > 0.); let ns0 = precise_time_ns(); let ns1 = precise_time_ns(); debug!("ns0={:?} ns", ns0); debug!("ns1={:?} ns", ns1); - assert!(ns1 >= ns0); + fail_unless!(ns1 >= ns0); let ns2 = precise_time_ns(); debug!("ns2={:?} ns", ns2); - assert!(ns2 >= ns1); + fail_unless!(ns2 >= ns1); } fn test_at_utc() { @@ -1154,7 +1154,7 @@ mod tests { // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = &local.tm_zone; - assert!(*zone == ~"PST" || *zone == ~"Pacific Standard Time"); + fail_unless!(*zone == ~"PST" || *zone == ~"Pacific Standard Time"); assert_eq!(local.tm_nsec, 54321_i32); } @@ -1176,12 +1176,12 @@ mod tests { let utc = at_utc(time); let local = at(time); - assert!(local.to_local() == local); - assert!(local.to_utc() == utc); - assert!(local.to_utc().to_local() == local); - assert!(utc.to_utc() == utc); - assert!(utc.to_local() == local); - assert!(utc.to_local().to_utc() == utc); + fail_unless!(local.to_local() == local); + fail_unless!(local.to_utc() == utc); + fail_unless!(local.to_utc().to_local() == local); + fail_unless!(utc.to_utc() == utc); + fail_unless!(utc.to_local() == local); + fail_unless!(utc.to_local().to_utc() == utc); } fn test_strptime() { @@ -1189,41 +1189,41 @@ mod tests { match strptime("", "") { Ok(ref tm) => { - assert!(tm.tm_sec == 0_i32); - assert!(tm.tm_min == 0_i32); - assert!(tm.tm_hour == 0_i32); - assert!(tm.tm_mday == 0_i32); - assert!(tm.tm_mon == 0_i32); - assert!(tm.tm_year == 0_i32); - assert!(tm.tm_wday == 0_i32); - assert!(tm.tm_isdst == 0_i32); - assert!(tm.tm_gmtoff == 0_i32); - assert!(tm.tm_zone == ~""); - assert!(tm.tm_nsec == 0_i32); + fail_unless!(tm.tm_sec == 0_i32); + fail_unless!(tm.tm_min == 0_i32); + fail_unless!(tm.tm_hour == 0_i32); + fail_unless!(tm.tm_mday == 0_i32); + fail_unless!(tm.tm_mon == 0_i32); + fail_unless!(tm.tm_year == 0_i32); + fail_unless!(tm.tm_wday == 0_i32); + fail_unless!(tm.tm_isdst == 0_i32); + fail_unless!(tm.tm_gmtoff == 0_i32); + fail_unless!(tm.tm_zone == ~""); + fail_unless!(tm.tm_nsec == 0_i32); } Err(_) => () } let format = "%a %b %e %T.%f %Y"; assert_eq!(strptime("", format), Err(~"Invalid time")); - assert!(strptime("Fri Feb 13 15:31:30", format) + fail_unless!(strptime("Fri Feb 13 15:31:30", format) == Err(~"Invalid time")); match strptime("Fri Feb 13 15:31:30.01234 2009", format) { Err(e) => fail!(e), Ok(ref tm) => { - assert!(tm.tm_sec == 30_i32); - assert!(tm.tm_min == 31_i32); - assert!(tm.tm_hour == 15_i32); - assert!(tm.tm_mday == 13_i32); - assert!(tm.tm_mon == 1_i32); - assert!(tm.tm_year == 109_i32); - assert!(tm.tm_wday == 5_i32); - assert!(tm.tm_yday == 0_i32); - assert!(tm.tm_isdst == 0_i32); - assert!(tm.tm_gmtoff == 0_i32); - assert!(tm.tm_zone == ~""); - assert!(tm.tm_nsec == 12340000_i32); + fail_unless!(tm.tm_sec == 30_i32); + fail_unless!(tm.tm_min == 31_i32); + fail_unless!(tm.tm_hour == 15_i32); + fail_unless!(tm.tm_mday == 13_i32); + fail_unless!(tm.tm_mon == 1_i32); + fail_unless!(tm.tm_year == 109_i32); + fail_unless!(tm.tm_wday == 5_i32); + fail_unless!(tm.tm_yday == 0_i32); + fail_unless!(tm.tm_isdst == 0_i32); + fail_unless!(tm.tm_gmtoff == 0_i32); + fail_unless!(tm.tm_zone == ~""); + fail_unless!(tm.tm_nsec == 12340000_i32); } } @@ -1244,7 +1244,7 @@ mod tests { ~"Saturday" ]; for day in days.iter() { - assert!(test(*day, "%A")); + fail_unless!(test(*day, "%A")); } let days = [ @@ -1257,7 +1257,7 @@ mod tests { ~"Sat" ]; for day in days.iter() { - assert!(test(*day, "%a")); + fail_unless!(test(*day, "%a")); } let months = [ @@ -1275,7 +1275,7 @@ mod tests { ~"December" ]; for day in months.iter() { - assert!(test(*day, "%B")); + fail_unless!(test(*day, "%B")); } let months = [ @@ -1293,56 +1293,56 @@ mod tests { ~"Dec" ]; for day in months.iter() { - assert!(test(*day, "%b")); + fail_unless!(test(*day, "%b")); } - assert!(test("19", "%C")); - assert!(test("Fri Feb 13 23:31:30 2009", "%c")); - assert!(test("02/13/09", "%D")); - assert!(test("03", "%d")); - assert!(test("13", "%d")); - assert!(test(" 3", "%e")); - assert!(test("13", "%e")); - assert!(test("2009-02-13", "%F")); - assert!(test("03", "%H")); - assert!(test("13", "%H")); - assert!(test("03", "%I")); // FIXME (#2350): flesh out - assert!(test("11", "%I")); // FIXME (#2350): flesh out - assert!(test("044", "%j")); - assert!(test(" 3", "%k")); - assert!(test("13", "%k")); - assert!(test(" 1", "%l")); - assert!(test("11", "%l")); - assert!(test("03", "%M")); - assert!(test("13", "%M")); - assert!(test("\n", "%n")); - assert!(test("am", "%P")); - assert!(test("pm", "%P")); - assert!(test("AM", "%p")); - assert!(test("PM", "%p")); - assert!(test("23:31", "%R")); - assert!(test("11:31:30 AM", "%r")); - assert!(test("11:31:30 PM", "%r")); - assert!(test("03", "%S")); - assert!(test("13", "%S")); - assert!(test("15:31:30", "%T")); - assert!(test("\t", "%t")); - assert!(test("1", "%u")); - assert!(test("7", "%u")); - assert!(test("13-Feb-2009", "%v")); - assert!(test("0", "%w")); - assert!(test("6", "%w")); - assert!(test("2009", "%Y")); - assert!(test("09", "%y")); - assert!(strptime("UTC", "%Z").unwrap().tm_zone == + fail_unless!(test("19", "%C")); + fail_unless!(test("Fri Feb 13 23:31:30 2009", "%c")); + fail_unless!(test("02/13/09", "%D")); + fail_unless!(test("03", "%d")); + fail_unless!(test("13", "%d")); + fail_unless!(test(" 3", "%e")); + fail_unless!(test("13", "%e")); + fail_unless!(test("2009-02-13", "%F")); + fail_unless!(test("03", "%H")); + fail_unless!(test("13", "%H")); + fail_unless!(test("03", "%I")); // FIXME (#2350): flesh out + fail_unless!(test("11", "%I")); // FIXME (#2350): flesh out + fail_unless!(test("044", "%j")); + fail_unless!(test(" 3", "%k")); + fail_unless!(test("13", "%k")); + fail_unless!(test(" 1", "%l")); + fail_unless!(test("11", "%l")); + fail_unless!(test("03", "%M")); + fail_unless!(test("13", "%M")); + fail_unless!(test("\n", "%n")); + fail_unless!(test("am", "%P")); + fail_unless!(test("pm", "%P")); + fail_unless!(test("AM", "%p")); + fail_unless!(test("PM", "%p")); + fail_unless!(test("23:31", "%R")); + fail_unless!(test("11:31:30 AM", "%r")); + fail_unless!(test("11:31:30 PM", "%r")); + fail_unless!(test("03", "%S")); + fail_unless!(test("13", "%S")); + fail_unless!(test("15:31:30", "%T")); + fail_unless!(test("\t", "%t")); + fail_unless!(test("1", "%u")); + fail_unless!(test("7", "%u")); + fail_unless!(test("13-Feb-2009", "%v")); + fail_unless!(test("0", "%w")); + fail_unless!(test("6", "%w")); + fail_unless!(test("2009", "%Y")); + fail_unless!(test("09", "%y")); + fail_unless!(strptime("UTC", "%Z").unwrap().tm_zone == ~"UTC"); - assert!(strptime("PST", "%Z").unwrap().tm_zone == + fail_unless!(strptime("PST", "%Z").unwrap().tm_zone == ~""); - assert!(strptime("-0000", "%z").unwrap().tm_gmtoff == + fail_unless!(strptime("-0000", "%z").unwrap().tm_gmtoff == 0); - assert!(strptime("-0800", "%z").unwrap().tm_gmtoff == + fail_unless!(strptime("-0800", "%z").unwrap().tm_gmtoff == 0); - assert!(test("%", "%%")); + fail_unless!(test("%", "%%")); // Test for #7256 assert_eq!(strptime("360", "%Y-%m-%d"), Err(~"Invalid year")) @@ -1413,7 +1413,7 @@ mod tests { // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = local.strftime("%Z"); - assert!(zone == ~"PST" || zone == ~"Pacific Standard Time"); + fail_unless!(zone == ~"PST" || zone == ~"Pacific Standard Time"); assert_eq!(local.strftime("%z"), ~"-0800"); assert_eq!(local.strftime("%%"), ~"%"); @@ -1422,7 +1422,7 @@ mod tests { // abbreviation. let rfc822 = local.rfc822(); let prefix = ~"Fri, 13 Feb 2009 15:31:30 "; - assert!(rfc822 == prefix + "PST" || rfc822 == prefix + "Pacific Standard Time"); + fail_unless!(rfc822 == prefix + "PST" || rfc822 == prefix + "Pacific Standard Time"); assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); assert_eq!(local.rfc822z(), ~"Fri, 13 Feb 2009 15:31:30 -0800"); @@ -1441,28 +1441,28 @@ mod tests { let d = &Timespec::new(2, 1); let e = &Timespec::new(2, 1); - assert!(d.eq(e)); - assert!(c.ne(e)); + fail_unless!(d.eq(e)); + fail_unless!(c.ne(e)); - assert!(a.lt(b)); - assert!(b.lt(c)); - assert!(c.lt(d)); + fail_unless!(a.lt(b)); + fail_unless!(b.lt(c)); + fail_unless!(c.lt(d)); - assert!(a.le(b)); - assert!(b.le(c)); - assert!(c.le(d)); - assert!(d.le(e)); - assert!(e.le(d)); + fail_unless!(a.le(b)); + fail_unless!(b.le(c)); + fail_unless!(c.le(d)); + fail_unless!(d.le(e)); + fail_unless!(e.le(d)); - assert!(b.ge(a)); - assert!(c.ge(b)); - assert!(d.ge(c)); - assert!(e.ge(d)); - assert!(d.ge(e)); + fail_unless!(b.ge(a)); + fail_unless!(c.ge(b)); + fail_unless!(d.ge(c)); + fail_unless!(e.ge(d)); + fail_unless!(d.ge(e)); - assert!(b.gt(a)); - assert!(c.gt(b)); - assert!(d.gt(c)); + fail_unless!(b.gt(a)); + fail_unless!(c.gt(b)); + fail_unless!(d.gt(c)); } #[test] diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 5941afb7d7573..c3e1fbae23f07 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -418,8 +418,8 @@ impl Uuid { let vs = hex_groups.concat(); // At this point, we know we have a valid hex string, without hyphens - assert!(vs.len() == 32); - assert!(vs.chars().all(|c| c.is_digit_radix(16))); + fail_unless!(vs.len() == 32); + fail_unless!(vs.chars().all(|c| c.is_digit_radix(16))); // Allocate output UUID buffer let mut ub = [0u8, ..16]; @@ -531,8 +531,8 @@ mod test { let nil = Uuid::nil(); let not_nil = Uuid::new_v4(); - assert!(nil.is_nil()); - assert!(!not_nil.is_nil()); + fail_unless!(nil.is_nil()); + fail_unless!(!not_nil.is_nil()); } #[test] @@ -541,30 +541,30 @@ mod test { let uuid1 = Uuid::new(Version4Random).unwrap(); let s = uuid1.to_simple_str(); - assert!(s.len() == 32); - assert!(uuid1.get_version().unwrap() == Version4Random); + fail_unless!(s.len() == 32); + fail_unless!(uuid1.get_version().unwrap() == Version4Random); // Test unsupported versions - assert!(Uuid::new(Version1Mac) == None); - assert!(Uuid::new(Version2Dce) == None); - assert!(Uuid::new(Version3Md5) == None); - assert!(Uuid::new(Version5Sha1) == None); + fail_unless!(Uuid::new(Version1Mac) == None); + fail_unless!(Uuid::new(Version2Dce) == None); + fail_unless!(Uuid::new(Version3Md5) == None); + fail_unless!(Uuid::new(Version5Sha1) == None); } #[test] fn test_new_v4() { let uuid1 = Uuid::new_v4(); - assert!(uuid1.get_version().unwrap() == Version4Random); - assert!(uuid1.get_variant().unwrap() == VariantRFC4122); + fail_unless!(uuid1.get_version().unwrap() == Version4Random); + fail_unless!(uuid1.get_variant().unwrap() == VariantRFC4122); } #[test] fn test_get_version() { let uuid1 = Uuid::new_v4(); - assert!(uuid1.get_version().unwrap() == Version4Random); - assert!(uuid1.get_version_num() == 4); + fail_unless!(uuid1.get_version().unwrap() == Version4Random); + fail_unless!(uuid1.get_version_num() == 4); } #[test] @@ -576,12 +576,12 @@ mod test { let uuid5 = Uuid::parse_string("F9168C5E-CEB2-4faa-D6BF-329BF39FA1E4").unwrap(); let uuid6 = Uuid::parse_string("f81d4fae-7dec-11d0-7765-00a0c91e6bf6").unwrap(); - assert!(uuid1.get_variant().unwrap() == VariantRFC4122); - assert!(uuid2.get_variant().unwrap() == VariantRFC4122); - assert!(uuid3.get_variant().unwrap() == VariantRFC4122); - assert!(uuid4.get_variant().unwrap() == VariantMicrosoft); - assert!(uuid5.get_variant().unwrap() == VariantMicrosoft); - assert!(uuid6.get_variant().unwrap() == VariantNCS); + fail_unless!(uuid1.get_variant().unwrap() == VariantRFC4122); + fail_unless!(uuid2.get_variant().unwrap() == VariantRFC4122); + fail_unless!(uuid3.get_variant().unwrap() == VariantRFC4122); + fail_unless!(uuid4.get_variant().unwrap() == VariantMicrosoft); + fail_unless!(uuid5.get_variant().unwrap() == VariantMicrosoft); + fail_unless!(uuid6.get_variant().unwrap() == VariantNCS); } #[test] @@ -590,53 +590,53 @@ mod test { ErrorInvalidGroupLength, ErrorInvalidLength}; // Invalid - assert!(Uuid::parse_string("").is_err()); - assert!(Uuid::parse_string("!").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E45").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faaXB6BFF329BF39FA1E4").is_err()); - assert!(Uuid::parse_string("F9168C5E-CEB-24fa-eB6BFF32-BF39FA1E4").is_err()); - assert!(Uuid::parse_string("01020304-1112-2122-3132-41424344").is_err()); - assert!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c").is_err()); - assert!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c88").is_err()); - assert!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0cg8").is_err()); - assert!(Uuid::parse_string("67e5504410b1426%9247bb680e5fe0c8").is_err()); + fail_unless!(Uuid::parse_string("").is_err()); + fail_unless!(Uuid::parse_string("!").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E45").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faaXB6BFF329BF39FA1E4").is_err()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB-24fa-eB6BFF32-BF39FA1E4").is_err()); + fail_unless!(Uuid::parse_string("01020304-1112-2122-3132-41424344").is_err()); + fail_unless!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c").is_err()); + fail_unless!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c88").is_err()); + fail_unless!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0cg8").is_err()); + fail_unless!(Uuid::parse_string("67e5504410b1426%9247bb680e5fe0c8").is_err()); // Valid - assert!(Uuid::parse_string("00000000000000000000000000000000").is_ok()); - assert!(Uuid::parse_string("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); - assert!(Uuid::parse_string("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); - assert!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").is_ok()); - assert!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c8").is_ok()); - assert!(Uuid::parse_string("01020304-1112-2122-3132-414243444546").is_ok()); - assert!(Uuid::parse_string("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); + fail_unless!(Uuid::parse_string("00000000000000000000000000000000").is_ok()); + fail_unless!(Uuid::parse_string("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); + fail_unless!(Uuid::parse_string("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); + fail_unless!(Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").is_ok()); + fail_unless!(Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c8").is_ok()); + fail_unless!(Uuid::parse_string("01020304-1112-2122-3132-414243444546").is_ok()); + fail_unless!(Uuid::parse_string("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); // Nil let nil = Uuid::nil(); - assert!(Uuid::parse_string("00000000000000000000000000000000").unwrap() == nil); - assert!(Uuid::parse_string("00000000-0000-0000-0000-000000000000").unwrap() == nil); + fail_unless!(Uuid::parse_string("00000000000000000000000000000000").unwrap() == nil); + fail_unless!(Uuid::parse_string("00000000-0000-0000-0000-000000000000").unwrap() == nil); // Round-trip let uuid_orig = Uuid::new_v4(); let orig_str = uuid_orig.to_str(); let uuid_out = Uuid::parse_string(orig_str).unwrap(); - assert!(uuid_orig == uuid_out); + fail_unless!(uuid_orig == uuid_out); // Test error reporting let e = Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c").unwrap_err(); - assert!(match e { ErrorInvalidLength(n) => n==31, _ => false }); + fail_unless!(match e { ErrorInvalidLength(n) => n==31, _ => false }); let e = Uuid::parse_string("67e550X410b1426f9247bb680e5fe0cd").unwrap_err(); - assert!(match e { ErrorInvalidCharacter(c, n) => c=='X' && n==6, _ => false }); + fail_unless!(match e { ErrorInvalidCharacter(c, n) => c=='X' && n==6, _ => false }); let e = Uuid::parse_string("67e550-4105b1426f9247bb680e5fe0c").unwrap_err(); - assert!(match e { ErrorInvalidGroups(n) => n==2, _ => false }); + fail_unless!(match e { ErrorInvalidGroups(n) => n==2, _ => false }); let e = Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF1-02BF39FA1E4").unwrap_err(); - assert!(match e { ErrorInvalidGroupLength(g, n, e) => g==3 && n==5 && e==4, _ => false }); + fail_unless!(match e { ErrorInvalidGroupLength(g, n, e) => g==3 && n==5 && e==4, _ => false }); } #[test] @@ -644,8 +644,8 @@ mod test { let uuid1 = Uuid::new_v4(); let s = uuid1.to_simple_str(); - assert!(s.len() == 32); - assert!(s.chars().all(|c| c.is_digit_radix(16))); + fail_unless!(s.len() == 32); + fail_unless!(s.chars().all(|c| c.is_digit_radix(16))); } #[test] @@ -653,8 +653,8 @@ mod test { let uuid1 = Uuid::new_v4(); let s = uuid1.to_str(); - assert!(s.len() == 32); - assert!(s.chars().all(|c| c.is_digit_radix(16))); + fail_unless!(s.len() == 32); + fail_unless!(s.chars().all(|c| c.is_digit_radix(16))); } #[test] @@ -662,8 +662,8 @@ mod test { let uuid1 = Uuid::new_v4(); let s = uuid1.to_hyphenated_str(); - assert!(s.len() == 36); - assert!(s.chars().all(|c| c.is_digit_radix(16) || c == '-')); + fail_unless!(s.len() == 36); + fail_unless!(s.chars().all(|c| c.is_digit_radix(16) || c == '-')); } #[test] @@ -672,9 +672,9 @@ mod test { let ss = uuid1.to_urn_str(); let s = ss.slice(9, ss.len()); - assert!(ss.starts_with("urn:uuid:")); - assert!(s.len() == 36); - assert!(s.chars().all(|c| c.is_digit_radix(16) || c == '-')); + fail_unless!(ss.starts_with("urn:uuid:")); + fail_unless!(s.len() == 36); + fail_unless!(s.chars().all(|c| c.is_digit_radix(16) || c == '-')); } #[test] @@ -686,7 +686,7 @@ mod test { let hsn = str::from_chars(hs.chars().filter(|&c| c != '-').collect::<~[char]>()); - assert!(hsn == ss); + fail_unless!(hsn == ss); } #[test] @@ -695,11 +695,11 @@ mod test { let hs = uuid.to_hyphenated_str(); let uuid_hs = Uuid::parse_string(hs).unwrap(); - assert!(uuid_hs == uuid); + fail_unless!(uuid_hs == uuid); let ss = uuid.to_str(); let uuid_ss = Uuid::parse_string(ss).unwrap(); - assert!(uuid_ss == uuid); + fail_unless!(uuid_ss == uuid); } #[test] @@ -707,10 +707,10 @@ mod test { let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); - assert!(uuid1 == uuid1); - assert!(uuid2 == uuid2); - assert!(uuid1 != uuid2); - assert!(uuid2 != uuid1); + fail_unless!(uuid1 == uuid1); + fail_unless!(uuid2 == uuid2); + fail_unless!(uuid1 != uuid2); + fail_unless!(uuid2 != uuid1); } #[test] @@ -724,7 +724,7 @@ mod test { let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"; let result = u.to_simple_str(); - assert!(result == expected); + fail_unless!(result == expected); } #[test] @@ -735,7 +735,7 @@ mod test { let u = Uuid::from_bytes(b).unwrap(); let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"; - assert!(u.to_simple_str() == expected); + fail_unless!(u.to_simple_str() == expected); } #[test] @@ -743,8 +743,8 @@ mod test { let u = Uuid::new_v4(); let ub = u.to_bytes(); - assert!(ub.len() == 16); - assert!(! ub.iter().all(|&b| b == 0)); + fail_unless!(ub.len() == 16); + fail_unless!(! ub.iter().all(|&b| b == 0)); } #[test] @@ -756,7 +756,7 @@ mod test { let b_out = u.to_bytes(); - assert!(b_in == b_out); + fail_unless!(b_in == b_out); } #[test] @@ -765,14 +765,14 @@ mod test { let u2 = u1.clone(); let u3 = Uuid::new_v4(); - assert!(u1 == u1); - assert!(u1 == u2); - assert!(u2 == u1); + fail_unless!(u1 == u1); + fail_unless!(u1 == u2); + fail_unless!(u2 == u1); - assert!(u1 != u3); - assert!(u3 != u1); - assert!(u2 != u3); - assert!(u3 != u2); + fail_unless!(u1 != u3); + fail_unless!(u3 != u1); + fail_unless!(u2 != u3); + fail_unless!(u3 != u2); } #[test] @@ -781,8 +781,8 @@ mod test { let u: ~Uuid = rand::Rand::rand(&mut rng); let ub = u.to_bytes(); - assert!(ub.len() == 16); - assert!(! ub.iter().all(|&b| b == 0)); + fail_unless!(ub.len() == 16); + fail_unless!(! ub.iter().all(|&b| b == 0)); } #[test] @@ -805,8 +805,8 @@ mod test { let id1 = Uuid::new_v4(); let id2 = Uuid::new_v4(); set.insert(id1); - assert!(set.contains(&id1)); - assert!(!set.contains(&id2)); + fail_unless!(set.contains(&id1)); + fail_unless!(!set.contains(&id2)); } } diff --git a/src/test/auxiliary/extern_calling_convention.rs b/src/test/auxiliary/extern_calling_convention.rs index 41c57831da64f..833986a6cf1b3 100644 --- a/src/test/auxiliary/extern_calling_convention.rs +++ b/src/test/auxiliary/extern_calling_convention.rs @@ -14,10 +14,10 @@ #[inline(never)] #[cfg(target_arch = "x86_64")] pub extern "win64" fn foo(a: int, b: int, c: int, d: int) { - assert!(a == 1); - assert!(b == 2); - assert!(c == 3); - assert!(d == 4); + fail_unless!(a == 1); + fail_unless!(b == 2); + fail_unless!(c == 3); + fail_unless!(d == 4); println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}", a, b, c, d) @@ -27,10 +27,10 @@ pub extern "win64" fn foo(a: int, b: int, c: int, d: int) { #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] pub extern fn foo(a: int, b: int, c: int, d: int) { - assert!(a == 1); - assert!(b == 2); - assert!(c == 3); - assert!(d == 4); + fail_unless!(a == 1); + fail_unless!(b == 2); + fail_unless!(c == 3); + fail_unless!(d == 4); println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}", a, b, c, d) diff --git a/src/test/auxiliary/linkage-visibility.rs b/src/test/auxiliary/linkage-visibility.rs index ab3539ebf6f54..717dcc1488ade 100644 --- a/src/test/auxiliary/linkage-visibility.rs +++ b/src/test/auxiliary/linkage-visibility.rs @@ -29,8 +29,8 @@ fn baz() { } pub fn test() { let lib = DynamicLibrary::open(None).unwrap(); unsafe { - assert!(lib.symbol::("foo").is_ok()); - assert!(lib.symbol::("baz").is_err()); - assert!(lib.symbol::("bar").is_err()); + fail_unless!(lib.symbol::("foo").is_ok()); + fail_unless!(lib.symbol::("baz").is_err()); + fail_unless!(lib.symbol::("bar").is_err()); } } diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index ac77e62f2c014..66639e11d906e 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -43,7 +43,7 @@ fn ascending>(map: &mut M, n_keys: uint) { timed("remove", || { for i in range(0, n_keys) { - assert!(map.remove(&i)); + fail_unless!(map.remove(&i)); } }); } @@ -65,7 +65,7 @@ fn descending>(map: &mut M, n_keys: uint) { timed("remove", || { for i in range(0, n_keys) { - assert!(map.remove(&i)); + fail_unless!(map.remove(&i)); } }); } @@ -85,7 +85,7 @@ fn vector>(map: &mut M, n_keys: uint, dist: &[uint]) { timed("remove", || { for i in range(0u, n_keys) { - assert!(map.remove(&dist[i])); + fail_unless!(map.remove(&dist[i])); } }); } diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index 25ced5f35da1c..a1ad26871d3e2 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -52,7 +52,7 @@ impl Results { } for i in range(0u, num_keys) { - assert!(set.contains(&i)); + fail_unless!(set.contains(&i)); } }) } @@ -74,7 +74,7 @@ impl Results { timed(&mut self.delete_ints, || { for i in range(0u, num_keys) { - assert!(set.remove(&i)); + fail_unless!(set.remove(&i)); } }) } @@ -94,7 +94,7 @@ impl Results { } for i in range(0u, num_keys) { - assert!(set.contains(&i.to_str())); + fail_unless!(set.contains(&i.to_str())); } }) } @@ -116,7 +116,7 @@ impl Results { } timed(&mut self.delete_strings, || { for i in range(0u, num_keys) { - assert!(set.remove(&i.to_str())); + fail_unless!(set.remove(&i.to_str())); } }) } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index a4041ae181644..625eb8c8b1846 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -68,7 +68,7 @@ impl Sudoku { } pub fn read(mut reader: BufferedReader) -> Sudoku { - assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */ + fail_unless!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */ let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] }); for line in reader.lines() { @@ -269,7 +269,7 @@ fn check_DEFAULT_SUDOKU_solution() { sudoku.solve(); // THEN - assert!(sudoku.equal(&solution)); + fail_unless!(sudoku.equal(&solution)); } fn main() { diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 189a3ac74480e..36492459f42e7 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -69,7 +69,7 @@ fn spawn_supervised_blocking(myname: &str, f: proc()) { builder.spawn(f); error!("{} group waiting", myname); let x = res.recv(); - assert!(x.is_ok()); + fail_unless!(x.is_ok()); } fn main() { @@ -99,5 +99,5 @@ fn main() { error!("Grandparent group wakes up and fails"); fail!(); }); - assert!(x.is_err()); + fail_unless!(x.is_err()); } diff --git a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs index 1787cd5d0b46c..269e0e20f015b 100644 --- a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs @@ -19,5 +19,5 @@ fn main() { }); y.unwrap(); // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).read(|state| { assert!(*state == 1); }) + // (&option::unwrap(y)).read(|state| { fail_unless!(*state == 1); }) } diff --git a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs index 8f93d672b9016..37b005ff8ed24 100644 --- a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs @@ -17,5 +17,5 @@ fn main() { x.write_downgrade(|write_mode| y = Some(write_mode)); y.unwrap(); // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).write(|state| { assert!(*state == 1); }) + // (&option::unwrap(y)).write(|state| { fail_unless!(*state == 1); }) } diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs index 015d31bf42cce..8d19e1bc288a9 100644 --- a/src/test/compile-fail/bind-by-move-no-guards.rs +++ b/src/test/compile-fail/bind-by-move-no-guards.rs @@ -14,7 +14,7 @@ fn main() { c.send(false); match x { Some(z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard - Some(z) => { assert!(!z.recv()); }, + Some(z) => { fail_unless!(!z.recv()); }, None => fail!() } } diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs index c82f752a4548e..48443daa8041f 100644 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ b/src/test/compile-fail/builtin-superkinds-self-type.rs @@ -22,5 +22,5 @@ impl Foo for T { } fn main() { let (p,c) = Chan::new(); 1193182.foo(c); - assert!(p.recv() == 1193182); + fail_unless!(p.recv() == 1193182); } diff --git a/src/test/compile-fail/cast-from-nil.rs b/src/test/compile-fail/cast-from-nil.rs index 558a54787183d..1c2a3e1742672 100644 --- a/src/test/compile-fail/cast-from-nil.rs +++ b/src/test/compile-fail/cast-from-nil.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern: cast from nil: `()` as `u32` -fn main() { let u = (assert!(true) as u32); } +fn main() { let u = (fail_unless!(true) as u32); } diff --git a/src/test/compile-fail/crateresolve5.rs b/src/test/compile-fail/crateresolve5.rs index 124696630cc08..0abbc6b76e498 100644 --- a/src/test/compile-fail/crateresolve5.rs +++ b/src/test/compile-fail/crateresolve5.rs @@ -18,5 +18,5 @@ extern crate cr5_2 = "crateresolve5#0.2"; fn main() { // Nominal types from two multiple versions of a crate are different types - assert!(cr5_1::nominal() == cr5_2::nominal()); //~ ERROR mismatched types: expected + fail_unless!(cr5_1::nominal() == cr5_2::nominal()); //~ ERROR mismatched types: expected } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index ed1725f3240fa..3442f6713c2bb 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -27,5 +27,5 @@ fn main() { let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough repeater(tmp1) }; - assert!(3 == *(y.get())); + fail_unless!(3 == *(y.get())); } diff --git a/src/test/compile-fail/match-static-const-lc.rs b/src/test/compile-fail/match-static-const-lc.rs index fd605b79dbecd..9dd659bab3002 100644 --- a/src/test/compile-fail/match-static-const-lc.rs +++ b/src/test/compile-fail/match-static-const-lc.rs @@ -21,7 +21,7 @@ fn f() { //~^ ERROR static constant in pattern should be all caps (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); } mod m { @@ -35,7 +35,7 @@ fn g() { //~^ ERROR static constant in pattern should be all caps (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); } mod n { @@ -49,7 +49,7 @@ fn h() { //~^ ERROR static constant in pattern should be all caps (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); } fn main () { diff --git a/src/test/compile-fail/mod_file_correct_spans.rs b/src/test/compile-fail/mod_file_correct_spans.rs index f8ea5dda18336..832e6d8a6a79a 100644 --- a/src/test/compile-fail/mod_file_correct_spans.rs +++ b/src/test/compile-fail/mod_file_correct_spans.rs @@ -13,5 +13,5 @@ mod mod_file_aux; fn main() { - assert!(mod_file_aux::bar() == 10); //~ ERROR unresolved name + fail_unless!(mod_file_aux::bar() == 10); //~ ERROR unresolved name } diff --git a/src/test/compile-fail/omitted-arg-wrong-types.rs b/src/test/compile-fail/omitted-arg-wrong-types.rs index 1f1a6849acad5..718697db09e84 100644 --- a/src/test/compile-fail/omitted-arg-wrong-types.rs +++ b/src/test/compile-fail/omitted-arg-wrong-types.rs @@ -13,9 +13,9 @@ fn let_in(x: T, f: |T|) {} fn main() { - let_in(3u, |i| { assert!(i == 3); }); + let_in(3u, |i| { fail_unless!(i == 3); }); //~^ ERROR expected `uint` but found `int` - let_in(3, |i| { assert!(i == 3u); }); + let_in(3, |i| { fail_unless!(i == 3u); }); //~^ ERROR expected `int` but found `uint` } diff --git a/src/test/compile-fail/once-cant-call-twice-on-heap.rs b/src/test/compile-fail/once-cant-call-twice-on-heap.rs index 675dcf95595a8..0bf196d642226 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-heap.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-heap.rs @@ -23,7 +23,7 @@ fn foo(blk: proc()) { fn main() { let x = Arc::new(true); foo(proc() { - assert!(*x.get()); + fail_unless!(*x.get()); drop(x); }); } diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs index 48dd484c1c26b..cd1c4afaf2f85 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-stack.rs @@ -23,7 +23,7 @@ fn foo(blk: once ||) { fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + fail_unless!(*x.get()); drop(x); }) } diff --git a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs index 804ea46b4266f..48c3dd8f89084 100644 --- a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs +++ b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs @@ -22,7 +22,7 @@ fn foo(blk: ||) { fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + fail_unless!(*x.get()); drop(x); //~ ERROR cannot move out of captured outer variable }) } diff --git a/src/test/compile-fail/private-struct-field-cross-crate.rs b/src/test/compile-fail/private-struct-field-cross-crate.rs index 0993ac9a64ad3..c6bdc8239cb4c 100644 --- a/src/test/compile-fail/private-struct-field-cross-crate.rs +++ b/src/test/compile-fail/private-struct-field-cross-crate.rs @@ -14,5 +14,5 @@ use cci_class::kitties::cat; fn main() { let nyan : cat = cat(52u, 99); - assert!((nyan.meows == 52u)); //~ ERROR field `meows` is private + fail_unless!((nyan.meows == 52u)); //~ ERROR field `meows` is private } diff --git a/src/test/compile-fail/private-struct-field.rs b/src/test/compile-fail/private-struct-field.rs index 2f6a51e163729..86a14587006ec 100644 --- a/src/test/compile-fail/private-struct-field.rs +++ b/src/test/compile-fail/private-struct-field.rs @@ -20,5 +20,5 @@ mod cat { fn main() { let nyan = cat::new_cat(); - assert!(nyan.meows == 52); //~ ERROR field `meows` is private + fail_unless!(nyan.meows == 52); //~ ERROR field `meows` is private } diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index 3719be3612bc0..54d437b9dbb48 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -24,7 +24,7 @@ fn foo(cond: || -> bool, make_box: || -> @int) { assert_eq!(*x, *y); if cond() { break; } } - assert!(*y != 0); + fail_unless!(*y != 0); } fn main() {} diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs index f2ef1d1952505..b13835a89d4f8 100644 --- a/src/test/compile-fail/tag-type-args.rs +++ b/src/test/compile-fail/tag-type-args.rs @@ -12,6 +12,6 @@ enum quux { bar } -fn foo(c: quux) { assert!((false)); } +fn foo(c: quux) { fail_unless!((false)); } fn main() { fail!(); } diff --git a/src/test/pretty/do1.rs b/src/test/pretty/do1.rs index cd7a5b29a8af1..179d25af5ca79 100644 --- a/src/test/pretty/do1.rs +++ b/src/test/pretty/do1.rs @@ -12,4 +12,4 @@ fn f(f: |int|) { f(10) } -fn main() { f(|i| { assert!(i == 10) }) } +fn main() { f(|i| { fail_unless!(i == 10) }) } diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs index c52c11b1b9188..65ad8cb551da1 100644 --- a/src/test/run-fail/assert-as-macro.rs +++ b/src/test/run-fail/assert-as-macro.rs @@ -11,5 +11,5 @@ // error-pattern:assertion failed: 1 == 2 fn main() { - assert!(1 == 2); + fail_unless!(1 == 2); } diff --git a/src/test/run-fail/assert-macro-explicit.rs b/src/test/run-fail/assert-macro-explicit.rs index 8e70c2c3561a2..ea23bc23dfaa5 100644 --- a/src/test/run-fail/assert-macro-explicit.rs +++ b/src/test/run-fail/assert-macro-explicit.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'assertion failed: false' fn main() { - assert!(false); + fail_unless!(false); } diff --git a/src/test/run-fail/assert-macro-fmt.rs b/src/test/run-fail/assert-macro-fmt.rs index 53a37c5d68445..424c8b7330522 100644 --- a/src/test/run-fail/assert-macro-fmt.rs +++ b/src/test/run-fail/assert-macro-fmt.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-assert-fmt 42 rust' fn main() { - assert!(false, "test-assert-fmt {} {}", 42, "rust"); + fail_unless!(false, "test-assert-fmt {} {}", 42, "rust"); } diff --git a/src/test/run-fail/assert-macro-owned.rs b/src/test/run-fail/assert-macro-owned.rs index f45af290b3d3d..01eff9cdbee04 100644 --- a/src/test/run-fail/assert-macro-owned.rs +++ b/src/test/run-fail/assert-macro-owned.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-assert-owned' fn main() { - assert!(false, ~"test-assert-owned"); + fail_unless!(false, ~"test-assert-owned"); } diff --git a/src/test/run-fail/assert-macro-static.rs b/src/test/run-fail/assert-macro-static.rs index a35258462deaa..9888abbf480aa 100644 --- a/src/test/run-fail/assert-macro-static.rs +++ b/src/test/run-fail/assert-macro-static.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-assert-static' fn main() { - assert!(false, "test-assert-static"); + fail_unless!(false, "test-assert-static"); } diff --git a/src/test/run-fail/fail.rs b/src/test/run-fail/fail.rs index 42cf79af66ee8..23207dcf43706 100644 --- a/src/test/run-fail/fail.rs +++ b/src/test/run-fail/fail.rs @@ -12,4 +12,4 @@ // error-pattern:1 == 2 -fn main() { assert!((1 == 2)); } +fn main() { fail_unless!((1 == 2)); } diff --git a/src/test/run-fail/issue-2761.rs b/src/test/run-fail/issue-2761.rs index 95050a4dcf19e..cf35d9624f3b0 100644 --- a/src/test/run-fail/issue-2761.rs +++ b/src/test/run-fail/issue-2761.rs @@ -11,5 +11,5 @@ // error-pattern:custom message fn main() { - assert!(false, "custom message"); + fail_unless!(false, "custom message"); } diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs index fb5fdffffeca5..ec26ea6f3718d 100644 --- a/src/test/run-fail/linked-failure.rs +++ b/src/test/run-fail/linked-failure.rs @@ -16,7 +16,7 @@ extern crate extra; use std::comm; use std::task; -fn child() { assert!((1 == 2)); } +fn child() { fail_unless!((1 == 2)); } fn main() { let (p, _c) = comm::stream::(); diff --git a/src/test/run-fail/linked-failure4.rs b/src/test/run-fail/linked-failure4.rs index fc47f470dd0ff..f5209644662e6 100644 --- a/src/test/run-fail/linked-failure4.rs +++ b/src/test/run-fail/linked-failure4.rs @@ -14,7 +14,7 @@ use std::comm; use std::task; -fn child() { assert!((1 == 2)); } +fn child() { fail_unless!((1 == 2)); } fn parent() { let (p, _c) = comm::stream::(); diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs index ae189889967f7..bde8053cf07ec 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -19,5 +19,5 @@ fn main() { } fn startfn() { - assert!("Ensure that the child task runs by failing".is_empty()); + fail_unless!("Ensure that the child task runs by failing".is_empty()); } diff --git a/src/test/run-fail/unwind-assert.rs b/src/test/run-fail/unwind-assert.rs index 4ed79147947e2..52fc6396fe957 100644 --- a/src/test/run-fail/unwind-assert.rs +++ b/src/test/run-fail/unwind-assert.rs @@ -14,5 +14,5 @@ fn main() { let _a = @0; - assert!(false); + fail_unless!(false); } diff --git a/src/test/run-make/rustdoc-hidden-line/foo.rs b/src/test/run-make/rustdoc-hidden-line/foo.rs index d9b7810cc8618..f74c19a53ac80 100644 --- a/src/test/run-make/rustdoc-hidden-line/foo.rs +++ b/src/test/run-make/rustdoc-hidden-line/foo.rs @@ -24,7 +24,7 @@ /// /// fn test() { /// let x = Bar(Foo); -/// assert!(x == x); // check that the derivings worked +/// fail_unless!(x == x); // check that the derivings worked /// } /// /// } diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs index 08777490f212b..e7dfa3593887a 100644 --- a/src/test/run-make/static-unwinding/main.rs +++ b/src/test/run-make/static-unwinding/main.rs @@ -29,7 +29,7 @@ fn main() { }); unsafe { - assert!(lib::statik == 1); - assert!(statik == 1); + fail_unless!(lib::statik == 1); + fail_unless!(statik == 1); } } diff --git a/src/test/run-pass/arith-2.rs b/src/test/run-pass/arith-2.rs index 70df6e46e59d7..3ca889428d7e4 100644 --- a/src/test/run-pass/arith-2.rs +++ b/src/test/run-pass/arith-2.rs @@ -12,6 +12,6 @@ pub fn main() { let i32_c: int = 0x10101010; - assert!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) == + fail_unless!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) == i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)); } diff --git a/src/test/run-pass/arith-unsigned.rs b/src/test/run-pass/arith-unsigned.rs index ae94ad379d012..43ad8a31926ec 100644 --- a/src/test/run-pass/arith-unsigned.rs +++ b/src/test/run-pass/arith-unsigned.rs @@ -12,22 +12,22 @@ // Unsigned integer operations pub fn main() { - assert!((0u8 < 255u8)); - assert!((0u8 <= 255u8)); - assert!((255u8 > 0u8)); - assert!((255u8 >= 0u8)); + fail_unless!((0u8 < 255u8)); + fail_unless!((0u8 <= 255u8)); + fail_unless!((255u8 > 0u8)); + fail_unless!((255u8 >= 0u8)); assert_eq!(250u8 / 10u8, 25u8); assert_eq!(255u8 % 10u8, 5u8); - assert!((0u16 < 60000u16)); - assert!((0u16 <= 60000u16)); - assert!((60000u16 > 0u16)); - assert!((60000u16 >= 0u16)); + fail_unless!((0u16 < 60000u16)); + fail_unless!((0u16 <= 60000u16)); + fail_unless!((60000u16 > 0u16)); + fail_unless!((60000u16 >= 0u16)); assert_eq!(60000u16 / 10u16, 6000u16); assert_eq!(60005u16 % 10u16, 5u16); - assert!((0u32 < 4000000000u32)); - assert!((0u32 <= 4000000000u32)); - assert!((4000000000u32 > 0u32)); - assert!((4000000000u32 >= 0u32)); + fail_unless!((0u32 < 4000000000u32)); + fail_unless!((0u32 <= 4000000000u32)); + fail_unless!((4000000000u32 > 0u32)); + fail_unless!((4000000000u32 >= 0u32)); assert_eq!(4000000000u32 / 10u32, 400000000u32); assert_eq!(4000000005u32 % 10u32, 5u32); // 64-bit numbers have some flakiness yet. Not tested diff --git a/src/test/run-pass/artificial-block.rs b/src/test/run-pass/artificial-block.rs index 7bc1354c3cefe..e3159df837852 100644 --- a/src/test/run-pass/artificial-block.rs +++ b/src/test/run-pass/artificial-block.rs @@ -10,4 +10,4 @@ fn f() -> int { { return 3; } } -pub fn main() { assert!((f() == 3)); } +pub fn main() { fail_unless!((f() == 3)); } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 85c5ae444ebda..40f6aa3e1145f 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -40,7 +40,7 @@ fn length>(x: T) -> uint { pub fn main() { let x = ~[0,1,2,3]; // Call a method - x.iterate(|y| { assert!(x[*y] == *y); true }); + x.iterate(|y| { fail_unless!(x[*y] == *y); true }); // Call a parameterized function assert_eq!(length(x.clone()), x.len()); // Call a parameterized function, with type arguments that require @@ -50,7 +50,7 @@ pub fn main() { // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; // Call a method - z.iterate(|y| { assert!(z[*y] == *y); true }); + z.iterate(|y| { fail_unless!(z[*y] == *y); true }); // Call a parameterized function assert_eq!(length::(z), z.len()); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 5383e9d5479b4..5bb268690f137 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -41,7 +41,7 @@ fn test_ebml<'a, A: let d: extra::ebml::Doc<'a> = EBReader::Doc(bytes); let mut decoder: EBReader::Decoder<'a> = EBReader::Decoder(d); let a2: A = Decodable::decode(&mut decoder); - assert!(*a1 == a2); + fail_unless!(*a1 == a2); } #[deriving(Decodable, Encodable)] diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 2fe39dc624c91..5ac1f3310315a 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -12,23 +12,23 @@ fn test_nil() { assert_eq!((), ()); - assert!((!(() != ()))); - assert!((!(() < ()))); - assert!((() <= ())); - assert!((!(() > ()))); - assert!((() >= ())); + fail_unless!((!(() != ()))); + fail_unless!((!(() < ()))); + fail_unless!((() <= ())); + fail_unless!((!(() > ()))); + fail_unless!((() >= ())); } fn test_bool() { - assert!((!(true < false))); - assert!((!(true <= false))); - assert!((true > false)); - assert!((true >= false)); + fail_unless!((!(true < false))); + fail_unless!((!(true <= false))); + fail_unless!((true > false)); + fail_unless!((true >= false)); - assert!((false < true)); - assert!((false <= true)); - assert!((!(false > true))); - assert!((!(false >= true))); + fail_unless!((false < true)); + fail_unless!((false <= true)); + fail_unless!((!(false > true))); + fail_unless!((!(false >= true))); // Bools support bitwise binops assert_eq!(false & false, false); @@ -53,13 +53,13 @@ fn test_ptr() { let p3: *u8 = ::std::cast::transmute(1); assert_eq!(p1, p2); - assert!(p1 != p3); - assert!(p1 < p3); - assert!(p1 <= p3); - assert!(p3 > p1); - assert!(p3 >= p3); - assert!(p1 <= p2); - assert!(p1 >= p2); + fail_unless!(p1 != p3); + fail_unless!(p1 < p3); + fail_unless!(p1 <= p3); + fail_unless!(p3 > p1); + fail_unless!(p3 >= p3); + fail_unless!(p1 <= p2); + fail_unless!(p1 >= p2); } } @@ -87,9 +87,9 @@ fn test_class() { } assert_eq!(q, r); r.y = 17; - assert!((r.y != q.y)); + fail_unless!((r.y != q.y)); assert_eq!(r.y, 17); - assert!((q != r)); + fail_unless!((q != r)); } pub fn main() { diff --git a/src/test/run-pass/bool-not.rs b/src/test/run-pass/bool-not.rs index e98087810b2a4..f09f79c510b3c 100644 --- a/src/test/run-pass/bool-not.rs +++ b/src/test/run-pass/bool-not.rs @@ -12,6 +12,6 @@ pub fn main() { - if !false { assert!((true)); } else { assert!((false)); } - if !true { assert!((false)); } else { assert!((true)); } + if !false { fail_unless!((true)); } else { fail_unless!((false)); } + if !true { fail_unless!((false)); } else { fail_unless!((true)); } } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index 4aedb4e96cfa3..61f58df618aa7 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -17,7 +17,7 @@ fn borrow(x: &int, f: |x: &int|) { fn test1(x: @~int) { borrow(&*(*x).clone(), |p| { let x_a = &**x as *int; - assert!((x_a as uint) != (p as *int as uint)); + fail_unless!((x_a as uint) != (p as *int as uint)); assert_eq!(unsafe{*x_a}, *p); }) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index 5cdda81c43604..815ffffabf24e 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -32,6 +32,6 @@ pub fn main() { info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(&(*x.f) as *int != &(*b_x) as *int); + fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 3050d6fa01130..4bbc9d02e40c0 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -32,6 +32,6 @@ pub fn main() { info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(&(*x.f) as *int != &(*b_x) as *int); + fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index 76dfbffc09c06..0c6606ea2d647 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -30,6 +30,6 @@ pub fn main() { info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(&(*x) as *int != &(*b_x) as *int); + fail_unless!(&(*x) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index 00e59f5132db7..6c6a4ebf81478 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -32,6 +32,6 @@ pub fn main() { info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(&(*x.f) as *int != &(*b_x) as *int); + fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowed-ptr-pattern-2.rs b/src/test/run-pass/borrowed-ptr-pattern-2.rs index b15f9e76234a7..e1e5d6854283d 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-2.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-2.rs @@ -16,6 +16,6 @@ fn foo(s: &~str) -> bool { } pub fn main() { - assert!(foo(&~"kitty")); - assert!(!foo(&~"gata")); + fail_unless!(foo(&~"kitty")); + fail_unless!(!foo(&~"gata")); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-3.rs b/src/test/run-pass/borrowed-ptr-pattern-3.rs index 030e055c4ccb7..4bdecd5eeec0e 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-3.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-3.rs @@ -16,6 +16,6 @@ fn foo<'r>(s: &'r uint) -> bool { } pub fn main() { - assert!(foo(&3)); - assert!(!foo(&4)); + fail_unless!(foo(&3)); + fail_unless!(!foo(&4)); } diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs index b68ecd3f4d3e0..bceedcad4a81d 100644 --- a/src/test/run-pass/box-compare.rs +++ b/src/test/run-pass/box-compare.rs @@ -11,7 +11,7 @@ pub fn main() { - assert!((@1 < @3)); - assert!((@@~"hello " > @@~"hello")); - assert!((@@@~"hello" != @@@~"there")); + fail_unless!((@1 < @3)); + fail_unless!((@@~"hello " > @@~"hello")); + fail_unless!((@@@~"hello" != @@@~"there")); } diff --git a/src/test/run-pass/box.rs b/src/test/run-pass/box.rs index f3acc1272463d..5df13d45d867c 100644 --- a/src/test/run-pass/box.rs +++ b/src/test/run-pass/box.rs @@ -10,4 +10,4 @@ #[feature(managed_boxes)]; -pub fn main() { let x: @int = @10; assert!((*x == 10)); } +pub fn main() { let x: @int = @10; fail_unless!((*x == 10)); } diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index 1ae77bc1eca84..ce4fc64059d52 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -16,18 +16,18 @@ pub fn main() { assert_eq!(i, 20); let xs = [1, 2, 3, 4, 5, 6]; for x in xs.iter() { - if *x == 3 { break; } assert!((*x <= 3)); + if *x == 3 { break; } fail_unless!((*x <= 3)); } i = 0; - while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); } + while i < 10 { i += 1; if i % 2 == 0 { continue; } fail_unless!((i % 2 != 0)); } i = 0; loop { - i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); + i += 1; if i % 2 == 0 { continue; } fail_unless!((i % 2 != 0)); if i >= 10 { break; } } let ys = ~[1, 2, 3, 4, 5, 6]; for x in ys.iter() { if *x % 2 == 0 { continue; } - assert!((*x % 2 != 0)); + fail_unless!((*x % 2 != 0)); } } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs index 7dc12c70b9be4..9171be9b6eecb 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs @@ -27,5 +27,5 @@ fn foo(val: T, chan: Chan) { pub fn main() { let (p,c) = Chan::new(); foo(31337, c); - assert!(p.recv() == 31337); + fail_unless!(p.recv() == 31337); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index b67edf245b2d9..5c7d7d7c8f0ed 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -31,5 +31,5 @@ fn foo(val: T, chan: Chan) { pub fn main() { let (p,c) = Chan::new(); foo(X(31337), c); - assert!(p.recv() == X(31337)); + fail_unless!(p.recv() == X(31337)); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities.rs b/src/test/run-pass/builtin-superkinds-capabilities.rs index fa3903b41d1ba..2acf81118db7a 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities.rs @@ -23,5 +23,5 @@ fn foo(val: T, chan: Chan) { pub fn main() { let (p,c) = Chan::new(); foo(31337, c); - assert!(p.recv() == 31337); + fail_unless!(p.recv() == 31337); } diff --git a/src/test/run-pass/builtin-superkinds-self-type.rs b/src/test/run-pass/builtin-superkinds-self-type.rs index a71bedfefe021..0bbdfa1c6384f 100644 --- a/src/test/run-pass/builtin-superkinds-self-type.rs +++ b/src/test/run-pass/builtin-superkinds-self-type.rs @@ -22,5 +22,5 @@ impl Foo for T { } pub fn main() { let (p,c) = Chan::new(); 1193182.foo(c); - assert!(p.recv() == 1193182); + fail_unless!(p.recv() == 1193182); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 940f62789bbc3..390c534eb28c1 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -28,5 +28,5 @@ fn atoll(s: ~str) -> i64 { pub fn main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); - assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); + fail_unless!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); } diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index e5e1736044c5d..d32f456950838 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -23,6 +23,6 @@ pub fn main() { //let bt1 = sys::frame_address(); //info!("%?", bt1); - //assert!(bt0 == bt1); + //fail_unless!(bt0 == bt1); }) } diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index 41717177f75bc..b4e5bd5faa6a9 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -18,6 +18,6 @@ pub fn main() { //info!("%?", bt0); cci_iter_lib::iter([1, 2, 3], |i| { println!("{}", *i); - //assert!(bt0 == sys::rusti::frame_address(2u32)); + //fail_unless!(bt0 == sys::rusti::frame_address(2u32)); }) } diff --git a/src/test/run-pass/cci_no_inline_exe.rs b/src/test/run-pass/cci_no_inline_exe.rs index faa2a35011704..db8893ca97159 100644 --- a/src/test/run-pass/cci_no_inline_exe.rs +++ b/src/test/run-pass/cci_no_inline_exe.rs @@ -28,6 +28,6 @@ pub fn main() { //let bt1 = sys::frame_address(); //info!("%?", bt1); - //assert!(bt0 != bt1); + //fail_unless!(bt0 != bt1); }) } diff --git a/src/test/run-pass/cfg-macros-foo.rs b/src/test/run-pass/cfg-macros-foo.rs index 6b447b8871118..2a8e86f5fb088 100644 --- a/src/test/run-pass/cfg-macros-foo.rs +++ b/src/test/run-pass/cfg-macros-foo.rs @@ -33,5 +33,5 @@ mod foo { } pub fn main() { - assert!(bar!()) + fail_unless!(bar!()) } diff --git a/src/test/run-pass/cfg-macros-notfoo.rs b/src/test/run-pass/cfg-macros-notfoo.rs index da62eaffc41ab..c3c3683ac4f1e 100644 --- a/src/test/run-pass/cfg-macros-notfoo.rs +++ b/src/test/run-pass/cfg-macros-notfoo.rs @@ -33,5 +33,5 @@ mod foo { } pub fn main() { - assert!(!bar!()) + fail_unless!(!bar!()) } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 14e27e683af12..eef8720ed0291 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -116,11 +116,11 @@ impl cat { pub fn main() { let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan"); for _ in range(1u, 5) { nyan.speak(); } - assert!(*nyan.find(&1).unwrap() == ~"nyan"); + fail_unless!(*nyan.find(&1).unwrap() == ~"nyan"); assert_eq!(nyan.find(&10), None); let mut spotty: cat = cat::new(2, 57, tuxedo); for _ in range(0u, 6) { spotty.speak(); } assert_eq!(spotty.len(), 8); - assert!((spotty.contains_key(&2))); + fail_unless!((spotty.contains_key(&2))); assert_eq!(spotty.get(&3), &tuxedo); } diff --git a/src/test/run-pass/class-implement-trait-cross-crate.rs b/src/test/run-pass/class-implement-trait-cross-crate.rs index caa4a3b2feb6f..387635f6134a5 100644 --- a/src/test/run-pass/class-implement-trait-cross-crate.rs +++ b/src/test/run-pass/class-implement-trait-cross-crate.rs @@ -60,7 +60,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { pub fn main() { let mut nyan = cat(0u, 2, ~"nyan"); nyan.eat(); - assert!((!nyan.eat())); + fail_unless!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; - assert!((nyan.eat())); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/class-implement-traits.rs b/src/test/run-pass/class-implement-traits.rs index dbd34f35e2740..ad03c03f36061 100644 --- a/src/test/run-pass/class-implement-traits.rs +++ b/src/test/run-pass/class-implement-traits.rs @@ -65,7 +65,7 @@ fn make_speak(mut c: C) { pub fn main() { let mut nyan = cat(0u, 2, ~"nyan"); nyan.eat(); - assert!((!nyan.eat())); + fail_unless!((!nyan.eat())); for _ in range(1u, 10u) { make_speak(nyan.clone()); } diff --git a/src/test/run-pass/classes-cross-crate.rs b/src/test/run-pass/classes-cross-crate.rs index 2e1d19b9dda2d..30d4259ed86a5 100644 --- a/src/test/run-pass/classes-cross-crate.rs +++ b/src/test/run-pass/classes-cross-crate.rs @@ -16,7 +16,7 @@ use cci_class_4::kitties::cat; pub fn main() { let mut nyan = cat(0u, 2, ~"nyan"); nyan.eat(); - assert!((!nyan.eat())); + fail_unless!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; - assert!((nyan.eat())); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index f65bf329823c2..d9c81530246c0 100644 --- a/src/test/run-pass/classes.rs +++ b/src/test/run-pass/classes.rs @@ -51,7 +51,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { pub fn main() { let mut nyan = cat(0u, 2, ~"nyan"); nyan.eat(); - assert!((!nyan.eat())); + fail_unless!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; - assert!((nyan.eat())); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index 738878527bf8e..f0a9fcaca1d5e 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -15,7 +15,7 @@ use std::task; fn adder(x: @int, y: @int) -> int { return *x + *y; } fn failer() -> @int { fail!(); } pub fn main() { - assert!(task::try(proc() { + fail_unless!(task::try(proc() { adder(@2, failer()); () }).is_err()); } diff --git a/src/test/run-pass/cmp-default.rs b/src/test/run-pass/cmp-default.rs index 3650564d929ca..0d0a419955a67 100644 --- a/src/test/run-pass/cmp-default.rs +++ b/src/test/run-pass/cmp-default.rs @@ -41,22 +41,22 @@ impl Ord for RevInt { } pub fn main() { - assert!(Int(2) > Int(1)); - assert!(Int(2) >= Int(1)); - assert!(Int(1) >= Int(1)); - assert!(Int(1) < Int(2)); - assert!(Int(1) <= Int(2)); - assert!(Int(1) <= Int(1)); - - assert!(RevInt(2) < RevInt(1)); - assert!(RevInt(2) <= RevInt(1)); - assert!(RevInt(1) <= RevInt(1)); - assert!(RevInt(1) > RevInt(2)); - assert!(RevInt(1) >= RevInt(2)); - assert!(RevInt(1) >= RevInt(1)); - - assert!(Fool(true) == Fool(false)); - assert!(Fool(true) != Fool(true)); - assert!(Fool(false) != Fool(false)); - assert!(Fool(false) == Fool(true)); + fail_unless!(Int(2) > Int(1)); + fail_unless!(Int(2) >= Int(1)); + fail_unless!(Int(1) >= Int(1)); + fail_unless!(Int(1) < Int(2)); + fail_unless!(Int(1) <= Int(2)); + fail_unless!(Int(1) <= Int(1)); + + fail_unless!(RevInt(2) < RevInt(1)); + fail_unless!(RevInt(2) <= RevInt(1)); + fail_unless!(RevInt(1) <= RevInt(1)); + fail_unless!(RevInt(1) > RevInt(2)); + fail_unless!(RevInt(1) >= RevInt(2)); + fail_unless!(RevInt(1) >= RevInt(1)); + + fail_unless!(Fool(true) == Fool(false)); + fail_unless!(Fool(true) != Fool(true)); + fail_unless!(Fool(false) != Fool(false)); + fail_unless!(Fool(false) == Fool(true)); } diff --git a/src/test/run-pass/compare-generic-enums.rs b/src/test/run-pass/compare-generic-enums.rs index c6f4fecf8acc6..9c91bad0df720 100644 --- a/src/test/run-pass/compare-generic-enums.rs +++ b/src/test/run-pass/compare-generic-enums.rs @@ -15,8 +15,8 @@ fn cmp(x: Option, y: Option) -> bool { } pub fn main() { - assert!(!cmp(Some(3), None)); - assert!(!cmp(Some(3), Some(4))); - assert!(cmp(Some(3), Some(3))); - assert!(cmp(None, None)); + fail_unless!(!cmp(Some(3), None)); + fail_unless!(!cmp(Some(3), Some(4))); + fail_unless!(cmp(Some(3), Some(3))); + fail_unless!(cmp(None, None)); } diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index ba1011de08177..c424127536a8e 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -86,7 +86,7 @@ pub fn main() { fail!() } pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible // if they had the bogus definition - assert!((b)); + fail_unless!((b)); let _x: t = true; let _y: tg = bar; diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index ac2e879ceacc9..b533da032d38e 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -22,7 +22,7 @@ pub fn main() { _ => fail!() } match Y { - Bar(s) => assert!(s == 2654435769), + Bar(s) => fail_unless!(s == 2654435769), _ => fail!() } match Z { diff --git a/src/test/run-pass/const-binops.rs b/src/test/run-pass/const-binops.rs index d89b81370f7b8..010a9a0d83473 100644 --- a/src/test/run-pass/const-binops.rs +++ b/src/test/run-pass/const-binops.rs @@ -13,7 +13,7 @@ macro_rules! assert_approx_eq( ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, + fail_unless!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) ) diff --git a/src/test/run-pass/const-enum-struct.rs b/src/test/run-pass/const-enum-struct.rs index 3229293fd7a46..2f430a03fabd5 100644 --- a/src/test/run-pass/const-enum-struct.rs +++ b/src/test/run-pass/const-enum-struct.rs @@ -14,6 +14,6 @@ static C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-struct2.rs b/src/test/run-pass/const-enum-struct2.rs index 4530a65002772..36572a7f50735 100644 --- a/src/test/run-pass/const-enum-struct2.rs +++ b/src/test/run-pass/const-enum-struct2.rs @@ -14,6 +14,6 @@ static C: S = S { a: V0, b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-structlike.rs b/src/test/run-pass/const-enum-structlike.rs index 8b5e98f6ebade..221d9bac23dd4 100644 --- a/src/test/run-pass/const-enum-structlike.rs +++ b/src/test/run-pass/const-enum-structlike.rs @@ -20,6 +20,6 @@ static C: E = S1 { u: 23 }; pub fn main() { match C { S0 { .. } => fail!(), - S1 { u } => assert!(u == 23) + S1 { u } => fail_unless!(u == 23) } } diff --git a/src/test/run-pass/const-enum-tuple.rs b/src/test/run-pass/const-enum-tuple.rs index 17d8341457d35..5ef8691cad16c 100644 --- a/src/test/run-pass/const-enum-tuple.rs +++ b/src/test/run-pass/const-enum-tuple.rs @@ -13,6 +13,6 @@ static C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuple2.rs b/src/test/run-pass/const-enum-tuple2.rs index 5d7a161720c18..6fb713daf9a2d 100644 --- a/src/test/run-pass/const-enum-tuple2.rs +++ b/src/test/run-pass/const-enum-tuple2.rs @@ -13,6 +13,6 @@ static C: (E, u16, u16) = (V0, 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct.rs b/src/test/run-pass/const-enum-tuplestruct.rs index 40137afa2eee2..a168c4a7caf2d 100644 --- a/src/test/run-pass/const-enum-tuplestruct.rs +++ b/src/test/run-pass/const-enum-tuplestruct.rs @@ -14,6 +14,6 @@ static C: S = S(V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct2.rs b/src/test/run-pass/const-enum-tuplestruct2.rs index f6345efcb4348..7ad5feb269bac 100644 --- a/src/test/run-pass/const-enum-tuplestruct2.rs +++ b/src/test/run-pass/const-enum-tuplestruct2.rs @@ -14,6 +14,6 @@ static C: S = S(V0, 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; - assert!(n != 0xBAD); + fail_unless!(n != 0xBAD); assert_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index 4c81eaae1d802..4924abec72d36 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -19,7 +19,7 @@ pub fn main() { _ => fail!() } match C1 { - V1(n) => assert!(n == 0xDEADBEE), + V1(n) => fail_unless!(n == 0xDEADBEE), _ => fail!() } } diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index 95c4ed836c769..29b3d1a6ca163 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -13,7 +13,7 @@ static C: &'static [E] = &[V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { - V1(n) => assert!(n == 0xDEADBEE), + V1(n) => fail_unless!(n == 0xDEADBEE), _ => fail!() } match C[2] { diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 3dc5b918f7f58..396be424c2aec 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -13,7 +13,7 @@ static C: [E, ..3] = [V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { - V1(n) => assert!(n == 0xDEADBEE), + V1(n) => fail_unless!(n == 0xDEADBEE), _ => fail!() } match C[2] { diff --git a/src/test/run-pass/const-str-ptr.rs b/src/test/run-pass/const-str-ptr.rs index b0efa3bb33f94..025cc28bb686a 100644 --- a/src/test/run-pass/const-str-ptr.rs +++ b/src/test/run-pass/const-str-ptr.rs @@ -20,8 +20,8 @@ pub fn main() { assert_eq!(str::raw::from_utf8(A), "hi"); assert_eq!(str::raw::from_buf_len(foo, A.len()), ~"hi"); assert_eq!(str::raw::from_buf_len(C, B.len()), ~"hi"); - assert!(*C == A[0]); - assert!(*(&B[0] as *u8) == A[0]); + fail_unless!(*C == A[0]); + fail_unless!(*(&B[0] as *u8) == A[0]); let bar = str::raw::from_utf8(A).to_c_str(); assert_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), ~"hi"); diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index fcf797cf3e6e3..0e7f7df81eebb 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -94,7 +94,7 @@ fn test_destroy_actually_kills(force: bool) { let mut p = run::Process::new(BLOCK_COMMAND, [], run::ProcessOptions::new()) .unwrap(); - assert!(process_exists(p.get_id())); + fail_unless!(process_exists(p.get_id())); if force { p.force_destroy(); @@ -102,7 +102,7 @@ fn test_destroy_actually_kills(force: bool) { p.destroy(); } - assert!(!process_exists(p.get_id())); + fail_unless!(!process_exists(p.get_id())); } #[test] diff --git a/src/test/run-pass/crateresolve2.rs b/src/test/run-pass/crateresolve2.rs index 1419d68ad6837..50d3a54b56e09 100644 --- a/src/test/run-pass/crateresolve2.rs +++ b/src/test/run-pass/crateresolve2.rs @@ -15,17 +15,17 @@ mod a { extern crate crateresolve2 = "crateresolve2#0.1"; - pub fn f() { assert!(crateresolve2::f() == 10); } + pub fn f() { fail_unless!(crateresolve2::f() == 10); } } mod b { extern crate crateresolve2 = "crateresolve2#0.2"; - pub fn f() { assert!(crateresolve2::f() == 20); } + pub fn f() { fail_unless!(crateresolve2::f() == 20); } } mod c { extern crate crateresolve2 = "crateresolve2#0.3"; - pub fn f() { assert!(crateresolve2::f() == 30); } + pub fn f() { fail_unless!(crateresolve2::f() == 30); } } pub fn main() { diff --git a/src/test/run-pass/crateresolve3.rs b/src/test/run-pass/crateresolve3.rs index fd83c8f515a51..7f0bb59585e38 100644 --- a/src/test/run-pass/crateresolve3.rs +++ b/src/test/run-pass/crateresolve3.rs @@ -17,12 +17,12 @@ mod a { extern crate crateresolve3 = "crateresolve3#0.1"; - pub fn f() { assert!(crateresolve3::f() == 10); } + pub fn f() { fail_unless!(crateresolve3::f() == 10); } } mod b { extern crate crateresolve3 = "crateresolve3#0.2"; - pub fn f() { assert!(crateresolve3::g() == 20); } + pub fn f() { fail_unless!(crateresolve3::g() == 20); } } pub fn main() { diff --git a/src/test/run-pass/crateresolve4.rs b/src/test/run-pass/crateresolve4.rs index 3243c909e03a9..82143943767cc 100644 --- a/src/test/run-pass/crateresolve4.rs +++ b/src/test/run-pass/crateresolve4.rs @@ -16,12 +16,12 @@ pub mod a { extern crate crateresolve4b = "crateresolve4b#0.1"; - pub fn f() { assert!(crateresolve4b::f() == 20); } + pub fn f() { fail_unless!(crateresolve4b::f() == 20); } } pub mod b { extern crate crateresolve4b = "crateresolve4b#0.2"; - pub fn f() { assert!(crateresolve4b::g() == 10); } + pub fn f() { fail_unless!(crateresolve4b::g() == 10); } } pub fn main() { diff --git a/src/test/run-pass/crateresolve5.rs b/src/test/run-pass/crateresolve5.rs index ca690b9089bb5..8c61f698df631 100644 --- a/src/test/run-pass/crateresolve5.rs +++ b/src/test/run-pass/crateresolve5.rs @@ -17,8 +17,8 @@ extern crate cr5_2 = "crateresolve5#0.2"; pub fn main() { // Structural types can be used between two versions of the same crate - assert!(cr5_1::struct_nameval().name == cr5_2::struct_nameval().name); - assert!(cr5_1::struct_nameval().val == cr5_2::struct_nameval().val); + fail_unless!(cr5_1::struct_nameval().name == cr5_2::struct_nameval().name); + fail_unless!(cr5_1::struct_nameval().val == cr5_2::struct_nameval().val); // Make sure these are actually two different crates - assert!(cr5_1::f() == 10 && cr5_2::f() == 20); + fail_unless!(cr5_1::f() == 10 && cr5_2::f() == 20); } diff --git a/src/test/run-pass/deep.rs b/src/test/run-pass/deep.rs index 2f82e729adf58..226622eab49ac 100644 --- a/src/test/run-pass/deep.rs +++ b/src/test/run-pass/deep.rs @@ -15,4 +15,4 @@ fn f(x: int) -> int { if x == 1 { return 1; } else { let y: int = 1 + f(x - 1); return y; } } -pub fn main() { assert!((f(5000) == 5000)); } +pub fn main() { fail_unless!((f(5000) == 5000)); } diff --git a/src/test/run-pass/deriving-cmp-shortcircuit.rs b/src/test/run-pass/deriving-cmp-shortcircuit.rs index 431c856ee88a5..6c3b2faf97557 100644 --- a/src/test/run-pass/deriving-cmp-shortcircuit.rs +++ b/src/test/run-pass/deriving-cmp-shortcircuit.rs @@ -39,8 +39,8 @@ pub fn main() { let a = ShortCircuit { x: 1, y: FailCmp }; let b = ShortCircuit { x: 2, y: FailCmp }; - assert!(a != b); - assert!(a < b); - assert!(!a.equals(&b)); + fail_unless!(a != b); + fail_unless!(a < b); + fail_unless!(!a.equals(&b)); assert_eq!(a.cmp(&b), ::std::cmp::Less); } diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs index 50ccac793c265..163bfc91f9bcd 100644 --- a/src/test/run-pass/deriving-encodable-decodable.rs +++ b/src/test/run-pass/deriving-encodable-decodable.rs @@ -63,7 +63,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable + let doc = ebml::reader::Doc(@w.get_ref()); let mut dec = Decoder(doc); let obj2 = Decodable::decode(&mut dec); - assert!(obj == obj2); + fail_unless!(obj == obj2); } pub fn main() { diff --git a/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs b/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs index 723738495e757..acd12d6d38fe4 100644 --- a/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs +++ b/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs @@ -19,8 +19,8 @@ struct A<'a> { pub fn main() { let (a, b) = (A { x: &1 }, A { x: &2 }); - assert!(a.equals(&a)); - assert!(b.equals(&b)); + fail_unless!(a.equals(&a)); + fail_unless!(b.equals(&b)); assert_eq!(a.cmp(&a), Equal); diff --git a/src/test/run-pass/deriving-self-lifetime.rs b/src/test/run-pass/deriving-self-lifetime.rs index 528c4f70baf6b..818d2d831d89a 100644 --- a/src/test/run-pass/deriving-self-lifetime.rs +++ b/src/test/run-pass/deriving-self-lifetime.rs @@ -23,14 +23,14 @@ pub fn main() { assert_eq!(b, b); - assert!(a < b); - assert!(b > a); + fail_unless!(a < b); + fail_unless!(b > a); - assert!(a <= b); - assert!(a <= a); - assert!(b <= b); + fail_unless!(a <= b); + fail_unless!(a <= a); + fail_unless!(b <= b); - assert!(b >= a); - assert!(b >= b); - assert!(a >= a); + fail_unless!(b >= a); + fail_unless!(b >= b); + fail_unless!(a >= a); } diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 3c4fb6c8c81b1..894a849347352 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -19,7 +19,7 @@ pub fn main() { let a = Bar; let b = Bar; assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); + fail_unless!(!(a != b)); + fail_unless!(a.eq(&b)); + fail_unless!(!a.ne(&b)); } diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs index b2974b4be0b39..398dd3e274b8d 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -18,7 +18,7 @@ pub fn main() { let a = Bar(1, 2); let b = Bar(1, 2); assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); + fail_unless!(!(a != b)); + fail_unless!(a.eq(&b)); + fail_unless!(!a.ne(&b)); } diff --git a/src/test/run-pass/deriving-via-extension-struct-empty.rs b/src/test/run-pass/deriving-via-extension-struct-empty.rs index 74698b9db28bc..49c738b34a08a 100644 --- a/src/test/run-pass/deriving-via-extension-struct-empty.rs +++ b/src/test/run-pass/deriving-via-extension-struct-empty.rs @@ -13,5 +13,5 @@ struct Foo; pub fn main() { assert_eq!(Foo, Foo); - assert!(!(Foo != Foo)); + fail_unless!(!(Foo != Foo)); } diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index 38ecd6db63cbc..e47429442ee13 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -19,5 +19,5 @@ enum S { pub fn main() { let x = X { x: 1, y: 2 }; assert_eq!(x, x); - assert!(!(x != x)); + fail_unless!(!(x != x)); } diff --git a/src/test/run-pass/deriving-via-extension-struct-tuple.rs b/src/test/run-pass/deriving-via-extension-struct-tuple.rs index cc76751e27f4b..dd59bc5c662bb 100644 --- a/src/test/run-pass/deriving-via-extension-struct-tuple.rs +++ b/src/test/run-pass/deriving-via-extension-struct-tuple.rs @@ -16,11 +16,11 @@ pub fn main() { let a2 = Foo(5, 6, ~"abc"); let b = Foo(5, 7, ~"def"); - assert!(a1 == a1); - assert!(a2 == a1); - assert!(!(a1 == b)); + fail_unless!(a1 == a1); + fail_unless!(a2 == a1); + fail_unless!(!(a1 == b)); - assert!(a1 != b); - assert!(!(a1 != a1)); - assert!(!(a2 != a1)); + fail_unless!(a1 != b); + fail_unless!(!(a1 != a1)); + fail_unless!(!(a2 != a1)); } diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index 44aca59aa9c07..9d90e2e21658c 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -19,7 +19,7 @@ pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 }; assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); + fail_unless!(!(a != b)); + fail_unless!(a.eq(&b)); + fail_unless!(!a.ne(&b)); } diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index 110f0918c0248..3fc47f758e012 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -22,7 +22,7 @@ pub fn main() { let a = Foo { x: 1, y: 2.0, z: 3 }; let b = Foo { x: 1, y: 2.0, z: 3 }; assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); + fail_unless!(!(a != b)); + fail_unless!(a.eq(&b)); + fail_unless!(!a.ne(&b)); } diff --git a/src/test/run-pass/else-if.rs b/src/test/run-pass/else-if.rs index 476d3f42d6ee3..15e68bccba87e 100644 --- a/src/test/run-pass/else-if.rs +++ b/src/test/run-pass/else-if.rs @@ -12,19 +12,19 @@ pub fn main() { if 1 == 2 { - assert!((false)); + fail_unless!((false)); } else if 2 == 3 { - assert!((false)); - } else if 3 == 4 { assert!((false)); } else { assert!((true)); } - if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); } + fail_unless!((false)); + } else if 3 == 4 { fail_unless!((false)); } else { fail_unless!((true)); } + if 1 == 2 { fail_unless!((false)); } else if 2 == 2 { fail_unless!((true)); } if 1 == 2 { - assert!((false)); + fail_unless!((false)); } else if 2 == 2 { if 1 == 1 { - assert!((true)); - } else { if 2 == 1 { assert!((false)); } else { assert!((false)); } } + fail_unless!((true)); + } else { if 2 == 1 { fail_unless!((false)); } else { fail_unless!((false)); } } } if 1 == 2 { - assert!((false)); - } else { if 1 == 2 { assert!((false)); } else { assert!((true)); } } + fail_unless!((false)); + } else { if 1 == 2 { fail_unless!((false)); } else { fail_unless!((true)); } } } diff --git a/src/test/run-pass/enum-alignment.rs b/src/test/run-pass/enum-alignment.rs index 5763c61379865..b02bc6c9172b7 100644 --- a/src/test/run-pass/enum-alignment.rs +++ b/src/test/run-pass/enum-alignment.rs @@ -26,6 +26,6 @@ pub fn main() { let x = Some(0u64); match x { None => fail!(), - Some(ref y) => assert!(is_aligned(y)) + Some(ref y) => fail_unless!(is_aligned(y)) } } diff --git a/src/test/run-pass/enum-discr.rs b/src/test/run-pass/enum-discr.rs index 1d7ec0aa1bc37..ee0b390bb4b14 100644 --- a/src/test/run-pass/enum-discr.rs +++ b/src/test/run-pass/enum-discr.rs @@ -25,6 +25,6 @@ enum Hero { pub fn main() { let pet: Animal = Snake; let hero: Hero = Superman; - assert!(pet as uint == 3); - assert!(hero as int == -2); + fail_unless!(pet as uint == 3); + fail_unless!(hero as int == -2); } diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index ee2c1ffba11f8..3df378b152b68 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -20,6 +20,6 @@ pub fn main() { } fn test_color(color: color, val: int, _name: ~str) { - assert!(color as int == val); - assert!(color as f64 == val as f64); + fail_unless!(color as int == val); + fail_unless!(color as f64 == val as f64); } diff --git a/src/test/run-pass/enum-nullable-const-null-with-fields.rs b/src/test/run-pass/enum-nullable-const-null-with-fields.rs index 5defd83702225..017c98f45cbd6 100644 --- a/src/test/run-pass/enum-nullable-const-null-with-fields.rs +++ b/src/test/run-pass/enum-nullable-const-null-with-fields.rs @@ -15,5 +15,5 @@ static C: Result<(), ~int> = Ok(()); // So we won't actually compile if the bug is present, but we check the value in main anyway. pub fn main() { - assert!(C.is_ok()); + fail_unless!(C.is_ok()); } diff --git a/src/test/run-pass/estr-slice.rs b/src/test/run-pass/estr-slice.rs index f579e7a3d20ac..17ea00ad576b5 100644 --- a/src/test/run-pass/estr-slice.rs +++ b/src/test/run-pass/estr-slice.rs @@ -22,7 +22,7 @@ pub fn main() { let z : &str = &"thing"; assert_eq!(v, x); - assert!(x != z); + fail_unless!(x != z); let a = &"aaaa"; let b = &"bbbb"; @@ -32,27 +32,27 @@ pub fn main() { info!("{}", a); - assert!(a < b); - assert!(a <= b); - assert!(a != b); - assert!(b >= a); - assert!(b > a); + fail_unless!(a < b); + fail_unless!(a <= b); + fail_unless!(a != b); + fail_unless!(b >= a); + fail_unless!(b > a); info!("{}", b); - assert!(a < c); - assert!(a <= c); - assert!(a != c); - assert!(c >= a); - assert!(c > a); + fail_unless!(a < c); + fail_unless!(a <= c); + fail_unless!(a != c); + fail_unless!(c >= a); + fail_unless!(c > a); info!("{}", c); - assert!(c < cc); - assert!(c <= cc); - assert!(c != cc); - assert!(cc >= c); - assert!(cc > c); + fail_unless!(c < cc); + fail_unless!(c <= cc); + fail_unless!(c != cc); + fail_unless!(cc >= c); + fail_unless!(cc > c); info!("{}", cc); } diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index eb00bf205cf76..02bd10b24f630 100644 --- a/src/test/run-pass/evec-internal.rs +++ b/src/test/run-pass/evec-internal.rs @@ -27,25 +27,25 @@ pub fn main() { log(debug, a); - assert!(a < b); - assert!(a <= b); - assert!(a != b); - assert!(b >= a); - assert!(b > a); + fail_unless!(a < b); + fail_unless!(a <= b); + fail_unless!(a != b); + fail_unless!(b >= a); + fail_unless!(b > a); log(debug, b); - assert!(b < c); - assert!(b <= c); - assert!(b != c); - assert!(c >= b); - assert!(c > b); - - assert!(a < c); - assert!(a <= c); - assert!(a != c); - assert!(c >= a); - assert!(c > a); + fail_unless!(b < c); + fail_unless!(b <= c); + fail_unless!(b != c); + fail_unless!(c >= b); + fail_unless!(c > b); + + fail_unless!(a < c); + fail_unless!(a <= c); + fail_unless!(a != c); + fail_unless!(c >= a); + fail_unless!(c > a); log(debug, c); diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index a0af5e5a9e001..52f64e1c66f46 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -24,33 +24,33 @@ pub fn main() { info!("{:?}", a); - assert!(a < b); - assert!(a <= b); - assert!(a != b); - assert!(b >= a); - assert!(b > a); + fail_unless!(a < b); + fail_unless!(a <= b); + fail_unless!(a != b); + fail_unless!(b >= a); + fail_unless!(b > a); info!("{:?}", b); - assert!(b < c); - assert!(b <= c); - assert!(b != c); - assert!(c >= b); - assert!(c > b); + fail_unless!(b < c); + fail_unless!(b <= c); + fail_unless!(b != c); + fail_unless!(c >= b); + fail_unless!(c > b); - assert!(a < c); - assert!(a <= c); - assert!(a != c); - assert!(c >= a); - assert!(c > a); + fail_unless!(a < c); + fail_unless!(a <= c); + fail_unless!(a != c); + fail_unless!(c >= a); + fail_unless!(c > a); info!("{:?}", c); - assert!(a < cc); - assert!(a <= cc); - assert!(a != cc); - assert!(cc >= a); - assert!(cc > a); + fail_unless!(a < cc); + fail_unless!(a <= cc); + fail_unless!(a != cc); + fail_unless!(cc >= a); + fail_unless!(cc > a); info!("{:?}", cc); } diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 004761479f379..3899e66141de7 100644 --- a/src/test/run-pass/export-unexported-dep.rs +++ b/src/test/run-pass/export-unexported-dep.rs @@ -24,7 +24,7 @@ mod foo { pub fn f() -> t { return t1; } - pub fn g(v: t) { assert!((v == t1)); } + pub fn g(v: t) { fail_unless!((v == t1)); } } pub fn main() { foo::g(foo::f()); } diff --git a/src/test/run-pass/expr-block-box.rs b/src/test/run-pass/expr-block-box.rs index 6d6a2a60af0e1..5ec9a6faddad8 100644 --- a/src/test/run-pass/expr-block-box.rs +++ b/src/test/run-pass/expr-block-box.rs @@ -10,4 +10,4 @@ #[feature(managed_boxes)]; -pub fn main() { let x = { @100 }; assert!((*x == 100)); } +pub fn main() { let x = { @100 }; fail_unless!((*x == 100)); } diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index 9ca41c56dc960..b8af0731ae5bb 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -14,7 +14,7 @@ fn test_fn() { type t = 'static || -> int; fn ten() -> int { return 10; } let rs: t = ten; - assert!((rs() == 10)); + fail_unless!((rs() == 10)); } pub fn main() { test_fn(); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index f081d13a5b0b1..fed56fc0038cc 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -14,7 +14,7 @@ type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = { expected }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 9727f41d144c7..0502bdad65ac8 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -16,7 +16,7 @@ type compare<'a, T> = 'a |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 43ddfe6d58f3c..d68fce52ac266 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -14,7 +14,7 @@ type compare<'a, T> = 'a |~T, ~T| -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { expected.clone() }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 787f50c1b037a..bf37091467cd7 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -14,7 +14,7 @@ type compare<'a, T> = 'a |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 3a1a79aa38e2a..58d5037c47d1e 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -16,7 +16,7 @@ type compare<'a, T> = 'a |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected.clone() }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_bool() { diff --git a/src/test/run-pass/expr-block-unique.rs b/src/test/run-pass/expr-block-unique.rs index 6ef7ffe86fa18..ea4b037788fa6 100644 --- a/src/test/run-pass/expr-block-unique.rs +++ b/src/test/run-pass/expr-block-unique.rs @@ -11,4 +11,4 @@ -pub fn main() { let x = { ~100 }; assert!((*x == 100)); } +pub fn main() { let x = { ~100 }; fail_unless!((*x == 100)); } diff --git a/src/test/run-pass/expr-block.rs b/src/test/run-pass/expr-block.rs index ee1d955b0d361..404aee69457a6 100644 --- a/src/test/run-pass/expr-block.rs +++ b/src/test/run-pass/expr-block.rs @@ -13,11 +13,11 @@ // Tests for standalone blocks as expressions -fn test_basic() { let rs: bool = { true }; assert!((rs)); } +fn test_basic() { let rs: bool = { true }; fail_unless!((rs)); } struct RS { v1: int, v2: int } -fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert!((rs.v2 == 20)); } +fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; fail_unless!((rs.v2 == 20)); } fn test_filled_with_stuff() { let rs = { let mut a = 0; while a < 10 { a += 1; } a }; diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index f79b7198b50e7..1333bb30aba81 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert!((x == 10)); } +fn test_if_fail() { let x = if false { fail!() } else { 10 }; fail_unless!((x == 10)); } fn test_else_fail() { let x = if true { 10 } else { fail!() }; diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index cba01fbd8dd81..1590187449ed1 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -14,7 +14,7 @@ type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, not_expected: @T, eq: compare) { let actual: @T = if true { expected } else { not_expected }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index eba30fa9bca42..5298f405fe6a8 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -16,7 +16,7 @@ type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 7e58d466b9044..9e718dd8b860f 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -15,7 +15,7 @@ type compare = 'static |T, T| -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected.clone() } else { not_expected }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_bool() { diff --git a/src/test/run-pass/expr-if.rs b/src/test/run-pass/expr-if.rs index 23446b3f650c5..1bc7b6a054995 100644 --- a/src/test/run-pass/expr-if.rs +++ b/src/test/run-pass/expr-if.rs @@ -13,43 +13,43 @@ // Tests for if as expressions -fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); } +fn test_if() { let rs: bool = if true { true } else { false }; fail_unless!((rs)); } fn test_else() { let rs: bool = if false { false } else { true }; - assert!((rs)); + fail_unless!((rs)); } fn test_elseif1() { let rs: bool = if true { true } else if true { false } else { false }; - assert!((rs)); + fail_unless!((rs)); } fn test_elseif2() { let rs: bool = if false { false } else if true { true } else { false }; - assert!((rs)); + fail_unless!((rs)); } fn test_elseif3() { let rs: bool = if false { false } else if false { false } else { true }; - assert!((rs)); + fail_unless!((rs)); } fn test_inferrence() { let rs = if true { true } else { false }; - assert!((rs)); + fail_unless!((rs)); } fn test_if_as_if_condition() { let rs1 = if if false { false } else { true } { true } else { false }; - assert!((rs1)); + fail_unless!((rs1)); let rs2 = if if true { false } else { true } { false } else { true }; - assert!((rs2)); + fail_unless!((rs2)); } fn test_if_as_block_result() { let rs = if true { if false { false } else { true } } else { false }; - assert!((rs)); + fail_unless!((rs)); } pub fn main() { diff --git a/src/test/run-pass/expr-match-generic-box1.rs b/src/test/run-pass/expr-match-generic-box1.rs index 82e80e7da7dc3..7d36bfb0dc7ff 100644 --- a/src/test/run-pass/expr-match-generic-box1.rs +++ b/src/test/run-pass/expr-match-generic-box1.rs @@ -14,7 +14,7 @@ type compare = 'static |@T, @T| -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = match true { true => { expected }, _ => fail!() }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs index 1ad9db4625788..03292f31e782a 100644 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ b/src/test/run-pass/expr-match-generic-box2.rs @@ -16,7 +16,7 @@ type compare = 'static |T, T| -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index af9022ed3222c..b8fc936ad9ecf 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -17,7 +17,7 @@ fn test_generic(expected: ~T, eq: compare) { true => { expected.clone() }, _ => fail!("wat") }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index 9784847159071..28c35dd6a4491 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -17,7 +17,7 @@ fn test_generic(expected: T, eq: compare) { true => expected.clone(), _ => fail!("wat") }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-match-generic.rs b/src/test/run-pass/expr-match-generic.rs index 4e7e7d6bdcf06..de43c3f3ee95a 100644 --- a/src/test/run-pass/expr-match-generic.rs +++ b/src/test/run-pass/expr-match-generic.rs @@ -14,7 +14,7 @@ type compare = extern "Rust" fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; - assert!((eq(expected, actual))); + fail_unless!((eq(expected, actual))); } fn test_bool() { diff --git a/src/test/run-pass/expr-match.rs b/src/test/run-pass/expr-match.rs index b8996de41999c..d7a5e954b6c90 100644 --- a/src/test/run-pass/expr-match.rs +++ b/src/test/run-pass/expr-match.rs @@ -15,14 +15,14 @@ // Tests for using match as an expression fn test_basic() { let mut rs: bool = match true { true => { true } false => { false } }; - assert!((rs)); + fail_unless!((rs)); rs = match false { true => { false } false => { true } }; - assert!((rs)); + fail_unless!((rs)); } fn test_inferrence() { let rs = match true { true => { true } false => { false } }; - assert!((rs)); + fail_unless!((rs)); } fn test_alt_as_alt_head() { @@ -33,7 +33,7 @@ fn test_alt_as_alt_head() { true => { false } false => { true } }; - assert!((rs)); + fail_unless!((rs)); } fn test_alt_as_block_result() { @@ -42,7 +42,7 @@ fn test_alt_as_block_result() { true => { false } false => { match true { true => { true } false => { false } } } }; - assert!((rs)); + fail_unless!((rs)); } pub fn main() { diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index d9505e01de95b..5cf4984bb114a 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -15,9 +15,9 @@ use std::cell::Cell; struct Point {x: int, y: int, z: int} fn f(p: @Cell) { - assert!((p.get().z == 12)); + fail_unless!((p.get().z == 12)); p.set(Point {x: 10, y: 11, z: 13}); - assert!((p.get().z == 13)); + fail_unless!((p.get().z == 13)); } pub fn main() { diff --git a/src/test/run-pass/extern-compare-with-return-type.rs b/src/test/run-pass/extern-compare-with-return-type.rs index 53a5d3e962118..8463ae072c8b3 100644 --- a/src/test/run-pass/extern-compare-with-return-type.rs +++ b/src/test/run-pass/extern-compare-with-return-type.rs @@ -21,7 +21,7 @@ extern fn uintuintuintuintret(x: uint, y: uint, z: uint) -> uint { x+y+z } pub fn main() { assert_eq!(voidret1, voidret1); - assert!(voidret1 != voidret2); + fail_unless!(voidret1 != voidret2); assert_eq!(uintret, uintret); diff --git a/src/test/run-pass/extern-fn-reachable.rs b/src/test/run-pass/extern-fn-reachable.rs index d0526b75c966c..a8a681cd48ea0 100644 --- a/src/test/run-pass/extern-fn-reachable.rs +++ b/src/test/run-pass/extern-fn-reachable.rs @@ -30,10 +30,10 @@ pub mod bar { pub fn main() { unsafe { let a = DynamicLibrary::open(None).unwrap(); - assert!(a.symbol::("fun1").is_ok()); - assert!(a.symbol::("fun2").is_err()); - assert!(a.symbol::("fun3").is_err()); - assert!(a.symbol::("fun4").is_ok()); - assert!(a.symbol::("fun5").is_err()); + fail_unless!(a.symbol::("fun1").is_ok()); + fail_unless!(a.symbol::("fun2").is_err()); + fail_unless!(a.symbol::("fun3").is_err()); + fail_unless!(a.symbol::("fun4").is_ok()); + fail_unless!(a.symbol::("fun5").is_err()); } } diff --git a/src/test/run-pass/extern-take-value.rs b/src/test/run-pass/extern-take-value.rs index b883fbd6f6a04..571875c93f08f 100644 --- a/src/test/run-pass/extern-take-value.rs +++ b/src/test/run-pass/extern-take-value.rs @@ -20,5 +20,5 @@ pub fn main() { let c: extern "C" fn() = g; assert_eq!(a, b); - assert!(a != c); + fail_unless!(a != c); } diff --git a/src/test/run-pass/extoption_env-not-defined.rs b/src/test/run-pass/extoption_env-not-defined.rs index 891133c78d477..f261970c73941 100644 --- a/src/test/run-pass/extoption_env-not-defined.rs +++ b/src/test/run-pass/extoption_env-not-defined.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - assert!(option_env!("__HOPEFULLY_DOESNT_EXIST__").is_none()); + fail_unless!(option_env!("__HOPEFULLY_DOESNT_EXIST__").is_none()); } diff --git a/src/test/run-pass/fail-in-dtor-drops-fields.rs b/src/test/run-pass/fail-in-dtor-drops-fields.rs index be4a497989ce8..2dc4f029ec637 100644 --- a/src/test/run-pass/fail-in-dtor-drops-fields.rs +++ b/src/test/run-pass/fail-in-dtor-drops-fields.rs @@ -36,7 +36,7 @@ pub fn main() { let ret = task::try(proc() { let _a = A { b: B { foo: 3 } }; }); - assert!(ret.is_err()); - unsafe { assert!(dropped); } + fail_unless!(ret.is_err()); + unsafe { fail_unless!(dropped); } } diff --git a/src/test/run-pass/field-destruction-order.rs b/src/test/run-pass/field-destruction-order.rs index 1d4c08f0bb5de..e724a404d5d76 100644 --- a/src/test/run-pass/field-destruction-order.rs +++ b/src/test/run-pass/field-destruction-order.rs @@ -33,7 +33,7 @@ static mut hit: bool = false; impl Drop for A { fn drop(&mut self) { unsafe { - assert!(!hit); + fail_unless!(!hit); hit = true; } } @@ -42,7 +42,7 @@ impl Drop for A { impl Drop for B { fn drop(&mut self) { unsafe { - assert!(hit); + fail_unless!(hit); } } } diff --git a/src/test/run-pass/float-nan.rs b/src/test/run-pass/float-nan.rs index 66c84d52745cd..ceeccb98cdd84 100644 --- a/src/test/run-pass/float-nan.rs +++ b/src/test/run-pass/float-nan.rs @@ -14,81 +14,81 @@ use std::num::Float; pub fn main() { let nan: f64 = Float::nan(); - assert!((nan).is_nan()); + fail_unless!((nan).is_nan()); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); assert_eq!(-inf, neg_inf); - assert!( nan != nan); - assert!( nan != -nan); - assert!(-nan != -nan); - assert!(-nan != nan); + fail_unless!( nan != nan); + fail_unless!( nan != -nan); + fail_unless!(-nan != -nan); + fail_unless!(-nan != nan); - assert!( nan != 1.); - assert!( nan != 0.); - assert!( nan != inf); - assert!( nan != -inf); + fail_unless!( nan != 1.); + fail_unless!( nan != 0.); + fail_unless!( nan != inf); + fail_unless!( nan != -inf); - assert!( 1. != nan); - assert!( 0. != nan); - assert!( inf != nan); - assert!(-inf != nan); + fail_unless!( 1. != nan); + fail_unless!( 0. != nan); + fail_unless!( inf != nan); + fail_unless!(-inf != nan); - assert!(!( nan == nan)); - assert!(!( nan == -nan)); - assert!(!( nan == 1.)); - assert!(!( nan == 0.)); - assert!(!( nan == inf)); - assert!(!( nan == -inf)); - assert!(!( 1. == nan)); - assert!(!( 0. == nan)); - assert!(!( inf == nan)); - assert!(!(-inf == nan)); - assert!(!(-nan == nan)); - assert!(!(-nan == -nan)); + fail_unless!(!( nan == nan)); + fail_unless!(!( nan == -nan)); + fail_unless!(!( nan == 1.)); + fail_unless!(!( nan == 0.)); + fail_unless!(!( nan == inf)); + fail_unless!(!( nan == -inf)); + fail_unless!(!( 1. == nan)); + fail_unless!(!( 0. == nan)); + fail_unless!(!( inf == nan)); + fail_unless!(!(-inf == nan)); + fail_unless!(!(-nan == nan)); + fail_unless!(!(-nan == -nan)); - assert!(!( nan > nan)); - assert!(!( nan > -nan)); - assert!(!( nan > 0.)); - assert!(!( nan > inf)); - assert!(!( nan > -inf)); - assert!(!( 0. > nan)); - assert!(!( inf > nan)); - assert!(!(-inf > nan)); - assert!(!(-nan > nan)); + fail_unless!(!( nan > nan)); + fail_unless!(!( nan > -nan)); + fail_unless!(!( nan > 0.)); + fail_unless!(!( nan > inf)); + fail_unless!(!( nan > -inf)); + fail_unless!(!( 0. > nan)); + fail_unless!(!( inf > nan)); + fail_unless!(!(-inf > nan)); + fail_unless!(!(-nan > nan)); - assert!(!(nan < 0.)); - assert!(!(nan < 1.)); - assert!(!(nan < -1.)); - assert!(!(nan < inf)); - assert!(!(nan < -inf)); - assert!(!(nan < nan)); - assert!(!(nan < -nan)); + fail_unless!(!(nan < 0.)); + fail_unless!(!(nan < 1.)); + fail_unless!(!(nan < -1.)); + fail_unless!(!(nan < inf)); + fail_unless!(!(nan < -inf)); + fail_unless!(!(nan < nan)); + fail_unless!(!(nan < -nan)); - assert!(!( 0. < nan)); - assert!(!( 1. < nan)); - assert!(!( -1. < nan)); - assert!(!( inf < nan)); - assert!(!(-inf < nan)); - assert!(!(-nan < nan)); + fail_unless!(!( 0. < nan)); + fail_unless!(!( 1. < nan)); + fail_unless!(!( -1. < nan)); + fail_unless!(!( inf < nan)); + fail_unless!(!(-inf < nan)); + fail_unless!(!(-nan < nan)); - assert!((nan + inf).is_nan()); - assert!((nan + -inf).is_nan()); - assert!((nan + 0.).is_nan()); - assert!((nan + 1.).is_nan()); - assert!((nan * 1.).is_nan()); - assert!((nan / 1.).is_nan()); - assert!((nan / 0.).is_nan()); - assert!((0.0/0.0f64).is_nan()); - assert!((-inf + inf).is_nan()); - assert!((inf - inf).is_nan()); + fail_unless!((nan + inf).is_nan()); + fail_unless!((nan + -inf).is_nan()); + fail_unless!((nan + 0.).is_nan()); + fail_unless!((nan + 1.).is_nan()); + fail_unless!((nan * 1.).is_nan()); + fail_unless!((nan / 1.).is_nan()); + fail_unless!((nan / 0.).is_nan()); + fail_unless!((0.0/0.0f64).is_nan()); + fail_unless!((-inf + inf).is_nan()); + fail_unless!((inf - inf).is_nan()); - assert!(!(-1.0f64).is_nan()); - assert!(!(0.0f64).is_nan()); - assert!(!(0.1f64).is_nan()); - assert!(!(1.0f64).is_nan()); - assert!(!(inf).is_nan()); - assert!(!(-inf).is_nan()); - assert!(!(1./-inf).is_nan()); + fail_unless!(!(-1.0f64).is_nan()); + fail_unless!(!(0.0f64).is_nan()); + fail_unless!(!(0.1f64).is_nan()); + fail_unless!(!(1.0f64).is_nan()); + fail_unless!(!(inf).is_nan()); + fail_unless!(!(-inf).is_nan()); + fail_unless!(!(1./-inf).is_nan()); } diff --git a/src/test/run-pass/float2.rs b/src/test/run-pass/float2.rs index 713d863029c7c..6df04e06107e4 100644 --- a/src/test/run-pass/float2.rs +++ b/src/test/run-pass/float2.rs @@ -23,12 +23,12 @@ pub fn main() { let j = 3.1e+9; let k = 3.2e-10; assert_eq!(a, b); - assert!((c < b)); + fail_unless!((c < b)); assert_eq!(c, d); - assert!((e < g)); - assert!((f < h)); + fail_unless!((e < g)); + fail_unless!((f < h)); assert_eq!(g, 1000000.0f32); assert_eq!(h, i); - assert!((j > k)); - assert!((k < a)); + fail_unless!((j > k)); + fail_unless!((k < a)); } diff --git a/src/test/run-pass/floatlits.rs b/src/test/run-pass/floatlits.rs index d1300e7f30c04..bbb1ec5bfa7ad 100644 --- a/src/test/run-pass/floatlits.rs +++ b/src/test/run-pass/floatlits.rs @@ -12,9 +12,9 @@ pub fn main() { let f = 4.999999999999; - assert!((f > 4.90)); - assert!((f < 5.0)); + fail_unless!((f > 4.90)); + fail_unless!((f < 5.0)); let g = 4.90000000001e-10; - assert!((g > 5e-11)); - assert!((g < 5e-9)); + fail_unless!((g > 5e-11)); + fail_unless!((g < 5e-9)); } diff --git a/src/test/run-pass/foreach-external-iterators-break.rs b/src/test/run-pass/foreach-external-iterators-break.rs index 87ed7826fed57..4d01532c7648e 100644 --- a/src/test/run-pass/foreach-external-iterators-break.rs +++ b/src/test/run-pass/foreach-external-iterators-break.rs @@ -17,5 +17,5 @@ pub fn main() { } y += *i; } - assert!(y == 11); + fail_unless!(y == 11); } diff --git a/src/test/run-pass/foreach-external-iterators-nested.rs b/src/test/run-pass/foreach-external-iterators-nested.rs index 78aba778421b1..1c99de038b4b4 100644 --- a/src/test/run-pass/foreach-external-iterators-nested.rs +++ b/src/test/run-pass/foreach-external-iterators-nested.rs @@ -19,5 +19,5 @@ pub fn main() { } q += *i + p; } - assert!(q == 1010100); + fail_unless!(q == 1010100); } diff --git a/src/test/run-pass/foreach-external-iterators.rs b/src/test/run-pass/foreach-external-iterators.rs index 593a996d8dfe9..f49ba7afb24f2 100644 --- a/src/test/run-pass/foreach-external-iterators.rs +++ b/src/test/run-pass/foreach-external-iterators.rs @@ -14,5 +14,5 @@ pub fn main() { for i in x.iter() { y += *i } - assert!(y == 100); + fail_unless!(y == 100); } diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index 2f88a54e3f5e0..e2aa04992b7be 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -15,4 +15,4 @@ // Issue #45: infer type parameters in function applications fn id(x: T) -> T { return x; } -pub fn main() { let x: int = 42; let y: int = id(x); assert!((x == y)); } +pub fn main() { let x: int = 42; let y: int = id(x); fail_unless!((x == y)); } diff --git a/src/test/run-pass/generic-tag-match.rs b/src/test/run-pass/generic-tag-match.rs index f740d8cb2d159..993efffb124c2 100644 --- a/src/test/run-pass/generic-tag-match.rs +++ b/src/test/run-pass/generic-tag-match.rs @@ -15,7 +15,7 @@ enum foo { arm(T), } fn altfoo(f: foo) { let mut hit = false; match f { arm::(_x) => { info!("in arm"); hit = true; } } - assert!((hit)); + fail_unless!((hit)); } pub fn main() { altfoo::(arm::(10)); } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index 7c4139664afa4..0f5cc364d482d 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -17,7 +17,7 @@ struct Pair { x: int, y: int } pub fn main() { let nop: noption = some::(5); - match nop { some::(n) => { info!("{:?}", n); assert!((n == 5)); } } + match nop { some::(n) => { info!("{:?}", n); fail_unless!((n == 5)); } } let nop2: noption = some(Pair{x: 17, y: 42}); match nop2 { some(t) => { diff --git a/src/test/run-pass/generic-temporary.rs b/src/test/run-pass/generic-temporary.rs index eca325a50f99c..5f7813435f59f 100644 --- a/src/test/run-pass/generic-temporary.rs +++ b/src/test/run-pass/generic-temporary.rs @@ -12,7 +12,7 @@ fn mk() -> int { return 1; } -fn chk(a: int) { info!("{}", a); assert!((a == 1)); } +fn chk(a: int) { info!("{}", a); fail_unless!((a == 1)); } fn apply(produce: extern fn() -> T, consume: extern fn(T)) { diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 55ecf919b7240..34c8c1a859b9a 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -20,7 +20,7 @@ pub fn main() { match getopts(args, opts) { Ok(ref m) => - assert!(!m.opt_present("b")), + fail_unless!(!m.opt_present("b")), Err(ref f) => fail!("{:?}", (*f).clone().to_err_msg()) }; diff --git a/src/test/run-pass/glob-std.rs b/src/test/run-pass/glob-std.rs index c1e6f04e67d0d..960cb50ecace2 100644 --- a/src/test/run-pass/glob-std.rs +++ b/src/test/run-pass/glob-std.rs @@ -39,7 +39,7 @@ pub fn main() { let root = TempDir::new("glob-tests"); let root = root.expect("Should have created a temp directory"); - assert!(os::change_dir(root.path())); + fail_unless!(os::change_dir(root.path())); mk_file("aaa", true); mk_file("aaa/apple", true); diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index a76b9d5ca0aa0..f9a1f67be5d7e 100644 --- a/src/test/run-pass/global-scope.rs +++ b/src/test/run-pass/global-scope.rs @@ -14,7 +14,7 @@ pub fn f() -> int { return 1; } pub mod foo { pub fn f() -> int { return 2; } - pub fn g() { assert!((f() == 2)); assert!((::f() == 1)); } + pub fn g() { fail_unless!((f() == 2)); fail_unless!((::f() == 1)); } } pub fn main() { return foo::g(); } diff --git a/src/test/run-pass/i32-sub.rs b/src/test/run-pass/i32-sub.rs index e5451431adedf..936caca4667b1 100644 --- a/src/test/run-pass/i32-sub.rs +++ b/src/test/run-pass/i32-sub.rs @@ -11,4 +11,4 @@ -pub fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert!((x == 400_i32)); } +pub fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; fail_unless!((x == 400_i32)); } diff --git a/src/test/run-pass/inner-attrs-on-impl.rs b/src/test/run-pass/inner-attrs-on-impl.rs index 69ae9d34385c1..69b55814a3c28 100644 --- a/src/test/run-pass/inner-attrs-on-impl.rs +++ b/src/test/run-pass/inner-attrs-on-impl.rs @@ -29,5 +29,5 @@ impl Foo { pub fn main() { - assert!(Foo.method()); + fail_unless!(Foo.method()); } diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index db9edfbefdc7e..2b7b64f8076ed 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -15,7 +15,7 @@ macro_rules! assert_approx_eq( ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, + fail_unless!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) ) @@ -103,13 +103,13 @@ pub fn main() { // Causes linker error // undefined reference to llvm.ceil.f32/64 - //assert!((ceilf32(-2.3f32) == -2.0f32)); - //assert!((ceilf64(3.8f64) == 4.0f64)); + //fail_unless!((ceilf32(-2.3f32) == -2.0f32)); + //fail_unless!((ceilf64(3.8f64) == 4.0f64)); // Causes linker error // undefined reference to llvm.trunc.f32/64 - //assert!((truncf32(0.1f32) == 0.0f32)); - //assert!((truncf64(-0.1f64) == 0.0f64)); + //fail_unless!((truncf32(0.1f32) == 0.0f32)); + //fail_unless!((truncf64(-0.1f64) == 0.0f64)); } } diff --git a/src/test/run-pass/issue-10734.rs b/src/test/run-pass/issue-10734.rs index a30cf71732851..0c663b7e5ae11 100644 --- a/src/test/run-pass/issue-10734.rs +++ b/src/test/run-pass/issue-10734.rs @@ -18,7 +18,7 @@ struct Foo { impl Drop for Foo { fn drop(&mut self) { // Test to make sure we haven't dropped already - assert!(!self.dropped); + fail_unless!(!self.dropped); self.dropped = true; // And record the fact that we dropped for verification later unsafe { drop_count += 1; } @@ -31,7 +31,7 @@ pub fn main() { let _a = Foo{ dropped: false }; } // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert!(drop_count == 1); } + unsafe { fail_unless!(drop_count == 1); } // An `if false {} else { expr }` statement should compile the same as `{ expr }`. if false { @@ -40,5 +40,5 @@ pub fn main() { let _a = Foo{ dropped: false }; } // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert!(drop_count == 2); } + unsafe { fail_unless!(drop_count == 2); } } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index d6dfdde1aa60f..2d1bbe1dfb070 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -79,7 +79,7 @@ pub mod pipes { pub fn send(mut p: send_packet, payload: T) { let p = p.unwrap(); let mut p = unsafe { uniquify(p) }; - assert!((*p).payload.is_none()); + fail_unless!((*p).payload.is_none()); (*p).payload = Some(payload); let old_state = swap_state_rel(&mut (*p).state, full); match old_state { diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index 44222315dcd09..8f29a0700b903 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -33,5 +33,5 @@ fn defer(b: @Cell) -> defer { pub fn main() { let dtor_ran = @Cell::new(false); let _ = defer(dtor_ran); - assert!(dtor_ran.get()); + fail_unless!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index f48e763966b1a..447f45be06baa 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -33,5 +33,5 @@ fn defer(b: @Cell) -> defer { pub fn main() { let dtor_ran = @Cell::new(false); defer(dtor_ran); - assert!(dtor_ran.get()); + fail_unless!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 2816609ef97dc..1dea3c9bdd2a2 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -73,14 +73,14 @@ fn read_board_grid(mut input: rdr) -> ~[~[square]] { } grid.push(row); let width = grid[0].len(); - for row in grid.iter() { assert!(row.len() == width) } + for row in grid.iter() { fail_unless!(row.len() == width) } grid } mod test { #[test] pub fn trivial_to_str() { - assert!(lambda.to_str() == "\\") + fail_unless!(lambda.to_str() == "\\") } } diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs index 34a855233a8ba..06695a9081828 100644 --- a/src/test/run-pass/issue-3168.rs +++ b/src/test/run-pass/issue-3168.rs @@ -30,6 +30,6 @@ pub fn main() { p3.recv(); }); error!("parent tries"); - assert!(!p.recv().try_send(())); + fail_unless!(!p.recv().try_send(())); error!("all done!"); } diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 1217f32826f6d..3f5859b09e245 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -12,4 +12,4 @@ fn quux(x: T) -> T { let f = id::; return f(x); } fn id(x: T) -> T { return x; } -pub fn main() { assert!((quux(10) == 10)); } +pub fn main() { fail_unless!((quux(10) == 10)); } diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 374607326dfef..741e6a15b8b94 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -24,7 +24,7 @@ fn tester() let loader: rsrc_loader = proc(_path) {result::Ok(~"more blah")}; let path = path::Path::new("blah"); - assert!(loader(&path).is_ok()); + fail_unless!(loader(&path).is_ok()); } pub fn main() {} diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index e7089a6a21e5f..f7589a164985c 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -33,11 +33,11 @@ fn check_strs(actual: &str, expected: &str) -> bool pub fn main() { -// assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); -// assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); +// fail_unless!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); +// fail_unless!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); let t = Text(@~"foo"); let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); let v = format!("{:?}", u); // this is the line that causes the seg fault - assert!(v.len() > 0); + fail_unless!(v.len() > 0); } diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index 5cc098e591cfe..e5620b3489ce0 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -22,6 +22,6 @@ pub fn main() { let mut table = HashMap::new(); table.insert(~"one", 1); table.insert(~"two", 2); - assert!(check_strs(table.to_str(), "{one: 1, two: 2}") || + fail_unless!(check_strs(table.to_str(), "{one: 1, two: 2}") || check_strs(table.to_str(), "{two: 2, one: 1}")); } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 8e5dd762c630f..43f354ee3b72a 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -153,7 +153,7 @@ pub fn check_strs(actual: &str, expected: &str) -> bool { fn test_ascii_art_ctor() { let art = AsciiArt(3, 3, '*'); - assert!(check_strs(art.to_str(), "...\n...\n...")); + fail_unless!(check_strs(art.to_str(), "...\n...\n...")); } @@ -162,7 +162,7 @@ fn test_add_pt() { art.add_pt(0, 0); art.add_pt(0, -10); art.add_pt(1, 2); - assert!(check_strs(art.to_str(), "*..\n...\n.*.")); + fail_unless!(check_strs(art.to_str(), "*..\n...\n.*.")); } @@ -170,7 +170,7 @@ fn test_shapes() { let mut art = AsciiArt(4, 4, '*'); art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}}); art.add_point(Point {x: 2, y: 2}); - assert!(check_strs(art.to_str(), "****\n*..*\n*.**\n****")); + fail_unless!(check_strs(art.to_str(), "****\n*..*\n*.**\n****")); } pub fn main() { diff --git a/src/test/run-pass/issue-3574.rs b/src/test/run-pass/issue-3574.rs index b216ca9a1ca30..3e3de98a54dd4 100644 --- a/src/test/run-pass/issue-3574.rs +++ b/src/test/run-pass/issue-3574.rs @@ -24,6 +24,6 @@ fn compare(x: &str, y: &str) -> bool pub fn main() { - assert!(compare("foo", "foo")); - assert!(compare(~"foo", ~"foo")); + fail_unless!(compare("foo", "foo")); + fail_unless!(compare(~"foo", ~"foo")); } diff --git a/src/test/run-pass/issue-3935.rs b/src/test/run-pass/issue-3935.rs index af1538c6e62a0..626932850cf42 100644 --- a/src/test/run-pass/issue-3935.rs +++ b/src/test/run-pass/issue-3935.rs @@ -17,5 +17,5 @@ pub fn main() { let town_bike = Bike { name: ~"schwinn" }; let my_bike = Bike { name: ~"surly" }; - assert!(town_bike != my_bike); + fail_unless!(town_bike != my_bike); } diff --git a/src/test/run-pass/issue-5239-2.rs b/src/test/run-pass/issue-5239-2.rs index 863acc5c0c3c0..4ba7640682ba3 100644 --- a/src/test/run-pass/issue-5239-2.rs +++ b/src/test/run-pass/issue-5239-2.rs @@ -13,5 +13,5 @@ pub fn main() { let _f: |int| -> int = |ref x: int| { *x }; let foo = 10; - assert!(_f(foo) == 10); + fail_unless!(_f(foo) == 10); } diff --git a/src/test/run-pass/issue-6130.rs b/src/test/run-pass/issue-6130.rs index d88397499feae..0a30691e6c83a 100644 --- a/src/test/run-pass/issue-6130.rs +++ b/src/test/run-pass/issue-6130.rs @@ -12,9 +12,9 @@ pub fn main() { let i: uint = 0; - assert!(i <= 0xFFFF_FFFF_u); + fail_unless!(i <= 0xFFFF_FFFF_u); let i: int = 0; - assert!(i >= -0x8000_0000_i); - assert!(i <= 0x7FFF_FFFF_i); + fail_unless!(i >= -0x8000_0000_i); + fail_unless!(i <= 0x7FFF_FFFF_i); } diff --git a/src/test/run-pass/issue-8498.rs b/src/test/run-pass/issue-8498.rs index ac95b5e7c1953..ca062043f837b 100644 --- a/src/test/run-pass/issue-8498.rs +++ b/src/test/run-pass/issue-8498.rs @@ -12,14 +12,14 @@ pub fn main() { match &[(~5,~7)] { ps => { let (ref y, _) = ps[0]; - assert!(**y == 5); + fail_unless!(**y == 5); } } match Some(&[(~5,)]) { Some(ps) => { let (ref y,) = ps[0]; - assert!(**y == 5); + fail_unless!(**y == 5); } None => () } @@ -27,8 +27,8 @@ pub fn main() { match Some(&[(~5,~7)]) { Some(ps) => { let (ref y, ref z) = ps[0]; - assert!(**y == 5); - assert!(**z == 7); + fail_unless!(**y == 5); + fail_unless!(**z == 7); } None => () } diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 9b3db58ea9b29..4c843cd211479 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -12,9 +12,9 @@ fn test_stack_assign() { let s: ~str = ~"a"; info!("{}", s.clone()); let t: ~str = ~"a"; - assert!(s == t); + fail_unless!(s == t); let u: ~str = ~"b"; - assert!((s != u)); + fail_unless!((s != u)); } fn test_heap_lit() { ~"a big string"; } @@ -22,9 +22,9 @@ fn test_heap_lit() { ~"a big string"; } fn test_heap_assign() { let s: ~str = ~"a big ol' string"; let t: ~str = ~"a big ol' string"; - assert!(s == t); + fail_unless!(s == t); let u: ~str = ~"a bad ol' string"; - assert!((s != u)); + fail_unless!((s != u)); } fn test_heap_log() { let s = ~"a big ol' string"; info!("{}", s); } @@ -36,7 +36,7 @@ fn test_stack_add() { assert_eq!(~"" + "", ~""); } -fn test_stack_heap_add() { assert!((~"a" + "bracadabra" == ~"abracadabra")); } +fn test_stack_heap_add() { fail_unless!((~"a" + "bracadabra" == ~"abracadabra")); } fn test_heap_add() { assert_eq!(~"this should" + " totally work", ~"this should totally work"); @@ -54,10 +54,10 @@ fn test_append() { let mut s = ~"c"; s.push_str("offee"); - assert!(s == ~"coffee"); + fail_unless!(s == ~"coffee"); s.push_str("&tea"); - assert!(s == ~"coffee&tea"); + fail_unless!(s == ~"coffee&tea"); } pub fn main() { diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index c44b7389666f9..40f2b55e3cea1 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -11,7 +11,7 @@ fn range_(a: int, b: int, it: |int|) { - assert!((a < b)); + fail_unless!((a < b)); let mut i: int = a; while i < b { it(i); i += 1; } } diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index a3dc848344c4f..efa1b37bf5931 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -10,13 +10,13 @@ -fn incr(x: &mut int) -> bool { *x += 1; assert!((false)); return false; } +fn incr(x: &mut int) -> bool { *x += 1; fail_unless!((false)); return false; } pub fn main() { let x = 1 == 2 || 3 == 3; - assert!((x)); + fail_unless!((x)); let mut y: int = 10; info!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); - if true && x { assert!((true)); } else { assert!((false)); } + if true && x { fail_unless!((true)); } else { fail_unless!((false)); } } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index 67bbd0967206b..63419f119c726 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -17,11 +17,11 @@ pub fn main() { let s = ~"hello there"; let mut i: int = 0; for c in s.bytes() { - if i == 0 { assert!((c == 'h' as u8)); } - if i == 1 { assert!((c == 'e' as u8)); } - if i == 2 { assert!((c == 'l' as u8)); } - if i == 3 { assert!((c == 'l' as u8)); } - if i == 4 { assert!((c == 'o' as u8)); } + if i == 0 { fail_unless!((c == 'h' as u8)); } + if i == 1 { fail_unless!((c == 'e' as u8)); } + if i == 2 { fail_unless!((c == 'l' as u8)); } + if i == 3 { fail_unless!((c == 'l' as u8)); } + if i == 4 { fail_unless!((c == 'o' as u8)); } // ... i += 1; diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index 05c5a7a67f563..cc5383c6bde48 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -27,6 +27,6 @@ pub fn main() { let x = list::from_vec([a(22u), b(~"hi")]); let exp = ~"@Cons(a(22u), @Cons(b(~\"hi\"), @Nil))"; let act = format!("{:?}", x); - assert!(act == exp); + fail_unless!(act == exp); check_log(exp, x); } diff --git a/src/test/run-pass/logging-only-prints-once.rs b/src/test/run-pass/logging-only-prints-once.rs index 362d61da69581..175c405e6135e 100644 --- a/src/test/run-pass/logging-only-prints-once.rs +++ b/src/test/run-pass/logging-only-prints-once.rs @@ -19,7 +19,7 @@ struct Foo(Cell); impl fmt::Show for Foo { fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result { let Foo(ref f) = *self; - assert!(f.get() == 0); + fail_unless!(f.get() == 0); f.set(1); Ok(()) } @@ -31,7 +31,7 @@ pub fn main() { let mut f = Foo(Cell::new(0)); debug!("{}", f); let Foo(ref mut f) = f; - assert!(f.get() == 1); + fail_unless!(f.get() == 1); c.send(()); }); p.recv(); diff --git a/src/test/run-pass/loop-break-cont-1.rs b/src/test/run-pass/loop-break-cont-1.rs index 3b7e03ae58de4..69ab5f7d7dcff 100644 --- a/src/test/run-pass/loop-break-cont-1.rs +++ b/src/test/run-pass/loop-break-cont-1.rs @@ -13,5 +13,5 @@ pub fn main() { loop { break; } - assert!(true); + fail_unless!(true); } diff --git a/src/test/run-pass/loop-break-cont.rs b/src/test/run-pass/loop-break-cont.rs index d6f148f559dba..ee54ab76ccc1d 100644 --- a/src/test/run-pass/loop-break-cont.rs +++ b/src/test/run-pass/loop-break-cont.rs @@ -31,7 +31,7 @@ pub fn main() { } is_even = true; } - assert!(!is_even); + fail_unless!(!is_even); loop { error!("c"); if i == 22u { @@ -44,5 +44,5 @@ pub fn main() { } is_even = true; } - assert!(is_even); + fail_unless!(is_even); } diff --git a/src/test/run-pass/macro-2.rs b/src/test/run-pass/macro-2.rs index 1407c995c2580..e467fadd563ef 100644 --- a/src/test/run-pass/macro-2.rs +++ b/src/test/run-pass/macro-2.rs @@ -21,5 +21,5 @@ pub fn main() { }) ) - assert!(mylambda_tt!(y, y * 2)(8) == 16) + fail_unless!(mylambda_tt!(y, y * 2)(8) == 16) } diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 4b89844194a57..f01886dad3d7e 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -24,7 +24,7 @@ macro_rules! overly_complicated ( ) pub fn main() { - assert!(overly_complicated!(f, x, Option, { return Some(x); }, + fail_unless!(overly_complicated!(f, x, Option, { return Some(x); }, Some(8u), Some(y), y) == 8u) } diff --git a/src/test/run-pass/macro-local-data-key.rs b/src/test/run-pass/macro-local-data-key.rs index e03256bfe499d..569a030609789 100644 --- a/src/test/run-pass/macro-local-data-key.rs +++ b/src/test/run-pass/macro-local-data-key.rs @@ -17,8 +17,8 @@ mod bar { } pub fn main() { - local_data::get(foo, |x| assert!(x.is_none())); - local_data::get(bar::baz, |y| assert!(y.is_none())); + local_data::get(foo, |x| fail_unless!(x.is_none())); + local_data::get(bar::baz, |y| fail_unless!(y.is_none())); local_data::set(foo, 3); local_data::set(bar::baz, -10.0); diff --git a/src/test/run-pass/match-implicit-copy-unique.rs b/src/test/run-pass/match-implicit-copy-unique.rs index 23074894490d6..58429f22f5d89 100644 --- a/src/test/run-pass/match-implicit-copy-unique.rs +++ b/src/test/run-pass/match-implicit-copy-unique.rs @@ -14,7 +14,7 @@ pub fn main() { let mut x = ~Pair {a: ~10, b: ~20}; match x { ~Pair {a: ref mut a, b: ref mut _b} => { - assert!(**a == 10); *a = ~30; assert!(**a == 30); + fail_unless!(**a == 10); *a = ~30; fail_unless!(**a == 30); } } } diff --git a/src/test/run-pass/match-pattern-lit.rs b/src/test/run-pass/match-pattern-lit.rs index 84e9012be4e24..e533b38040351 100644 --- a/src/test/run-pass/match-pattern-lit.rs +++ b/src/test/run-pass/match-pattern-lit.rs @@ -18,4 +18,4 @@ fn altlit(f: int) -> int { } } -pub fn main() { assert!((altlit(10) == 20)); assert!((altlit(11) == 22)); } +pub fn main() { fail_unless!((altlit(10) == 20)); fail_unless!((altlit(11) == 22)); } diff --git a/src/test/run-pass/match-ref-binding-in-guard-3256.rs b/src/test/run-pass/match-ref-binding-in-guard-3256.rs index de4da6e3b06d7..b3656cb0bd1da 100644 --- a/src/test/run-pass/match-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/match-ref-binding-in-guard-3256.rs @@ -15,7 +15,7 @@ pub fn main() { let x = Some(unstable::sync::Exclusive::new(true)); match x { Some(ref z) if z.with(|b| *b) => { - z.with(|b| assert!(*b)); + z.with(|b| fail_unless!(*b)); }, _ => fail!() } diff --git a/src/test/run-pass/match-static-const-rename.rs b/src/test/run-pass/match-static-const-rename.rs index df62ba7298d29..1f880e6f11a82 100644 --- a/src/test/run-pass/match-static-const-rename.rs +++ b/src/test/run-pass/match-static-const-rename.rs @@ -25,12 +25,12 @@ fn f() { (0, A) => 0, (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); let r = match (0,97) { (0, A) => 0, (x, y) => 1 + x + y, }; - assert!(r == 0); + fail_unless!(r == 0); } mod m { @@ -43,12 +43,12 @@ fn g() { (0, AHA) => 0, (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); let r = match (0,7) { (0, AHA) => 0, (x, y) => 1 + x + y, }; - assert!(r == 0); + fail_unless!(r == 0); } fn h() { @@ -56,12 +56,12 @@ fn h() { (0, self::m::aha) => 0, (x, y) => 1 + x + y, }; - assert!(r == 1); + fail_unless!(r == 1); let r = match (0,7) { (0, self::m::aha) => 0, (x, y) => 1 + x + y, }; - assert!(r == 0); + fail_unless!(r == 0); } pub fn main () { diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 42e782928b8da..1bb46a36b07a4 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -44,7 +44,7 @@ fn transform(x: Option) -> Option<~str> { pub fn main() { assert_eq!(transform(Some(10)), Some(~"11")); assert_eq!(transform(None), None); - assert!((~[~"hi"]) + fail_unless!((~[~"hi"]) .bind(|x| ~[x.clone(), *x + "!"] ) .bind(|x| ~[x.clone(), *x + "?"] ) == ~[~"hi", ~"hi?", ~"hi!", ~"hi!?"]); diff --git a/src/test/run-pass/move-2-unique.rs b/src/test/run-pass/move-2-unique.rs index e3595d4ac9a31..08f67a7fa5c82 100644 --- a/src/test/run-pass/move-2-unique.rs +++ b/src/test/run-pass/move-2-unique.rs @@ -11,4 +11,4 @@ struct X { x: int, y: int, z: int } -pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = x; fail_unless!((y.y == 2)); } diff --git a/src/test/run-pass/move-2.rs b/src/test/run-pass/move-2.rs index 14d4ea3ff35fc..9a778c6aea476 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.rs @@ -12,4 +12,4 @@ struct X { x: int, y: int, z: int } -pub fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = x; fail_unless!((y.y == 2)); } diff --git a/src/test/run-pass/move-4-unique.rs b/src/test/run-pass/move-4-unique.rs index 660fb447bb0e5..527273950497f 100644 --- a/src/test/run-pass/move-4-unique.rs +++ b/src/test/run-pass/move-4-unique.rs @@ -20,4 +20,4 @@ fn test(foo: ~Triple) -> ~Triple { return quux; } -pub fn main() { let x = ~Triple{a: 1, b: 2, c: 3}; let y = test(x); assert!((y.c == 3)); } +pub fn main() { let x = ~Triple{a: 1, b: 2, c: 3}; let y = test(x); fail_unless!((y.c == 3)); } diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index ed3cdc81c3179..10ac47e102ee7 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test(foo: ~~[int]) { assert!((foo[0] == 10)); } +fn test(foo: ~~[int]) { fail_unless!((foo[0] == 10)); } pub fn main() { let x = ~~[10]; diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index 18cee34c25ca6..db7901aa9e236 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -fn test(foo: @~[int]) { assert!((foo[0] == 10)); } +fn test(foo: @~[int]) { fail_unless!((foo[0] == 10)); } pub fn main() { let x = @~[10]; diff --git a/src/test/run-pass/move-arg.rs b/src/test/run-pass/move-arg.rs index 87db5cbe2f13e..6d9aafa513690 100644 --- a/src/test/run-pass/move-arg.rs +++ b/src/test/run-pass/move-arg.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test(foo: int) { assert!((foo == 10)); } +fn test(foo: int) { fail_unless!((foo == 10)); } pub fn main() { let x = 10; test(x); } diff --git a/src/test/run-pass/multi-let.rs b/src/test/run-pass/multi-let.rs index eb1444be37844..96e982f925045 100644 --- a/src/test/run-pass/multi-let.rs +++ b/src/test/run-pass/multi-let.rs @@ -11,5 +11,5 @@ pub fn main() { let x = 10; let y = x; - assert!((y == 10)); + fail_unless!((y == 10)); } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index 5801ccebb0fcd..932322866fa17 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -14,7 +14,7 @@ fn f(mut y: ~int) { } fn g() { - let frob: |~int| = |mut q| { *q = 2; assert!(*q == 2); }; + let frob: |~int| = |mut q| { *q = 2; fail_unless!(*q == 2); }; let w = ~37; frob(w); diff --git a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs index 855c77e92cf51..153149bb925d7 100644 --- a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs +++ b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs @@ -17,7 +17,7 @@ fn test1() { fn test2() { let mut ints = [0, ..32]; for i in ints.mut_iter() { *i += 22; } - for i in ints.iter() { assert!(*i == 22); } + for i in ints.iter() { fail_unless!(*i == 22); } } pub fn main() { diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 1cbed9c29ece2..350f4bd170901 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -15,7 +15,7 @@ struct C { c: int } pub fn main() { match A {a: 10, b: 20} { - x@A {a, b: 20} => { assert!(x.a == 10); assert!(a == 10); } + x@A {a, b: 20} => { fail_unless!(x.a == 10); fail_unless!(a == 10); } A {b: _b, ..} => { fail!(); } } let mut x@B {b, ..} = B {a: 10, b: C {c: 20}}; diff --git a/src/test/run-pass/no-landing-pads.rs b/src/test/run-pass/no-landing-pads.rs index 799ad538c8d55..df7c243229d4d 100644 --- a/src/test/run-pass/no-landing-pads.rs +++ b/src/test/run-pass/no-landing-pads.rs @@ -28,5 +28,5 @@ fn main() { let _a = A; fail!(); }); - assert!(unsafe { !HIT }); + fail_unless!(unsafe { !HIT }); } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index cb08c81d9e0ed..e298549fbfd03 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -25,12 +25,12 @@ fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } fn safe_head(ls: @List) -> T { - assert!(!is_empty(ls)); + fail_unless!(!is_empty(ls)); return head(ls); } pub fn main() { let mylist = @Cons(@1u, @Nil); - assert!((nonempty_list(mylist))); + fail_unless!((nonempty_list(mylist))); assert_eq!(*safe_head(mylist), 1u); } diff --git a/src/test/run-pass/nul-characters.rs b/src/test/run-pass/nul-characters.rs index 22786c0abc89b..181afd5c46d36 100644 --- a/src/test/run-pass/nul-characters.rs +++ b/src/test/run-pass/nul-characters.rs @@ -39,6 +39,6 @@ pub fn main() assert_eq!('\u0000', '\U00000000'); // NUL characters should make a difference - assert!("Hello World" != "Hello \0World"); - assert!("Hello World" != "Hello World\0"); + fail_unless!("Hello World" != "Hello \0World"); + fail_unless!("Hello World" != "Hello World\0"); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index ccf6414439162..e730a4f44d41c 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -50,10 +50,10 @@ impl E { macro_rules! check_option { ($e:expr: $T:ty) => {{ - check_option!($e: $T, |ptr| assert!(*ptr == $e)); + check_option!($e: $T, |ptr| fail_unless!(*ptr == $e)); }}; ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{ - assert!(option::None::<$T>.is_none()); + fail_unless!(option::None::<$T>.is_none()); let e = $e; let s_ = option::Some::<$T>(e); let $v = s_.get_ref(); @@ -63,10 +63,10 @@ macro_rules! check_option { macro_rules! check_fancy { ($e:expr: $T:ty) => {{ - check_fancy!($e: $T, |ptr| assert!(*ptr == $e)); + check_fancy!($e: $T, |ptr| fail_unless!(*ptr == $e)); }}; ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{ - assert!(Nothing::<$T>((), ((), ()), [23i8, ..0]).is_none()); + fail_unless!(Nothing::<$T>((), ((), ()), [23i8, ..0]).is_none()); let e = $e; let t_ = Thing::<$T>(23, e); match t_.get_ref() { @@ -92,6 +92,6 @@ pub fn main() { check_type!(~[20, 22]: ~[int]); let mint: uint = unsafe { cast::transmute(main) }; check_type!(main: extern fn(), |pthing| { - assert!(mint == unsafe { cast::transmute(*pthing) }) + fail_unless!(mint == unsafe { cast::transmute(*pthing) }) }); } diff --git a/src/test/run-pass/once-move-out-on-heap.rs b/src/test/run-pass/once-move-out-on-heap.rs index 5067a6c4f926f..0ea5a310ffe7d 100644 --- a/src/test/run-pass/once-move-out-on-heap.rs +++ b/src/test/run-pass/once-move-out-on-heap.rs @@ -23,7 +23,7 @@ fn foo(blk: proc()) { pub fn main() { let x = Arc::new(true); foo(proc() { - assert!(*x.get()); + fail_unless!(*x.get()); drop(x); }); } diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs index ffee1e400afff..0e86562b1d980 100644 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ b/src/test/run-pass/once-move-out-on-stack.rs @@ -23,7 +23,7 @@ fn foo(blk: once ||) { pub fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + fail_unless!(*x.get()); drop(x); }) } diff --git a/src/test/run-pass/operator-associativity.rs b/src/test/run-pass/operator-associativity.rs index bee6d23a27d62..a1af35be65325 100644 --- a/src/test/run-pass/operator-associativity.rs +++ b/src/test/run-pass/operator-associativity.rs @@ -12,4 +12,4 @@ // Testcase for issue #130, operator associativity. -pub fn main() { assert!((3 * 5 / 2 == 7)); } +pub fn main() { fail_unless!((3 * 5 / 2 == 7)); } diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index b475222619d62..3196896265442 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -48,9 +48,9 @@ pub fn main() { list.push(foo.clone(), 22); list.push(bar.clone(), 44); - assert!(list[foo] == 22) - assert!(list[bar] == 44) + fail_unless!(list[foo] == 22) + fail_unless!(list[bar] == 44) - assert!(list[foo] == 22) - assert!(list[bar] == 44) + fail_unless!(list[foo] == 22) + fail_unless!(list[bar] == 44) } diff --git a/src/test/run-pass/readalias.rs b/src/test/run-pass/readalias.rs index 51e955c476109..8a4f473ad9ae8 100644 --- a/src/test/run-pass/readalias.rs +++ b/src/test/run-pass/readalias.rs @@ -13,6 +13,6 @@ struct Point {x: int, y: int, z: int} -fn f(p: Point) { assert!((p.z == 12)); } +fn f(p: Point) { fail_unless!((p.z == 12)); } pub fn main() { let x: Point = Point {x: 10, y: 11, z: 12}; f(x); } diff --git a/src/test/run-pass/reexported-static-methods-cross-crate.rs b/src/test/run-pass/reexported-static-methods-cross-crate.rs index b3a7cf7442865..7c9635c162c68 100644 --- a/src/test/run-pass/reexported-static-methods-cross-crate.rs +++ b/src/test/run-pass/reexported-static-methods-cross-crate.rs @@ -20,6 +20,6 @@ use reexported_static_methods::Bort; pub fn main() { assert_eq!(42, Foo::foo()); assert_eq!(84, Baz::bar()); - assert!(Boz::boz(1)); + fail_unless!(Boz::boz(1)); assert_eq!(~"bort()", Bort::bort()); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs index 18458aa232056..3e00bda71c095 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs @@ -22,7 +22,7 @@ pub fn main() { match i { i => { let y = &x; - assert!(i < *y); + fail_unless!(i < *y); } } let mut y = 4; diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index 8f7452f2d06ed..4afa1528deeba 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -14,5 +14,5 @@ pub fn main() { let v = ~[1, 2, 3]; let x = view(v); let y = view(x); - assert!((v[0] == x[0]) && (v[0] == y[0])); + fail_unless!((v[0] == x[0]) && (v[0] == y[0])); } diff --git a/src/test/run-pass/regions-lifetime-static-items-enclosing-scopes.rs b/src/test/run-pass/regions-lifetime-static-items-enclosing-scopes.rs index 975dcab190251..0249bddc3d111 100644 --- a/src/test/run-pass/regions-lifetime-static-items-enclosing-scopes.rs +++ b/src/test/run-pass/regions-lifetime-static-items-enclosing-scopes.rs @@ -15,7 +15,7 @@ extern crate extra; use std::cmp::Eq; fn f(o: &mut Option) { - assert!(*o == None); + fail_unless!(*o == None); } pub fn main() { diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index 3f14d7befac27..9cf959b5b8314 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -36,7 +36,7 @@ fn rename_directory() { libc::fopen(fromp, modebuf) }) }); - assert!((ostream as uint != 0u)); + fail_unless!((ostream as uint != 0u)); let s = ~"hello"; "hello".with_c_str(|buf| { let write_len = libc::fwrite(buf as *libc::c_void, @@ -50,8 +50,8 @@ fn rename_directory() { let new_path = tmpdir.join_many(["quux", "blat"]); fs::mkdir_recursive(&new_path, io::UserRWX); fs::rename(&old_path, &new_path.join("newdir")); - assert!(new_path.join("newdir").is_dir()); - assert!(new_path.join_many(["newdir", "temp.txt"]).exists()); + fail_unless!(new_path.join("newdir").is_dir()); + fail_unless!(new_path.join_many(["newdir", "temp.txt"]).exists()); } } diff --git a/src/test/run-pass/resolve-issue-2428.rs b/src/test/run-pass/resolve-issue-2428.rs index 57f6596d1d720..23c6d07676028 100644 --- a/src/test/run-pass/resolve-issue-2428.rs +++ b/src/test/run-pass/resolve-issue-2428.rs @@ -10,4 +10,4 @@ static foo: int = 4 >> 1; enum bs { thing = foo } -pub fn main() { assert!((thing as int == foo)); } +pub fn main() { fail_unless!((thing as int == foo)); } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 93183f8dba475..2fc52fc8058e1 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -35,7 +35,7 @@ fn shrinky_pointer(i: @@Cell) -> shrinky_pointer { pub fn main() { let my_total = @@Cell::new(10); - { let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); } + { let pt = shrinky_pointer(my_total); fail_unless!((pt.look_at() == 10)); } error!("my_total = {}", my_total.get()); assert_eq!(my_total.get(), 9); } diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index 1c5ad9ce525df..984afcafe4be6 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -43,5 +43,5 @@ pub fn main() { let c = @Cell::new(true); sink(none); sink(some(close_res(c))); - assert!(!c.get()); + fail_unless!(!c.get()); } diff --git a/src/test/run-pass/self-re-assign.rs b/src/test/run-pass/self-re-assign.rs index 041c5cf4a640e..02d9a2befa50b 100644 --- a/src/test/run-pass/self-re-assign.rs +++ b/src/test/run-pass/self-re-assign.rs @@ -16,9 +16,9 @@ use std::rc::Rc; pub fn main() { let mut x = ~3; x = x; - assert!(*x == 3); + fail_unless!(*x == 3); let mut x = Rc::new(3); x = x; - assert!(*x.borrow() == 3); + fail_unless!(*x.borrow() == 3); } diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs index 98a3709a61a02..282d2f111b79e 100644 --- a/src/test/run-pass/self-shadowing-import.rs +++ b/src/test/run-pass/self-shadowing-import.rs @@ -20,7 +20,7 @@ mod a { mod c { use a::b::a; - pub fn bar() { assert!((a::foo() == 1)); } + pub fn bar() { fail_unless!((a::foo() == 1)); } } pub fn main() { c::bar(); } diff --git a/src/test/run-pass/send_str_hashmap.rs b/src/test/run-pass/send_str_hashmap.rs index 8599f9d383605..51825e62178e6 100644 --- a/src/test/run-pass/send_str_hashmap.rs +++ b/src/test/run-pass/send_str_hashmap.rs @@ -20,15 +20,15 @@ use std::option::Some; pub fn main() { let mut map: HashMap = HashMap::new(); - assert!(map.insert(Slice("foo"), 42)); - assert!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(Slice("foo"), 42)); - assert!(!map.insert(Owned(~"foo"), 42)); + fail_unless!(map.insert(Slice("foo"), 42)); + fail_unless!(!map.insert(Owned(~"foo"), 42)); + fail_unless!(!map.insert(Slice("foo"), 42)); + fail_unless!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(Slice("foo"), 43)); - assert!(!map.insert(Owned(~"foo"), 44)); - assert!(!map.insert(Slice("foo"), 45)); - assert!(!map.insert(Owned(~"foo"), 46)); + fail_unless!(!map.insert(Slice("foo"), 43)); + fail_unless!(!map.insert(Owned(~"foo"), 44)); + fail_unless!(!map.insert(Slice("foo"), 45)); + fail_unless!(!map.insert(Owned(~"foo"), 46)); let v = 46; @@ -37,20 +37,20 @@ pub fn main() { let (a, b, c, d) = (50, 51, 52, 53); - assert!(map.insert(Slice("abc"), a)); - assert!(map.insert(Owned(~"bcd"), b)); - assert!(map.insert(Slice("cde"), c)); - assert!(map.insert(Owned(~"def"), d)); + fail_unless!(map.insert(Slice("abc"), a)); + fail_unless!(map.insert(Owned(~"bcd"), b)); + fail_unless!(map.insert(Slice("cde"), c)); + fail_unless!(map.insert(Owned(~"def"), d)); - assert!(!map.insert(Slice("abc"), a)); - assert!(!map.insert(Owned(~"bcd"), b)); - assert!(!map.insert(Slice("cde"), c)); - assert!(!map.insert(Owned(~"def"), d)); + fail_unless!(!map.insert(Slice("abc"), a)); + fail_unless!(!map.insert(Owned(~"bcd"), b)); + fail_unless!(!map.insert(Slice("cde"), c)); + fail_unless!(!map.insert(Owned(~"def"), d)); - assert!(!map.insert(Owned(~"abc"), a)); - assert!(!map.insert(Slice("bcd"), b)); - assert!(!map.insert(Owned(~"cde"), c)); - assert!(!map.insert(Slice("def"), d)); + fail_unless!(!map.insert(Owned(~"abc"), a)); + fail_unless!(!map.insert(Slice("bcd"), b)); + fail_unless!(!map.insert(Owned(~"cde"), c)); + fail_unless!(!map.insert(Slice("def"), d)); assert_eq!(map.find_equiv(&("abc")), Some(&a)); assert_eq!(map.find_equiv(&("bcd")), Some(&b)); diff --git a/src/test/run-pass/send_str_treemap.rs b/src/test/run-pass/send_str_treemap.rs index 1543d34ae88b9..46de7849801ea 100644 --- a/src/test/run-pass/send_str_treemap.rs +++ b/src/test/run-pass/send_str_treemap.rs @@ -22,15 +22,15 @@ use std::option::Some; pub fn main() { let mut map: TreeMap = TreeMap::new(); - assert!(map.insert(Slice("foo"), 42)); - assert!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(Slice("foo"), 42)); - assert!(!map.insert(Owned(~"foo"), 42)); + fail_unless!(map.insert(Slice("foo"), 42)); + fail_unless!(!map.insert(Owned(~"foo"), 42)); + fail_unless!(!map.insert(Slice("foo"), 42)); + fail_unless!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(Slice("foo"), 43)); - assert!(!map.insert(Owned(~"foo"), 44)); - assert!(!map.insert(Slice("foo"), 45)); - assert!(!map.insert(Owned(~"foo"), 46)); + fail_unless!(!map.insert(Slice("foo"), 43)); + fail_unless!(!map.insert(Owned(~"foo"), 44)); + fail_unless!(!map.insert(Slice("foo"), 45)); + fail_unless!(!map.insert(Owned(~"foo"), 46)); let v = 46; @@ -39,20 +39,20 @@ pub fn main() { let (a, b, c, d) = (50, 51, 52, 53); - assert!(map.insert(Slice("abc"), a)); - assert!(map.insert(Owned(~"bcd"), b)); - assert!(map.insert(Slice("cde"), c)); - assert!(map.insert(Owned(~"def"), d)); + fail_unless!(map.insert(Slice("abc"), a)); + fail_unless!(map.insert(Owned(~"bcd"), b)); + fail_unless!(map.insert(Slice("cde"), c)); + fail_unless!(map.insert(Owned(~"def"), d)); - assert!(!map.insert(Slice("abc"), a)); - assert!(!map.insert(Owned(~"bcd"), b)); - assert!(!map.insert(Slice("cde"), c)); - assert!(!map.insert(Owned(~"def"), d)); + fail_unless!(!map.insert(Slice("abc"), a)); + fail_unless!(!map.insert(Owned(~"bcd"), b)); + fail_unless!(!map.insert(Slice("cde"), c)); + fail_unless!(!map.insert(Owned(~"def"), d)); - assert!(!map.insert(Owned(~"abc"), a)); - assert!(!map.insert(Slice("bcd"), b)); - assert!(!map.insert(Owned(~"cde"), c)); - assert!(!map.insert(Slice("def"), d)); + fail_unless!(!map.insert(Owned(~"abc"), a)); + fail_unless!(!map.insert(Slice("bcd"), b)); + fail_unless!(!map.insert(Owned(~"cde"), c)); + fail_unless!(!map.insert(Slice("def"), d)); assert_eq!(map.find(&Slice("abc")), Some(&a)); assert_eq!(map.find(&Slice("bcd")), Some(&b)); @@ -64,7 +64,7 @@ pub fn main() { assert_eq!(map.find(&Owned(~"cde")), Some(&c)); assert_eq!(map.find(&Owned(~"def")), Some(&d)); - assert!(map.pop(&Slice("foo")).is_some()); + fail_unless!(map.pop(&Slice("foo")).is_some()); assert_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str()) .to_owned_vec() .concat(), diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index 86907bdf2a38f..289fa595c2dc6 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -11,16 +11,16 @@ pub fn main() { - assert!((~"hello" < ~"hellr")); - assert!((~"hello " > ~"hello")); - assert!((~"hello" != ~"there")); - assert!((~[1, 2, 3, 4] > ~[1, 2, 3])); - assert!((~[1, 2, 3] < ~[1, 2, 3, 4])); - assert!((~[1, 2, 4, 4] > ~[1, 2, 3, 4])); - assert!((~[1, 2, 3, 4] < ~[1, 2, 4, 4])); - assert!((~[1, 2, 3] <= ~[1, 2, 3])); - assert!((~[1, 2, 3] <= ~[1, 2, 3, 3])); - assert!((~[1, 2, 3, 4] > ~[1, 2, 3])); + fail_unless!((~"hello" < ~"hellr")); + fail_unless!((~"hello " > ~"hello")); + fail_unless!((~"hello" != ~"there")); + fail_unless!((~[1, 2, 3, 4] > ~[1, 2, 3])); + fail_unless!((~[1, 2, 3] < ~[1, 2, 3, 4])); + fail_unless!((~[1, 2, 4, 4] > ~[1, 2, 3, 4])); + fail_unless!((~[1, 2, 3, 4] < ~[1, 2, 4, 4])); + fail_unless!((~[1, 2, 3] <= ~[1, 2, 3])); + fail_unless!((~[1, 2, 3] <= ~[1, 2, 3, 3])); + fail_unless!((~[1, 2, 3, 4] > ~[1, 2, 3])); assert_eq!(~[1, 2, 3], ~[1, 2, 3]); - assert!((~[1, 2, 3] != ~[1, 1, 3])); + fail_unless!((~[1, 2, 3] != ~[1, 1, 3])); } diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index c5211889f3f0c..15c724cdaf1fe 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -27,4 +27,4 @@ fn foo(c: ~[int]) { enum t { none, some(T), } -pub fn main() { let x = 10; let x = x + 20; assert!((x == 30)); foo(~[]); } +pub fn main() { let x = 10; let x = x + 20; fail_unless!((x == 30)); foo(~[]); } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 002736693788a..533b402b09da5 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -16,4 +16,4 @@ pub fn main() { task::spawn(proc() child(10) ); } -fn child(i: int) { error!("{}", i); assert!((i == 10)); } +fn child(i: int) { error!("{}", i); fail_unless!((i == 10)); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index 33f4c9d9a982a..38fcd485a58a0 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -31,6 +31,6 @@ pub fn main() { } } - assert!(path.exists()); + fail_unless!(path.exists()); assert_eq!(path.stat().unwrap().size, 1000); } diff --git a/src/test/run-pass/static-mut-foreign.rs b/src/test/run-pass/static-mut-foreign.rs index 0afe01bf7edc8..129b9eaeddc46 100644 --- a/src/test/run-pass/static-mut-foreign.rs +++ b/src/test/run-pass/static-mut-foreign.rs @@ -27,16 +27,16 @@ fn static_bound_set(a: &'static mut libc::c_int) { } unsafe fn run() { - assert!(rust_dbg_static_mut == 3); + fail_unless!(rust_dbg_static_mut == 3); rust_dbg_static_mut = 4; - assert!(rust_dbg_static_mut == 4); + fail_unless!(rust_dbg_static_mut == 4); rust_dbg_static_mut_check_four(); rust_dbg_static_mut += 1; - assert!(rust_dbg_static_mut == 5); + fail_unless!(rust_dbg_static_mut == 5); rust_dbg_static_mut *= 3; - assert!(rust_dbg_static_mut == 15); + fail_unless!(rust_dbg_static_mut == 15); rust_dbg_static_mut = -3; - assert!(rust_dbg_static_mut == -3); + fail_unless!(rust_dbg_static_mut == -3); static_bound(&rust_dbg_static_mut); static_bound_set(&mut rust_dbg_static_mut); } diff --git a/src/test/run-pass/static-mut-xc.rs b/src/test/run-pass/static-mut-xc.rs index c7b17d91a8fc6..499292b429bbe 100644 --- a/src/test/run-pass/static-mut-xc.rs +++ b/src/test/run-pass/static-mut-xc.rs @@ -24,15 +24,15 @@ fn static_bound_set(a: &'static mut int) { } unsafe fn run() { - assert!(static_mut_xc::a == 3); + fail_unless!(static_mut_xc::a == 3); static_mut_xc::a = 4; - assert!(static_mut_xc::a == 4); + fail_unless!(static_mut_xc::a == 4); static_mut_xc::a += 1; - assert!(static_mut_xc::a == 5); + fail_unless!(static_mut_xc::a == 5); static_mut_xc::a *= 3; - assert!(static_mut_xc::a == 15); + fail_unless!(static_mut_xc::a == 15); static_mut_xc::a = -3; - assert!(static_mut_xc::a == -3); + fail_unless!(static_mut_xc::a == -3); static_bound(&static_mut_xc::a); static_bound_set(&mut static_mut_xc::a); } diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index c67a72e90c9e1..9579420df9aa0 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -23,14 +23,14 @@ pub fn main() { let a = (1, 2, 3); let b = (1, 2, 3); assert_eq!(a, b); - assert!((a != (1, 2, 4))); - assert!((a < (1, 2, 4))); - assert!((a <= (1, 2, 4))); - assert!(((1, 2, 4) > a)); - assert!(((1, 2, 4) >= a)); + fail_unless!((a != (1, 2, 4))); + fail_unless!((a < (1, 2, 4))); + fail_unless!((a <= (1, 2, 4))); + fail_unless!(((1, 2, 4) > a)); + fail_unless!(((1, 2, 4) >= a)); let x = large; let y = small; - assert!((x != y)); + fail_unless!((x != y)); assert_eq!(x, large); - assert!((x != small)); + fail_unless!((x != small)); } diff --git a/src/test/run-pass/swap-1.rs b/src/test/run-pass/swap-1.rs index 82a76512e08f7..65de924b9f9c1 100644 --- a/src/test/run-pass/swap-1.rs +++ b/src/test/run-pass/swap-1.rs @@ -13,5 +13,5 @@ use std::mem::swap; pub fn main() { let mut x = 3; let mut y = 7; swap(&mut x, &mut y); - assert!((x == 7)); assert!((y == 3)); + fail_unless!((x == 7)); fail_unless!((y == 3)); } diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs index dcce94da1eadc..e89028de06252 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/run-pass/syntax-extension-minor.rs @@ -16,6 +16,6 @@ pub fn main() { let asdf_fdsa = ~"<.<"; assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<"); - assert!(stringify!(use_mention_distinction) == + fail_unless!(stringify!(use_mention_distinction) == "use_mention_distinction"); } diff --git a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment index 5d326a50f0206..26db74195c504 100644 --- a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment +++ b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment @@ -1,7 +1,7 @@ /* this is for run-pass/syntax-extension-source-utils.rs */ { - assert!(file!().ends_with("includeme.fragment")); - assert!(line!() == 5u); + fail_unless!(file!().ends_with("includeme.fragment")); + fail_unless!(line!() == 5u); format!("victory robot {}", line!()) } diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 276f792d65939..af767cc927099 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -23,19 +23,19 @@ macro_rules! indirect_line( () => ( line!() ) ) pub fn main() { assert_eq!(line!(), 25); - //assert!((col!() == 11)); + //fail_unless!((col!() == 11)); assert_eq!(indirect_line!(), 27); - assert!((file!().to_owned().ends_with("syntax-extension-source-utils.rs"))); + fail_unless!((file!().to_owned().ends_with("syntax-extension-source-utils.rs"))); assert_eq!(stringify!((2*3) + 5).to_owned(), ~"( 2 * 3 ) + 5"); - assert!(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() + fail_unless!(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() == ~"victory robot 6"); - assert!( + fail_unless!( include_str!("syntax-extension-source-utils-files/includeme.fragment").to_owned() .starts_with("/* this is for ")); - assert!( + fail_unless!( include_bin!("syntax-extension-source-utils-files/includeme.fragment") [1] == (42 as u8)); // '*' // The Windows tests are wrapped in an extra module for some reason - assert!((m1::m2::where_am_i().ends_with("m1::m2"))); + fail_unless!((m1::m2::where_am_i().ends_with("m1::m2"))); } diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index 60786075697ba..58947c1d67d24 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -31,5 +31,5 @@ fn is_8_byte_aligned(u: &a_tag) -> bool { pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(&x.t)); + fail_unless!(is_8_byte_aligned(&x.t)); } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 41ae28f0a9d94..d312831c57e64 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -41,32 +41,32 @@ fn variant_data_is_aligned(amnt: uint, u: &a_tag) -> bool { pub fn main() { let x = mk_rec(22u64, 23u64); - assert!(is_aligned(8u, &x.tA)); - assert!(variant_data_is_aligned(8u, &x.tA)); - assert!(is_aligned(8u, &x.tB)); - assert!(variant_data_is_aligned(8u, &x.tB)); + fail_unless!(is_aligned(8u, &x.tA)); + fail_unless!(variant_data_is_aligned(8u, &x.tA)); + fail_unless!(is_aligned(8u, &x.tB)); + fail_unless!(variant_data_is_aligned(8u, &x.tB)); let x = mk_rec(22u64, 23u32); - assert!(is_aligned(8u, &x.tA)); - assert!(variant_data_is_aligned(8u, &x.tA)); - assert!(is_aligned(8u, &x.tB)); - assert!(variant_data_is_aligned(4u, &x.tB)); + fail_unless!(is_aligned(8u, &x.tA)); + fail_unless!(variant_data_is_aligned(8u, &x.tA)); + fail_unless!(is_aligned(8u, &x.tB)); + fail_unless!(variant_data_is_aligned(4u, &x.tB)); let x = mk_rec(22u32, 23u64); - assert!(is_aligned(8u, &x.tA)); - assert!(variant_data_is_aligned(4u, &x.tA)); - assert!(is_aligned(8u, &x.tB)); - assert!(variant_data_is_aligned(8u, &x.tB)); + fail_unless!(is_aligned(8u, &x.tA)); + fail_unless!(variant_data_is_aligned(4u, &x.tA)); + fail_unless!(is_aligned(8u, &x.tB)); + fail_unless!(variant_data_is_aligned(8u, &x.tB)); let x = mk_rec(22u32, 23u32); - assert!(is_aligned(4u, &x.tA)); - assert!(variant_data_is_aligned(4u, &x.tA)); - assert!(is_aligned(4u, &x.tB)); - assert!(variant_data_is_aligned(4u, &x.tB)); + fail_unless!(is_aligned(4u, &x.tA)); + fail_unless!(variant_data_is_aligned(4u, &x.tA)); + fail_unless!(is_aligned(4u, &x.tB)); + fail_unless!(variant_data_is_aligned(4u, &x.tB)); let x = mk_rec(22f64, 23f64); - assert!(is_aligned(8u, &x.tA)); - assert!(variant_data_is_aligned(8u, &x.tA)); - assert!(is_aligned(8u, &x.tB)); - assert!(variant_data_is_aligned(8u, &x.tB)); + fail_unless!(is_aligned(8u, &x.tA)); + fail_unless!(variant_data_is_aligned(8u, &x.tA)); + fail_unless!(is_aligned(8u, &x.tB)); + fail_unless!(variant_data_is_aligned(8u, &x.tB)); } diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index 351c2dec99b7e..177e3a563ae23 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -31,5 +31,5 @@ fn is_8_byte_aligned(u: &a_tag) -> bool { pub fn main() { let x = mk_rec(); - assert!(is_8_byte_aligned(&x.t)); + fail_unless!(is_8_byte_aligned(&x.t)); } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 8eed2653a901a..c602156905840 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -38,11 +38,11 @@ pub fn main() { } fn test_color(color: color, val: int, name: ~str) { - //assert!(unsafe::transmute(color) == val); + //fail_unless!(unsafe::transmute(color) == val); assert_eq!(color as int, val); assert_eq!(color as f64, val as f64); - assert!(get_color_alt(color) == name); - assert!(get_color_if(color) == name); + fail_unless!(get_color_alt(color) == name); + fail_unless!(get_color_if(color) == name); } fn get_color_alt(color: color) -> ~str { diff --git a/src/test/run-pass/tag.rs b/src/test/run-pass/tag.rs index 989f911134bb3..2eaac9d81db7c 100644 --- a/src/test/run-pass/tag.rs +++ b/src/test/run-pass/tag.rs @@ -31,6 +31,6 @@ impl Eq for colour { fn ne(&self, other: &colour) -> bool { !(*self).eq(other) } } -fn f() { let x = red(1, 2); let y = green; assert!((x != y)); } +fn f() { let x = red(1, 2); let y = green; fail_unless!((x != y)); } pub fn main() { f(); } diff --git a/src/test/run-pass/tail-cps.rs b/src/test/run-pass/tail-cps.rs index d0ba12bec1c90..ae8c0eeee76b9 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -11,7 +11,7 @@ -fn checktrue(rs: bool) -> bool { assert!((rs)); return true; } +fn checktrue(rs: bool) -> bool { fail_unless!((rs)); return true; } pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } diff --git a/src/test/run-pass/tail-direct.rs b/src/test/run-pass/tail-direct.rs index fd03d28050326..a377cbcda4694 100644 --- a/src/test/run-pass/tail-direct.rs +++ b/src/test/run-pass/tail-direct.rs @@ -11,7 +11,7 @@ -pub fn main() { assert!((even(42))); assert!((odd(45))); } +pub fn main() { fail_unless!((even(42))); fail_unless!((odd(45))); } fn even(n: int) -> bool { if n == 0 { return true; } else { return odd(n - 1); } } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 1c64cf9cff5c6..06c1ec2a015aa 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -21,10 +21,10 @@ fn start(c: &Chan>) { let mut a; let mut b; a = p.recv(); - assert!(a == ~"A"); + fail_unless!(a == ~"A"); error!("{:?}", a); b = p.recv(); - assert!(b == ~"B"); + fail_unless!(b == ~"B"); error!("{:?}", b); } diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index d42ce9793e0fa..f687539446a62 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -31,10 +31,10 @@ fn test_tempdir() { let path = { let p = TempDir::new_in(&Path::new("."), "foobar").unwrap(); let p = p.path(); - assert!(p.as_vec().ends_with(bytes!("foobar"))); + fail_unless!(p.as_vec().ends_with(bytes!("foobar"))); p.clone() }; - assert!(!path.exists()); + fail_unless!(!path.exists()); } fn test_rm_tempdir() { @@ -46,7 +46,7 @@ fn test_rm_tempdir() { }; task::try(f); let path = rd.recv(); - assert!(!path.exists()); + fail_unless!(!path.exists()); let tmp = TempDir::new("test_rm_tempdir").unwrap(); let path = tmp.path().clone(); @@ -55,7 +55,7 @@ fn test_rm_tempdir() { fail!("fail to unwind past `tmp`"); }; task::try(f); - assert!(!path.exists()); + fail_unless!(!path.exists()); let path; { @@ -64,18 +64,18 @@ fn test_rm_tempdir() { }; let tmp = task::try(f).ok().expect("test_rm_tmdir"); path = tmp.path().clone(); - assert!(path.exists()); + fail_unless!(path.exists()); } - assert!(!path.exists()); + fail_unless!(!path.exists()); let path; { let tmp = TempDir::new("test_rm_tempdir").unwrap(); path = tmp.unwrap(); } - assert!(path.exists()); + fail_unless!(path.exists()); fs::rmdir_recursive(&path); - assert!(!path.exists()); + fail_unless!(!path.exists()); } // Ideally these would be in std::os but then core would need @@ -86,9 +86,9 @@ fn recursive_mkdir_rel() { debug!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(), cwd.display(), path.exists()); fs::mkdir_recursive(&path, io::UserRWX); - assert!(path.is_dir()); + fail_unless!(path.is_dir()); fs::mkdir_recursive(&path, io::UserRWX); - assert!(path.is_dir()); + fail_unless!(path.is_dir()); } fn recursive_mkdir_dot() { @@ -104,14 +104,14 @@ fn recursive_mkdir_rel_2() { debug!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(), cwd.display(), path.exists()); fs::mkdir_recursive(&path, io::UserRWX); - assert!(path.is_dir()); - assert!(path.dir_path().is_dir()); + fail_unless!(path.is_dir()); + fail_unless!(path.dir_path().is_dir()); let path2 = Path::new("quux/blat"); debug!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(), cwd.display()); fs::mkdir_recursive(&path2, io::UserRWX); - assert!(path2.is_dir()); - assert!(path2.dir_path().is_dir()); + fail_unless!(path2.is_dir()); + fail_unless!(path2.dir_path().is_dir()); } // Ideally this would be in core, but needs TempFile @@ -129,14 +129,14 @@ pub fn test_rmdir_recursive_ok() { fs::mkdir(&root.join("foo").join("bar"), rwx); fs::mkdir(&root.join("foo").join("bar").join("blat"), rwx); fs::rmdir_recursive(&root); - assert!(!root.exists()); - assert!(!root.join("bar").exists()); - assert!(!root.join("bar").join("blat").exists()); + fail_unless!(!root.exists()); + fail_unless!(!root.join("bar").exists()); + fail_unless!(!root.join("bar").join("blat").exists()); } fn in_tmpdir(f: ||) { let tmpdir = TempDir::new("test").expect("can't make tmpdir"); - assert!(os::change_dir(tmpdir.path())); + fail_unless!(os::change_dir(tmpdir.path())); f(); } diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index eee667fdb0411..b5c431b23f3cc 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -28,9 +28,9 @@ fn checktests() { // Pull the tests out of the secreturn test module let tests = __test::TESTS; - assert!( + fail_unless!( tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore)); - assert!( + fail_unless!( tests.iter().any(|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore)); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index fa94f1012d026..49eeacf3f6594 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -88,17 +88,17 @@ fn check_legs(arc: Arc<~[~Pet:Freeze+Send]>) { for pet in arc.get().iter() { legs += pet.num_legs(); } - assert!(legs == 12); + fail_unless!(legs == 12); } fn check_names(arc: Arc<~[~Pet:Freeze+Send]>) { for pet in arc.get().iter() { pet.name(|name| { - assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8); + fail_unless!(name[0] == 'a' as u8 && name[1] == 'l' as u8); }) } } fn check_pedigree(arc: Arc<~[~Pet:Freeze+Send]>) { for pet in arc.get().iter() { - assert!(pet.of_good_pedigree()); + fail_unless!(pet.of_good_pedigree()); } } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 339afb47fa6dd..4e4c4886c7ff5 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -58,8 +58,8 @@ pub fn main() { right: Some(t1), val: ~2 as ~to_str})); let expected = ~"[2, some([1, none, none]), some([1, none, none])]"; - assert!(t2.to_str_() == expected); - assert!(foo(t2) == expected); + fail_unless!(t2.to_str_() == expected); + fail_unless!(foo(t2) == expected); { let Tree(t1_) = t1; diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index c0344136059df..aa3ac523f75da 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -78,13 +78,13 @@ pub fn main () { // Trying out a real one - assert!(12.test_neq(&10)); - assert!(!10.test_neq(&10)); - assert!(a.test_neq(&b)); - assert!(!a.test_neq(&a)); - - assert!(neq(&12, &10)); - assert!(!neq(&10, &10)); - assert!(neq(&a, &b)); - assert!(!neq(&a, &a)); + fail_unless!(12.test_neq(&10)); + fail_unless!(!10.test_neq(&10)); + fail_unless!(a.test_neq(&b)); + fail_unless!(!a.test_neq(&a)); + + fail_unless!(neq(&12, &10)); + fail_unless!(!neq(&10, &10)); + fail_unless!(neq(&a, &b)); + fail_unless!(!neq(&a, &a)); } diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index 3a0f2dd9464da..30b1b26eaa1c9 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -29,6 +29,6 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); - assert!(x != y); + fail_unless!(x != y); assert_eq!(x, z); } diff --git a/src/test/run-pass/trait-inheritance-self-in-supertype.rs b/src/test/run-pass/trait-inheritance-self-in-supertype.rs index 63ac921e2a52b..9803fc8f07921 100644 --- a/src/test/run-pass/trait-inheritance-self-in-supertype.rs +++ b/src/test/run-pass/trait-inheritance-self-in-supertype.rs @@ -57,17 +57,17 @@ fn compare(f1: F) -> bool { } pub fn main() { - assert!(compare::(6.28318530717958647692528676655900576)); - assert!(compare::(6.29)); - assert!(compare::(6.3)); - assert!(compare::(6.19)); - assert!(!compare::(7.28318530717958647692528676655900576)); - assert!(!compare::(6.18)); + fail_unless!(compare::(6.28318530717958647692528676655900576)); + fail_unless!(compare::(6.29)); + fail_unless!(compare::(6.3)); + fail_unless!(compare::(6.19)); + fail_unless!(!compare::(7.28318530717958647692528676655900576)); + fail_unless!(!compare::(6.18)); - assert!(compare::(6.28318530717958647692528676655900576)); - assert!(compare::(6.29)); - assert!(compare::(6.3)); - assert!(compare::(6.19)); - assert!(!compare::(7.28318530717958647692528676655900576)); - assert!(!compare::(6.18)); + fail_unless!(compare::(6.28318530717958647692528676655900576)); + fail_unless!(compare::(6.29)); + fail_unless!(compare::(6.3)); + fail_unless!(compare::(6.19)); + fail_unless!(!compare::(7.28318530717958647692528676655900576)); + fail_unless!(!compare::(6.18)); } diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index cd57e6a7dd059..48c48c4b47b41 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -31,5 +31,5 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let z = f(x, y); - assert!(z.val == 8) + fail_unless!(z.val == 8) } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index b6468b4483ddc..1861aac088ab1 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -25,16 +25,16 @@ impl to_str for ~[T] { } pub fn main() { - assert!(1.to_string() == ~"1"); - assert!((~[2, 3, 4]).to_string() == ~"[2, 3, 4]"); + fail_unless!(1.to_string() == ~"1"); + fail_unless!((~[2, 3, 4]).to_string() == ~"[2, 3, 4]"); fn indirect(x: T) -> ~str { x.to_string() + "!" } - assert!(indirect(~[10, 20]) == ~"[10, 20]!"); + fail_unless!(indirect(~[10, 20]) == ~"[10, 20]!"); fn indirect2(x: T) -> ~str { indirect(x) } - assert!(indirect2(~[1]) == ~"[1]!"); + fail_unless!(indirect2(~[1]) == ~"[1]!"); } diff --git a/src/test/run-pass/traits-default-method-self.rs b/src/test/run-pass/traits-default-method-self.rs index 1027008624a24..9c9b4525b218b 100644 --- a/src/test/run-pass/traits-default-method-self.rs +++ b/src/test/run-pass/traits-default-method-self.rs @@ -22,5 +22,5 @@ impl Cat for int { } pub fn main() { - assert!(5.meow()); + fail_unless!(5.meow()); } diff --git a/src/test/run-pass/traits-default-method-trivial.rs b/src/test/run-pass/traits-default-method-trivial.rs index c6a7ab5ba4967..fa64943403409 100644 --- a/src/test/run-pass/traits-default-method-trivial.rs +++ b/src/test/run-pass/traits-default-method-trivial.rs @@ -25,5 +25,5 @@ impl Cat for int { } pub fn main() { - assert!(5.meow()); + fail_unless!(5.meow()); } diff --git a/src/test/run-pass/type-namespace.rs b/src/test/run-pass/type-namespace.rs index e9b0324456a2f..2fb8f34120c00 100644 --- a/src/test/run-pass/type-namespace.rs +++ b/src/test/run-pass/type-namespace.rs @@ -12,4 +12,4 @@ struct A { a: int } fn a(a: A) -> int { return a.a; } -pub fn main() { let x: A = A {a: 1}; assert!((a(x) == 1)); } +pub fn main() { let x: A = A {a: 1}; fail_unless!((a(x) == 1)); } diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index 970a5c5011b2e..6d477816ba850 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -29,7 +29,7 @@ pub fn main() { assert_eq!(size_of::(), 3 as uint); // Alignment causes padding before the char and the u32. - assert!(size_of::() == + fail_unless!(size_of::() == 16 as uint); assert_eq!(size_of::(), size_of::()); assert_eq!(size_of::(), size_of::()); diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index a0c2a489bf64a..43c4ff8c24ce5 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -49,18 +49,18 @@ impl Equal for ColorTree { } pub fn main() { - assert!(Equal::isEq(cyan, cyan)); - assert!(Equal::isEq(magenta, magenta)); - assert!(!Equal::isEq(cyan, yellow)); - assert!(!Equal::isEq(magenta, cyan)); + fail_unless!(Equal::isEq(cyan, cyan)); + fail_unless!(Equal::isEq(magenta, magenta)); + fail_unless!(!Equal::isEq(cyan, yellow)); + fail_unless!(!Equal::isEq(magenta, cyan)); - assert!(Equal::isEq(leaf(cyan), leaf(cyan))); - assert!(!Equal::isEq(leaf(cyan), leaf(yellow))); + fail_unless!(Equal::isEq(leaf(cyan), leaf(cyan))); + fail_unless!(!Equal::isEq(leaf(cyan), leaf(yellow))); - assert!(Equal::isEq(branch(@leaf(magenta), @leaf(cyan)), + fail_unless!(Equal::isEq(branch(@leaf(magenta), @leaf(cyan)), branch(@leaf(magenta), @leaf(cyan)))); - assert!(!Equal::isEq(branch(@leaf(magenta), @leaf(cyan)), + fail_unless!(!Equal::isEq(branch(@leaf(magenta), @leaf(cyan)), branch(@leaf(magenta), @leaf(magenta)))); error!("Assertions all succeeded!"); diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 50af6cb71c1f4..09893d7650cf4 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -48,18 +48,18 @@ impl Equal for ColorTree { } pub fn main() { - assert!(cyan.isEq(cyan)); - assert!(magenta.isEq(magenta)); - assert!(!cyan.isEq(yellow)); - assert!(!magenta.isEq(cyan)); + fail_unless!(cyan.isEq(cyan)); + fail_unless!(magenta.isEq(magenta)); + fail_unless!(!cyan.isEq(yellow)); + fail_unless!(!magenta.isEq(cyan)); - assert!(leaf(cyan).isEq(leaf(cyan))); - assert!(!leaf(cyan).isEq(leaf(yellow))); + fail_unless!(leaf(cyan).isEq(leaf(cyan))); + fail_unless!(!leaf(cyan).isEq(leaf(yellow))); - assert!(branch(@leaf(magenta), @leaf(cyan)) + fail_unless!(branch(@leaf(magenta), @leaf(cyan)) .isEq(branch(@leaf(magenta), @leaf(cyan)))); - assert!(!branch(@leaf(magenta), @leaf(cyan)) + fail_unless!(!branch(@leaf(magenta), @leaf(cyan)) .isEq(branch(@leaf(magenta), @leaf(magenta)))); error!("Assertions all succeeded!"); diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index 71e19b51c7266..7ad9d8dfe0597 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -59,9 +59,9 @@ pub fn main() { let (d, e, f) = (TypeId::of::(), TypeId::of::<&'static str>(), TypeId::of::()); - assert!(a != b); - assert!(a != c); - assert!(b != c); + fail_unless!(a != b); + fail_unless!(a != c); + fail_unless!(b != c); assert_eq!(a, d); assert_eq!(b, e); diff --git a/src/test/run-pass/typestate-multi-decl.rs b/src/test/run-pass/typestate-multi-decl.rs index 42910c4700581..a70e10820a4f2 100644 --- a/src/test/run-pass/typestate-multi-decl.rs +++ b/src/test/run-pass/typestate-multi-decl.rs @@ -11,5 +11,5 @@ pub fn main() { let (x, y) = (10, 20); let z = x + y; - assert!((z == 30)); + fail_unless!((z == 30)); } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index b50d315483596..237ade196f035 100644 --- a/src/test/run-pass/unique-cmp.rs +++ b/src/test/run-pass/unique-cmp.rs @@ -10,9 +10,9 @@ pub fn main() { let i = ~100; - assert!(i == ~100); - assert!(i < ~101); - assert!(i <= ~100); - assert!(i > ~99); - assert!(i >= ~99); + fail_unless!(i == ~100); + fail_unless!(i < ~101); + fail_unless!(i <= ~100); + fail_unless!(i > ~99); + fail_unless!(i >= ~99); } diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index b1fc4e76ea084..74a25b68a81c5 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -12,7 +12,7 @@ fn test1() { enum bar { u(~int), w(int), } let x = u(~10); - assert!(match x { + fail_unless!(match x { u(a) => { error!("{:?}", a); *a diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 51fceae39b405..62e9e03d3a10f 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - assert!((~[~100])[0] == ~100); + fail_unless!((~[~100])[0] == ~100); } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 11425a94ce9e1..9176fbf94626a 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -17,7 +17,7 @@ fn sendable() { } fn g(i: T, j: T) { - assert!(i != j); + fail_unless!(i != j); } let i = ~100; @@ -35,7 +35,7 @@ fn copyable() { } fn g(i: T, j: T) { - assert!(i != j); + fail_unless!(i != j); } let i = ~100; @@ -53,7 +53,7 @@ fn noncopyable() { } fn g(i: T, j: T) { - assert!(i != j); + fail_unless!(i != j); } let i = ~100; diff --git a/src/test/run-pass/unique-pat-2.rs b/src/test/run-pass/unique-pat-2.rs index 49a873e793a8d..ef9ed082c00ec 100644 --- a/src/test/run-pass/unique-pat-2.rs +++ b/src/test/run-pass/unique-pat-2.rs @@ -14,7 +14,7 @@ struct Foo {a: int, b: uint} enum bar { u(~Foo), w(int), } pub fn main() { - assert!(match u(~Foo{a: 10, b: 40u}) { + fail_unless!(match u(~Foo{a: 10, b: 40u}) { u(~Foo{a: a, b: b}) => { a + (b as int) } _ => { 66 } } == 50); diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index 077bbdfb0baa4..94dba13512bf3 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -12,7 +12,7 @@ enum bar { u(~int), w(int), } pub fn main() { - assert!(match u(~10) { + fail_unless!(match u(~10) { u(a) => { error!("{:?}", a); *a diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 8143188b9770f..f9a6d2068586a 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -42,5 +42,5 @@ pub fn main() { let (p, c) = Chan::new(); task::spawn(proc() f(c.clone())); error!("hiiiiiiiii"); - assert!(p.recv()); + fail_unless!(p.recv()); } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 3066a247e4e6b..796a8c7c42614 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -18,36 +18,36 @@ pub fn main() { let s: ~str = str::from_chars(chs); let schs: ~[char] = s.chars().collect(); - assert!(s.len() == 10u); - assert!(s.char_len() == 4u); - assert!(schs.len() == 4u); - assert!(str::from_chars(schs) == s); - assert!(s.char_at(0u) == 'e'); - assert!(s.char_at(1u) == 'é'); + fail_unless!(s.len() == 10u); + fail_unless!(s.char_len() == 4u); + fail_unless!(schs.len() == 4u); + fail_unless!(str::from_chars(schs) == s); + fail_unless!(s.char_at(0u) == 'e'); + fail_unless!(s.char_at(1u) == 'é'); - assert!((str::is_utf8(s.as_bytes()))); + fail_unless!((str::is_utf8(s.as_bytes()))); // invalid prefix - assert!((!str::is_utf8([0x80_u8]))); + fail_unless!((!str::is_utf8([0x80_u8]))); // invalid 2 byte prefix - assert!((!str::is_utf8([0xc0_u8]))); - assert!((!str::is_utf8([0xc0_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xc0_u8]))); + fail_unless!((!str::is_utf8([0xc0_u8, 0x10_u8]))); // invalid 3 byte prefix - assert!((!str::is_utf8([0xe0_u8]))); - assert!((!str::is_utf8([0xe0_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xe0_u8, 0xff_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xe0_u8]))); + fail_unless!((!str::is_utf8([0xe0_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xe0_u8, 0xff_u8, 0x10_u8]))); // invalid 4 byte prefix - assert!((!str::is_utf8([0xf0_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0xff_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xf0_u8]))); + fail_unless!((!str::is_utf8([0xf0_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xf0_u8, 0xff_u8, 0x10_u8]))); + fail_unless!((!str::is_utf8([0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]))); let mut stack = ~"a×c€"; assert_eq!(stack.pop_char(), '€'); assert_eq!(stack.pop_char(), 'c'); stack.push_char('u'); - assert!(stack == ~"a×u"); + fail_unless!(stack == ~"a×u"); assert_eq!(stack.shift_char(), 'a'); assert_eq!(stack.shift_char(), '×'); stack.unshift_char('ß'); - assert!(stack == ~"ßu"); + fail_unless!(stack == ~"ßu"); } diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index 9197f14787460..c166d158fb00b 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -18,7 +18,7 @@ pub fn main() { let ε = 0.00001; let Π = 3.14; let लंच = Π * Π + 1.54; - assert!(num::abs((लंच - 1.54) - (Π * Π)) < ε); + fail_unless!(num::abs((लंच - 1.54) - (Π * Π)) < ε); assert_eq!(საჭმელად_გემრიელი_სადილი(), 0); } diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 658d4e0842668..18afc13510147 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -21,10 +21,10 @@ pub fn main() { ]; match x { [ref first, ..tail] => { - assert!(first.string == ~"foo"); + fail_unless!(first.string == ~"foo"); assert_eq!(tail.len(), 2); - assert!(tail[0].string == ~"bar"); - assert!(tail[1].string == ~"baz"); + fail_unless!(tail[0].string == ~"bar"); + fail_unless!(tail[1].string == ~"baz"); match tail { [Foo { .. }, _, Foo { .. }, .. _tail] => { diff --git a/src/test/run-pass/vector-sort-failure-safe.rs b/src/test/run-pass/vector-sort-failure-safe.rs index 74f27e480909c..e9ebfc174a622 100644 --- a/src/test/run-pass/vector-sort-failure-safe.rs +++ b/src/test/run-pass/vector-sort-failure-safe.rs @@ -78,7 +78,7 @@ pub fn main() { unsafe { for (i, &c) in drop_counts.iter().enumerate() { let expected = if i < len {1} else {0}; - assert!(c == expected, + fail_unless!(c == expected, "found drop count == {} for i == {}, len == {}", c, i, len); } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 10726a9c396b3..7e616891b5c6e 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -29,7 +29,7 @@ fn what() { let i = @Cell::new(false); let dont = {||the(i)}; dont(); - assert!((i.get())); + fail_unless!((i.get())); } fn zombiejesus() { @@ -64,8 +64,8 @@ fn notsure() { fn canttouchthis() -> uint { fn p() -> bool { true } - let _a = (assert!((true)) == (assert!(p()))); - let _c = (assert!((p())) == ()); + let _a = (fail_unless!((true)) == (fail_unless!(p()))); + let _c = (fail_unless!((p())) == ()); let _b: bool = (info!("{}", 0) == (return 0u)); } diff --git a/src/test/run-pass/while-cont.rs b/src/test/run-pass/while-cont.rs index ed7ba12ea0f2f..6e2433bfaae35 100644 --- a/src/test/run-pass/while-cont.rs +++ b/src/test/run-pass/while-cont.rs @@ -12,7 +12,7 @@ pub fn main() { let mut i = 1; while i > 0 { - assert!((i > 0)); + fail_unless!((i > 0)); info!("{}", i); i -= 1; continue; diff --git a/src/test/run-pass/while-loop-constraints-2.rs b/src/test/run-pass/while-loop-constraints-2.rs index a21aa4a9a6246..6feb56f5da3e7 100644 --- a/src/test/run-pass/while-loop-constraints-2.rs +++ b/src/test/run-pass/while-loop-constraints-2.rs @@ -20,5 +20,5 @@ pub fn main() { while false { x = y; y = z; } info!("{}", y); } - assert!((y == 42 && z == 50)); + fail_unless!((y == 42 && z == 50)); } diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index 8142cafd89e91..e01c5a2c65625 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -20,7 +20,7 @@ pub fn main() { let x = Some(unstable::sync::Exclusive::new(true)); match x { Some(ref z) if z.with(|b| *b) => { - z.with(|b| assert!(*b)); + z.with(|b| fail_unless!(*b)); }, _ => fail!() } diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 522e5fd978ead..305eff9c54003 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -31,9 +31,9 @@ mod kernel32 { pub fn main() { let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) }; - assert!(mem != 0u); + fail_unless!(mem != 0u); let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) }; - assert!(res != 0u8); + fail_unless!(res != 0u8); } #[cfg(not(windows))] diff --git a/src/test/run-pass/zero-size-type-destructors.rs b/src/test/run-pass/zero-size-type-destructors.rs index fd272a47de9c2..94da189211449 100644 --- a/src/test/run-pass/zero-size-type-destructors.rs +++ b/src/test/run-pass/zero-size-type-destructors.rs @@ -25,5 +25,5 @@ pub fn foo() { pub fn main() { foo(); - assert!((unsafe { destructions } == 0)); + fail_unless!((unsafe { destructions } == 0)); } From e32253d54768c454bf1106105f44c7124d6b1ef0 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 22 Feb 2014 17:49:37 +1100 Subject: [PATCH 4/4] Rename uses of `assert_eq!` to `fail_unless_eq!`. --- src/doc/guide-container.md | 10 +- src/doc/rust.md | 2 +- src/doc/tutorial.md | 8 +- src/libcollections/bitv.rs | 48 +- src/libcollections/btree.rs | 12 +- src/libcollections/dlist.rs | 164 ++-- src/libcollections/enum_set.rs | 16 +- src/libcollections/list.rs | 28 +- src/libcollections/lru_cache.rs | 34 +- src/libcollections/priority_queue.rs | 72 +- src/libcollections/ringbuf.rs | 188 ++-- src/libcollections/smallintmap.rs | 90 +- src/libcollections/treemap.rs | 96 +-- src/libextra/c_vec.rs | 8 +- src/libextra/json.rs | 296 +++---- src/libextra/stats.rs | 20 +- src/libextra/url.rs | 310 +++---- src/libflate/lib.rs | 4 +- src/libfourcc/lib.rs | 4 +- src/libgetopts/lib.rs | 74 +- src/libglob/lib.rs | 2 +- src/libgreen/sched.rs | 6 +- src/libgreen/stack.rs | 8 +- src/libgreen/task.rs | 2 +- src/libnative/io/file.rs | 18 +- src/libnative/io/net.rs | 2 +- src/libnative/io/process.rs | 10 +- src/libnative/io/timer_other.rs | 4 +- src/libnative/io/timer_timerfd.rs | 6 +- src/libnative/io/timer_win32.rs | 10 +- src/libnative/task.rs | 2 +- src/libnum/bigint.rs | 138 +-- src/libnum/complex.rs | 68 +- src/libnum/lib.rs | 138 +-- src/libnum/rational.rs | 152 ++-- src/librustc/back/rpath.rs | 14 +- src/librustc/front/assign_node_ids_and_map.rs | 2 +- src/librustc/metadata/decoder.rs | 2 +- src/librustc/metadata/encoder.rs | 4 +- src/librustc/metadata/tydecode.rs | 58 +- src/librustc/middle/astencode.rs | 4 +- src/librustc/middle/borrowck/check_loans.rs | 8 +- .../middle/borrowck/gather_loans/mod.rs | 2 +- src/librustc/middle/borrowck/move_data.rs | 2 +- src/librustc/middle/dataflow.rs | 4 +- src/librustc/middle/graph.rs | 30 +- src/librustc/middle/resolve.rs | 4 +- src/librustc/middle/trans/adt.rs | 26 +- src/librustc/middle/trans/base.rs | 2 +- src/librustc/middle/trans/builder.rs | 2 +- src/librustc/middle/trans/callee.rs | 6 +- src/librustc/middle/trans/cleanup.rs | 8 +- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/consts.rs | 6 +- src/librustc/middle/trans/glue.rs | 2 +- src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/check/mod.rs | 2 +- src/librustc/middle/typeck/check/vtable.rs | 4 +- src/librustc/middle/typeck/coherence.rs | 4 +- src/librustc/middle/typeck/infer/combine.rs | 4 +- .../typeck/infer/region_inference/mod.rs | 4 +- src/librustc/middle/typeck/infer/unify.rs | 2 +- src/librustc/middle/typeck/variance.rs | 8 +- src/librustc/util/sha2.rs | 4 +- src/librustdoc/passes.rs | 10 +- src/librustdoc/visit_ast.rs | 2 +- src/librustuv/access.rs | 2 +- src/librustuv/async.rs | 4 +- src/librustuv/file.rs | 6 +- src/librustuv/homing.rs | 4 +- src/librustuv/idle.rs | 28 +- src/librustuv/lib.rs | 6 +- src/librustuv/net.rs | 54 +- src/librustuv/pipe.rs | 10 +- src/librustuv/queue.rs | 4 +- src/librustuv/signal.rs | 4 +- src/librustuv/stream.rs | 2 +- src/librustuv/timer.rs | 16 +- src/librustuv/uvio.rs | 2 +- src/librustuv/uvll.rs | 4 +- src/libsemver/lib.rs | 44 +- src/libserialize/base64.rs | 46 +- src/libserialize/ebml.rs | 42 +- src/libserialize/hex.rs | 14 +- src/libserialize/serialize.rs | 8 +- src/libstd/any.rs | 58 +- src/libstd/ascii.rs | 108 +-- src/libstd/bool.rs | 258 +++--- src/libstd/c_str.rs | 92 +- src/libstd/cast.rs | 4 +- src/libstd/cell.rs | 12 +- src/libstd/char.rs | 64 +- src/libstd/clone.rs | 10 +- src/libstd/cmp.rs | 22 +- src/libstd/comm/mod.rs | 44 +- src/libstd/comm/oneshot.rs | 2 +- src/libstd/comm/select.rs | 54 +- src/libstd/comm/shared.rs | 14 +- src/libstd/comm/stream.rs | 14 +- src/libstd/fmt/mod.rs | 2 +- src/libstd/fmt/num.rs | 284 +++---- src/libstd/fmt/parse.rs | 2 +- src/libstd/gc.rs | 12 +- src/libstd/hash.rs | 10 +- src/libstd/hashmap.rs | 82 +- src/libstd/io/buffered.rs | 92 +- src/libstd/io/comm_adapters.rs | 26 +- src/libstd/io/extensions.rs | 36 +- src/libstd/io/fs.rs | 64 +- src/libstd/io/mem.rs | 118 +-- src/libstd/io/net/ip.rs | 64 +- src/libstd/io/net/tcp.rs | 20 +- src/libstd/io/net/udp.rs | 30 +- src/libstd/io/net/unix.rs | 8 +- src/libstd/io/process.rs | 6 +- src/libstd/io/result.rs | 10 +- src/libstd/io/signal.rs | 2 +- src/libstd/io/stdio.rs | 2 +- src/libstd/io/timer.rs | 12 +- src/libstd/io/util.rs | 36 +- src/libstd/iter.rs | 464 +++++----- src/libstd/local_data.rs | 24 +- src/libstd/managed.rs | 6 +- src/libstd/mem.rs | 60 +- src/libstd/num/f32.rs | 124 +-- src/libstd/num/f64.rs | 122 +-- src/libstd/num/int_macros.rs | 152 ++-- src/libstd/num/mod.rs | 678 +++++++-------- src/libstd/num/strconv.rs | 16 +- src/libstd/num/uint_macros.rs | 98 +-- src/libstd/option.rs | 86 +- src/libstd/os.rs | 26 +- src/libstd/path/mod.rs | 4 +- src/libstd/path/posix.rs | 82 +- src/libstd/path/windows.rs | 92 +- src/libstd/ptr.rs | 40 +- src/libstd/rand/distributions/mod.rs | 6 +- src/libstd/rand/isaac.rs | 20 +- src/libstd/rand/mod.rs | 44 +- src/libstd/rand/reader.rs | 14 +- src/libstd/rand/reseeding.rs | 8 +- src/libstd/rc.rs | 12 +- src/libstd/repr.rs | 2 +- src/libstd/result.rs | 64 +- src/libstd/rt/logging.rs | 26 +- src/libstd/rt/thread.rs | 22 +- src/libstd/rt/thread_local_storage.rs | 10 +- src/libstd/run.rs | 30 +- src/libstd/str.rs | 800 +++++++++--------- src/libstd/sync/arc.rs | 8 +- src/libstd/sync/atomics.rs | 24 +- src/libstd/sync/deque.rs | 14 +- src/libstd/sync/mpmc_bounded_queue.rs | 4 +- src/libstd/sync/spsc_queue.rs | 24 +- src/libstd/task.rs | 8 +- src/libstd/to_str.rs | 26 +- src/libstd/trie.rs | 66 +- src/libstd/tuple.rs | 26 +- src/libstd/unstable/finally.rs | 8 +- src/libstd/unstable/mod.rs | 2 +- src/libstd/unstable/raw.rs | 4 +- src/libstd/unstable/sync.rs | 4 +- src/libstd/vec.rs | 752 ++++++++-------- src/libsync/arc.rs | 52 +- src/libsync/future.rs | 16 +- src/libsync/sync/mod.rs | 10 +- src/libsync/sync/mutex.rs | 14 +- src/libsync/sync/one.rs | 4 +- src/libsyntax/abi.rs | 28 +- src/libsyntax/ast_map.rs | 4 +- src/libsyntax/ast_util.rs | 78 +- src/libsyntax/codemap.rs | 28 +- src/libsyntax/crateid.rs | 54 +- src/libsyntax/ext/expand.rs | 16 +- src/libsyntax/parse/comments.rs | 22 +- src/libsyntax/parse/lexer.rs | 22 +- src/libsyntax/parse/mod.rs | 26 +- src/libsyntax/print/pp.rs | 6 +- src/libsyntax/print/pprust.rs | 6 +- src/libsyntax/util/interner.rs | 68 +- src/libsyntax/util/parser_testing.rs | 20 +- src/libsyntax/util/small_vector.rs | 36 +- src/libterm/terminfo/parm.rs | 28 +- src/libterm/terminfo/parser/compiled.rs | 6 +- src/libtest/lib.rs | 70 +- src/libtime/lib.rs | 162 ++-- src/libuuid/lib.rs | 2 +- src/test/auxiliary/xcrate_static_addresses.rs | 4 +- src/test/bench/core-map.rs | 6 +- src/test/bench/msgsend-pipes-shared.rs | 2 +- src/test/bench/msgsend-pipes.rs | 2 +- src/test/bench/shootout-pfib.rs | 2 +- src/test/bench/std-smallintmap.rs | 2 +- src/test/bench/sudoku.rs | 42 +- src/test/compile-fail/autoderef-full-lval.rs | 4 +- .../borrowck-loan-blocks-mut-uniq.rs | 4 +- .../compile-fail/borrowck-ref-mut-of-imm.rs | 2 +- src/test/compile-fail/issue-2548.rs | 4 +- src/test/compile-fail/issue-2969.rs | 2 +- src/test/compile-fail/issue-5927.rs | 2 +- .../compile-fail/kindck-owned-trait-scoped.rs | 2 +- .../macro-crate-unexported-macro.rs | 2 +- src/test/compile-fail/mod_file_disambig.rs | 2 +- src/test/compile-fail/mod_file_not_exist.rs | 2 +- .../compile-fail/mod_file_with_path_attr.rs | 2 +- src/test/compile-fail/no-capture-arc.rs | 4 +- src/test/compile-fail/no-reuse-move-arc.rs | 4 +- .../compile-fail/regions-glb-free-free.rs | 2 +- .../regions-infer-borrow-scope-too-big.rs | 2 +- .../regions-infer-borrow-scope-within-loop.rs | 2 +- src/test/compile-fail/regions-trait-1.rs | 2 +- .../regions-var-type-out-of-scope.rs | 2 +- .../compile-fail/vtable-res-trait-param.rs | 2 +- src/test/pretty/record-trailing-comma.rs | 2 +- src/test/run-fail/assert-eq-macro-fail.rs | 2 +- src/test/run-fail/str-overrun.rs | 2 +- src/test/run-fail/unwind-match.rs | 2 +- src/test/run-fail/vec-overrun.rs | 4 +- src/test/run-make/mixing-deps/prog.rs | 2 +- src/test/run-make/volatile-intrinsics/main.rs | 2 +- src/test/run-pass-fulldeps/macro-crate.rs | 4 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- .../syntax-extension-fourcc.rs | 18 +- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +- src/test/run-pass/argument-passing.rs | 10 +- src/test/run-pass/arith-0.rs | 2 +- src/test/run-pass/arith-1.rs | 32 +- src/test/run-pass/arith-unsigned.rs | 12 +- src/test/run-pass/asm-out-assign.rs | 6 +- src/test/run-pass/assert-eq-macro-success.rs | 10 +- src/test/run-pass/assign-assign.rs | 24 +- src/test/run-pass/assignability-trait.rs | 6 +- src/test/run-pass/attr-no-drop-flag-size.rs | 2 +- src/test/run-pass/auto-loop.rs | 2 +- src/test/run-pass/auto-ref-slice-plus-ref.rs | 4 +- src/test/run-pass/auto-ref-sliceable.rs | 2 +- src/test/run-pass/autobind.rs | 4 +- .../run-pass/autoderef-method-on-trait.rs | 2 +- .../run-pass/autoderef-method-priority.rs | 2 +- .../autoderef-method-twice-but-not-thrice.rs | 2 +- src/test/run-pass/autoderef-method-twice.rs | 2 +- src/test/run-pass/autoderef-method.rs | 2 +- .../autoref-intermediate-types-issue-3585.rs | 2 +- src/test/run-pass/big-literals.rs | 12 +- .../run-pass/binary-minus-without-space.rs | 2 +- .../bind-field-short-with-modifiers.rs | 8 +- src/test/run-pass/binops.rs | 28 +- src/test/run-pass/bitwise.rs | 20 +- src/test/run-pass/block-arg-call-as.rs | 4 +- src/test/run-pass/block-expr-precedence.rs | 4 +- src/test/run-pass/block-fn-coerce.rs | 4 +- src/test/run-pass/block-iter-1.rs | 2 +- src/test/run-pass/block-iter-2.rs | 2 +- .../borrowck-borrow-from-expr-block.rs | 2 +- .../run-pass/borrowck-closures-two-imm.rs | 6 +- .../run-pass/borrowck-fixed-length-vecs.rs | 2 +- .../run-pass/borrowck-freeze-frozen-mut.rs | 12 +- .../run-pass/borrowck-move-by-capture-ok.rs | 2 +- .../run-pass/borrowck-mut-vec-as-imm-slice.rs | 2 +- src/test/run-pass/borrowck-nested-calls.rs | 4 +- .../borrowck-pat-reassign-no-binding.rs | 2 +- .../borrowck-preserve-box-in-field.rs | 8 +- .../borrowck-preserve-box-in-moved-value.rs | 2 +- .../run-pass/borrowck-preserve-box-in-uniq.rs | 8 +- src/test/run-pass/borrowck-preserve-box.rs | 8 +- .../run-pass/borrowck-preserve-cond-box.rs | 8 +- .../run-pass/borrowck-preserve-expl-deref.rs | 8 +- src/test/run-pass/borrowck-rvalues-mutable.rs | 4 +- .../borrowck-scope-of-deref-issue-4666.rs | 4 +- src/test/run-pass/borrowck-univariant-enum.rs | 2 +- .../borrowed-ptr-pattern-infallible.rs | 4 +- .../run-pass/borrowed-ptr-pattern-option.rs | 2 +- src/test/run-pass/borrowed-ptr-pattern.rs | 4 +- src/test/run-pass/box-unbox.rs | 2 +- src/test/run-pass/break.rs | 4 +- src/test/run-pass/bug-7183-generics.rs | 10 +- .../run-pass/by-value-self-in-mut-slot.rs | 2 +- src/test/run-pass/c-stack-returning-int64.rs | 2 +- .../call-closure-from-overloaded-op.rs | 2 +- src/test/run-pass/capturing-logging.rs | 2 +- src/test/run-pass/cast.rs | 14 +- src/test/run-pass/cci_borrow.rs | 2 +- src/test/run-pass/cci_nested_exe.rs | 8 +- src/test/run-pass/cfgs-on-items.rs | 4 +- src/test/run-pass/char.rs | 14 +- .../class-cast-to-trait-cross-crate-2.rs | 2 +- .../class-cast-to-trait-multiple-types.rs | 4 +- src/test/run-pass/class-exports.rs | 2 +- .../class-impl-very-parameterized-trait.rs | 6 +- src/test/run-pass/class-method-cross-crate.rs | 4 +- .../run-pass/class-methods-cross-crate.rs | 6 +- src/test/run-pass/class-methods.rs | 6 +- .../class-poly-methods-cross-crate.rs | 8 +- src/test/run-pass/class-poly-methods.rs | 8 +- src/test/run-pass/class-separate-impl.rs | 2 +- .../run-pass/classes-simple-cross-crate.rs | 4 +- src/test/run-pass/classes-simple-method.rs | 4 +- src/test/run-pass/classes-simple.rs | 4 +- .../cleanup-rvalue-during-if-and-while.rs | 4 +- src/test/run-pass/cleanup-rvalue-for-scope.rs | 2 +- src/test/run-pass/cleanup-rvalue-scopes.rs | 2 +- src/test/run-pass/clone-with-exterior.rs | 4 +- .../close-over-big-then-small-data.rs | 4 +- src/test/run-pass/closure-inference.rs | 2 +- src/test/run-pass/closure-inference2.rs | 4 +- .../run-pass/coerce-reborrow-imm-ptr-rcvr.rs | 2 +- .../run-pass/coerce-reborrow-imm-vec-rcvr.rs | 4 +- .../run-pass/coerce-reborrow-mut-vec-arg.rs | 2 +- .../run-pass/coerce-reborrow-mut-vec-rcvr.rs | 2 +- .../run-pass/coerce-to-closure-and-proc.rs | 16 +- src/test/run-pass/comm.rs | 2 +- src/test/run-pass/concat.rs | 6 +- src/test/run-pass/conditional-compile.rs | 2 +- src/test/run-pass/const-autoderef.rs | 4 +- src/test/run-pass/const-big-enum.rs | 4 +- src/test/run-pass/const-binops.rs | 72 +- src/test/run-pass/const-cast-ptr-int.rs | 2 +- src/test/run-pass/const-cast.rs | 4 +- src/test/run-pass/const-const.rs | 2 +- src/test/run-pass/const-contents.rs | 12 +- src/test/run-pass/const-cross-crate-const.rs | 8 +- src/test/run-pass/const-cross-crate-extern.rs | 2 +- src/test/run-pass/const-deref.rs | 2 +- src/test/run-pass/const-enum-cast.rs | 16 +- src/test/run-pass/const-enum-struct.rs | 2 +- src/test/run-pass/const-enum-struct2.rs | 2 +- src/test/run-pass/const-enum-tuple.rs | 2 +- src/test/run-pass/const-enum-tuple2.rs | 2 +- src/test/run-pass/const-enum-tuplestruct.rs | 2 +- src/test/run-pass/const-enum-tuplestruct2.rs | 2 +- src/test/run-pass/const-extern-function.rs | 4 +- .../run-pass/const-fields-and-indexing.rs | 6 +- src/test/run-pass/const-fn-val.rs | 2 +- src/test/run-pass/const-negative.rs | 2 +- .../run-pass/const-nullary-univariant-enum.rs | 4 +- src/test/run-pass/const-rec-and-tup.rs | 2 +- .../run-pass/const-region-ptrs-noncopy.rs | 2 +- src/test/run-pass/const-region-ptrs.rs | 4 +- src/test/run-pass/const-str-ptr.rs | 8 +- src/test/run-pass/const-struct.rs | 10 +- src/test/run-pass/const-tuple-struct.rs | 4 +- src/test/run-pass/const-vecs-and-slices.rs | 6 +- src/test/run-pass/consts-in-patterns.rs | 2 +- src/test/run-pass/crateresolve1.rs | 2 +- src/test/run-pass/crateresolve8.rs | 2 +- .../cross-crate-newtype-struct-pat.rs | 2 +- .../default-method-supertrait-vtable.rs | 2 +- .../run-pass/deriving-cmp-generic-enum.rs | 16 +- .../deriving-cmp-generic-struct-enum.rs | 16 +- .../run-pass/deriving-cmp-generic-struct.rs | 16 +- .../deriving-cmp-generic-tuple-struct.rs | 16 +- .../run-pass/deriving-cmp-shortcircuit.rs | 2 +- src/test/run-pass/deriving-primitive.rs | 10 +- ...deriving-self-lifetime-totalord-totaleq.rs | 8 +- src/test/run-pass/deriving-self-lifetime.rs | 4 +- src/test/run-pass/deriving-show.rs | 2 +- src/test/run-pass/deriving-to-str.rs | 22 +- .../run-pass/deriving-via-extension-c-enum.rs | 2 +- .../run-pass/deriving-via-extension-enum.rs | 2 +- .../deriving-via-extension-struct-empty.rs | 2 +- ...-via-extension-struct-like-enum-variant.rs | 2 +- .../run-pass/deriving-via-extension-struct.rs | 2 +- .../deriving-via-extension-type-params.rs | 2 +- src/test/run-pass/div-mod.rs | 20 +- src/test/run-pass/empty-tag.rs | 2 +- src/test/run-pass/enum-clike-ffi-as-int.rs | 2 +- src/test/run-pass/enum-discrim-autosizing.rs | 16 +- .../run-pass/enum-discrim-manual-sizing.rs | 20 +- src/test/run-pass/enum-discrim-width-stuff.rs | 12 +- src/test/run-pass/estr-slice.rs | 6 +- src/test/run-pass/estr-uniq.rs | 4 +- src/test/run-pass/evec-internal-boxes.rs | 4 +- src/test/run-pass/evec-internal.rs | 4 +- src/test/run-pass/evec-slice.rs | 4 +- src/test/run-pass/exec-env.rs | 2 +- src/test/run-pass/explicit-self-generic.rs | 2 +- .../run-pass/explicit-self-objects-uniq.rs | 2 +- src/test/run-pass/explicit-self.rs | 6 +- src/test/run-pass/exponential-notation.rs | 2 +- src/test/run-pass/expr-block-slot.rs | 4 +- src/test/run-pass/expr-block.rs | 2 +- src/test/run-pass/expr-copy.rs | 4 +- src/test/run-pass/expr-elseif-ref.rs | 2 +- src/test/run-pass/expr-fn.rs | 16 +- src/test/run-pass/expr-if-box.rs | 4 +- src/test/run-pass/expr-if-fail.rs | 4 +- src/test/run-pass/expr-if-struct.rs | 4 +- src/test/run-pass/expr-if-unique.rs | 2 +- src/test/run-pass/expr-match-box.rs | 4 +- src/test/run-pass/expr-match-fail.rs | 4 +- src/test/run-pass/expr-match-struct.rs | 4 +- src/test/run-pass/expr-match-unique.rs | 2 +- src/test/run-pass/exterior.rs | 6 +- src/test/run-pass/extern-call-deep.rs | 2 +- src/test/run-pass/extern-call-deep2.rs | 2 +- src/test/run-pass/extern-call-direct.rs | 2 +- src/test/run-pass/extern-call-indirect.rs | 2 +- src/test/run-pass/extern-call-scrub.rs | 2 +- .../extern-compare-with-return-type.rs | 8 +- src/test/run-pass/extern-crosscrate.rs | 2 +- src/test/run-pass/extern-pass-TwoU16s.rs | 2 +- src/test/run-pass/extern-pass-TwoU32s.rs | 2 +- src/test/run-pass/extern-pass-TwoU64s.rs | 2 +- src/test/run-pass/extern-pass-TwoU8s.rs | 2 +- src/test/run-pass/extern-pass-char.rs | 2 +- src/test/run-pass/extern-pass-double.rs | 2 +- src/test/run-pass/extern-pass-u32.rs | 2 +- src/test/run-pass/extern-pass-u64.rs | 2 +- src/test/run-pass/extern-return-TwoU16s.rs | 4 +- src/test/run-pass/extern-return-TwoU32s.rs | 4 +- src/test/run-pass/extern-return-TwoU64s.rs | 4 +- src/test/run-pass/extern-return-TwoU8s.rs | 4 +- src/test/run-pass/extern-stress.rs | 2 +- src/test/run-pass/extern-take-value.rs | 2 +- src/test/run-pass/extern-yield.rs | 2 +- src/test/run-pass/fact.rs | 2 +- src/test/run-pass/fixed_length_copy.rs | 4 +- src/test/run-pass/fixed_length_vec_glue.rs | 2 +- src/test/run-pass/float-nan.rs | 2 +- src/test/run-pass/float2.rs | 8 +- src/test/run-pass/fn-bare-assign.rs | 4 +- src/test/run-pass/fn-bare-size.rs | 2 +- src/test/run-pass/fn-bare-spawn.rs | 2 +- src/test/run-pass/fn-pattern-expected-type.rs | 4 +- src/test/run-pass/for-destruct.rs | 2 +- ...xternal-iterators-hashmap-break-restart.rs | 4 +- .../foreach-external-iterators-hashmap.rs | 4 +- .../foreach-external-iterators-loop.rs | 2 +- src/test/run-pass/foreach-nested.rs | 8 +- src/test/run-pass/foreach-put-structured.rs | 4 +- .../run-pass/foreach-simple-outer-slot.rs | 2 +- src/test/run-pass/foreign-call-no-runtime.rs | 2 +- src/test/run-pass/foreign-fn-linkname.rs | 2 +- src/test/run-pass/foreign-lib-path.rs | 2 +- src/test/run-pass/format-ref-cell.rs | 2 +- src/test/run-pass/fsu-moves-and-copies.rs | 40 +- src/test/run-pass/fun-call-variants.rs | 2 +- src/test/run-pass/fun-indirect-call.rs | 2 +- .../run-pass/func-arg-incomplete-pattern.rs | 2 +- src/test/run-pass/func-arg-ref-pattern.rs | 4 +- src/test/run-pass/func-arg-wild-pattern.rs | 2 +- src/test/run-pass/generic-alias-box.rs | 2 +- src/test/run-pass/generic-alias-unique.rs | 2 +- src/test/run-pass/generic-box.rs | 2 +- .../run-pass/generic-default-type-params.rs | 12 +- src/test/run-pass/generic-derived-type.rs | 4 +- src/test/run-pass/generic-exterior-box.rs | 2 +- src/test/run-pass/generic-exterior-unique.rs | 2 +- src/test/run-pass/generic-fn.rs | 6 +- src/test/run-pass/generic-object.rs | 2 +- src/test/run-pass/generic-static-methods.rs | 2 +- src/test/run-pass/generic-tag-values.rs | 4 +- src/test/run-pass/generic-tup.rs | 4 +- src/test/run-pass/generic-type.rs | 4 +- src/test/run-pass/generic-unique.rs | 2 +- src/test/run-pass/glob-std.rs | 100 +-- src/test/run-pass/guards-not-exhaustive.rs | 2 +- src/test/run-pass/guards.rs | 4 +- src/test/run-pass/hygiene-dodging-1.rs | 2 +- src/test/run-pass/i8-incr.rs | 2 +- src/test/run-pass/ifmt.rs | 2 +- src/test/run-pass/import-glob-crate.rs | 2 +- .../inferred-suffix-in-pattern-range.rs | 6 +- src/test/run-pass/init-res-into-things.rs | 12 +- src/test/run-pass/inner-static.rs | 6 +- src/test/run-pass/int-conversion-coherence.rs | 2 +- src/test/run-pass/integer-literal-radix.rs | 12 +- src/test/run-pass/integral-indexing.rs | 20 +- src/test/run-pass/intrinsic-alignment.rs | 16 +- src/test/run-pass/intrinsic-atomics-cc.rs | 2 +- src/test/run-pass/intrinsic-atomics.rs | 48 +- src/test/run-pass/intrinsic-move-val.rs | 4 +- src/test/run-pass/intrinsics-integer.rs | 156 ++-- src/test/run-pass/issue-1112.rs | 12 +- src/test/run-pass/issue-1701.rs | 8 +- src/test/run-pass/issue-2214.rs | 2 +- src/test/run-pass/issue-2216.rs | 2 +- src/test/run-pass/issue-2428.rs | 2 +- src/test/run-pass/issue-2718.rs | 2 +- src/test/run-pass/issue-2748-b.rs | 4 +- src/test/run-pass/issue-2895.rs | 8 +- src/test/run-pass/issue-2936.rs | 2 +- src/test/run-pass/issue-2989.rs | 2 +- src/test/run-pass/issue-3091.rs | 2 +- src/test/run-pass/issue-3211.rs | 2 +- src/test/run-pass/issue-3290.rs | 2 +- src/test/run-pass/issue-3683.rs | 2 +- src/test/run-pass/issue-3796.rs | 4 +- src/test/run-pass/issue-3979-generics.rs | 2 +- src/test/run-pass/issue-3979-xcrate.rs | 2 +- src/test/run-pass/issue-3979.rs | 2 +- src/test/run-pass/issue-4241.rs | 6 +- src/test/run-pass/issue-4401.rs | 2 +- src/test/run-pass/issue-4448.rs | 2 +- src/test/run-pass/issue-5530.rs | 16 +- src/test/run-pass/issue-5917.rs | 2 +- src/test/run-pass/issue-6153.rs | 2 +- src/test/run-pass/issue-6334.rs | 2 +- src/test/run-pass/issue-8860.rs | 12 +- src/test/run-pass/issue-8898.rs | 2 +- src/test/run-pass/issue-9188.rs | 2 +- src/test/run-pass/issue-9259.rs | 2 +- .../issue-9394-inherited-trait-calls.rs | 12 +- src/test/run-pass/issue-979.rs | 2 +- src/test/run-pass/issue-9918.rs | 2 +- src/test/run-pass/issue2378c.rs | 2 +- src/test/run-pass/istr.rs | 12 +- src/test/run-pass/ivec-add.rs | 8 +- .../run-pass/kindck-owned-trait-contains-1.rs | 2 +- src/test/run-pass/lambda-infer-unresolved.rs | 2 +- src/test/run-pass/last-use-in-cap-clause.rs | 2 +- src/test/run-pass/lazy-and-or.rs | 2 +- src/test/run-pass/let-destruct-ref.rs | 2 +- src/test/run-pass/let-var-hygiene.rs | 2 +- src/test/run-pass/linear-for-loop.rs | 4 +- .../log-knows-the-names-of-variants-in-std.rs | 2 +- .../log-knows-the-names-of-variants.rs | 8 +- src/test/run-pass/log-str.rs | 4 +- src/test/run-pass/loop-break-cont.rs | 2 +- src/test/run-pass/loop-scope.rs | 2 +- src/test/run-pass/macro-crate-def-only.rs | 2 +- .../run-pass/macro-export-inner-module.rs | 2 +- src/test/run-pass/macro-local-data-key.rs | 4 +- src/test/run-pass/macro-path.rs | 2 +- src/test/run-pass/macro-stmt.rs | 6 +- src/test/run-pass/macro-with-attrs1.rs | 2 +- src/test/run-pass/macro-with-attrs2.rs | 2 +- src/test/run-pass/match-borrowed_str.rs | 24 +- src/test/run-pass/match-in-macro.rs | 2 +- src/test/run-pass/match-pattern-drop.rs | 6 +- src/test/run-pass/match-pipe-binding.rs | 20 +- .../run-pass/match-ref-binding-mut-option.rs | 2 +- src/test/run-pass/match-ref-binding-mut.rs | 2 +- src/test/run-pass/match-ref-binding.rs | 2 +- src/test/run-pass/match-str.rs | 2 +- src/test/run-pass/match-tag.rs | 6 +- src/test/run-pass/match-unique-bind.rs | 2 +- src/test/run-pass/match-vec-rvalue.rs | 8 +- src/test/run-pass/match-with-ret-arm.rs | 2 +- src/test/run-pass/mod-inside-fn.rs | 2 +- src/test/run-pass/mod_dir_implicit.rs | 2 +- src/test/run-pass/mod_dir_path.rs | 2 +- src/test/run-pass/mod_dir_path2.rs | 2 +- src/test/run-pass/mod_dir_path3.rs | 2 +- src/test/run-pass/mod_dir_path_multi.rs | 4 +- src/test/run-pass/mod_dir_recursive.rs | 2 +- src/test/run-pass/mod_dir_simple.rs | 2 +- src/test/run-pass/mod_file.rs | 2 +- src/test/run-pass/mod_file_with_path_attr.rs | 2 +- src/test/run-pass/monad.rs | 4 +- .../run-pass/monomorphize-abi-alignment.rs | 4 +- src/test/run-pass/morestack3.rs | 20 +- src/test/run-pass/move-1-unique.rs | 8 +- src/test/run-pass/move-1.rs | 8 +- src/test/run-pass/move-3-unique.rs | 4 +- src/test/run-pass/move-3.rs | 4 +- src/test/run-pass/move-4.rs | 2 +- src/test/run-pass/move-out-of-field.rs | 2 +- src/test/run-pass/move-scalar.rs | 2 +- src/test/run-pass/mut-function-arguments.rs | 2 +- src/test/run-pass/mut-in-ident-patterns.rs | 22 +- ...ility-inherits-through-fixed-length-vec.rs | 2 +- src/test/run-pass/mutable-alias-vec.rs | 2 +- src/test/run-pass/nested-class.rs | 4 +- .../nested-function-names-issue-8587.rs | 6 +- src/test/run-pass/nested-patterns.rs | 4 +- src/test/run-pass/nested_item_main.rs | 4 +- src/test/run-pass/newlambdas.rs | 4 +- src/test/run-pass/newtype-polymorphic.rs | 6 +- src/test/run-pass/newtype-struct-drop-run.rs | 2 +- src/test/run-pass/newtype-temporary.rs | 2 +- src/test/run-pass/newtype.rs | 2 +- src/test/run-pass/non-boolean-pure-fns.rs | 2 +- src/test/run-pass/non-legacy-modes.rs | 2 +- src/test/run-pass/nul-characters.rs | 18 +- src/test/run-pass/nullable-pointer-size.rs | 4 +- src/test/run-pass/nullary-or-pattern.rs | 4 +- .../run-pass/numeric-method-autoexport.rs | 24 +- .../objects-coerce-freeze-borrored.rs | 4 +- ...cts-owned-object-borrowed-method-header.rs | 2 +- ...owned-object-borrowed-method-headerless.rs | 2 +- .../objects-owned-object-owned-method.rs | 2 +- src/test/run-pass/one-tuple.rs | 4 +- src/test/run-pass/opeq.rs | 8 +- src/test/run-pass/operator-overloading.rs | 12 +- src/test/run-pass/option-unwrap.rs | 2 +- src/test/run-pass/or-pattern.rs | 6 +- .../run-pass/packed-struct-borrow-element.rs | 2 +- .../run-pass/packed-struct-generic-layout.rs | 4 +- .../run-pass/packed-struct-generic-size.rs | 6 +- src/test/run-pass/packed-struct-layout.rs | 4 +- src/test/run-pass/packed-struct-match.rs | 4 +- src/test/run-pass/packed-struct-size-xc.rs | 2 +- src/test/run-pass/packed-struct-size.rs | 10 +- src/test/run-pass/packed-struct-vec.rs | 6 +- .../run-pass/packed-tuple-struct-layout.rs | 4 +- src/test/run-pass/packed-tuple-struct-size.rs | 10 +- .../run-pass/pattern-bound-var-in-for-each.rs | 2 +- .../phase-syntax-link-does-resolve.rs | 2 +- src/test/run-pass/placement-new-arena.rs | 2 +- src/test/run-pass/private-class-field.rs | 2 +- src/test/run-pass/raw-str.rs | Bin 1365 -> 1415 bytes src/test/run-pass/rcvr-borrowed-to-region.rs | 8 +- src/test/run-pass/rcvr-borrowed-to-slice.rs | 6 +- src/test/run-pass/rec-align-u32.rs | 6 +- src/test/run-pass/rec-align-u64.rs | 6 +- src/test/run-pass/rec-extend.rs | 12 +- src/test/run-pass/rec-tup.rs | 18 +- src/test/run-pass/rec.rs | 18 +- src/test/run-pass/record-pat.rs | 4 +- .../reexported-static-methods-cross-crate.rs | 6 +- src/test/run-pass/reflect-visit-type.rs | 2 +- .../run-pass/regions-appearance-constraint.rs | 6 +- src/test/run-pass/regions-borrow-at.rs | 2 +- src/test/run-pass/regions-borrow-estr-uniq.rs | 4 +- .../run-pass/regions-borrow-evec-fixed.rs | 2 +- src/test/run-pass/regions-borrow-evec-uniq.rs | 4 +- src/test/run-pass/regions-borrow-uniq.rs | 2 +- src/test/run-pass/regions-copy-closure.rs | 4 +- .../run-pass/regions-dependent-addr-of.rs | 18 +- .../run-pass/regions-escape-into-other-fn.rs | 2 +- ...gions-infer-borrow-scope-within-loop-ok.rs | 2 +- .../run-pass/regions-infer-borrow-scope.rs | 2 +- src/test/run-pass/regions-infer-call-2.rs | 2 +- src/test/run-pass/regions-infer-call.rs | 2 +- ...regions-infer-contravariance-due-to-ret.rs | 2 +- src/test/run-pass/regions-mock-tcx.rs | 2 +- src/test/run-pass/regions-params.rs | 2 +- .../regions-return-interior-of-option.rs | 4 +- src/test/run-pass/rename-directory.rs | 4 +- src/test/run-pass/repeat-expr-in-static.rs | 2 +- .../run-pass/resource-assign-is-not-copy.rs | 2 +- src/test/run-pass/resource-destruct.rs | 2 +- src/test/run-pass/return-from-closure.rs | 2 +- .../self-in-mut-slot-default-method.rs | 4 +- .../self-in-mut-slot-immediate-value.rs | 4 +- src/test/run-pass/send_str_hashmap.rs | 36 +- src/test/run-pass/send_str_treemap.rs | 22 +- src/test/run-pass/sendfn-is-a-block.rs | 2 +- src/test/run-pass/sendfn-spawn-with-fn-arg.rs | 2 +- src/test/run-pass/seq-compare.rs | 2 +- src/test/run-pass/shift.rs | 42 +- src/test/run-pass/signed-shift-const-eval.rs | 2 +- src/test/run-pass/simd-binop.rs | 6 +- src/test/run-pass/simd-generics.rs | 8 +- src/test/run-pass/small-enum-range-edge.rs | 12 +- src/test/run-pass/small-enums-with-fields.rs | 8 +- src/test/run-pass/spawn-types.rs | 2 +- src/test/run-pass/spawn2.rs | 18 +- src/test/run-pass/stable-addr-of.rs | 2 +- src/test/run-pass/stat.rs | 2 +- .../run-pass/static-function-pointer-xc.rs | 8 +- src/test/run-pass/static-function-pointer.rs | 6 +- src/test/run-pass/static-impl.rs | 12 +- ...tic-method-in-trait-with-tps-intracrate.rs | 2 +- src/test/run-pass/static-method-xcrate.rs | 6 +- src/test/run-pass/static-methods-in-traits.rs | 4 +- src/test/run-pass/str-append.rs | 6 +- src/test/run-pass/str-concat.rs | 2 +- src/test/run-pass/str-growth.rs | 12 +- src/test/run-pass/str-idx.rs | 2 +- src/test/run-pass/str-multiline.rs | 4 +- src/test/run-pass/string-self-append.rs | 2 +- .../struct-destructuring-cross-crate.rs | 4 +- .../run-pass/struct-field-assignability.rs | 2 +- .../run-pass/struct-like-variant-match.rs | 8 +- .../struct-lit-functional-update-no-fields.rs | 4 +- src/test/run-pass/struct-new-as-field-name.rs | 2 +- src/test/run-pass/struct-return.rs | 14 +- src/test/run-pass/structured-compare.rs | 4 +- .../run-pass/supertrait-default-generics.rs | 2 +- src/test/run-pass/swap-2.rs | 8 +- src/test/run-pass/syntax-extension-bytes.rs | 8 +- src/test/run-pass/syntax-extension-minor.rs | 2 +- .../run-pass/syntax-extension-source-utils.rs | 6 +- src/test/run-pass/tag-align-shape.rs | 2 +- src/test/run-pass/tag-disr-val-shape.rs | 6 +- src/test/run-pass/tag-variant-disr-val.rs | 4 +- src/test/run-pass/task-comm-0.rs | 2 +- src/test/run-pass/task-comm-16.rs | 28 +- src/test/run-pass/task-comm-3.rs | 2 +- src/test/run-pass/task-comm-4.rs | 2 +- src/test/run-pass/task-comm-5.rs | 2 +- src/test/run-pass/task-comm-6.rs | 2 +- src/test/run-pass/task-comm-7.rs | 2 +- src/test/run-pass/task-comm-9.rs | 2 +- src/test/run-pass/task-comm-chan-nil.rs | 2 +- src/test/run-pass/task-spawn-move-and-copy.rs | 2 +- src/test/run-pass/trait-bounds.rs | 2 +- .../trait-default-method-bound-subst.rs | 4 +- .../trait-default-method-bound-subst2.rs | 2 +- .../trait-default-method-bound-subst3.rs | 4 +- .../trait-default-method-bound-subst4.rs | 4 +- .../run-pass/trait-default-method-bound.rs | 2 +- .../run-pass/trait-default-method-xc-2.rs | 12 +- src/test/run-pass/trait-default-method-xc.rs | 24 +- src/test/run-pass/trait-generic.rs | 8 +- .../run-pass/trait-inheritance-auto-xc-2.rs | 6 +- .../run-pass/trait-inheritance-auto-xc.rs | 6 +- src/test/run-pass/trait-inheritance-auto.rs | 6 +- .../trait-inheritance-call-bound-inherited.rs | 2 +- ...trait-inheritance-call-bound-inherited2.rs | 2 +- ...ritance-cast-without-call-to-supertrait.rs | 4 +- src/test/run-pass/trait-inheritance-cast.rs | 6 +- .../trait-inheritance-cross-trait-call-xc.rs | 2 +- .../trait-inheritance-cross-trait-call.rs | 2 +- .../run-pass/trait-inheritance-diamond.rs | 8 +- .../trait-inheritance-multiple-inheritors.rs | 6 +- .../trait-inheritance-multiple-params.rs | 10 +- .../trait-inheritance-overloading-simple.rs | 2 +- .../trait-inheritance-overloading-xc-exe.rs | 6 +- .../run-pass/trait-inheritance-overloading.rs | 6 +- src/test/run-pass/trait-inheritance-simple.rs | 4 +- src/test/run-pass/trait-inheritance-static.rs | 2 +- .../run-pass/trait-inheritance-static2.rs | 2 +- src/test/run-pass/trait-inheritance-subst2.rs | 2 +- .../run-pass/trait-inheritance-visibility.rs | 2 +- src/test/run-pass/trait-inheritance2.rs | 6 +- src/test/run-pass/trait-object-generics.rs | 2 +- .../run-pass/trait-region-pointer-simple.rs | 2 +- .../run-pass/trait-with-bounds-default.rs | 4 +- .../run-pass/traits-default-method-macro.rs | 2 +- src/test/run-pass/tup.rs | 8 +- .../tuple-struct-constructor-pointer.rs | 4 +- .../run-pass/tuple-struct-destructuring.rs | 4 +- src/test/run-pass/tuple-struct-matching.rs | 4 +- src/test/run-pass/tydesc-name.rs | 6 +- src/test/run-pass/type-sizes.rs | 22 +- src/test/run-pass/typeid-intrinsic.rs | 58 +- src/test/run-pass/u32-decr.rs | 2 +- src/test/run-pass/u8-incr-decr.rs | 2 +- src/test/run-pass/u8-incr.rs | 2 +- src/test/run-pass/unfold-cross-crate.rs | 4 +- src/test/run-pass/uniq-self-in-mut-slot.rs | 2 +- src/test/run-pass/unique-assign-copy.rs | 4 +- src/test/run-pass/unique-assign-drop.rs | 2 +- src/test/run-pass/unique-assign-generic.rs | 4 +- src/test/run-pass/unique-assign.rs | 2 +- src/test/run-pass/unique-autoderef-field.rs | 2 +- src/test/run-pass/unique-autoderef-index.rs | 2 +- src/test/run-pass/unique-containing-tag.rs | 4 +- src/test/run-pass/unique-copy-box.rs | 2 +- src/test/run-pass/unique-decl-init-copy.rs | 4 +- src/test/run-pass/unique-decl-init.rs | 2 +- src/test/run-pass/unique-decl-move-temp.rs | 2 +- src/test/run-pass/unique-decl-move.rs | 2 +- src/test/run-pass/unique-deref.rs | 2 +- src/test/run-pass/unique-destructure.rs | 2 +- src/test/run-pass/unique-fn-arg-move.rs | 2 +- src/test/run-pass/unique-fn-arg-mut.rs | 2 +- src/test/run-pass/unique-fn-arg.rs | 2 +- src/test/run-pass/unique-fn-ret.rs | 2 +- src/test/run-pass/unique-in-vec-copy.rs | 8 +- src/test/run-pass/unique-kinds.rs | 6 +- src/test/run-pass/unique-move-drop.rs | 2 +- src/test/run-pass/unique-move-temp.rs | 2 +- src/test/run-pass/unique-move.rs | 2 +- src/test/run-pass/unique-mutable.rs | 2 +- src/test/run-pass/unique-rec.rs | 2 +- src/test/run-pass/unique-send-2.rs | 2 +- src/test/run-pass/unique-send.rs | 2 +- src/test/run-pass/unique-swap.rs | 4 +- .../run-pass/unit-like-struct-drop-run.rs | 2 +- .../run-pass/unsafe-pointer-assignability.rs | 2 +- src/test/run-pass/utf8.rs | 18 +- src/test/run-pass/utf8_chars.rs | 8 +- src/test/run-pass/utf8_idents.rs | 10 +- src/test/run-pass/variadic-ffi.rs | 2 +- src/test/run-pass/vec-concat.rs | 6 +- src/test/run-pass/vec-growth.rs | 10 +- src/test/run-pass/vec-matching-autoslice.rs | 6 +- src/test/run-pass/vec-matching-fixed.rs | 6 +- src/test/run-pass/vec-matching-fold.rs | 4 +- src/test/run-pass/vec-matching.rs | 28 +- src/test/run-pass/vec-self-append.rs | 38 +- src/test/run-pass/vec-slice-drop.rs | 4 +- src/test/run-pass/vec-slice.rs | 4 +- src/test/run-pass/vec-tail-matching.rs | 6 +- src/test/run-pass/vec-to_str.rs | 8 +- src/test/run-pass/vec-trailing-comma.rs | 4 +- src/test/run-pass/vec.rs | 12 +- src/test/run-pass/while-with-break.rs | 2 +- src/test/run-pass/x86stdcall.rs | 2 +- .../run-pass/xcrate-address-insignificant.rs | 2 +- 784 files changed, 6273 insertions(+), 6273 deletions(-) diff --git a/src/doc/guide-container.md b/src/doc/guide-container.md index 5bb9780c8b276..24640b0608ff6 100644 --- a/src/doc/guide-container.md +++ b/src/doc/guide-container.md @@ -156,7 +156,7 @@ into a single value: ~~~ let xs = [1, 9, 2, 3, 14, 12]; let result = xs.iter().fold(0, |accumulator, item| accumulator - *item); -assert_eq!(result, -41); +fail_unless_eq!(result, -41); ~~~ Most adaptors return an adaptor object implementing the `Iterator` trait itself: @@ -165,7 +165,7 @@ Most adaptors return an adaptor object implementing the `Iterator` trait itself: let xs = [1, 9, 2, 3, 14, 12]; let ys = [5, 2, 1, 8]; let sum = xs.iter().chain(ys.iter()).fold(0, |a, b| a + *b); -assert_eq!(sum, 57); +fail_unless_eq!(sum, 57); ~~~ Some iterator adaptors may return `None` before exhausting the underlying @@ -200,7 +200,7 @@ let mut calls = 0; it.next(); } -assert_eq!(calls, 3); +fail_unless_eq!(calls, 3); ~~~ ## For loops @@ -266,7 +266,7 @@ Iterators offer generic conversion to containers with the `collect` adaptor: ~~~ let xs = [0, 1, 1, 2, 3, 5, 8]; let ys = xs.rev_iter().skip(1).map(|&x| x * 2).collect::<~[int]>(); -assert_eq!(ys, ~[10, 6, 4, 2, 2, 0]); +fail_unless_eq!(ys, ~[10, 6, 4, 2, 2, 0]); ~~~ The method requires a type hint for the container type, if the surrounding code @@ -384,7 +384,7 @@ the trailing underscore is a workaround for issue #5898 and will be removed. ~~~ let mut ys = [1, 2, 3, 4, 5]; ys.mut_iter().reverse_(); -assert_eq!(ys, [5, 4, 3, 2, 1]); +fail_unless_eq!(ys, [5, 4, 3, 2, 1]); ~~~ ## Random-access iterators diff --git a/src/doc/rust.md b/src/doc/rust.md index 33db8cda03651..2e7e156dec2ea 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -3009,7 +3009,7 @@ on `x: &int` are equivalent: let y = match *x { 0 => "zero", _ => "some" }; let z = match x { &0 => "zero", _ => "some" }; -assert_eq!(y, z); +fail_unless_eq!(y, z); ~~~~ A pattern that's just an identifier, like `Nil` in the previous example, diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 4efa152c0d560..debe1d21e5a1b 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1008,7 +1008,7 @@ struct Foo { d: u32 } -assert_eq!(size_of::(), size_of::() * 4); +fail_unless_eq!(size_of::(), size_of::() * 4); struct Bar { a: Foo, @@ -1017,7 +1017,7 @@ struct Bar { d: Foo } -assert_eq!(size_of::(), size_of::() * 16); +fail_unless_eq!(size_of::(), size_of::() * 16); ~~~ Our previous attempt at defining the `List` type included an `u32` and a `List` @@ -1677,7 +1677,7 @@ let x = Rc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); let y = x.clone(); // a new owner let z = x; // this moves `x` into `z`, rather than creating a new owner -assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +fail_unless_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // the variable is mutable, but not the contents of the box let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); @@ -1696,7 +1696,7 @@ let x = Gc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); let y = x; // does not perform a move, unlike with `Rc` let z = x; -assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +fail_unless_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); ~~~ With shared ownership, mutability cannot be inherited so the boxes are always immutable. However, diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index ee7624c35eb1e..8e635bce174ba 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -142,7 +142,7 @@ impl BigBitv { op: |uint, uint| -> uint) -> bool { let len = b.storage.len(); - assert_eq!(self.storage.len(), len); + fail_unless_eq!(self.storage.len(), len); let mut changed = false; for (i, (a, b)) in self.storage.mut_iter() .zip(b.storage.iter()) @@ -517,7 +517,7 @@ impl Bitv { * Both the bitvector and vector must have the same length. */ pub fn eq_vec(&self, v: &[bool]) -> bool { - assert_eq!(self.nbits, v.len()); + fail_unless_eq!(self.nbits, v.len()); let mut i = 0; while i < self.nbits { if self.get(i) != v[i] { return false; } @@ -955,10 +955,10 @@ mod tests { #[test] fn test_to_str() { let zerolen = Bitv::new(0u, false); - assert_eq!(zerolen.to_str(), ~""); + fail_unless_eq!(zerolen.to_str(), ~""); let eightbits = Bitv::new(8u, false); - assert_eq!(eightbits.to_str(), ~"00000000"); + fail_unless_eq!(eightbits.to_str(), ~"00000000"); } #[test] @@ -981,7 +981,7 @@ mod tests { let mut b = bitv::Bitv::new(2, false); b.set(0, true); b.set(1, false); - assert_eq!(b.to_str(), ~"10"); + fail_unless_eq!(b.to_str(), ~"10"); } #[test] @@ -1292,19 +1292,19 @@ mod tests { fn test_from_bytes() { let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let str = ~"10110110" + "00000000" + "11111111"; - assert_eq!(bitv.to_str(), str); + fail_unless_eq!(bitv.to_str(), str); } #[test] fn test_to_bytes() { let mut bv = Bitv::new(3, true); bv.set(1, false); - assert_eq!(bv.to_bytes(), ~[0b10100000]); + fail_unless_eq!(bv.to_bytes(), ~[0b10100000]); let mut bv = Bitv::new(9, false); bv.set(2, true); bv.set(8, true); - assert_eq!(bv.to_bytes(), ~[0b00100000, 0b10000000]); + fail_unless_eq!(bv.to_bytes(), ~[0b00100000, 0b10000000]); } #[test] @@ -1316,7 +1316,7 @@ mod tests { #[test] fn test_to_bools() { let bools = ~[false, false, true, false, false, true, true, false]; - assert_eq!(from_bytes([0b00100110]).to_bools(), bools); + fail_unless_eq!(from_bytes([0b00100110]).to_bools(), bools); } #[test] @@ -1325,7 +1325,7 @@ mod tests { let bitv = from_bools(bools); for (act, &ex) in bitv.iter().zip(bools.iter()) { - assert_eq!(ex, act); + fail_unless_eq!(ex, act); } } @@ -1335,7 +1335,7 @@ mod tests { let bitv = BitvSet::from_bitv(from_bools(bools)); let idxs: ~[uint] = bitv.iter().collect(); - assert_eq!(idxs, ~[0, 2, 3]); + fail_unless_eq!(idxs, ~[0, 2, 3]); } #[test] @@ -1345,8 +1345,8 @@ mod tests { for &b in bools.iter() { for &l in lengths.iter() { let bitset = BitvSet::from_bitv(Bitv::new(l, b)); - assert_eq!(bitset.contains(&1u), b) - assert_eq!(bitset.contains(&(l-1u)), b) + fail_unless_eq!(bitset.contains(&1u), b) + fail_unless_eq!(bitset.contains(&(l-1u)), b) fail_unless!(!bitset.contains(&l)) } } @@ -1407,7 +1407,7 @@ mod tests { fail_unless!(b.insert(400)); fail_unless!(!b.insert(400)); fail_unless!(b.contains(&400)); - assert_eq!(b.len(), 2); + fail_unless_eq!(b.len(), 2); } #[test] @@ -1431,11 +1431,11 @@ mod tests { let mut i = 0; let expected = [3, 5, 11, 77]; a.intersection(&b, |x| { - assert_eq!(*x, expected[i]); + fail_unless_eq!(*x, expected[i]); i += 1; true }); - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1455,11 +1455,11 @@ mod tests { let mut i = 0; let expected = [1, 5, 500]; a.difference(&b, |x| { - assert_eq!(*x, expected[i]); + fail_unless_eq!(*x, expected[i]); i += 1; true }); - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1481,11 +1481,11 @@ mod tests { let mut i = 0; let expected = [1, 5, 11, 14, 220]; a.symmetric_difference(&b, |x| { - assert_eq!(*x, expected[i]); + fail_unless_eq!(*x, expected[i]); i += 1; true }); - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1510,11 +1510,11 @@ mod tests { let mut i = 0; let expected = [1, 3, 5, 9, 11, 13, 19, 24, 160]; a.union(&b, |x| { - assert_eq!(*x, expected[i]); + fail_unless_eq!(*x, expected[i]); i += 1; true }); - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1529,7 +1529,7 @@ mod tests { fail_unless!(a.insert(1000)); fail_unless!(a.remove(&1000)); - assert_eq!(a.capacity(), uint::BITS); + fail_unless_eq!(a.capacity(), uint::BITS); } #[test] @@ -1542,7 +1542,7 @@ mod tests { let mut b = a.clone(); - assert_eq!(&a, &b); + fail_unless_eq!(&a, &b); fail_unless!(b.remove(&1)); fail_unless!(a.contains(&1)); diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 571d0e2bddec1..40a6e92f624cf 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -781,13 +781,13 @@ mod test_btree { #[test] fn bsearch_test_one() { let b = BTree::new(1, ~"abc", 2); - assert_eq!(Some(1), b.root.bsearch_node(2)); + fail_unless_eq!(Some(1), b.root.bsearch_node(2)); } #[test] fn bsearch_test_two() { let b = BTree::new(1, ~"abc", 2); - assert_eq!(Some(0), b.root.bsearch_node(0)); + fail_unless_eq!(Some(0), b.root.bsearch_node(0)); } #[test] @@ -798,7 +798,7 @@ mod test_btree { let leaf_elt_4 = LeafElt::new(5, ~"ddd"); let n = Node::new_leaf(~[leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4]); let b = BTree::new_with_node_len(n, 3, 2); - assert_eq!(Some(2), b.root.bsearch_node(3)); + fail_unless_eq!(Some(2), b.root.bsearch_node(3)); } #[test] @@ -809,7 +809,7 @@ mod test_btree { let leaf_elt_4 = LeafElt::new(5, ~"ddd"); let n = Node::new_leaf(~[leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4]); let b = BTree::new_with_node_len(n, 3, 2); - assert_eq!(Some(4), b.root.bsearch_node(800)); + fail_unless_eq!(Some(4), b.root.bsearch_node(800)); } //Tests the functionality of the get method. @@ -817,7 +817,7 @@ mod test_btree { fn get_test() { let b = BTree::new(1, ~"abc", 2); let val = b.get(1); - assert_eq!(val, Some(~"abc")); + fail_unless_eq!(val, Some(~"abc")); } //Tests the BTree's clone() method. @@ -856,7 +856,7 @@ mod test_btree { #[test] fn btree_tostr_test() { let b = BTree::new(1, ~"abc", 2); - assert_eq!(b.to_str(), ~"Key: 1, value: abc;") + fail_unless_eq!(b.to_str(), ~"Key: 1, value: abc;") } } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index cec83562f5575..597945ed4c4fb 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -668,7 +668,7 @@ mod tests { let mut last_ptr: Option<&Node> = None; let mut node_ptr: &Node; match list.list_head { - None => { assert_eq!(0u, list.length); return } + None => { fail_unless_eq!(0u, list.length); return } Some(ref node) => node_ptr = &**node, } loop { @@ -676,7 +676,7 @@ mod tests { (None , None ) => {} (None , _ ) => fail!("prev link for list_head"), (Some(p), Some(pptr)) => { - assert_eq!(p as *Node, pptr as *Node); + fail_unless_eq!(p as *Node, pptr as *Node); } _ => fail!("prev link is none, not good"), } @@ -692,47 +692,47 @@ mod tests { } } } - assert_eq!(len, list.length); + fail_unless_eq!(len, list.length); } #[test] fn test_basic() { let mut m: DList<~int> = DList::new(); - assert_eq!(m.pop_front(), None); - assert_eq!(m.pop_back(), None); - assert_eq!(m.pop_front(), None); + fail_unless_eq!(m.pop_front(), None); + fail_unless_eq!(m.pop_back(), None); + fail_unless_eq!(m.pop_front(), None); m.push_front(~1); - assert_eq!(m.pop_front(), Some(~1)); + fail_unless_eq!(m.pop_front(), Some(~1)); m.push_back(~2); m.push_back(~3); - assert_eq!(m.len(), 2); - assert_eq!(m.pop_front(), Some(~2)); - assert_eq!(m.pop_front(), Some(~3)); - assert_eq!(m.len(), 0); - assert_eq!(m.pop_front(), None); + fail_unless_eq!(m.len(), 2); + fail_unless_eq!(m.pop_front(), Some(~2)); + fail_unless_eq!(m.pop_front(), Some(~3)); + fail_unless_eq!(m.len(), 0); + fail_unless_eq!(m.pop_front(), None); m.push_back(~1); m.push_back(~3); m.push_back(~5); m.push_back(~7); - assert_eq!(m.pop_front(), Some(~1)); + fail_unless_eq!(m.pop_front(), Some(~1)); let mut n = DList::new(); n.push_front(2); n.push_front(3); { - assert_eq!(n.front().unwrap(), &3); + fail_unless_eq!(n.front().unwrap(), &3); let x = n.front_mut().unwrap(); - assert_eq!(*x, 3); + fail_unless_eq!(*x, 3); *x = 0; } { - assert_eq!(n.back().unwrap(), &2); + fail_unless_eq!(n.back().unwrap(), &2); let y = n.back_mut().unwrap(); - assert_eq!(*y, 2); + fail_unless_eq!(*y, 2); *y = 1; } - assert_eq!(n.pop_front(), Some(0)); - assert_eq!(n.pop_front(), Some(1)); + fail_unless_eq!(n.pop_front(), Some(0)); + fail_unless_eq!(n.pop_front(), Some(1)); } #[cfg(test)] @@ -752,8 +752,8 @@ mod tests { let mut n = DList::new(); n.push_back(2); m.append(n); - assert_eq!(m.len(), 1); - assert_eq!(m.pop_back(), Some(2)); + fail_unless_eq!(m.len(), 1); + fail_unless_eq!(m.pop_back(), Some(2)); check_links(&m); } { @@ -761,8 +761,8 @@ mod tests { let n = DList::new(); m.push_back(2); m.append(n); - assert_eq!(m.len(), 1); - assert_eq!(m.pop_back(), Some(2)); + fail_unless_eq!(m.len(), 1); + fail_unless_eq!(m.pop_back(), Some(2)); check_links(&m); } @@ -772,9 +772,9 @@ mod tests { m.append(list_from(u)); check_links(&m); let sum = v + u; - assert_eq!(sum.len(), m.len()); + fail_unless_eq!(sum.len(), m.len()); for elt in sum.move_iter() { - assert_eq!(m.pop_front(), Some(elt)) + fail_unless_eq!(m.pop_front(), Some(elt)) } } @@ -785,8 +785,8 @@ mod tests { let mut n = DList::new(); n.push_back(2); m.prepend(n); - assert_eq!(m.len(), 1); - assert_eq!(m.pop_back(), Some(2)); + fail_unless_eq!(m.len(), 1); + fail_unless_eq!(m.pop_back(), Some(2)); check_links(&m); } @@ -796,9 +796,9 @@ mod tests { m.prepend(list_from(u)); check_links(&m); let sum = u + v; - assert_eq!(sum.len(), m.len()); + fail_unless_eq!(sum.len(), m.len()); for elt in sum.move_iter() { - assert_eq!(m.pop_front(), Some(elt)) + fail_unless_eq!(m.pop_front(), Some(elt)) } } @@ -806,15 +806,15 @@ mod tests { fn test_rotate() { let mut n: DList = DList::new(); n.rotate_backward(); check_links(&n); - assert_eq!(n.len(), 0); + fail_unless_eq!(n.len(), 0); n.rotate_forward(); check_links(&n); - assert_eq!(n.len(), 0); + fail_unless_eq!(n.len(), 0); let v = ~[1,2,3,4,5]; let mut m = list_from(v); m.rotate_backward(); check_links(&m); m.rotate_forward(); check_links(&m); - assert_eq!(v.iter().collect::<~[&int]>(), m.iter().collect()); + fail_unless_eq!(v.iter().collect::<~[&int]>(), m.iter().collect()); m.rotate_forward(); check_links(&m); m.rotate_forward(); check_links(&m); m.pop_front(); check_links(&m); @@ -822,23 +822,23 @@ mod tests { m.rotate_backward(); check_links(&m); m.push_front(9); check_links(&m); m.rotate_forward(); check_links(&m); - assert_eq!(~[3,9,5,1,2], m.move_iter().collect()); + fail_unless_eq!(~[3,9,5,1,2], m.move_iter().collect()); } #[test] fn test_iterator() { let m = generate_test(); for (i, elt) in m.iter().enumerate() { - assert_eq!(i as int, *elt); + fail_unless_eq!(i as int, *elt); } let mut n = DList::new(); - assert_eq!(n.iter().next(), None); + fail_unless_eq!(n.iter().next(), None); n.push_front(4); let mut it = n.iter(); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(it.next().unwrap(), &4); - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next(), None); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.next().unwrap(), &4); + fail_unless_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.next(), None); } #[test] @@ -850,43 +850,43 @@ mod tests { let mut it = n.iter(); it.next(); let mut jt = it.clone(); - assert_eq!(it.next(), jt.next()); - assert_eq!(it.next_back(), jt.next_back()); - assert_eq!(it.next(), jt.next()); + fail_unless_eq!(it.next(), jt.next()); + fail_unless_eq!(it.next_back(), jt.next_back()); + fail_unless_eq!(it.next(), jt.next()); } #[test] fn test_iterator_double_end() { let mut n = DList::new(); - assert_eq!(n.iter().next(), None); + fail_unless_eq!(n.iter().next(), None); n.push_front(4); n.push_front(5); n.push_front(6); let mut it = n.iter(); - assert_eq!(it.size_hint(), (3, Some(3))); - assert_eq!(it.next().unwrap(), &6); - assert_eq!(it.size_hint(), (2, Some(2))); - assert_eq!(it.next_back().unwrap(), &4); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(it.next_back().unwrap(), &5); - assert_eq!(it.next_back(), None); - assert_eq!(it.next(), None); + fail_unless_eq!(it.size_hint(), (3, Some(3))); + fail_unless_eq!(it.next().unwrap(), &6); + fail_unless_eq!(it.size_hint(), (2, Some(2))); + fail_unless_eq!(it.next_back().unwrap(), &4); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.next_back().unwrap(), &5); + fail_unless_eq!(it.next_back(), None); + fail_unless_eq!(it.next(), None); } #[test] fn test_rev_iter() { let m = generate_test(); for (i, elt) in m.rev_iter().enumerate() { - assert_eq!((6 - i) as int, *elt); + fail_unless_eq!((6 - i) as int, *elt); } let mut n = DList::new(); - assert_eq!(n.rev_iter().next(), None); + fail_unless_eq!(n.rev_iter().next(), None); n.push_front(4); let mut it = n.rev_iter(); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(it.next().unwrap(), &4); - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next(), None); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.next().unwrap(), &4); + fail_unless_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.next(), None); } #[test] @@ -894,19 +894,19 @@ mod tests { let mut m = generate_test(); let mut len = m.len(); for (i, elt) in m.mut_iter().enumerate() { - assert_eq!(i as int, *elt); + fail_unless_eq!(i as int, *elt); len -= 1; } - assert_eq!(len, 0); + fail_unless_eq!(len, 0); let mut n = DList::new(); fail_unless!(n.mut_iter().next().is_none()); n.push_front(4); n.push_back(5); let mut it = n.mut_iter(); - assert_eq!(it.size_hint(), (2, Some(2))); + fail_unless_eq!(it.size_hint(), (2, Some(2))); fail_unless!(it.next().is_some()); fail_unless!(it.next().is_some()); - assert_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.size_hint(), (0, Some(0))); fail_unless!(it.next().is_none()); } @@ -918,12 +918,12 @@ mod tests { n.push_front(5); n.push_front(6); let mut it = n.mut_iter(); - assert_eq!(it.size_hint(), (3, Some(3))); - assert_eq!(*it.next().unwrap(), 6); - assert_eq!(it.size_hint(), (2, Some(2))); - assert_eq!(*it.next_back().unwrap(), 4); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(*it.next_back().unwrap(), 5); + fail_unless_eq!(it.size_hint(), (3, Some(3))); + fail_unless_eq!(*it.next().unwrap(), 6); + fail_unless_eq!(it.size_hint(), (2, Some(2))); + fail_unless_eq!(*it.next_back().unwrap(), 4); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(*it.next_back().unwrap(), 5); fail_unless!(it.next_back().is_none()); fail_unless!(it.next().is_none()); } @@ -941,8 +941,8 @@ mod tests { Some(elt) => { it.insert_next(*elt + 1); match it.peek_next() { - Some(x) => assert_eq!(*x, *elt + 2), - None => assert_eq!(8, *elt), + Some(x) => fail_unless_eq!(*x, *elt + 2), + None => fail_unless_eq!(8, *elt), } } } @@ -951,8 +951,8 @@ mod tests { it.insert_next(1); } check_links(&m); - assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.move_iter().collect::<~[int]>(), ~[-2,0,1,2,3,4,5,6,7,8,9,0,1]); + fail_unless_eq!(m.len(), 3 + len * 2); + fail_unless_eq!(m.move_iter().collect::<~[int]>(), ~[-2,0,1,2,3,4,5,6,7,8,9,0,1]); } #[test] @@ -961,32 +961,32 @@ mod tests { let n = list_from([-1, 0, 0, 7, 7, 9]); let len = m.len() + n.len(); m.merge(n, |a, b| a <= b); - assert_eq!(m.len(), len); + fail_unless_eq!(m.len(), len); check_links(&m); let res = m.move_iter().collect::<~[int]>(); - assert_eq!(res, ~[-1, 0, 0, 0, 1, 3, 5, 6, 7, 2, 7, 7, 9]); + fail_unless_eq!(res, ~[-1, 0, 0, 0, 1, 3, 5, 6, 7, 2, 7, 7, 9]); } #[test] fn test_insert_ordered() { let mut n = DList::new(); n.insert_ordered(1); - assert_eq!(n.len(), 1); - assert_eq!(n.pop_front(), Some(1)); + fail_unless_eq!(n.len(), 1); + fail_unless_eq!(n.pop_front(), Some(1)); let mut m = DList::new(); m.push_back(2); m.push_back(4); m.insert_ordered(3); check_links(&m); - assert_eq!(~[2,3,4], m.move_iter().collect::<~[int]>()); + fail_unless_eq!(~[2,3,4], m.move_iter().collect::<~[int]>()); } #[test] fn test_mut_rev_iter() { let mut m = generate_test(); for (i, elt) in m.mut_rev_iter().enumerate() { - assert_eq!((6-i) as int, *elt); + fail_unless_eq!((6-i) as int, *elt); } let mut n = DList::new(); fail_unless!(n.mut_rev_iter().next().is_none()); @@ -1001,7 +1001,7 @@ mod tests { let n = list_from([1,2,3]); spawn(proc() { check_links(&n); - assert_eq!(~[&1,&2,&3], n.iter().collect::<~[&int]>()); + fail_unless_eq!(~[&1,&2,&3], n.iter().collect::<~[&int]>()); }); } @@ -1009,11 +1009,11 @@ mod tests { fn test_eq() { let mut n: DList = list_from([]); let mut m = list_from([]); - assert_eq!(&n, &m); + fail_unless_eq!(&n, &m); n.push_front(1); fail_unless!(n != m); m.push_back(1); - assert_eq!(&n, &m); + fail_unless_eq!(&n, &m); let n = list_from([2,3,4]); let m = list_from([1,2,3]); @@ -1103,9 +1103,9 @@ mod tests { let mut i = 0u; for (a, &b) in m.move_iter().zip(v.iter()) { i += 1; - assert_eq!(a, b); + fail_unless_eq!(a, b); } - assert_eq!(i, v.len()); + fail_unless_eq!(i, v.len()); } #[bench] diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 6ab61eb91a83f..94fda5726489b 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -247,23 +247,23 @@ mod test { let mut e1: EnumSet = EnumSet::empty(); let elems: ~[Foo] = e1.iter().collect(); - assert_eq!(~[], elems) + fail_unless_eq!(~[], elems) e1.add(A); let elems: ~[Foo] = e1.iter().collect(); - assert_eq!(~[A], elems) + fail_unless_eq!(~[A], elems) e1.add(C); let elems: ~[Foo] = e1.iter().collect(); - assert_eq!(~[A,C], elems) + fail_unless_eq!(~[A,C], elems) e1.add(C); let elems: ~[Foo] = e1.iter().collect(); - assert_eq!(~[A,C], elems) + fail_unless_eq!(~[A,C], elems) e1.add(B); let elems: ~[Foo] = e1.iter().collect(); - assert_eq!(~[A,B,C], elems) + fail_unless_eq!(~[A,B,C], elems) } /////////////////////////////////////////////////////////////////////////// @@ -281,14 +281,14 @@ mod test { let e_union = e1 | e2; let elems: ~[Foo] = e_union.iter().collect(); - assert_eq!(~[A,B,C], elems) + fail_unless_eq!(~[A,B,C], elems) let e_intersection = e1 & e2; let elems: ~[Foo] = e_intersection.iter().collect(); - assert_eq!(~[C], elems) + fail_unless_eq!(~[C], elems) let e_subtract = e1 - e2; let elems: ~[Foo] = e_subtract.iter().collect(); - assert_eq!(~[A], elems) + fail_unless_eq!(~[A], elems) } } diff --git a/src/libcollections/list.rs b/src/libcollections/list.rs index f4f9332825a48..415829e2c62ed 100644 --- a/src/libcollections/list.rs +++ b/src/libcollections/list.rs @@ -193,19 +193,19 @@ mod tests { fn test_from_vec() { let l = from_vec([0, 1, 2]); - assert_eq!(head(l), 0); + fail_unless_eq!(head(l), 0); let tail_l = tail(l); - assert_eq!(head(tail_l), 1); + fail_unless_eq!(head(tail_l), 1); let tail_tail_l = tail(tail_l); - assert_eq!(head(tail_tail_l), 2); + fail_unless_eq!(head(tail_tail_l), 2); } #[test] fn test_from_vec_empty() { let empty : @list::List = from_vec([]); - assert_eq!(empty, @list::Nil::); + fail_unless_eq!(empty, @list::Nil::); } #[test] @@ -213,8 +213,8 @@ mod tests { fn add(a: &uint, b: &int) -> uint { return *a + (*b as uint); } let l = from_vec([0, 1, 2, 3, 4]); let empty = @list::Nil::; - assert_eq!(list::foldl(0u, l, add), 10u); - assert_eq!(list::foldl(0u, empty, add), 0u); + fail_unless_eq!(list::foldl(0u, l, add), 10u); + fail_unless_eq!(list::foldl(0u, empty, add), 0u); } #[test] @@ -223,14 +223,14 @@ mod tests { *a - *b } let l = from_vec([1, 2, 3, 4]); - assert_eq!(list::foldl(0, l, sub), -10); + fail_unless_eq!(list::foldl(0, l, sub), -10); } #[test] fn test_find_success() { fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec([0, 1, 2]); - assert_eq!(list::find(l, match_), option::Some(2)); + fail_unless_eq!(list::find(l, match_), option::Some(2)); } #[test] @@ -238,8 +238,8 @@ mod tests { fn match_(_i: &int) -> bool { return false; } let l = from_vec([0, 1, 2]); let empty = @list::Nil::; - assert_eq!(list::find(l, match_), option::None::); - assert_eq!(list::find(empty, match_), option::None::); + fail_unless_eq!(list::find(l, match_), option::None::); + fail_unless_eq!(list::find(empty, match_), option::None::); } #[test] @@ -247,8 +247,8 @@ mod tests { fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec([0, 1, 2]); let empty = @list::Nil::; - assert_eq!(list::any(l, match_), true); - assert_eq!(list::any(empty, match_), false); + fail_unless_eq!(list::any(l, match_), true); + fail_unless_eq!(list::any(empty, match_), false); } #[test] @@ -265,8 +265,8 @@ mod tests { fn test_len() { let l = from_vec([0, 1, 2]); let empty = @list::Nil::; - assert_eq!(list::len(l), 3u); - assert_eq!(list::len(empty), 0u); + fail_unless_eq!(list::len(l), 3u); + fail_unless_eq!(list::len(empty), 0u); } #[test] diff --git a/src/libcollections/lru_cache.rs b/src/libcollections/lru_cache.rs index b33f0278b91c6..0c21d3767612e 100644 --- a/src/libcollections/lru_cache.rs +++ b/src/libcollections/lru_cache.rs @@ -24,11 +24,11 @@ //! cache.put(2, 20); //! cache.put(3, 30); //! fail_unless!(cache.get(&1).is_none()); -//! assert_eq!(*cache.get(&2).unwrap(), 20); -//! assert_eq!(*cache.get(&3).unwrap(), 30); +//! fail_unless_eq!(*cache.get(&2).unwrap(), 20); +//! fail_unless_eq!(*cache.get(&3).unwrap(), 30); //! //! cache.put(2, 22); -//! assert_eq!(*cache.get(&2).unwrap(), 22); +//! fail_unless_eq!(*cache.get(&2).unwrap(), 22); //! //! cache.put(6, 60); //! fail_unless!(cache.get(&3).is_none()); @@ -279,7 +279,7 @@ mod tests { fn assert_opt_eq(opt: Option<&V>, v: V) { fail_unless!(opt.is_some()); - assert_eq!(opt.unwrap(), &v); + fail_unless_eq!(opt.unwrap(), &v); } #[test] @@ -289,7 +289,7 @@ mod tests { cache.put(2, 20); assert_opt_eq(cache.get(&1), 10); assert_opt_eq(cache.get(&2), 20); - assert_eq!(cache.len(), 2); + fail_unless_eq!(cache.len(), 2); } #[test] @@ -298,7 +298,7 @@ mod tests { cache.put(~"1", ~[10, 10]); cache.put(~"1", ~[10, 19]); assert_opt_eq(cache.get(&~"1"), ~[10, 19]); - assert_eq!(cache.len(), 1); + fail_unless_eq!(cache.len(), 1); } #[test] @@ -318,23 +318,23 @@ mod tests { let mut cache: LruCache = LruCache::new(2); cache.put(1, 10); cache.put(2, 20); - assert_eq!(cache.len(), 2); + fail_unless_eq!(cache.len(), 2); let opt1 = cache.pop(&1); fail_unless!(opt1.is_some()); - assert_eq!(opt1.unwrap(), 10); + fail_unless_eq!(opt1.unwrap(), 10); fail_unless!(cache.get(&1).is_none()); - assert_eq!(cache.len(), 1); + fail_unless_eq!(cache.len(), 1); } #[test] fn test_change_capacity() { let mut cache: LruCache = LruCache::new(2); - assert_eq!(cache.capacity(), 2); + fail_unless_eq!(cache.capacity(), 2); cache.put(1, 10); cache.put(2, 20); cache.change_capacity(1); fail_unless!(cache.get(&1).is_none()); - assert_eq!(cache.capacity(), 1); + fail_unless_eq!(cache.capacity(), 1); } #[test] @@ -343,15 +343,15 @@ mod tests { cache.put(1, 10); cache.put(2, 20); cache.put(3, 30); - assert_eq!(cache.to_str(), ~"{3: 30, 2: 20, 1: 10}"); + fail_unless_eq!(cache.to_str(), ~"{3: 30, 2: 20, 1: 10}"); cache.put(2, 22); - assert_eq!(cache.to_str(), ~"{2: 22, 3: 30, 1: 10}"); + fail_unless_eq!(cache.to_str(), ~"{2: 22, 3: 30, 1: 10}"); cache.put(6, 60); - assert_eq!(cache.to_str(), ~"{6: 60, 2: 22, 3: 30}"); + fail_unless_eq!(cache.to_str(), ~"{6: 60, 2: 22, 3: 30}"); cache.get(&3); - assert_eq!(cache.to_str(), ~"{3: 30, 6: 60, 2: 22}"); + fail_unless_eq!(cache.to_str(), ~"{3: 30, 6: 60, 2: 22}"); cache.change_capacity(2); - assert_eq!(cache.to_str(), ~"{3: 30, 6: 60}"); + fail_unless_eq!(cache.to_str(), ~"{3: 30, 6: 60}"); } #[test] @@ -362,6 +362,6 @@ mod tests { cache.clear(); fail_unless!(cache.get(&1).is_none()); fail_unless!(cache.get(&2).is_none()); - assert_eq!(cache.to_str(), ~"{}"); + fail_unless_eq!(cache.to_str(), ~"{}"); } } diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 5005d5cfce30a..e5c7dbaa3eba3 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -225,7 +225,7 @@ mod tests { let pq = PriorityQueue::from_vec(data); let mut i = 0; for el in pq.iter() { - assert_eq!(*el, iterout[i]); + fail_unless_eq!(*el, iterout[i]); i += 1; } } @@ -237,81 +237,81 @@ mod tests { sorted.sort(); let mut heap = PriorityQueue::from_vec(data); while !heap.is_empty() { - assert_eq!(heap.top(), sorted.last().unwrap()); - assert_eq!(heap.pop(), sorted.pop().unwrap()); + fail_unless_eq!(heap.top(), sorted.last().unwrap()); + fail_unless_eq!(heap.pop(), sorted.pop().unwrap()); } } #[test] fn test_push() { let mut heap = PriorityQueue::from_vec(~[2, 4, 9]); - assert_eq!(heap.len(), 3); + fail_unless_eq!(heap.len(), 3); fail_unless!(*heap.top() == 9); heap.push(11); - assert_eq!(heap.len(), 4); + fail_unless_eq!(heap.len(), 4); fail_unless!(*heap.top() == 11); heap.push(5); - assert_eq!(heap.len(), 5); + fail_unless_eq!(heap.len(), 5); fail_unless!(*heap.top() == 11); heap.push(27); - assert_eq!(heap.len(), 6); + fail_unless_eq!(heap.len(), 6); fail_unless!(*heap.top() == 27); heap.push(3); - assert_eq!(heap.len(), 7); + fail_unless_eq!(heap.len(), 7); fail_unless!(*heap.top() == 27); heap.push(103); - assert_eq!(heap.len(), 8); + fail_unless_eq!(heap.len(), 8); fail_unless!(*heap.top() == 103); } #[test] fn test_push_unique() { let mut heap = PriorityQueue::from_vec(~[~2, ~4, ~9]); - assert_eq!(heap.len(), 3); + fail_unless_eq!(heap.len(), 3); fail_unless!(*heap.top() == ~9); heap.push(~11); - assert_eq!(heap.len(), 4); + fail_unless_eq!(heap.len(), 4); fail_unless!(*heap.top() == ~11); heap.push(~5); - assert_eq!(heap.len(), 5); + fail_unless_eq!(heap.len(), 5); fail_unless!(*heap.top() == ~11); heap.push(~27); - assert_eq!(heap.len(), 6); + fail_unless_eq!(heap.len(), 6); fail_unless!(*heap.top() == ~27); heap.push(~3); - assert_eq!(heap.len(), 7); + fail_unless_eq!(heap.len(), 7); fail_unless!(*heap.top() == ~27); heap.push(~103); - assert_eq!(heap.len(), 8); + fail_unless_eq!(heap.len(), 8); fail_unless!(*heap.top() == ~103); } #[test] fn test_push_pop() { let mut heap = PriorityQueue::from_vec(~[5, 5, 2, 1, 3]); - assert_eq!(heap.len(), 5); - assert_eq!(heap.push_pop(6), 6); - assert_eq!(heap.len(), 5); - assert_eq!(heap.push_pop(0), 5); - assert_eq!(heap.len(), 5); - assert_eq!(heap.push_pop(4), 5); - assert_eq!(heap.len(), 5); - assert_eq!(heap.push_pop(1), 4); - assert_eq!(heap.len(), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.push_pop(6), 6); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.push_pop(0), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.push_pop(4), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.push_pop(1), 4); + fail_unless_eq!(heap.len(), 5); } #[test] fn test_replace() { let mut heap = PriorityQueue::from_vec(~[5, 5, 2, 1, 3]); - assert_eq!(heap.len(), 5); - assert_eq!(heap.replace(6), 5); - assert_eq!(heap.len(), 5); - assert_eq!(heap.replace(0), 6); - assert_eq!(heap.len(), 5); - assert_eq!(heap.replace(4), 5); - assert_eq!(heap.len(), 5); - assert_eq!(heap.replace(1), 4); - assert_eq!(heap.len(), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.replace(6), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.replace(0), 6); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.replace(4), 5); + fail_unless_eq!(heap.len(), 5); + fail_unless_eq!(heap.replace(1), 4); + fail_unless_eq!(heap.len(), 5); } fn check_to_vec(mut data: ~[int]) { @@ -320,8 +320,8 @@ mod tests { v.sort(); data.sort(); - assert_eq!(v, data); - assert_eq!(heap.to_sorted_vec(), data); + fail_unless_eq!(v, data); + fail_unless_eq!(heap.to_sorted_vec(), data); } #[test] @@ -381,7 +381,7 @@ mod tests { let mut q: PriorityQueue = xs.rev_iter().map(|&x| x).collect(); for &x in xs.iter() { - assert_eq!(q.pop(), x); + fail_unless_eq!(q.pop(), x); } } } diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 2aafed97abc0f..1a023328f1fef 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -336,7 +336,7 @@ impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {} /// Grow is only called on full elts, so nelts is also len(elts), unlike /// elsewhere. fn grow(nelts: uint, loptr: &mut uint, elts: &mut ~[Option]) { - assert_eq!(nelts, elts.len()); + fail_unless_eq!(nelts, elts.len()); let lo = *loptr; let newlen = nelts * 2; elts.reserve(newlen); @@ -441,46 +441,46 @@ mod tests { #[test] fn test_simple() { let mut d = RingBuf::new(); - assert_eq!(d.len(), 0u); + fail_unless_eq!(d.len(), 0u); d.push_front(17); d.push_front(42); d.push_back(137); - assert_eq!(d.len(), 3u); + fail_unless_eq!(d.len(), 3u); d.push_back(137); - assert_eq!(d.len(), 4u); + fail_unless_eq!(d.len(), 4u); debug!("{:?}", d.front()); - assert_eq!(*d.front().unwrap(), 42); + fail_unless_eq!(*d.front().unwrap(), 42); debug!("{:?}", d.back()); - assert_eq!(*d.back().unwrap(), 137); + fail_unless_eq!(*d.back().unwrap(), 137); let mut i = d.pop_front(); debug!("{:?}", i); - assert_eq!(i, Some(42)); + fail_unless_eq!(i, Some(42)); i = d.pop_back(); debug!("{:?}", i); - assert_eq!(i, Some(137)); + fail_unless_eq!(i, Some(137)); i = d.pop_back(); debug!("{:?}", i); - assert_eq!(i, Some(137)); + fail_unless_eq!(i, Some(137)); i = d.pop_back(); debug!("{:?}", i); - assert_eq!(i, Some(17)); - assert_eq!(d.len(), 0u); + fail_unless_eq!(i, Some(17)); + fail_unless_eq!(d.len(), 0u); d.push_back(3); - assert_eq!(d.len(), 1u); + fail_unless_eq!(d.len(), 1u); d.push_front(2); - assert_eq!(d.len(), 2u); + fail_unless_eq!(d.len(), 2u); d.push_back(4); - assert_eq!(d.len(), 3u); + fail_unless_eq!(d.len(), 3u); d.push_front(1); - assert_eq!(d.len(), 4u); + fail_unless_eq!(d.len(), 4u); debug!("{:?}", d.get(0)); debug!("{:?}", d.get(1)); debug!("{:?}", d.get(2)); debug!("{:?}", d.get(3)); - assert_eq!(*d.get(0), 1); - assert_eq!(*d.get(1), 2); - assert_eq!(*d.get(2), 3); - assert_eq!(*d.get(3), 4); + fail_unless_eq!(*d.get(0), 1); + fail_unless_eq!(*d.get(1), 2); + fail_unless_eq!(*d.get(2), 3); + fail_unless_eq!(*d.get(3), 4); } #[test] @@ -491,63 +491,63 @@ mod tests { let d: @int = @175; let mut deq = RingBuf::new(); - assert_eq!(deq.len(), 0); + fail_unless_eq!(deq.len(), 0); deq.push_front(a); deq.push_front(b); deq.push_back(c); - assert_eq!(deq.len(), 3); + fail_unless_eq!(deq.len(), 3); deq.push_back(d); - assert_eq!(deq.len(), 4); - assert_eq!(deq.front(), Some(&b)); - assert_eq!(deq.back(), Some(&d)); - assert_eq!(deq.pop_front(), Some(b)); - assert_eq!(deq.pop_back(), Some(d)); - assert_eq!(deq.pop_back(), Some(c)); - assert_eq!(deq.pop_back(), Some(a)); - assert_eq!(deq.len(), 0); + fail_unless_eq!(deq.len(), 4); + fail_unless_eq!(deq.front(), Some(&b)); + fail_unless_eq!(deq.back(), Some(&d)); + fail_unless_eq!(deq.pop_front(), Some(b)); + fail_unless_eq!(deq.pop_back(), Some(d)); + fail_unless_eq!(deq.pop_back(), Some(c)); + fail_unless_eq!(deq.pop_back(), Some(a)); + fail_unless_eq!(deq.len(), 0); deq.push_back(c); - assert_eq!(deq.len(), 1); + fail_unless_eq!(deq.len(), 1); deq.push_front(b); - assert_eq!(deq.len(), 2); + fail_unless_eq!(deq.len(), 2); deq.push_back(d); - assert_eq!(deq.len(), 3); + fail_unless_eq!(deq.len(), 3); deq.push_front(a); - assert_eq!(deq.len(), 4); - assert_eq!(*deq.get(0), a); - assert_eq!(*deq.get(1), b); - assert_eq!(*deq.get(2), c); - assert_eq!(*deq.get(3), d); + fail_unless_eq!(deq.len(), 4); + fail_unless_eq!(*deq.get(0), a); + fail_unless_eq!(*deq.get(1), b); + fail_unless_eq!(*deq.get(2), c); + fail_unless_eq!(*deq.get(3), d); } #[cfg(test)] fn test_parameterized(a: T, b: T, c: T, d: T) { let mut deq = RingBuf::new(); - assert_eq!(deq.len(), 0); + fail_unless_eq!(deq.len(), 0); deq.push_front(a.clone()); deq.push_front(b.clone()); deq.push_back(c.clone()); - assert_eq!(deq.len(), 3); + fail_unless_eq!(deq.len(), 3); deq.push_back(d.clone()); - assert_eq!(deq.len(), 4); - assert_eq!((*deq.front().unwrap()).clone(), b.clone()); - assert_eq!((*deq.back().unwrap()).clone(), d.clone()); - assert_eq!(deq.pop_front().unwrap(), b.clone()); - assert_eq!(deq.pop_back().unwrap(), d.clone()); - assert_eq!(deq.pop_back().unwrap(), c.clone()); - assert_eq!(deq.pop_back().unwrap(), a.clone()); - assert_eq!(deq.len(), 0); + fail_unless_eq!(deq.len(), 4); + fail_unless_eq!((*deq.front().unwrap()).clone(), b.clone()); + fail_unless_eq!((*deq.back().unwrap()).clone(), d.clone()); + fail_unless_eq!(deq.pop_front().unwrap(), b.clone()); + fail_unless_eq!(deq.pop_back().unwrap(), d.clone()); + fail_unless_eq!(deq.pop_back().unwrap(), c.clone()); + fail_unless_eq!(deq.pop_back().unwrap(), a.clone()); + fail_unless_eq!(deq.len(), 0); deq.push_back(c.clone()); - assert_eq!(deq.len(), 1); + fail_unless_eq!(deq.len(), 1); deq.push_front(b.clone()); - assert_eq!(deq.len(), 2); + fail_unless_eq!(deq.len(), 2); deq.push_back(d.clone()); - assert_eq!(deq.len(), 3); + fail_unless_eq!(deq.len(), 3); deq.push_front(a.clone()); - assert_eq!(deq.len(), 4); - assert_eq!((*deq.get(0)).clone(), a.clone()); - assert_eq!((*deq.get(1)).clone(), b.clone()); - assert_eq!((*deq.get(2)).clone(), c.clone()); - assert_eq!((*deq.get(3)).clone(), d.clone()); + fail_unless_eq!(deq.len(), 4); + fail_unless_eq!((*deq.get(0)).clone(), a.clone()); + fail_unless_eq!((*deq.get(1)).clone(), b.clone()); + fail_unless_eq!((*deq.get(2)).clone(), c.clone()); + fail_unless_eq!((*deq.get(3)).clone(), d.clone()); } #[test] @@ -556,10 +556,10 @@ mod tests { for i in range(0u, 66) { deq.push_front(i); } - assert_eq!(deq.len(), 66); + fail_unless_eq!(deq.len(), 66); for i in range(0u, 66) { - assert_eq!(*deq.get(i), 65 - i); + fail_unless_eq!(*deq.get(i), 65 - i); } let mut deq = RingBuf::new(); @@ -568,7 +568,7 @@ mod tests { } for i in range(0u, 66) { - assert_eq!(*deq.get(i), i); + fail_unless_eq!(*deq.get(i), i); } } @@ -662,10 +662,10 @@ mod tests { fn test_with_capacity() { let mut d = RingBuf::with_capacity(0); d.push_back(1); - assert_eq!(d.len(), 1); + fail_unless_eq!(d.len(), 1); let mut d = RingBuf::with_capacity(50); d.push_back(1); - assert_eq!(d.len(), 1); + fail_unless_eq!(d.len(), 1); } #[test] @@ -673,11 +673,11 @@ mod tests { let mut d = RingBuf::new(); d.push_back(0u64); d.reserve_exact(50); - assert_eq!(d.elts.capacity(), 50); + fail_unless_eq!(d.elts.capacity(), 50); let mut d = RingBuf::new(); d.push_back(0u32); d.reserve_exact(50); - assert_eq!(d.elts.capacity(), 50); + fail_unless_eq!(d.elts.capacity(), 50); } #[test] @@ -685,11 +685,11 @@ mod tests { let mut d = RingBuf::new(); d.push_back(0u64); d.reserve(50); - assert_eq!(d.elts.capacity(), 64); + fail_unless_eq!(d.elts.capacity(), 64); let mut d = RingBuf::new(); d.push_back(0u32); d.reserve(50); - assert_eq!(d.elts.capacity(), 64); + fail_unless_eq!(d.elts.capacity(), 64); } #[test] @@ -697,31 +697,31 @@ mod tests { let mut d: RingBuf = range(0, 5).collect(); d.pop_front(); d.swap(0, 3); - assert_eq!(d.iter().map(|&x|x).collect::<~[int]>(), ~[4, 2, 3, 1]); + fail_unless_eq!(d.iter().map(|&x|x).collect::<~[int]>(), ~[4, 2, 3, 1]); } #[test] fn test_iter() { let mut d = RingBuf::new(); - assert_eq!(d.iter().next(), None); - assert_eq!(d.iter().size_hint(), (0, Some(0))); + fail_unless_eq!(d.iter().next(), None); + fail_unless_eq!(d.iter().size_hint(), (0, Some(0))); for i in range(0, 5) { d.push_back(i); } - assert_eq!(d.iter().collect::<~[&int]>(), ~[&0,&1,&2,&3,&4]); + fail_unless_eq!(d.iter().collect::<~[&int]>(), ~[&0,&1,&2,&3,&4]); for i in range(6, 9) { d.push_front(i); } - assert_eq!(d.iter().collect::<~[&int]>(), ~[&8,&7,&6,&0,&1,&2,&3,&4]); + fail_unless_eq!(d.iter().collect::<~[&int]>(), ~[&8,&7,&6,&0,&1,&2,&3,&4]); let mut it = d.iter(); let mut len = d.len(); loop { match it.next() { None => break, - _ => { len -= 1; assert_eq!(it.size_hint(), (len, Some(len))) } + _ => { len -= 1; fail_unless_eq!(it.size_hint(), (len, Some(len))) } } } } @@ -729,17 +729,17 @@ mod tests { #[test] fn test_rev_iter() { let mut d = RingBuf::new(); - assert_eq!(d.rev_iter().next(), None); + fail_unless_eq!(d.rev_iter().next(), None); for i in range(0, 5) { d.push_back(i); } - assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0]); + fail_unless_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0]); for i in range(6, 9) { d.push_front(i); } - assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0,&6,&7,&8]); + fail_unless_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0,&6,&7,&8]); } #[test] @@ -750,10 +750,10 @@ mod tests { d.push_back(1); d.push_back(2); d.push_back(3); - assert_eq!(d.pop_front(), Some(1)); + fail_unless_eq!(d.pop_front(), Some(1)); d.push_back(4); - assert_eq!(d.mut_rev_iter().map(|x| *x).collect::<~[int]>(), + fail_unless_eq!(d.mut_rev_iter().map(|x| *x).collect::<~[int]>(), ~[4, 3, 2]); } @@ -767,15 +767,15 @@ mod tests { } for (i, elt) in d.mut_iter().enumerate() { - assert_eq!(*elt, 2 - i); + fail_unless_eq!(*elt, 2 - i); *elt = i; } { let mut it = d.mut_iter(); - assert_eq!(*it.next().unwrap(), 0); - assert_eq!(*it.next().unwrap(), 1); - assert_eq!(*it.next().unwrap(), 2); + fail_unless_eq!(*it.next().unwrap(), 0); + fail_unless_eq!(*it.next().unwrap(), 1); + fail_unless_eq!(*it.next().unwrap(), 2); fail_unless!(it.next().is_none()); } } @@ -790,15 +790,15 @@ mod tests { } for (i, elt) in d.mut_rev_iter().enumerate() { - assert_eq!(*elt, i); + fail_unless_eq!(*elt, i); *elt = i; } { let mut it = d.mut_rev_iter(); - assert_eq!(*it.next().unwrap(), 0); - assert_eq!(*it.next().unwrap(), 1); - assert_eq!(*it.next().unwrap(), 2); + fail_unless_eq!(*it.next().unwrap(), 0); + fail_unless_eq!(*it.next().unwrap(), 1); + fail_unless_eq!(*it.next().unwrap(), 2); fail_unless!(it.next().is_none()); } } @@ -809,14 +809,14 @@ mod tests { let v = ~[1,2,3,4,5,6,7]; let deq: RingBuf = v.iter().map(|&x| x).collect(); let u: ~[int] = deq.iter().map(|&x| x).collect(); - assert_eq!(u, v); + fail_unless_eq!(u, v); let mut seq = iter::count(0u, 2).take(256); let deq: RingBuf = seq.collect(); for (i, &x) in deq.iter().enumerate() { - assert_eq!(2*i, x); + fail_unless_eq!(2*i, x); } - assert_eq!(deq.len(), 256); + fail_unless_eq!(deq.len(), 256); } #[test] @@ -826,20 +826,20 @@ mod tests { d.push_front(42); d.push_back(137); d.push_back(137); - assert_eq!(d.len(), 4u); + fail_unless_eq!(d.len(), 4u); let mut e = d.clone(); - assert_eq!(e.len(), 4u); + fail_unless_eq!(e.len(), 4u); while !d.is_empty() { - assert_eq!(d.pop_back(), e.pop_back()); + fail_unless_eq!(d.pop_back(), e.pop_back()); } - assert_eq!(d.len(), 0u); - assert_eq!(e.len(), 0u); + fail_unless_eq!(d.len(), 0u); + fail_unless_eq!(e.len(), 0u); } #[test] fn test_eq() { let mut d = RingBuf::new(); - assert_eq!(&d, &RingBuf::with_capacity(0)); + fail_unless_eq!(&d, &RingBuf::with_capacity(0)); d.push_front(137); d.push_front(17); d.push_front(42); @@ -849,11 +849,11 @@ mod tests { e.push_back(17); e.push_back(137); e.push_back(137); - assert_eq!(&e, &d); + fail_unless_eq!(&e, &d); e.pop_back(); e.push_back(0); fail_unless!(e != d); e.clear(); - assert_eq!(e, RingBuf::new()); + fail_unless_eq!(e, RingBuf::new()); } } diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 391c5fd6d1940..4aacf98527e93 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -268,22 +268,22 @@ mod test_map { match m.find_mut(&5) { None => fail!(), Some(x) => *x = new } - assert_eq!(m.find(&5), Some(&new)); + fail_unless_eq!(m.find(&5), Some(&new)); } #[test] fn test_len() { let mut map = SmallIntMap::new(); - assert_eq!(map.len(), 0); + fail_unless_eq!(map.len(), 0); fail_unless!(map.is_empty()); fail_unless!(map.insert(5, 20)); - assert_eq!(map.len(), 1); + fail_unless_eq!(map.len(), 1); fail_unless!(!map.is_empty()); fail_unless!(map.insert(11, 12)); - assert_eq!(map.len(), 2); + fail_unless_eq!(map.len(), 2); fail_unless!(!map.is_empty()); fail_unless!(map.insert(14, 22)); - assert_eq!(map.len(), 3); + fail_unless_eq!(map.len(), 3); fail_unless!(!map.is_empty()); } @@ -322,9 +322,9 @@ mod test_map { map.update_with_key(3, 2, addMoreToCount); // check the total counts - assert_eq!(map.find(&3).unwrap(), &10); - assert_eq!(map.find(&5).unwrap(), &3); - assert_eq!(map.find(&9).unwrap(), &1); + fail_unless_eq!(map.find(&3).unwrap(), &10); + fail_unless_eq!(map.find(&5).unwrap(), &3); + fail_unless_eq!(map.find(&9).unwrap(), &1); // sadly, no sevens were counted fail_unless!(map.find(&7).is_none()); @@ -333,17 +333,17 @@ mod test_map { #[test] fn test_swap() { let mut m = SmallIntMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + fail_unless_eq!(m.swap(1, 2), None); + fail_unless_eq!(m.swap(1, 3), Some(2)); + fail_unless_eq!(m.swap(1, 4), Some(3)); } #[test] fn test_pop() { let mut m = SmallIntMap::new(); m.insert(1, 2); - assert_eq!(m.pop(&1), Some(2)); - assert_eq!(m.pop(&1), None); + fail_unless_eq!(m.pop(&1), Some(2)); + fail_unless_eq!(m.pop(&1), None); } #[test] @@ -357,17 +357,17 @@ mod test_map { fail_unless!(m.insert(10, 11)); let mut it = m.iter(); - assert_eq!(it.size_hint(), (0, Some(11))); - assert_eq!(it.next().unwrap(), (0, &1)); - assert_eq!(it.size_hint(), (0, Some(10))); - assert_eq!(it.next().unwrap(), (1, &2)); - assert_eq!(it.size_hint(), (0, Some(9))); - assert_eq!(it.next().unwrap(), (3, &5)); - assert_eq!(it.size_hint(), (0, Some(7))); - assert_eq!(it.next().unwrap(), (6, &10)); - assert_eq!(it.size_hint(), (0, Some(4))); - assert_eq!(it.next().unwrap(), (10, &11)); - assert_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.size_hint(), (0, Some(11))); + fail_unless_eq!(it.next().unwrap(), (0, &1)); + fail_unless_eq!(it.size_hint(), (0, Some(10))); + fail_unless_eq!(it.next().unwrap(), (1, &2)); + fail_unless_eq!(it.size_hint(), (0, Some(9))); + fail_unless_eq!(it.next().unwrap(), (3, &5)); + fail_unless_eq!(it.size_hint(), (0, Some(7))); + fail_unless_eq!(it.next().unwrap(), (6, &10)); + fail_unless_eq!(it.size_hint(), (0, Some(4))); + fail_unless_eq!(it.next().unwrap(), (10, &11)); + fail_unless_eq!(it.size_hint(), (0, Some(0))); fail_unless!(it.next().is_none()); } @@ -381,10 +381,10 @@ mod test_map { fail_unless!(m.insert(6, 10)); fail_unless!(m.insert(10, 11)); - assert_eq!(m.iter().size_hint(), (0, Some(11))); - assert_eq!(m.rev_iter().size_hint(), (0, Some(11))); - assert_eq!(m.mut_iter().size_hint(), (0, Some(11))); - assert_eq!(m.mut_rev_iter().size_hint(), (0, Some(11))); + fail_unless_eq!(m.iter().size_hint(), (0, Some(11))); + fail_unless_eq!(m.rev_iter().size_hint(), (0, Some(11))); + fail_unless_eq!(m.mut_iter().size_hint(), (0, Some(11))); + fail_unless_eq!(m.mut_rev_iter().size_hint(), (0, Some(11))); } #[test] @@ -402,11 +402,11 @@ mod test_map { } let mut it = m.iter(); - assert_eq!(it.next().unwrap(), (0, &1)); - assert_eq!(it.next().unwrap(), (1, &3)); - assert_eq!(it.next().unwrap(), (3, &8)); - assert_eq!(it.next().unwrap(), (6, &16)); - assert_eq!(it.next().unwrap(), (10, &21)); + fail_unless_eq!(it.next().unwrap(), (0, &1)); + fail_unless_eq!(it.next().unwrap(), (1, &3)); + fail_unless_eq!(it.next().unwrap(), (3, &8)); + fail_unless_eq!(it.next().unwrap(), (6, &16)); + fail_unless_eq!(it.next().unwrap(), (10, &21)); fail_unless!(it.next().is_none()); } @@ -421,11 +421,11 @@ mod test_map { fail_unless!(m.insert(10, 11)); let mut it = m.rev_iter(); - assert_eq!(it.next().unwrap(), (10, &11)); - assert_eq!(it.next().unwrap(), (6, &10)); - assert_eq!(it.next().unwrap(), (3, &5)); - assert_eq!(it.next().unwrap(), (1, &2)); - assert_eq!(it.next().unwrap(), (0, &1)); + fail_unless_eq!(it.next().unwrap(), (10, &11)); + fail_unless_eq!(it.next().unwrap(), (6, &10)); + fail_unless_eq!(it.next().unwrap(), (3, &5)); + fail_unless_eq!(it.next().unwrap(), (1, &2)); + fail_unless_eq!(it.next().unwrap(), (0, &1)); fail_unless!(it.next().is_none()); } @@ -444,11 +444,11 @@ mod test_map { } let mut it = m.iter(); - assert_eq!(it.next().unwrap(), (0, &1)); - assert_eq!(it.next().unwrap(), (1, &3)); - assert_eq!(it.next().unwrap(), (3, &8)); - assert_eq!(it.next().unwrap(), (6, &16)); - assert_eq!(it.next().unwrap(), (10, &21)); + fail_unless_eq!(it.next().unwrap(), (0, &1)); + fail_unless_eq!(it.next().unwrap(), (1, &3)); + fail_unless_eq!(it.next().unwrap(), (3, &8)); + fail_unless_eq!(it.next().unwrap(), (6, &16)); + fail_unless_eq!(it.next().unwrap(), (10, &21)); fail_unless!(it.next().is_none()); } @@ -460,8 +460,8 @@ mod test_map { for (k, v) in m.move_iter() { fail_unless!(!called); called = true; - assert_eq!(k, 1); - assert_eq!(v, ~2); + fail_unless_eq!(k, 1); + fail_unless_eq!(v, ~2); } fail_unless!(called); m.insert(2, ~1); diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 77b80c59ffc6f..11dd4ad53a223 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1091,7 +1091,7 @@ mod test_treemap { fail_unless!(m.insert(1, 2)); fail_unless!(m.insert(5, 3)); fail_unless!(m.insert(9, 3)); - assert_eq!(m.find(&2), None); + fail_unless_eq!(m.find(&2), None); } #[test] @@ -1104,7 +1104,7 @@ mod test_treemap { match m.find_mut(&5) { None => fail!(), Some(x) => *x = new } - assert_eq!(m.find(&5), Some(&new)); + fail_unless_eq!(m.find(&5), Some(&new)); } #[test] @@ -1113,7 +1113,7 @@ mod test_treemap { fail_unless!(m.insert(5, 2)); fail_unless!(m.insert(2, 9)); fail_unless!(!m.insert(2, 11)); - assert_eq!(m.find(&2).unwrap(), &11); + fail_unless_eq!(m.find(&2).unwrap(), &11); } #[test] @@ -1142,13 +1142,13 @@ mod test_treemap { m.insert(k1.clone(), v1.clone()); m.insert(k2.clone(), v2.clone()); - assert_eq!(m.find(&k2), Some(&v2)); - assert_eq!(m.find(&k1), Some(&v1)); + fail_unless_eq!(m.find(&k2), Some(&v2)); + fail_unless_eq!(m.find(&k1), Some(&v1)); } fn check_equal(ctrl: &[(K, V)], map: &TreeMap) { - assert_eq!(ctrl.is_empty(), map.is_empty()); + fail_unless_eq!(ctrl.is_empty(), map.is_empty()); for x in ctrl.iter() { let &(ref k, ref v) = x; fail_unless!(map.find(k).unwrap() == v) @@ -1171,7 +1171,7 @@ mod test_treemap { parent: &~TreeNode) { match *node { Some(ref r) => { - assert_eq!(r.key.cmp(&parent.key), Less); + fail_unless_eq!(r.key.cmp(&parent.key), Less); fail_unless!(r.level == parent.level - 1); // left is black check_left(&r.left, r); check_right(&r.right, r, false); @@ -1185,7 +1185,7 @@ mod test_treemap { parent_red: bool) { match *node { Some(ref r) => { - assert_eq!(r.key.cmp(&parent.key), Greater); + fail_unless_eq!(r.key.cmp(&parent.key), Greater); let red = r.level == parent.level; if parent_red { fail_unless!(!red) } // no dual horizontal links // Right red or black @@ -1243,19 +1243,19 @@ mod test_treemap { fn test_len() { let mut m = TreeMap::new(); fail_unless!(m.insert(3, 6)); - assert_eq!(m.len(), 1); + fail_unless_eq!(m.len(), 1); fail_unless!(m.insert(0, 0)); - assert_eq!(m.len(), 2); + fail_unless_eq!(m.len(), 2); fail_unless!(m.insert(4, 8)); - assert_eq!(m.len(), 3); + fail_unless_eq!(m.len(), 3); fail_unless!(m.remove(&3)); - assert_eq!(m.len(), 2); + fail_unless_eq!(m.len(), 2); fail_unless!(!m.remove(&5)); - assert_eq!(m.len(), 2); + fail_unless_eq!(m.len(), 2); fail_unless!(m.insert(2, 4)); - assert_eq!(m.len(), 3); + fail_unless_eq!(m.len(), 3); fail_unless!(m.insert(1, 2)); - assert_eq!(m.len(), 4); + fail_unless_eq!(m.len(), 4); } #[test] @@ -1270,11 +1270,11 @@ mod test_treemap { let mut n = 0; for (k, v) in m.iter() { - assert_eq!(*k, n); - assert_eq!(*v, n * 2); + fail_unless_eq!(*k, n); + fail_unless_eq!(*v, n * 2); n += 1; } - assert_eq!(n, 5); + fail_unless_eq!(n, 5); } #[test] @@ -1288,17 +1288,17 @@ mod test_treemap { let mut lb_it = m.lower_bound(&i); let (&k, &v) = lb_it.next().unwrap(); let lb = i + i % 2; - assert_eq!(lb, k); - assert_eq!(lb * 2, v); + fail_unless_eq!(lb, k); + fail_unless_eq!(lb * 2, v); let mut ub_it = m.upper_bound(&i); let (&k, &v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; - assert_eq!(ub, k); - assert_eq!(ub * 2, v); + fail_unless_eq!(ub, k); + fail_unless_eq!(ub * 2, v); } let mut end_it = m.lower_bound(&199); - assert_eq!(end_it.next(), None); + fail_unless_eq!(end_it.next(), None); } #[test] @@ -1313,8 +1313,8 @@ mod test_treemap { let mut n = 4; for (k, v) in m.rev_iter() { - assert_eq!(*k, n); - assert_eq!(*v, n * 2); + fail_unless_eq!(*k, n); + fail_unless_eq!(*v, n * 2); n -= 1; } } @@ -1331,7 +1331,7 @@ mod test_treemap { } for (&k, &v) in m.iter() { - assert_eq!(v, 111 * k); + fail_unless_eq!(v, 111 * k); } } #[test] @@ -1346,7 +1346,7 @@ mod test_treemap { } for (&k, &v) in m.iter() { - assert_eq!(v, 111 * k); + fail_unless_eq!(v, 111 * k); } } @@ -1363,14 +1363,14 @@ mod test_treemap { let mut lb_it = m_lower.mut_lower_bound(&i); let (&k, v) = lb_it.next().unwrap(); let lb = i + i % 2; - assert_eq!(lb, k); + fail_unless_eq!(lb, k); *v -= k; } for i in range(0, 198) { let mut ub_it = m_upper.mut_upper_bound(&i); let (&k, v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; - assert_eq!(ub, k); + fail_unless_eq!(ub, k); *v -= k; } @@ -1450,11 +1450,11 @@ mod test_treemap { let m = m; let mut a = m.iter(); - assert_eq!(a.next().unwrap(), (&x1, &y1)); - assert_eq!(a.next().unwrap(), (&x2, &y2)); - assert_eq!(a.next().unwrap(), (&x3, &y3)); - assert_eq!(a.next().unwrap(), (&x4, &y4)); - assert_eq!(a.next().unwrap(), (&x5, &y5)); + fail_unless_eq!(a.next().unwrap(), (&x1, &y1)); + fail_unless_eq!(a.next().unwrap(), (&x2, &y2)); + fail_unless_eq!(a.next().unwrap(), (&x3, &y3)); + fail_unless_eq!(a.next().unwrap(), (&x4, &y4)); + fail_unless_eq!(a.next().unwrap(), (&x5, &y5)); fail_unless!(a.next().is_none()); @@ -1465,7 +1465,7 @@ mod test_treemap { let mut i = 0; for x in b { - assert_eq!(expected[i], x); + fail_unless_eq!(expected[i], x); i += 1; if i == 2 { @@ -1474,7 +1474,7 @@ mod test_treemap { } for x in b { - assert_eq!(expected[i], x); + fail_unless_eq!(expected[i], x); i += 1; } } @@ -1486,7 +1486,7 @@ mod test_treemap { let map: TreeMap = xs.iter().map(|&x| x).collect(); for &(k, v) in xs.iter() { - assert_eq!(map.find(&k), Some(&v)); + fail_unless_eq!(map.find(&k), Some(&v)); } } @@ -1634,7 +1634,7 @@ mod test_set { let mut n = 0; for x in m.iter() { - assert_eq!(*x, n); + fail_unless_eq!(*x, n); n += 1 } } @@ -1651,7 +1651,7 @@ mod test_set { let mut n = 4; for x in m.rev_iter() { - assert_eq!(*x, n); + fail_unless_eq!(*x, n); n -= 1; } } @@ -1678,11 +1678,11 @@ mod test_set { let mut i = 0; f(&set_a, &set_b, |x| { - assert_eq!(*x, expected[i]); + fail_unless_eq!(*x, expected[i]); i += 1; true }); - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1765,10 +1765,10 @@ mod test_set { // FIXME: #5801: this needs a type hint to compile... let result: Option<(&uint, & &'static str)> = z.next(); - assert_eq!(result.unwrap(), (&5u, & &"bar")); + fail_unless_eq!(result.unwrap(), (&5u, & &"bar")); let result: Option<(&uint, & &'static str)> = z.next(); - assert_eq!(result.unwrap(), (&11u, & &"foo")); + fail_unless_eq!(result.unwrap(), (&11u, & &"foo")); let result: Option<(&uint, & &'static str)> = z.next(); fail_unless!(result.is_none()); @@ -1777,17 +1777,17 @@ mod test_set { #[test] fn test_swap() { let mut m = TreeMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + fail_unless_eq!(m.swap(1, 2), None); + fail_unless_eq!(m.swap(1, 3), Some(2)); + fail_unless_eq!(m.swap(1, 4), Some(3)); } #[test] fn test_pop() { let mut m = TreeMap::new(); m.insert(1, 2); - assert_eq!(m.pop(&1), Some(2)); - assert_eq!(m.pop(&1), None); + fail_unless_eq!(m.pop(&1), Some(2)); + fail_unless_eq!(m.pop(&1), None); } #[test] diff --git a/src/libextra/c_vec.rs b/src/libextra/c_vec.rs index b49876b200ece..94644d841318c 100644 --- a/src/libextra/c_vec.rs +++ b/src/libextra/c_vec.rs @@ -182,9 +182,9 @@ mod tests { *cv.get_mut(3) = 8; *cv.get_mut(4) = 9; - assert_eq!(*cv.get(3), 8); - assert_eq!(*cv.get(4), 9); - assert_eq!(cv.len(), 16); + fail_unless_eq!(*cv.get(3), 8); + fail_unless_eq!(*cv.get(4), 9); + fail_unless_eq!(cv.len(), 16); } #[test] @@ -217,7 +217,7 @@ mod tests { let cv = CVec::new_with_dtor(1 as *mut int, 0, proc() { fail!("Don't run this destructor!") }); let p = cv.unwrap(); - assert_eq!(p, 1 as *mut int); + fail_unless_eq!(p, 1 as *mut int); } } diff --git a/src/libextra/json.rs b/src/libextra/json.rs index f362e62e80bab..25b77dab9b238 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -1631,51 +1631,51 @@ mod tests { #[test] fn test_write_null() { - assert_eq!(Null.to_str(), ~"null"); - assert_eq!(Null.to_pretty_str(), ~"null"); + fail_unless_eq!(Null.to_str(), ~"null"); + fail_unless_eq!(Null.to_pretty_str(), ~"null"); } #[test] fn test_write_number() { - assert_eq!(Number(3.0).to_str(), ~"3"); - assert_eq!(Number(3.0).to_pretty_str(), ~"3"); + fail_unless_eq!(Number(3.0).to_str(), ~"3"); + fail_unless_eq!(Number(3.0).to_pretty_str(), ~"3"); - assert_eq!(Number(3.1).to_str(), ~"3.1"); - assert_eq!(Number(3.1).to_pretty_str(), ~"3.1"); + fail_unless_eq!(Number(3.1).to_str(), ~"3.1"); + fail_unless_eq!(Number(3.1).to_pretty_str(), ~"3.1"); - assert_eq!(Number(-1.5).to_str(), ~"-1.5"); - assert_eq!(Number(-1.5).to_pretty_str(), ~"-1.5"); + fail_unless_eq!(Number(-1.5).to_str(), ~"-1.5"); + fail_unless_eq!(Number(-1.5).to_pretty_str(), ~"-1.5"); - assert_eq!(Number(0.5).to_str(), ~"0.5"); - assert_eq!(Number(0.5).to_pretty_str(), ~"0.5"); + fail_unless_eq!(Number(0.5).to_str(), ~"0.5"); + fail_unless_eq!(Number(0.5).to_pretty_str(), ~"0.5"); } #[test] fn test_write_str() { - assert_eq!(String(~"").to_str(), ~"\"\""); - assert_eq!(String(~"").to_pretty_str(), ~"\"\""); + fail_unless_eq!(String(~"").to_str(), ~"\"\""); + fail_unless_eq!(String(~"").to_pretty_str(), ~"\"\""); - assert_eq!(String(~"foo").to_str(), ~"\"foo\""); - assert_eq!(String(~"foo").to_pretty_str(), ~"\"foo\""); + fail_unless_eq!(String(~"foo").to_str(), ~"\"foo\""); + fail_unless_eq!(String(~"foo").to_pretty_str(), ~"\"foo\""); } #[test] fn test_write_bool() { - assert_eq!(Boolean(true).to_str(), ~"true"); - assert_eq!(Boolean(true).to_pretty_str(), ~"true"); + fail_unless_eq!(Boolean(true).to_str(), ~"true"); + fail_unless_eq!(Boolean(true).to_pretty_str(), ~"true"); - assert_eq!(Boolean(false).to_str(), ~"false"); - assert_eq!(Boolean(false).to_pretty_str(), ~"false"); + fail_unless_eq!(Boolean(false).to_str(), ~"false"); + fail_unless_eq!(Boolean(false).to_pretty_str(), ~"false"); } #[test] fn test_write_list() { - assert_eq!(List(~[]).to_str(), ~"[]"); - assert_eq!(List(~[]).to_pretty_str(), ~"[]"); + fail_unless_eq!(List(~[]).to_str(), ~"[]"); + fail_unless_eq!(List(~[]).to_pretty_str(), ~"[]"); - assert_eq!(List(~[Boolean(true)]).to_str(), ~"[true]"); - assert_eq!( + fail_unless_eq!(List(~[Boolean(true)]).to_str(), ~"[true]"); + fail_unless_eq!( List(~[Boolean(true)]).to_pretty_str(), ~"\ [\n \ @@ -1688,9 +1688,9 @@ mod tests { Null, List(~[String(~"foo\nbar"), Number(3.5)])]); - assert_eq!(longTestList.to_str(), + fail_unless_eq!(longTestList.to_str(), ~"[false,null,[\"foo\\nbar\",3.5]]"); - assert_eq!( + fail_unless_eq!( longTestList.to_pretty_str(), ~"\ [\n \ @@ -1706,14 +1706,14 @@ mod tests { #[test] fn test_write_object() { - assert_eq!(mk_object([]).to_str(), ~"{}"); - assert_eq!(mk_object([]).to_pretty_str(), ~"{}"); + fail_unless_eq!(mk_object([]).to_str(), ~"{}"); + fail_unless_eq!(mk_object([]).to_pretty_str(), ~"{}"); - assert_eq!( + fail_unless_eq!( mk_object([(~"a", Boolean(true))]).to_str(), ~"{\"a\":true}" ); - assert_eq!( + fail_unless_eq!( mk_object([(~"a", Boolean(true))]).to_pretty_str(), ~"\ {\n \ @@ -1728,7 +1728,7 @@ mod tests { ])) ]); - assert_eq!( + fail_unless_eq!( complexObj.to_str(), ~"{\ \"b\":[\ @@ -1737,7 +1737,7 @@ mod tests { ]\ }" ); - assert_eq!( + fail_unless_eq!( complexObj.to_pretty_str(), ~"\ {\n \ @@ -1762,8 +1762,8 @@ mod tests { // We can't compare the strings directly because the object fields be // printed in a different order. - assert_eq!(a.clone(), from_str(a.to_str()).unwrap()); - assert_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap()); + fail_unless_eq!(a.clone(), from_str(a.to_str()).unwrap()); + fail_unless_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap()); } fn with_str_writer(f: |&mut io::Writer|) -> ~str { @@ -1778,14 +1778,14 @@ mod tests { #[test] fn test_write_enum() { let animal = Dog; - assert_eq!( + fail_unless_eq!( with_str_writer(|wr| { let mut encoder = Encoder::new(wr); animal.encode(&mut encoder); }), ~"\"Dog\"" ); - assert_eq!( + fail_unless_eq!( with_str_writer(|wr| { let mut encoder = PrettyEncoder::new(wr); animal.encode(&mut encoder); @@ -1794,14 +1794,14 @@ mod tests { ); let animal = Frog(~"Henry", 349); - assert_eq!( + fail_unless_eq!( with_str_writer(|wr| { let mut encoder = Encoder::new(wr); animal.encode(&mut encoder); }), ~"{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}" ); - assert_eq!( + fail_unless_eq!( with_str_writer(|wr| { let mut encoder = PrettyEncoder::new(wr); animal.encode(&mut encoder); @@ -1822,14 +1822,14 @@ mod tests { let mut encoder = Encoder::new(wr); value.encode(&mut encoder); }); - assert_eq!(s, ~"\"jodhpurs\""); + fail_unless_eq!(s, ~"\"jodhpurs\""); let value = Some(~"jodhpurs"); let s = with_str_writer(|wr| { let mut encoder = PrettyEncoder::new(wr); value.encode(&mut encoder); }); - assert_eq!(s, ~"\"jodhpurs\""); + fail_unless_eq!(s, ~"\"jodhpurs\""); } #[test] @@ -1839,213 +1839,213 @@ mod tests { let mut encoder = Encoder::new(wr); value.encode(&mut encoder); }); - assert_eq!(s, ~"null"); + fail_unless_eq!(s, ~"null"); let s = with_str_writer(|wr| { let mut encoder = Encoder::new(wr); value.encode(&mut encoder); }); - assert_eq!(s, ~"null"); + fail_unless_eq!(s, ~"null"); } #[test] fn test_trailing_characters() { - assert_eq!(from_str("nulla"), + fail_unless_eq!(from_str("nulla"), Err(Error {line: 1u, col: 5u, msg: ~"trailing characters"})); - assert_eq!(from_str("truea"), + fail_unless_eq!(from_str("truea"), Err(Error {line: 1u, col: 5u, msg: ~"trailing characters"})); - assert_eq!(from_str("falsea"), + fail_unless_eq!(from_str("falsea"), Err(Error {line: 1u, col: 6u, msg: ~"trailing characters"})); - assert_eq!(from_str("1a"), + fail_unless_eq!(from_str("1a"), Err(Error {line: 1u, col: 2u, msg: ~"trailing characters"})); - assert_eq!(from_str("[]a"), + fail_unless_eq!(from_str("[]a"), Err(Error {line: 1u, col: 3u, msg: ~"trailing characters"})); - assert_eq!(from_str("{}a"), + fail_unless_eq!(from_str("{}a"), Err(Error {line: 1u, col: 3u, msg: ~"trailing characters"})); } #[test] fn test_read_identifiers() { - assert_eq!(from_str("n"), + fail_unless_eq!(from_str("n"), Err(Error {line: 1u, col: 2u, msg: ~"invalid syntax"})); - assert_eq!(from_str("nul"), + fail_unless_eq!(from_str("nul"), Err(Error {line: 1u, col: 4u, msg: ~"invalid syntax"})); - assert_eq!(from_str("t"), + fail_unless_eq!(from_str("t"), Err(Error {line: 1u, col: 2u, msg: ~"invalid syntax"})); - assert_eq!(from_str("truz"), + fail_unless_eq!(from_str("truz"), Err(Error {line: 1u, col: 4u, msg: ~"invalid syntax"})); - assert_eq!(from_str("f"), + fail_unless_eq!(from_str("f"), Err(Error {line: 1u, col: 2u, msg: ~"invalid syntax"})); - assert_eq!(from_str("faz"), + fail_unless_eq!(from_str("faz"), Err(Error {line: 1u, col: 3u, msg: ~"invalid syntax"})); - assert_eq!(from_str("null"), Ok(Null)); - assert_eq!(from_str("true"), Ok(Boolean(true))); - assert_eq!(from_str("false"), Ok(Boolean(false))); - assert_eq!(from_str(" null "), Ok(Null)); - assert_eq!(from_str(" true "), Ok(Boolean(true))); - assert_eq!(from_str(" false "), Ok(Boolean(false))); + fail_unless_eq!(from_str("null"), Ok(Null)); + fail_unless_eq!(from_str("true"), Ok(Boolean(true))); + fail_unless_eq!(from_str("false"), Ok(Boolean(false))); + fail_unless_eq!(from_str(" null "), Ok(Null)); + fail_unless_eq!(from_str(" true "), Ok(Boolean(true))); + fail_unless_eq!(from_str(" false "), Ok(Boolean(false))); } #[test] fn test_decode_identifiers() { let mut decoder = Decoder::new(from_str("null").unwrap()); let v: () = Decodable::decode(&mut decoder); - assert_eq!(v, ()); + fail_unless_eq!(v, ()); let mut decoder = Decoder::new(from_str("true").unwrap()); let v: bool = Decodable::decode(&mut decoder); - assert_eq!(v, true); + fail_unless_eq!(v, true); let mut decoder = Decoder::new(from_str("false").unwrap()); let v: bool = Decodable::decode(&mut decoder); - assert_eq!(v, false); + fail_unless_eq!(v, false); } #[test] fn test_read_number() { - assert_eq!(from_str("+"), + fail_unless_eq!(from_str("+"), Err(Error {line: 1u, col: 1u, msg: ~"invalid syntax"})); - assert_eq!(from_str("."), + fail_unless_eq!(from_str("."), Err(Error {line: 1u, col: 1u, msg: ~"invalid syntax"})); - assert_eq!(from_str("-"), + fail_unless_eq!(from_str("-"), Err(Error {line: 1u, col: 2u, msg: ~"invalid number"})); - assert_eq!(from_str("00"), + fail_unless_eq!(from_str("00"), Err(Error {line: 1u, col: 2u, msg: ~"invalid number"})); - assert_eq!(from_str("1."), + fail_unless_eq!(from_str("1."), Err(Error {line: 1u, col: 3u, msg: ~"invalid number"})); - assert_eq!(from_str("1e"), + fail_unless_eq!(from_str("1e"), Err(Error {line: 1u, col: 3u, msg: ~"invalid number"})); - assert_eq!(from_str("1e+"), + fail_unless_eq!(from_str("1e+"), Err(Error {line: 1u, col: 4u, msg: ~"invalid number"})); - assert_eq!(from_str("3"), Ok(Number(3.0))); - assert_eq!(from_str("3.1"), Ok(Number(3.1))); - assert_eq!(from_str("-1.2"), Ok(Number(-1.2))); - assert_eq!(from_str("0.4"), Ok(Number(0.4))); - assert_eq!(from_str("0.4e5"), Ok(Number(0.4e5))); - assert_eq!(from_str("0.4e+15"), Ok(Number(0.4e15))); - assert_eq!(from_str("0.4e-01"), Ok(Number(0.4e-01))); - assert_eq!(from_str(" 3 "), Ok(Number(3.0))); + fail_unless_eq!(from_str("3"), Ok(Number(3.0))); + fail_unless_eq!(from_str("3.1"), Ok(Number(3.1))); + fail_unless_eq!(from_str("-1.2"), Ok(Number(-1.2))); + fail_unless_eq!(from_str("0.4"), Ok(Number(0.4))); + fail_unless_eq!(from_str("0.4e5"), Ok(Number(0.4e5))); + fail_unless_eq!(from_str("0.4e+15"), Ok(Number(0.4e15))); + fail_unless_eq!(from_str("0.4e-01"), Ok(Number(0.4e-01))); + fail_unless_eq!(from_str(" 3 "), Ok(Number(3.0))); } #[test] fn test_decode_numbers() { let mut decoder = Decoder::new(from_str("3").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 3.0); + fail_unless_eq!(v, 3.0); let mut decoder = Decoder::new(from_str("3.1").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 3.1); + fail_unless_eq!(v, 3.1); let mut decoder = Decoder::new(from_str("-1.2").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, -1.2); + fail_unless_eq!(v, -1.2); let mut decoder = Decoder::new(from_str("0.4").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 0.4); + fail_unless_eq!(v, 0.4); let mut decoder = Decoder::new(from_str("0.4e5").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 0.4e5); + fail_unless_eq!(v, 0.4e5); let mut decoder = Decoder::new(from_str("0.4e15").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 0.4e15); + fail_unless_eq!(v, 0.4e15); let mut decoder = Decoder::new(from_str("0.4e-01").unwrap()); let v: f64 = Decodable::decode(&mut decoder); - assert_eq!(v, 0.4e-01); + fail_unless_eq!(v, 0.4e-01); } #[test] fn test_read_str() { - assert_eq!(from_str("\""), + fail_unless_eq!(from_str("\""), Err(Error {line: 1u, col: 2u, msg: ~"EOF while parsing string" })); - assert_eq!(from_str("\"lol"), + fail_unless_eq!(from_str("\"lol"), Err(Error {line: 1u, col: 5u, msg: ~"EOF while parsing string" })); - assert_eq!(from_str("\"\""), Ok(String(~""))); - assert_eq!(from_str("\"foo\""), Ok(String(~"foo"))); - assert_eq!(from_str("\"\\\"\""), Ok(String(~"\""))); - assert_eq!(from_str("\"\\b\""), Ok(String(~"\x08"))); - assert_eq!(from_str("\"\\n\""), Ok(String(~"\n"))); - assert_eq!(from_str("\"\\r\""), Ok(String(~"\r"))); - assert_eq!(from_str("\"\\t\""), Ok(String(~"\t"))); - assert_eq!(from_str(" \"foo\" "), Ok(String(~"foo"))); - assert_eq!(from_str("\"\\u12ab\""), Ok(String(~"\u12ab"))); - assert_eq!(from_str("\"\\uAB12\""), Ok(String(~"\uAB12"))); + fail_unless_eq!(from_str("\"\""), Ok(String(~""))); + fail_unless_eq!(from_str("\"foo\""), Ok(String(~"foo"))); + fail_unless_eq!(from_str("\"\\\"\""), Ok(String(~"\""))); + fail_unless_eq!(from_str("\"\\b\""), Ok(String(~"\x08"))); + fail_unless_eq!(from_str("\"\\n\""), Ok(String(~"\n"))); + fail_unless_eq!(from_str("\"\\r\""), Ok(String(~"\r"))); + fail_unless_eq!(from_str("\"\\t\""), Ok(String(~"\t"))); + fail_unless_eq!(from_str(" \"foo\" "), Ok(String(~"foo"))); + fail_unless_eq!(from_str("\"\\u12ab\""), Ok(String(~"\u12ab"))); + fail_unless_eq!(from_str("\"\\uAB12\""), Ok(String(~"\uAB12"))); } #[test] fn test_decode_str() { let mut decoder = Decoder::new(from_str("\"\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~""); + fail_unless_eq!(v, ~""); let mut decoder = Decoder::new(from_str("\"foo\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"foo"); + fail_unless_eq!(v, ~"foo"); let mut decoder = Decoder::new(from_str("\"\\\"\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\""); + fail_unless_eq!(v, ~"\""); let mut decoder = Decoder::new(from_str("\"\\b\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\x08"); + fail_unless_eq!(v, ~"\x08"); let mut decoder = Decoder::new(from_str("\"\\n\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\n"); + fail_unless_eq!(v, ~"\n"); let mut decoder = Decoder::new(from_str("\"\\r\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\r"); + fail_unless_eq!(v, ~"\r"); let mut decoder = Decoder::new(from_str("\"\\t\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\t"); + fail_unless_eq!(v, ~"\t"); let mut decoder = Decoder::new(from_str("\"\\u12ab\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\u12ab"); + fail_unless_eq!(v, ~"\u12ab"); let mut decoder = Decoder::new(from_str("\"\\uAB12\"").unwrap()); let v: ~str = Decodable::decode(&mut decoder); - assert_eq!(v, ~"\uAB12"); + fail_unless_eq!(v, ~"\uAB12"); } #[test] fn test_read_list() { - assert_eq!(from_str("["), + fail_unless_eq!(from_str("["), Err(Error {line: 1u, col: 2u, msg: ~"EOF while parsing value"})); - assert_eq!(from_str("[1"), + fail_unless_eq!(from_str("[1"), Err(Error {line: 1u, col: 3u, msg: ~"EOF while parsing list"})); - assert_eq!(from_str("[1,"), + fail_unless_eq!(from_str("[1,"), Err(Error {line: 1u, col: 4u, msg: ~"EOF while parsing value"})); - assert_eq!(from_str("[1,]"), + fail_unless_eq!(from_str("[1,]"), Err(Error {line: 1u, col: 4u, msg: ~"invalid syntax"})); - assert_eq!(from_str("[6 7]"), + fail_unless_eq!(from_str("[6 7]"), Err(Error {line: 1u, col: 4u, msg: ~"expected `,` or `]`"})); - assert_eq!(from_str("[]"), Ok(List(~[]))); - assert_eq!(from_str("[ ]"), Ok(List(~[]))); - assert_eq!(from_str("[true]"), Ok(List(~[Boolean(true)]))); - assert_eq!(from_str("[ false ]"), Ok(List(~[Boolean(false)]))); - assert_eq!(from_str("[null]"), Ok(List(~[Null]))); - assert_eq!(from_str("[3, 1]"), + fail_unless_eq!(from_str("[]"), Ok(List(~[]))); + fail_unless_eq!(from_str("[ ]"), Ok(List(~[]))); + fail_unless_eq!(from_str("[true]"), Ok(List(~[Boolean(true)]))); + fail_unless_eq!(from_str("[ false ]"), Ok(List(~[Boolean(false)]))); + fail_unless_eq!(from_str("[null]"), Ok(List(~[Null]))); + fail_unless_eq!(from_str("[3, 1]"), Ok(List(~[Number(3.0), Number(1.0)]))); - assert_eq!(from_str("\n[3, 2]\n"), + fail_unless_eq!(from_str("\n[3, 2]\n"), Ok(List(~[Number(3.0), Number(2.0)]))); - assert_eq!(from_str("[2, [4, 1]]"), + fail_unless_eq!(from_str("[2, [4, 1]]"), Ok(List(~[Number(2.0), List(~[Number(4.0), Number(1.0)])]))); } @@ -2053,99 +2053,99 @@ mod tests { fn test_decode_list() { let mut decoder = Decoder::new(from_str("[]").unwrap()); let v: ~[()] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[]); + fail_unless_eq!(v, ~[]); let mut decoder = Decoder::new(from_str("[null]").unwrap()); let v: ~[()] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[()]); + fail_unless_eq!(v, ~[()]); let mut decoder = Decoder::new(from_str("[true]").unwrap()); let v: ~[bool] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[true]); + fail_unless_eq!(v, ~[true]); let mut decoder = Decoder::new(from_str("[true]").unwrap()); let v: ~[bool] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[true]); + fail_unless_eq!(v, ~[true]); let mut decoder = Decoder::new(from_str("[3, 1]").unwrap()); let v: ~[int] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[3, 1]); + fail_unless_eq!(v, ~[3, 1]); let mut decoder = Decoder::new(from_str("[[3], [1, 2]]").unwrap()); let v: ~[~[uint]] = Decodable::decode(&mut decoder); - assert_eq!(v, ~[~[3], ~[1, 2]]); + fail_unless_eq!(v, ~[~[3], ~[1, 2]]); } #[test] fn test_read_object() { - assert_eq!(from_str("{"), + fail_unless_eq!(from_str("{"), Err(Error { line: 1u, col: 2u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{ "), + fail_unless_eq!(from_str("{ "), Err(Error { line: 1u, col: 3u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{1"), + fail_unless_eq!(from_str("{1"), Err(Error { line: 1u, col: 2u, msg: ~"key must be a string"})); - assert_eq!(from_str("{ \"a\""), + fail_unless_eq!(from_str("{ \"a\""), Err(Error { line: 1u, col: 6u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{\"a\""), + fail_unless_eq!(from_str("{\"a\""), Err(Error { line: 1u, col: 5u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{\"a\" "), + fail_unless_eq!(from_str("{\"a\" "), Err(Error { line: 1u, col: 6u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{\"a\" 1"), + fail_unless_eq!(from_str("{\"a\" 1"), Err(Error {line: 1u, col: 6u, msg: ~"expected `:`"})); - assert_eq!(from_str("{\"a\":"), + fail_unless_eq!(from_str("{\"a\":"), Err(Error {line: 1u, col: 6u, msg: ~"EOF while parsing value"})); - assert_eq!(from_str("{\"a\":1"), + fail_unless_eq!(from_str("{\"a\":1"), Err(Error { line: 1u, col: 7u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{\"a\":1 1"), + fail_unless_eq!(from_str("{\"a\":1 1"), Err(Error {line: 1u, col: 8u, msg: ~"expected `,` or `}`"})); - assert_eq!(from_str("{\"a\":1,"), + fail_unless_eq!(from_str("{\"a\":1,"), Err(Error { line: 1u, col: 8u, msg: ~"EOF while parsing object"})); - assert_eq!(from_str("{}").unwrap(), mk_object([])); - assert_eq!(from_str("{\"a\": 3}").unwrap(), + fail_unless_eq!(from_str("{}").unwrap(), mk_object([])); + fail_unless_eq!(from_str("{\"a\": 3}").unwrap(), mk_object([(~"a", Number(3.0))])); - assert_eq!(from_str( + fail_unless_eq!(from_str( "{ \"a\": null, \"b\" : true }").unwrap(), mk_object([ (~"a", Null), (~"b", Boolean(true))])); - assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(), + fail_unless_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(), mk_object([ (~"a", Null), (~"b", Boolean(true))])); - assert_eq!(from_str( + fail_unless_eq!(from_str( "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(), mk_object([ (~"a", Number(1.0)), (~"b", List(~[Boolean(true)])) ])); - assert_eq!(from_str( + fail_unless_eq!(from_str( ~"{" + "\"a\": 1.0, " + "\"b\": [" + @@ -2175,7 +2175,7 @@ mod tests { }"; let mut decoder = Decoder::new(from_str(s).unwrap()); let v: Outer = Decodable::decode(&mut decoder); - assert_eq!( + fail_unless_eq!( v, Outer { inner: ~[ @@ -2189,23 +2189,23 @@ mod tests { fn test_decode_option() { let mut decoder = Decoder::new(from_str("null").unwrap()); let value: Option<~str> = Decodable::decode(&mut decoder); - assert_eq!(value, None); + fail_unless_eq!(value, None); let mut decoder = Decoder::new(from_str("\"jodhpurs\"").unwrap()); let value: Option<~str> = Decodable::decode(&mut decoder); - assert_eq!(value, Some(~"jodhpurs")); + fail_unless_eq!(value, Some(~"jodhpurs")); } #[test] fn test_decode_enum() { let mut decoder = Decoder::new(from_str("\"Dog\"").unwrap()); let value: Animal = Decodable::decode(&mut decoder); - assert_eq!(value, Dog); + fail_unless_eq!(value, Dog); let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"; let mut decoder = Decoder::new(from_str(s).unwrap()); let value: Animal = Decodable::decode(&mut decoder); - assert_eq!(value, Frog(~"Henry", 349)); + fail_unless_eq!(value, Frog(~"Henry", 349)); } #[test] @@ -2214,13 +2214,13 @@ mod tests { let mut decoder = Decoder::new(from_str(s).unwrap()); let mut map: TreeMap<~str, Animal> = Decodable::decode(&mut decoder); - assert_eq!(map.pop(&~"a"), Some(Dog)); - assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349))); + fail_unless_eq!(map.pop(&~"a"), Some(Dog)); + fail_unless_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349))); } #[test] fn test_multiline_errors() { - assert_eq!(from_str("{\n \"foo\":\n \"bar\""), + fail_unless_eq!(from_str("{\n \"foo\":\n \"bar\""), Err(Error { line: 3u, col: 8u, diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index 8b4d6945a29d5..8ec7769f96eb7 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -462,11 +462,11 @@ mod tests { write_boxplot(w, &summ2, 50).unwrap(); (write!(w, "\n")).unwrap(); - assert_eq!(summ.sum, summ2.sum); - assert_eq!(summ.min, summ2.min); - assert_eq!(summ.max, summ2.max); - assert_eq!(summ.mean, summ2.mean); - assert_eq!(summ.median, summ2.median); + fail_unless_eq!(summ.sum, summ2.sum); + fail_unless_eq!(summ.min, summ2.min); + fail_unless_eq!(summ.max, summ2.max); + fail_unless_eq!(summ.mean, summ2.mean); + fail_unless_eq!(summ.median, summ2.median); // We needed a few more digits to get exact equality on these // but they're within float epsilon, which is 1.0e-6. @@ -476,8 +476,8 @@ mod tests { assert_approx_eq!(summ.median_abs_dev, summ2.median_abs_dev); assert_approx_eq!(summ.median_abs_dev_pct, summ2.median_abs_dev_pct); - assert_eq!(summ.quartiles, summ2.quartiles); - assert_eq!(summ.iqr, summ2.iqr); + fail_unless_eq!(summ.quartiles, summ2.quartiles); + fail_unless_eq!(summ.iqr, summ2.iqr); } #[test] @@ -1005,7 +1005,7 @@ mod tests { let mut m = MemWriter::new(); write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap(); let out = str::from_utf8_owned(m.unwrap()).unwrap(); - assert_eq!(out, expected); + fail_unless_eq!(out, expected); } t(&Summary::new([-2.0, -1.0]), ~"-2 |[------******#*****---]| -1"); @@ -1015,11 +1015,11 @@ mod tests { } #[test] fn test_sum_f64s() { - assert_eq!([0.5, 3.2321, 1.5678].sum(), 5.2999); + fail_unless_eq!([0.5, 3.2321, 1.5678].sum(), 5.2999); } #[test] fn test_sum_f64_between_ints_that_sum_to_0() { - assert_eq!([1e30, 1.2, -1e30].sum(), 1.2); + fail_unless_eq!([1e30, 1.2, -1e30].sum(), 1.2); } } diff --git a/src/libextra/url.rs b/src/libextra/url.rs index b1c85ddef6b95..299f7ef50fb8b 100644 --- a/src/libextra/url.rs +++ b/src/libextra/url.rs @@ -873,53 +873,53 @@ impl IterBytes for Path { #[test] fn test_split_char_first() { let (u,v) = split_char_first("hello, sweet world", ','); - assert_eq!(u, ~"hello"); - assert_eq!(v, ~" sweet world"); + fail_unless_eq!(u, ~"hello"); + fail_unless_eq!(v, ~" sweet world"); let (u,v) = split_char_first("hello sweet world", ','); - assert_eq!(u, ~"hello sweet world"); - assert_eq!(v, ~""); + fail_unless_eq!(u, ~"hello sweet world"); + fail_unless_eq!(v, ~""); } #[test] fn test_get_authority() { let (u, h, p, r) = get_authority( "//user:pass@rust-lang.org/something").unwrap(); - assert_eq!(u, Some(UserInfo::new(~"user", Some(~"pass")))); - assert_eq!(h, ~"rust-lang.org"); + fail_unless_eq!(u, Some(UserInfo::new(~"user", Some(~"pass")))); + fail_unless_eq!(h, ~"rust-lang.org"); fail_unless!(p.is_none()); - assert_eq!(r, ~"/something"); + fail_unless_eq!(r, ~"/something"); let (u, h, p, r) = get_authority( "//rust-lang.org:8000?something").unwrap(); fail_unless!(u.is_none()); - assert_eq!(h, ~"rust-lang.org"); - assert_eq!(p, Some(~"8000")); - assert_eq!(r, ~"?something"); + fail_unless_eq!(h, ~"rust-lang.org"); + fail_unless_eq!(p, Some(~"8000")); + fail_unless_eq!(r, ~"?something"); let (u, h, p, r) = get_authority( "//rust-lang.org#blah").unwrap(); fail_unless!(u.is_none()); - assert_eq!(h, ~"rust-lang.org"); + fail_unless_eq!(h, ~"rust-lang.org"); fail_unless!(p.is_none()); - assert_eq!(r, ~"#blah"); + fail_unless_eq!(r, ~"#blah"); // ipv6 tests let (_, h, _, _) = get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap(); - assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + fail_unless_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); let (_, h, p, _) = get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap(); - assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); - assert_eq!(p, Some(~"8000")); + fail_unless_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + fail_unless_eq!(p, Some(~"8000")); let (u, h, p, _) = get_authority( "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah" ).unwrap(); - assert_eq!(u, Some(UserInfo::new(~"us", Some(~"p")))); - assert_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); - assert_eq!(p, Some(~"8000")); + fail_unless_eq!(u, Some(UserInfo::new(~"us", Some(~"p")))); + fail_unless_eq!(h, ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + fail_unless_eq!(p, Some(~"8000")); // invalid authorities; fail_unless!(get_authority("//user:pass@rust-lang:something").is_err()); @@ -931,22 +931,22 @@ fn test_get_authority() { // these parse as empty, because they don't start with '//' let (_, h, _, _) = get_authority("user:pass@rust-lang").unwrap(); - assert_eq!(h, ~""); + fail_unless_eq!(h, ~""); let (_, h, _, _) = get_authority("rust-lang.org").unwrap(); - assert_eq!(h, ~""); + fail_unless_eq!(h, ~""); } #[test] fn test_get_path() { let (p, r) = get_path("/something+%20orother", true).unwrap(); - assert_eq!(p, ~"/something+ orother"); - assert_eq!(r, ~""); + fail_unless_eq!(p, ~"/something+ orother"); + fail_unless_eq!(r, ~""); let (p, r) = get_path("test@email.com#fragment", false).unwrap(); - assert_eq!(p, ~"test@email.com"); - assert_eq!(r, ~"#fragment"); + fail_unless_eq!(p, ~"test@email.com"); + fail_unless_eq!(r, ~"#fragment"); let (p, r) = get_path("/gen/:addr=?q=v", false).unwrap(); - assert_eq!(p, ~"/gen/:addr="); - assert_eq!(r, ~"?q=v"); + fail_unless_eq!(p, ~"/gen/:addr="); + fail_unless_eq!(r, ~"?q=v"); //failure cases fail_unless!(get_path("something?q", true).is_err()); @@ -965,13 +965,13 @@ mod tests { let up = from_str(url); let u = up.unwrap(); - assert_eq!(&u.scheme, &~"http"); - assert_eq!(&u.user, &Some(UserInfo::new(~"user", Some(~"pass")))); - assert_eq!(&u.host, &~"rust-lang.org"); - assert_eq!(&u.port, &Some(~"8080")); - assert_eq!(&u.path, &~"/doc/~u"); - assert_eq!(&u.query, &~[(~"s", ~"v")]); - assert_eq!(&u.fragment, &Some(~"something")); + fail_unless_eq!(&u.scheme, &~"http"); + fail_unless_eq!(&u.user, &Some(UserInfo::new(~"user", Some(~"pass")))); + fail_unless_eq!(&u.host, &~"rust-lang.org"); + fail_unless_eq!(&u.port, &Some(~"8080")); + fail_unless_eq!(&u.path, &~"/doc/~u"); + fail_unless_eq!(&u.query, &~[(~"s", ~"v")]); + fail_unless_eq!(&u.fragment, &Some(~"something")); } #[test] @@ -980,9 +980,9 @@ mod tests { let up = path_from_str(path); let u = up.unwrap(); - assert_eq!(&u.path, &~"/doc/~u"); - assert_eq!(&u.query, &~[(~"s", ~"v")]); - assert_eq!(&u.fragment, &Some(~"something")); + fail_unless_eq!(&u.path, &~"/doc/~u"); + fail_unless_eq!(&u.query, &~[(~"s", ~"v")]); + fail_unless_eq!(&u.fragment, &Some(~"something")); } #[test] @@ -1004,16 +1004,16 @@ mod tests { fn test_url_host_with_port() { let urlstr = ~"scheme://host:1234"; let url = from_str(urlstr).unwrap(); - assert_eq!(&url.scheme, &~"scheme"); - assert_eq!(&url.host, &~"host"); - assert_eq!(&url.port, &Some(~"1234")); - assert_eq!(&url.path, &~""); // is empty path really correct? Other tests think so + fail_unless_eq!(&url.scheme, &~"scheme"); + fail_unless_eq!(&url.host, &~"host"); + fail_unless_eq!(&url.port, &Some(~"1234")); + fail_unless_eq!(&url.path, &~""); // is empty path really correct? Other tests think so let urlstr = ~"scheme://host:1234/"; let url = from_str(urlstr).unwrap(); - assert_eq!(&url.scheme, &~"scheme"); - assert_eq!(&url.host, &~"host"); - assert_eq!(&url.port, &Some(~"1234")); - assert_eq!(&url.path, &~"/"); + fail_unless_eq!(&url.scheme, &~"scheme"); + fail_unless_eq!(&url.host, &~"host"); + fail_unless_eq!(&url.port, &Some(~"1234")); + fail_unless_eq!(&url.path, &~"/"); } #[test] @@ -1058,62 +1058,62 @@ mod tests { #[test] fn test_full_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_userless_url_parse_and_format() { let url = ~"http://rust-lang.org/doc?s=v#something"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_queryless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc#something"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_empty_query_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?#something"; let should_be = ~"http://user:pass@rust-lang.org/doc#something"; - assert_eq!(from_str(url).unwrap().to_str(), should_be); + fail_unless_eq!(from_str(url).unwrap().to_str(), should_be); } #[test] fn test_fragmentless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?q=v"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_minimal_url_parse_and_format() { let url = ~"http://rust-lang.org/doc"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_url_with_port_parse_and_format() { let url = ~"http://rust-lang.org:80/doc"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_scheme_host_only_url_parse_and_format() { let url = ~"http://rust-lang.org"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_pathless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org?q=v#something"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_scheme_host_fragment_only_url_parse_and_format() { let url = ~"http://rust-lang.org#something"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] @@ -1135,134 +1135,134 @@ mod tests { #[test] fn test_url_without_authority() { let url = ~"mailto:test@email.com"; - assert_eq!(from_str(url).unwrap().to_str(), url); + fail_unless_eq!(from_str(url).unwrap().to_str(), url); } #[test] fn test_encode() { - assert_eq!(encode(""), ~""); - assert_eq!(encode("http://example.com"), ~"http://example.com"); - assert_eq!(encode("foo bar% baz"), ~"foo%20bar%25%20baz"); - assert_eq!(encode(" "), ~"%20"); - assert_eq!(encode("!"), ~"!"); - assert_eq!(encode("\""), ~"\""); - assert_eq!(encode("#"), ~"#"); - assert_eq!(encode("$"), ~"$"); - assert_eq!(encode("%"), ~"%25"); - assert_eq!(encode("&"), ~"&"); - assert_eq!(encode("'"), ~"%27"); - assert_eq!(encode("("), ~"("); - assert_eq!(encode(")"), ~")"); - assert_eq!(encode("*"), ~"*"); - assert_eq!(encode("+"), ~"+"); - assert_eq!(encode(","), ~","); - assert_eq!(encode("/"), ~"/"); - assert_eq!(encode(":"), ~":"); - assert_eq!(encode(";"), ~";"); - assert_eq!(encode("="), ~"="); - assert_eq!(encode("?"), ~"?"); - assert_eq!(encode("@"), ~"@"); - assert_eq!(encode("["), ~"["); - assert_eq!(encode("]"), ~"]"); + fail_unless_eq!(encode(""), ~""); + fail_unless_eq!(encode("http://example.com"), ~"http://example.com"); + fail_unless_eq!(encode("foo bar% baz"), ~"foo%20bar%25%20baz"); + fail_unless_eq!(encode(" "), ~"%20"); + fail_unless_eq!(encode("!"), ~"!"); + fail_unless_eq!(encode("\""), ~"\""); + fail_unless_eq!(encode("#"), ~"#"); + fail_unless_eq!(encode("$"), ~"$"); + fail_unless_eq!(encode("%"), ~"%25"); + fail_unless_eq!(encode("&"), ~"&"); + fail_unless_eq!(encode("'"), ~"%27"); + fail_unless_eq!(encode("("), ~"("); + fail_unless_eq!(encode(")"), ~")"); + fail_unless_eq!(encode("*"), ~"*"); + fail_unless_eq!(encode("+"), ~"+"); + fail_unless_eq!(encode(","), ~","); + fail_unless_eq!(encode("/"), ~"/"); + fail_unless_eq!(encode(":"), ~":"); + fail_unless_eq!(encode(";"), ~";"); + fail_unless_eq!(encode("="), ~"="); + fail_unless_eq!(encode("?"), ~"?"); + fail_unless_eq!(encode("@"), ~"@"); + fail_unless_eq!(encode("["), ~"["); + fail_unless_eq!(encode("]"), ~"]"); } #[test] fn test_encode_component() { - assert_eq!(encode_component(""), ~""); + fail_unless_eq!(encode_component(""), ~""); fail_unless!(encode_component("http://example.com") == ~"http%3A%2F%2Fexample.com"); fail_unless!(encode_component("foo bar% baz") == ~"foo%20bar%25%20baz"); - assert_eq!(encode_component(" "), ~"%20"); - assert_eq!(encode_component("!"), ~"%21"); - assert_eq!(encode_component("#"), ~"%23"); - assert_eq!(encode_component("$"), ~"%24"); - assert_eq!(encode_component("%"), ~"%25"); - assert_eq!(encode_component("&"), ~"%26"); - assert_eq!(encode_component("'"), ~"%27"); - assert_eq!(encode_component("("), ~"%28"); - assert_eq!(encode_component(")"), ~"%29"); - assert_eq!(encode_component("*"), ~"%2A"); - assert_eq!(encode_component("+"), ~"%2B"); - assert_eq!(encode_component(","), ~"%2C"); - assert_eq!(encode_component("/"), ~"%2F"); - assert_eq!(encode_component(":"), ~"%3A"); - assert_eq!(encode_component(";"), ~"%3B"); - assert_eq!(encode_component("="), ~"%3D"); - assert_eq!(encode_component("?"), ~"%3F"); - assert_eq!(encode_component("@"), ~"%40"); - assert_eq!(encode_component("["), ~"%5B"); - assert_eq!(encode_component("]"), ~"%5D"); + fail_unless_eq!(encode_component(" "), ~"%20"); + fail_unless_eq!(encode_component("!"), ~"%21"); + fail_unless_eq!(encode_component("#"), ~"%23"); + fail_unless_eq!(encode_component("$"), ~"%24"); + fail_unless_eq!(encode_component("%"), ~"%25"); + fail_unless_eq!(encode_component("&"), ~"%26"); + fail_unless_eq!(encode_component("'"), ~"%27"); + fail_unless_eq!(encode_component("("), ~"%28"); + fail_unless_eq!(encode_component(")"), ~"%29"); + fail_unless_eq!(encode_component("*"), ~"%2A"); + fail_unless_eq!(encode_component("+"), ~"%2B"); + fail_unless_eq!(encode_component(","), ~"%2C"); + fail_unless_eq!(encode_component("/"), ~"%2F"); + fail_unless_eq!(encode_component(":"), ~"%3A"); + fail_unless_eq!(encode_component(";"), ~"%3B"); + fail_unless_eq!(encode_component("="), ~"%3D"); + fail_unless_eq!(encode_component("?"), ~"%3F"); + fail_unless_eq!(encode_component("@"), ~"%40"); + fail_unless_eq!(encode_component("["), ~"%5B"); + fail_unless_eq!(encode_component("]"), ~"%5D"); } #[test] fn test_decode() { - assert_eq!(decode(""), ~""); - assert_eq!(decode("abc/def 123"), ~"abc/def 123"); - assert_eq!(decode("abc%2Fdef%20123"), ~"abc%2Fdef 123"); - assert_eq!(decode("%20"), ~" "); - assert_eq!(decode("%21"), ~"%21"); - assert_eq!(decode("%22"), ~"%22"); - assert_eq!(decode("%23"), ~"%23"); - assert_eq!(decode("%24"), ~"%24"); - assert_eq!(decode("%25"), ~"%"); - assert_eq!(decode("%26"), ~"%26"); - assert_eq!(decode("%27"), ~"'"); - assert_eq!(decode("%28"), ~"%28"); - assert_eq!(decode("%29"), ~"%29"); - assert_eq!(decode("%2A"), ~"%2A"); - assert_eq!(decode("%2B"), ~"%2B"); - assert_eq!(decode("%2C"), ~"%2C"); - assert_eq!(decode("%2F"), ~"%2F"); - assert_eq!(decode("%3A"), ~"%3A"); - assert_eq!(decode("%3B"), ~"%3B"); - assert_eq!(decode("%3D"), ~"%3D"); - assert_eq!(decode("%3F"), ~"%3F"); - assert_eq!(decode("%40"), ~"%40"); - assert_eq!(decode("%5B"), ~"%5B"); - assert_eq!(decode("%5D"), ~"%5D"); + fail_unless_eq!(decode(""), ~""); + fail_unless_eq!(decode("abc/def 123"), ~"abc/def 123"); + fail_unless_eq!(decode("abc%2Fdef%20123"), ~"abc%2Fdef 123"); + fail_unless_eq!(decode("%20"), ~" "); + fail_unless_eq!(decode("%21"), ~"%21"); + fail_unless_eq!(decode("%22"), ~"%22"); + fail_unless_eq!(decode("%23"), ~"%23"); + fail_unless_eq!(decode("%24"), ~"%24"); + fail_unless_eq!(decode("%25"), ~"%"); + fail_unless_eq!(decode("%26"), ~"%26"); + fail_unless_eq!(decode("%27"), ~"'"); + fail_unless_eq!(decode("%28"), ~"%28"); + fail_unless_eq!(decode("%29"), ~"%29"); + fail_unless_eq!(decode("%2A"), ~"%2A"); + fail_unless_eq!(decode("%2B"), ~"%2B"); + fail_unless_eq!(decode("%2C"), ~"%2C"); + fail_unless_eq!(decode("%2F"), ~"%2F"); + fail_unless_eq!(decode("%3A"), ~"%3A"); + fail_unless_eq!(decode("%3B"), ~"%3B"); + fail_unless_eq!(decode("%3D"), ~"%3D"); + fail_unless_eq!(decode("%3F"), ~"%3F"); + fail_unless_eq!(decode("%40"), ~"%40"); + fail_unless_eq!(decode("%5B"), ~"%5B"); + fail_unless_eq!(decode("%5D"), ~"%5D"); } #[test] fn test_decode_component() { - assert_eq!(decode_component(""), ~""); - assert_eq!(decode_component("abc/def 123"), ~"abc/def 123"); - assert_eq!(decode_component("abc%2Fdef%20123"), ~"abc/def 123"); - assert_eq!(decode_component("%20"), ~" "); - assert_eq!(decode_component("%21"), ~"!"); - assert_eq!(decode_component("%22"), ~"\""); - assert_eq!(decode_component("%23"), ~"#"); - assert_eq!(decode_component("%24"), ~"$"); - assert_eq!(decode_component("%25"), ~"%"); - assert_eq!(decode_component("%26"), ~"&"); - assert_eq!(decode_component("%27"), ~"'"); - assert_eq!(decode_component("%28"), ~"("); - assert_eq!(decode_component("%29"), ~")"); - assert_eq!(decode_component("%2A"), ~"*"); - assert_eq!(decode_component("%2B"), ~"+"); - assert_eq!(decode_component("%2C"), ~","); - assert_eq!(decode_component("%2F"), ~"/"); - assert_eq!(decode_component("%3A"), ~":"); - assert_eq!(decode_component("%3B"), ~";"); - assert_eq!(decode_component("%3D"), ~"="); - assert_eq!(decode_component("%3F"), ~"?"); - assert_eq!(decode_component("%40"), ~"@"); - assert_eq!(decode_component("%5B"), ~"["); - assert_eq!(decode_component("%5D"), ~"]"); + fail_unless_eq!(decode_component(""), ~""); + fail_unless_eq!(decode_component("abc/def 123"), ~"abc/def 123"); + fail_unless_eq!(decode_component("abc%2Fdef%20123"), ~"abc/def 123"); + fail_unless_eq!(decode_component("%20"), ~" "); + fail_unless_eq!(decode_component("%21"), ~"!"); + fail_unless_eq!(decode_component("%22"), ~"\""); + fail_unless_eq!(decode_component("%23"), ~"#"); + fail_unless_eq!(decode_component("%24"), ~"$"); + fail_unless_eq!(decode_component("%25"), ~"%"); + fail_unless_eq!(decode_component("%26"), ~"&"); + fail_unless_eq!(decode_component("%27"), ~"'"); + fail_unless_eq!(decode_component("%28"), ~"("); + fail_unless_eq!(decode_component("%29"), ~")"); + fail_unless_eq!(decode_component("%2A"), ~"*"); + fail_unless_eq!(decode_component("%2B"), ~"+"); + fail_unless_eq!(decode_component("%2C"), ~","); + fail_unless_eq!(decode_component("%2F"), ~"/"); + fail_unless_eq!(decode_component("%3A"), ~":"); + fail_unless_eq!(decode_component("%3B"), ~";"); + fail_unless_eq!(decode_component("%3D"), ~"="); + fail_unless_eq!(decode_component("%3F"), ~"?"); + fail_unless_eq!(decode_component("%40"), ~"@"); + fail_unless_eq!(decode_component("%5B"), ~"["); + fail_unless_eq!(decode_component("%5D"), ~"]"); } #[test] fn test_encode_form_urlencoded() { let mut m = HashMap::new(); - assert_eq!(encode_form_urlencoded(&m), ~""); + fail_unless_eq!(encode_form_urlencoded(&m), ~""); m.insert(~"", ~[]); m.insert(~"foo", ~[]); - assert_eq!(encode_form_urlencoded(&m), ~""); + fail_unless_eq!(encode_form_urlencoded(&m), ~""); let mut m = HashMap::new(); m.insert(~"foo", ~[~"bar", ~"123"]); - assert_eq!(encode_form_urlencoded(&m), ~"foo=bar&foo=123"); + fail_unless_eq!(encode_form_urlencoded(&m), ~"foo=bar&foo=123"); let mut m = HashMap::new(); m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]); @@ -1272,12 +1272,12 @@ mod tests { #[test] fn test_decode_form_urlencoded() { - assert_eq!(decode_form_urlencoded([]).len(), 0); + fail_unless_eq!(decode_form_urlencoded([]).len(), 0); let s = "a=1&foo+bar=abc&foo+bar=12+%3D+34".as_bytes(); let form = decode_form_urlencoded(s); - assert_eq!(form.len(), 2); - assert_eq!(form.get(&~"a"), &~[~"1"]); - assert_eq!(form.get(&~"foo bar"), &~[~"abc", ~"12 = 34"]); + fail_unless_eq!(form.len(), 2); + fail_unless_eq!(form.get(&~"a"), &~[~"1"]); + fail_unless_eq!(form.get(&~"foo bar"), &~[~"abc", ~"12 = 34"]); } } diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 1bd33a0fb8919..312a41c6382ad 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -119,7 +119,7 @@ mod tests { debug!("{} bytes deflated to {} ({:.1f}% size)", input.len(), cmp.len(), 100.0 * ((cmp.len() as f64) / (input.len() as f64))); - assert_eq!(input, out); + fail_unless_eq!(input, out); } } @@ -128,6 +128,6 @@ mod tests { let bytes = ~[1, 2, 3, 4, 5]; let deflated = deflate_bytes(bytes); let inflated = inflate_bytes(deflated); - assert_eq!(inflated, bytes); + fail_unless_eq!(inflated, bytes); } } diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 270416305dd1c..962b417fcd390 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -27,9 +27,9 @@ extern crate fourcc; fn main() { let val = fourcc!("\xC0\xFF\xEE!"); - assert_eq!(val, 0xC0FFEE21u32); + fail_unless_eq!(val, 0xC0FFEE21u32); let little_val = fourcc!("foo ", little); - assert_eq!(little_val, 0x21EEFFC0u32); + fail_unless_eq!(little_val, 0x21EEFFC0u32); } ``` diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index c5dadf123ada9..02612a5cefa3c 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -883,9 +883,9 @@ mod tests { match rs { Ok(ref m) => { fail_unless!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!(m.opt_present("t")); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => { fail!("test_reqopt failed (long arg)"); } } @@ -893,9 +893,9 @@ mod tests { match getopts(short_args, opts) { Ok(ref m) => { fail_unless!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => { fail!("test_reqopt failed (short arg)"); } } @@ -948,9 +948,9 @@ mod tests { match rs { Ok(ref m) => { fail_unless!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } @@ -958,9 +958,9 @@ mod tests { match getopts(short_args, opts) { Ok(ref m) => { fail_unless!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } @@ -1092,7 +1092,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("v"), 1); + fail_unless_eq!(m.opt_count("v"), 1); } _ => fail!() } @@ -1105,7 +1105,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("v"), 2); + fail_unless_eq!(m.opt_count("v"), 2); } _ => fail!() } @@ -1118,7 +1118,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("v"), 2); + fail_unless_eq!(m.opt_count("v"), 2); } _ => fail!() } @@ -1131,7 +1131,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 1); + fail_unless_eq!(m.opt_count("verbose"), 1); } _ => fail!() } @@ -1144,7 +1144,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 2); + fail_unless_eq!(m.opt_count("verbose"), 2); } _ => fail!() } @@ -1157,8 +1157,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert_eq!(m.opt_count("verbose"), 4); - assert_eq!(m.opt_count("v"), 4); + fail_unless_eq!(m.opt_count("verbose"), 4); + fail_unless_eq!(m.opt_count("v"), 4); } _ => fail!() } @@ -1173,9 +1173,9 @@ mod tests { match rs { Ok(ref m) => { fail_unless!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } @@ -1183,9 +1183,9 @@ mod tests { match getopts(short_args, opts) { Ok(ref m) => { fail_unless!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } @@ -1229,9 +1229,9 @@ mod tests { match rs { Ok(ref m) => { fail_unless!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("test").unwrap(), ~"20"); fail_unless!(m.opt_present("t")); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("t").unwrap(), ~"20"); let pair = m.opt_strs("test"); fail_unless!(pair[0] == ~"20"); fail_unless!(pair[1] == ~"30"); @@ -1275,10 +1275,10 @@ mod tests { Ok(ref m) => { fail_unless!(m.free[0] == ~"prog"); fail_unless!(m.free[1] == ~"free1"); - assert_eq!(m.opt_str("s").unwrap(), ~"20"); + fail_unless_eq!(m.opt_str("s").unwrap(), ~"20"); fail_unless!(m.free[2] == ~"free2"); fail_unless!((m.opt_present("flag"))); - assert_eq!(m.opt_str("long").unwrap(), ~"30"); + fail_unless_eq!(m.opt_str("long").unwrap(), ~"30"); fail_unless!((m.opt_present("f"))); let pair = m.opt_strs("m"); fail_unless!(pair[0] == ~"40"); @@ -1310,9 +1310,9 @@ mod tests { fail_unless!(!matches_single.opts_present([~"thing"])); fail_unless!(!matches_single.opts_present([])); - assert_eq!(matches_single.opts_str([~"e"]).unwrap(), ~"foo"); - assert_eq!(matches_single.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo"); - assert_eq!(matches_single.opts_str([~"encrypt", ~"e"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_single.opts_str([~"e"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_single.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_single.opts_str([~"encrypt", ~"e"]).unwrap(), ~"foo"); let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"]; let matches_both = &match getopts(args_both, opts) { @@ -1327,10 +1327,10 @@ mod tests { fail_unless!(!matches_both.opts_present([~"thing"])); fail_unless!(!matches_both.opts_present([])); - assert_eq!(matches_both.opts_str([~"e"]).unwrap(), ~"foo"); - assert_eq!(matches_both.opts_str([~"encrypt"]).unwrap(), ~"foo"); - assert_eq!(matches_both.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo"); - assert_eq!(matches_both.opts_str([~"encrypt", ~"e"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_both.opts_str([~"e"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_both.opts_str([~"encrypt"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_both.opts_str([~"e", ~"encrypt"]).unwrap(), ~"foo"); + fail_unless_eq!(matches_both.opts_str([~"encrypt", ~"e"]).unwrap(), ~"foo"); } #[test] @@ -1343,9 +1343,9 @@ mod tests { result::Err(_) => fail!() }; fail_unless!(matches.opts_present([~"L"])); - assert_eq!(matches.opts_str([~"L"]).unwrap(), ~"foo"); + fail_unless_eq!(matches.opts_str([~"L"]).unwrap(), ~"foo"); fail_unless!(matches.opts_present([~"M"])); - assert_eq!(matches.opts_str([~"M"]).unwrap(), ~"."); + fail_unless_eq!(matches.opts_str([~"M"]).unwrap(), ~"."); } @@ -1361,7 +1361,7 @@ mod tests { aliases: ~[] }]; let verbose = reqopt("b", "banana", "some bananas", "VAL"); - assert_eq!(verbose.long_to_short(), short); + fail_unless_eq!(verbose.long_to_short(), short); } #[test] @@ -1373,8 +1373,8 @@ mod tests { let args = ~[~"-a", ~"--apple", ~"-a"]; let matches = getopts(args, opts).unwrap(); - assert_eq!(3, matches.opt_count("a")); - assert_eq!(3, matches.opt_count("apple")); + fail_unless_eq!(3, matches.opt_count("a")); + fail_unless_eq!(3, matches.opt_count("apple")); } #[test] @@ -1404,7 +1404,7 @@ Options: debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", generated_usage); - assert_eq!(generated_usage, expected); + fail_unless_eq!(generated_usage, expected); } #[test] @@ -1478,6 +1478,6 @@ Options: debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", generated_usage); - assert_eq!(generated_usage, expected); + fail_unless_eq!(generated_usage, expected); } } diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 29b26f09bc01a..4ddc575281f4c 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -661,7 +661,7 @@ mod test { #[test] fn test_pattern_escape() { let s = "_[_]_?_*_!_"; - assert_eq!(Pattern::escape(s), ~"_[[]_[]]_[?]_[*]_!_"); + fail_unless_eq!(Pattern::escape(s), ~"_[[]_[]]_[?]_[*]_!_"); fail_unless!(Pattern::new(Pattern::escape(s)).matches(s)); } diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index a91440e844e13..cf971f3837a3e 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1095,7 +1095,7 @@ mod test { let sched1_id = port.recv(); let mut task = pool.task(TaskOpts::new(), proc() { - assert_eq!(sched_id(), sched1_id); + fail_unless_eq!(sched_id(), sched1_id); dchan.send(()); }); task.give_home(HomeSched(handle1)); @@ -1282,13 +1282,13 @@ mod test { let id = sched_id(); chan1.send(()); port2.recv(); - assert_eq!(id, sched_id()); + fail_unless_eq!(id, sched_id()); }); pool2.spawn(TaskOpts::new(), proc() { let id = sched_id(); port1.recv(); - assert_eq!(id, sched_id()); + fail_unless_eq!(id, sched_id()); chan2.send(()); }); diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs index 8a5e6be17c87d..78adce227e6d2 100644 --- a/src/libgreen/stack.rs +++ b/src/libgreen/stack.rs @@ -167,10 +167,10 @@ mod tests { let s = p.take_stack(10); p.give_stack(s); let s = p.take_stack(4); - assert_eq!(s.min_size, 10); + fail_unless_eq!(s.min_size, 10); p.give_stack(s); let s = p.take_stack(14); - assert_eq!(s.min_size, 14); + fail_unless_eq!(s.min_size, 14); p.give_stack(s); } @@ -182,7 +182,7 @@ mod tests { p.give_stack(s); let s = p.take_stack(10); - assert_eq!(s.min_size, 10); - assert_eq!(s.valgrind_id, 100); + fail_unless_eq!(s.min_size, 10); + fail_unless_eq!(s.valgrind_id, 100); } } diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index eb9d30ecc4180..6e5998fc74ca4 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -513,7 +513,7 @@ mod tests { let _c = c; fail!() }); - assert_eq!(p.recv_opt(), None); + fail_unless_eq!(p.recv_opt(), None); } #[test] diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs index 0a3e66ff1aabd..24ffc6c40886a 100644 --- a/src/libnative/io/file.rs +++ b/src/libnative/io/file.rs @@ -529,7 +529,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { paths.push(Path::new(cstr)); entry_ptr = readdir(dir_ptr); } - assert_eq!(closedir(dir_ptr), 0); + fail_unless_eq!(closedir(dir_ptr), 0); Ok(paths) } else { Err(super::last_error()) @@ -957,10 +957,10 @@ mod tests { let mut buf = [0u8, ..4]; match reader.inner_read(buf) { Ok(4) => { - assert_eq!(buf[0], 't' as u8); - assert_eq!(buf[1], 'e' as u8); - assert_eq!(buf[2], 's' as u8); - assert_eq!(buf[3], 't' as u8); + fail_unless_eq!(buf[0], 't' as u8); + fail_unless_eq!(buf[1], 'e' as u8); + fail_unless_eq!(buf[2], 's' as u8); + fail_unless_eq!(buf[3], 't' as u8); } r => fail!("invalid read: {:?}", r) } @@ -983,10 +983,10 @@ mod tests { let _ = file.seek(0, io::SeekSet).unwrap(); match file.read(buf) { Ok(4) => { - assert_eq!(buf[0], 't' as u8); - assert_eq!(buf[1], 'e' as u8); - assert_eq!(buf[2], 's' as u8); - assert_eq!(buf[3], 't' as u8); + fail_unless_eq!(buf[0], 't' as u8); + fail_unless_eq!(buf[1], 'e' as u8); + fail_unless_eq!(buf[2], 's' as u8); + fail_unless_eq!(buf[3], 't' as u8); } r => fail!("invalid read: {:?}", r) } diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index cd38405ce8d38..a2abde668203c 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -229,7 +229,7 @@ pub fn init() { let mut data: WSADATA = mem::init(); let ret = WSAStartup(0x202, // version 2.2 &mut data); - assert_eq!(ret, 0); + fail_unless_eq!(ret, 0); INITIALIZED = true; } } diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index c76ee8ca4bd10..7579937a45f27 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -417,7 +417,7 @@ fn spawn_process_os(config: p::ProcessConfig, static FIOCLEX: c_ulong = 0x5451; let ret = ioctl(fd, FIOCLEX); - assert_eq!(ret, 0); + fail_unless_eq!(ret, 0); } let pipe = os::pipe(); @@ -736,19 +736,19 @@ mod tests { #[test] #[cfg(windows)] fn test_make_command_line() { use super::make_command_line; - assert_eq!( + fail_unless_eq!( make_command_line("prog", [~"aaa", ~"bbb", ~"ccc"]), ~"prog aaa bbb ccc" ); - assert_eq!( + fail_unless_eq!( make_command_line("C:\\Program Files\\blah\\blah.exe", [~"aaa"]), ~"\"C:\\Program Files\\blah\\blah.exe\" aaa" ); - assert_eq!( + fail_unless_eq!( make_command_line("C:\\Program Files\\test", [~"aa\"bb"]), ~"\"C:\\Program Files\\test\" aa\\\"bb" ); - assert_eq!( + fail_unless_eq!( make_command_line("echo", [~"a b c"]), ~"echo \"a b c\"" ); diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs index 5171f958cacad..59a628095982e 100644 --- a/src/libnative/io/timer_other.rs +++ b/src/libnative/io/timer_other.rs @@ -90,7 +90,7 @@ pub enum Req { fn now() -> u64 { unsafe { let mut now: libc::timeval = mem::init(); - assert_eq!(imp::gettimeofday(&mut now, ptr::null()), 0); + fail_unless_eq!(imp::gettimeofday(&mut now, ptr::null()), 0); return (now.tv_sec as u64) * 1000 + (now.tv_usec as u64) / 1000; } } @@ -187,7 +187,7 @@ fn helper(input: libc::c_int, messages: Port) { // drain the file descriptor let mut buf = [0]; - assert_eq!(fd.inner_read(buf).unwrap(), 1); + fail_unless_eq!(fd.inner_read(buf).unwrap(), 1); } -1 if os::errno() == libc::EINTR as int => {} diff --git a/src/libnative/io/timer_timerfd.rs b/src/libnative/io/timer_timerfd.rs index 47e927c87802c..3a93f4fb4eea2 100644 --- a/src/libnative/io/timer_timerfd.rs +++ b/src/libnative/io/timer_timerfd.rs @@ -66,14 +66,14 @@ fn helper(input: libc::c_int, messages: Port) { let ret = unsafe { imp::epoll_ctl(efd, imp::EPOLL_CTL_ADD, fd, &event) }; - assert_eq!(ret, 0); + fail_unless_eq!(ret, 0); } fn del(efd: libc::c_int, fd: libc::c_int) { let event = imp::epoll_event { events: 0, data: 0 }; let ret = unsafe { imp::epoll_ctl(efd, imp::EPOLL_CTL_DEL, fd, &event) }; - assert_eq!(ret, 0); + fail_unless_eq!(ret, 0); } add(efd, input); @@ -137,7 +137,7 @@ fn helper(input: libc::c_int, messages: Port) { let ret = unsafe { imp::timerfd_settime(fd, 0, &timeval, ptr::null()) }; - assert_eq!(ret, 0); + fail_unless_eq!(ret, 0); } Data(RemoveTimer(fd, chan)) => { diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs index 4d8184c74e66d..bdc9f7da54af8 100644 --- a/src/libnative/io/timer_win32.rs +++ b/src/libnative/io/timer_win32.rs @@ -69,8 +69,8 @@ fn helper(input: libc::HANDLE, messages: Port) { } } Data(Shutdown) => { - assert_eq!(objs.len(), 1); - assert_eq!(chans.len(), 0); + fail_unless_eq!(objs.len(), 1); + fail_unless_eq!(chans.len(), 0); break 'outer; } _ => break @@ -128,7 +128,7 @@ impl rtio::RtioTimer for Timer { // there are 10^6 nanoseconds in a millisecond, and the parameter is in // 100ns intervals, so we multiply by 10^4. let due = -(msecs * 10000) as libc::LARGE_INTEGER; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { imp::SetWaitableTimer(self.obj, &due, 0, ptr::null(), ptr::mut_null(), 0) }, 1); @@ -142,7 +142,7 @@ impl rtio::RtioTimer for Timer { // see above for the calculation let due = -(msecs * 10000) as libc::LARGE_INTEGER; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { imp::SetWaitableTimer(self.obj, &due, 0, ptr::null(), ptr::mut_null(), 0) }, 1); @@ -158,7 +158,7 @@ impl rtio::RtioTimer for Timer { // see above for the calculation let due = -(msecs * 10000) as libc::LARGE_INTEGER; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { imp::SetWaitableTimer(self.obj, &due, msecs as libc::LONG, ptr::null(), ptr::mut_null(), 0) }, 1); diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 56ded99345705..d7441cffb2d78 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -275,7 +275,7 @@ mod tests { let _c = c; fail!() }); - assert_eq!(p.recv_opt(), None); + fail_unless_eq!(p.recv_opt(), None); } #[test] diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index 838b10393b3bc..98a3f0388d472 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -244,7 +244,7 @@ impl Sub for BigUint { lo }); - assert_eq!(borrow, 0); // <=> fail_unless!((self >= other)); + fail_unless_eq!(borrow, 0); // <=> fail_unless!((self >= other)); return BigUint::new(diff); } } @@ -1424,17 +1424,17 @@ mod biguint_tests { for (j0, nj) in data.slice(i, data.len()).iter().enumerate() { let j = j0 + i; if i == j { - assert_eq!(ni.cmp(nj), Equal); - assert_eq!(nj.cmp(ni), Equal); - assert_eq!(ni, nj); + fail_unless_eq!(ni.cmp(nj), Equal); + fail_unless_eq!(nj.cmp(ni), Equal); + fail_unless_eq!(ni, nj); fail_unless!(!(ni != nj)); fail_unless!(ni <= nj); fail_unless!(ni >= nj); fail_unless!(!(ni < nj)); fail_unless!(!(ni > nj)); } else { - assert_eq!(ni.cmp(nj), Less); - assert_eq!(nj.cmp(ni), Greater); + fail_unless_eq!(ni.cmp(nj), Less); + fail_unless_eq!(nj.cmp(ni), Greater); fail_unless!(!(ni == nj)); fail_unless!(ni != nj); @@ -1458,7 +1458,7 @@ mod biguint_tests { fn check(left: ~[BigDigit], right: ~[BigDigit], expected: ~[BigDigit]) { - assert_eq!(BigUint::new(left) & BigUint::new(right), + fail_unless_eq!(BigUint::new(left) & BigUint::new(right), BigUint::new(expected)); } check(~[], ~[], ~[]); @@ -1472,7 +1472,7 @@ mod biguint_tests { fn check(left: ~[BigDigit], right: ~[BigDigit], expected: ~[BigDigit]) { - assert_eq!(BigUint::new(left) | BigUint::new(right), + fail_unless_eq!(BigUint::new(left) | BigUint::new(right), BigUint::new(expected)); } check(~[], ~[], ~[]); @@ -1486,7 +1486,7 @@ mod biguint_tests { fn check(left: ~[BigDigit], right: ~[BigDigit], expected: ~[BigDigit]) { - assert_eq!(BigUint::new(left) ^ BigUint::new(right), + fail_unless_eq!(BigUint::new(left) ^ BigUint::new(right), BigUint::new(expected)); } check(~[], ~[], ~[]); @@ -1500,7 +1500,7 @@ mod biguint_tests { fn check(s: &str, shift: uint, ans: &str) { let opt_biguint: Option = FromStrRadix::from_str_radix(s, 16); let bu = (opt_biguint.unwrap() << shift).to_str_radix(16); - assert_eq!(bu.as_slice(), ans); + fail_unless_eq!(bu.as_slice(), ans); } check("0", 3, "0"); @@ -1539,7 +1539,7 @@ mod biguint_tests { let opt_biguint: Option = FromStrRadix::from_str_radix(s, 16); let bu = (opt_biguint.unwrap() >> shift).to_str_radix(16); - assert_eq!(bu.as_slice(), ans); + fail_unless_eq!(bu.as_slice(), ans); } check("0", 3, "0"); @@ -1595,10 +1595,10 @@ mod biguint_tests { check(BigUint::new(~[ 0, 0, 0, 1 ]), (1 << (3*BigDigit::bits))); check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::MAX); - assert_eq!(i64::MIN.to_biguint(), None); - assert_eq!(BigUint::new(~[-1, -1, -1, -1 ]).to_i64(), None); - assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_i64(), None); - assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None); + fail_unless_eq!(i64::MIN.to_biguint(), None); + fail_unless_eq!(BigUint::new(~[-1, -1, -1, -1 ]).to_i64(), None); + fail_unless_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_i64(), None); + fail_unless_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None); } #[cfg(target_word_size = "64")] @@ -1620,10 +1620,10 @@ mod biguint_tests { check(BigUint::new(~[ 0, 1 ]), (1 << (1*BigDigit::bits))); check(BigUint::new(~[-1, -1 >> 1]), i64::MAX); - assert_eq!(i64::MIN.to_biguint(), None); - assert_eq!(BigUint::new(~[-1, -1 ]).to_i64(), None); - assert_eq!(BigUint::new(~[ 0, 0, 1]).to_i64(), None); - assert_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None); + fail_unless_eq!(i64::MIN.to_biguint(), None); + fail_unless_eq!(BigUint::new(~[-1, -1 ]).to_i64(), None); + fail_unless_eq!(BigUint::new(~[ 0, 0, 1]).to_i64(), None); + fail_unless_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None); } #[cfg(target_word_size = "32")] @@ -1650,8 +1650,8 @@ mod biguint_tests { check(BigUint::new(~[ 0, 0, 0, 1]), (1 << (3*BigDigit::bits))); check(BigUint::new(~[-1, -1, -1, -1]), u64::MAX); - assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_u64(), None); - assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None); + fail_unless_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_u64(), None); + fail_unless_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None); } #[cfg(target_word_size = "64")] @@ -1674,15 +1674,15 @@ mod biguint_tests { check(BigUint::new(~[ 0, 1]), (1 << (1*BigDigit::bits))); check(BigUint::new(~[-1, -1]), u64::MAX); - assert_eq!(BigUint::new(~[ 0, 0, 1]).to_u64(), None); - assert_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None); + fail_unless_eq!(BigUint::new(~[ 0, 0, 1]).to_u64(), None); + fail_unless_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None); } #[test] fn test_convert_to_bigint() { fn check(n: BigUint, ans: BigInt) { - assert_eq!(n.to_bigint().unwrap(), ans); - assert_eq!(n.to_bigint().unwrap().to_biguint().unwrap(), n); + fail_unless_eq!(n.to_bigint().unwrap(), ans); + fail_unless_eq!(n.to_bigint().unwrap().to_biguint().unwrap(), n); } check(Zero::zero(), Zero::zero()); check(BigUint::new(~[1,2,3]), @@ -1800,10 +1800,10 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); if !a.is_zero() { - assert_eq!(c.div_rem(&a), (b.clone(), Zero::zero())); + fail_unless_eq!(c.div_rem(&a), (b.clone(), Zero::zero())); } if !b.is_zero() { - assert_eq!(c.div_rem(&b), (a.clone(), Zero::zero())); + fail_unless_eq!(c.div_rem(&b), (a.clone(), Zero::zero())); } } @@ -1825,7 +1825,7 @@ mod biguint_tests { let big_b: BigUint = FromPrimitive::from_uint(b).unwrap(); let big_c: BigUint = FromPrimitive::from_uint(c).unwrap(); - assert_eq!(big_a.gcd(&big_b), big_c); + fail_unless_eq!(big_a.gcd(&big_b), big_c); } check(10, 2, 2); @@ -1842,7 +1842,7 @@ mod biguint_tests { let big_b: BigUint = FromPrimitive::from_uint(b).unwrap(); let big_c: BigUint = FromPrimitive::from_uint(c).unwrap(); - assert_eq!(big_a.lcm(&big_b), big_c); + fail_unless_eq!(big_a.lcm(&big_b), big_c); } check(1, 0, 0); @@ -1933,7 +1933,7 @@ mod biguint_tests { let &(ref n, ref rs) = num_pair; for str_pair in rs.iter() { let &(ref radix, ref str) = str_pair; - assert_eq!(&n.to_str_radix(*radix), str); + fail_unless_eq!(&n.to_str_radix(*radix), str); } } } @@ -1945,17 +1945,17 @@ mod biguint_tests { let &(ref n, ref rs) = num_pair; for str_pair in rs.iter() { let &(ref radix, ref str) = str_pair; - assert_eq!(n, &FromStrRadix::from_str_radix(*str, *radix).unwrap()); + fail_unless_eq!(n, &FromStrRadix::from_str_radix(*str, *radix).unwrap()); } } let zed: Option = FromStrRadix::from_str_radix("Z", 10); - assert_eq!(zed, None); + fail_unless_eq!(zed, None); let blank: Option = FromStrRadix::from_str_radix("_", 2); - assert_eq!(blank, None); + fail_unless_eq!(blank, None); let minus_one: Option = FromStrRadix::from_str_radix("-1", 10); - assert_eq!(minus_one, None); + fail_unless_eq!(minus_one, None); } #[test] @@ -1975,7 +1975,7 @@ mod biguint_tests { let ans = match FromStrRadix::from_str_radix(s, 10) { Some(x) => x, None => fail!() }; - assert_eq!(n, ans); + fail_unless_eq!(n, ans); } check(3, "6"); @@ -1986,17 +1986,17 @@ mod biguint_tests { #[test] fn test_bits() { - assert_eq!(BigUint::new(~[0,0,0,0]).bits(), 0); + fail_unless_eq!(BigUint::new(~[0,0,0,0]).bits(), 0); let n: BigUint = FromPrimitive::from_uint(0).unwrap(); - assert_eq!(n.bits(), 0); + fail_unless_eq!(n.bits(), 0); let n: BigUint = FromPrimitive::from_uint(1).unwrap(); - assert_eq!(n.bits(), 1); + fail_unless_eq!(n.bits(), 1); let n: BigUint = FromPrimitive::from_uint(3).unwrap(); - assert_eq!(n.bits(), 2); + fail_unless_eq!(n.bits(), 2); let n: BigUint = FromStrRadix::from_str_radix("4000000000", 16).unwrap(); - assert_eq!(n.bits(), 39); + fail_unless_eq!(n.bits(), 39); let one: BigUint = One::one(); - assert_eq!((one << 426).bits(), 427); + fail_unless_eq!((one << 426).bits(), 427); } #[test] @@ -2011,7 +2011,7 @@ mod biguint_tests { let mut rng = task_rng(); for _ in range(0, 10) { - assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), + fail_unless_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), &FromPrimitive::from_uint(237).unwrap()), FromPrimitive::from_uint(236).unwrap()); } @@ -2064,7 +2064,7 @@ mod bigint_tests { fn check(inp_s: Sign, inp_n: uint, ans_s: Sign, ans_n: uint) { let inp = BigInt::from_biguint(inp_s, FromPrimitive::from_uint(inp_n).unwrap()); let ans = BigInt { sign: ans_s, data: FromPrimitive::from_uint(ans_n).unwrap()}; - assert_eq!(inp, ans); + fail_unless_eq!(inp, ans); } check(Plus, 1, Plus, 1); check(Plus, 0, Zero, 0); @@ -2086,17 +2086,17 @@ mod bigint_tests { for (j0, nj) in nums.slice(i, nums.len()).iter().enumerate() { let j = i + j0; if i == j { - assert_eq!(ni.cmp(nj), Equal); - assert_eq!(nj.cmp(ni), Equal); - assert_eq!(ni, nj); + fail_unless_eq!(ni.cmp(nj), Equal); + fail_unless_eq!(nj.cmp(ni), Equal); + fail_unless_eq!(ni, nj); fail_unless!(!(ni != nj)); fail_unless!(ni <= nj); fail_unless!(ni >= nj); fail_unless!(!(ni < nj)); fail_unless!(!(ni > nj)); } else { - assert_eq!(ni.cmp(nj), Less); - assert_eq!(nj.cmp(ni), Greater); + fail_unless_eq!(ni.cmp(nj), Less); + fail_unless_eq!(nj.cmp(ni), Greater); fail_unless!(!(ni == nj)); fail_unless!(ni != nj); @@ -2128,19 +2128,19 @@ mod bigint_tests { check(i64::MIN.to_bigint().unwrap(), i64::MIN); check(i64::MAX.to_bigint().unwrap(), i64::MAX); - assert_eq!( + fail_unless_eq!( (i64::MAX as u64 + 1).to_bigint().unwrap().to_i64(), None); - assert_eq!( + fail_unless_eq!( BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_i64(), None); - assert_eq!( + fail_unless_eq!( BigInt::from_biguint(Minus, BigUint::new(~[1, 0, 0, 1<<(BigDigit::bits-1)])).to_i64(), None); - assert_eq!( + fail_unless_eq!( BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_i64(), None); } @@ -2158,20 +2158,20 @@ mod bigint_tests { check(u64::MIN.to_bigint().unwrap(), u64::MIN); check(u64::MAX.to_bigint().unwrap(), u64::MAX); - assert_eq!( + fail_unless_eq!( BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None); let max_value: BigUint = FromPrimitive::from_u64(u64::MAX).unwrap(); - assert_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None); - assert_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None); + fail_unless_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None); + fail_unless_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None); } #[test] fn test_convert_to_biguint() { fn check(n: BigInt, ans_1: BigUint) { - assert_eq!(n.to_biguint().unwrap(), ans_1); - assert_eq!(n.to_biguint().unwrap().to_bigint().unwrap(), n); + fail_unless_eq!(n.to_biguint().unwrap(), ans_1); + fail_unless_eq!(n.to_biguint().unwrap().to_bigint().unwrap(), n); } let zero: BigInt = Zero::zero(); let unsigned_zero: BigUint = Zero::zero(); @@ -2182,7 +2182,7 @@ mod bigint_tests { check(zero, unsigned_zero); check(positive, BigUint::new(~[1,2,3])); - assert_eq!(negative.to_biguint(), None); + fail_unless_eq!(negative.to_biguint(), None); } static sum_triples: &'static [(&'static [BigDigit], @@ -2307,7 +2307,7 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) { let (d, m) = a.div_mod_floor(b); if !m.is_zero() { - assert_eq!(m.sign, b.sign); + fail_unless_eq!(m.sign, b.sign); } fail_unless!(m.abs() <= b.abs()); fail_unless!(*a == b * d + m); @@ -2358,7 +2358,7 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) { let (q, r) = a.div_rem(b); if !r.is_zero() { - assert_eq!(r.sign, a.sign); + fail_unless_eq!(r.sign, a.sign); } fail_unless!(r.abs() <= b.abs()); fail_unless!(*a == b * q + r); @@ -2402,7 +2402,7 @@ mod bigint_tests { let big_b: BigInt = FromPrimitive::from_int(b).unwrap(); let big_c: BigInt = FromPrimitive::from_int(c).unwrap(); - assert_eq!(big_a.gcd(&big_b), big_c); + fail_unless_eq!(big_a.gcd(&big_b), big_c); } check(10, 2, 2); @@ -2422,7 +2422,7 @@ mod bigint_tests { let big_b: BigInt = FromPrimitive::from_int(b).unwrap(); let big_c: BigInt = FromPrimitive::from_int(c).unwrap(); - assert_eq!(big_a.lcm(&big_b), big_c); + fail_unless_eq!(big_a.lcm(&big_b), big_c); } check(1, 0, 0); @@ -2439,16 +2439,16 @@ mod bigint_tests { fn test_abs_sub() { let zero: BigInt = Zero::zero(); let one: BigInt = One::one(); - assert_eq!((-one).abs_sub(&one), zero); + fail_unless_eq!((-one).abs_sub(&one), zero); let one: BigInt = One::one(); let zero: BigInt = Zero::zero(); - assert_eq!(one.abs_sub(&one), zero); + fail_unless_eq!(one.abs_sub(&one), zero); let one: BigInt = One::one(); let zero: BigInt = Zero::zero(); - assert_eq!(one.abs_sub(&zero), one); + fail_unless_eq!(one.abs_sub(&zero), one); let one: BigInt = One::one(); let two: BigInt = FromPrimitive::from_int(2).unwrap(); - assert_eq!(one.abs_sub(&-one), two); + fail_unless_eq!(one.abs_sub(&-one), two); } #[test] @@ -2472,7 +2472,7 @@ mod bigint_tests { let x: BigInt = FromPrimitive::from_int(n).unwrap(); x }); - assert_eq!(FromStrRadix::from_str_radix(s, 10), ans); + fail_unless_eq!(FromStrRadix::from_str_radix(s, 10), ans); } check("10", Some(10)); check("1", Some(1)); @@ -2495,7 +2495,7 @@ mod bigint_tests { fail_unless!(-BigInt::new(Minus, ~[1, 1, 1]) == BigInt::new(Plus, ~[1, 1, 1])); let zero: BigInt = Zero::zero(); - assert_eq!(-zero, zero); + fail_unless_eq!(-zero, zero); } #[test] @@ -2510,7 +2510,7 @@ mod bigint_tests { let mut rng = task_rng(); for _ in range(0, 10) { - assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), + fail_unless_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), &FromPrimitive::from_uint(237).unwrap()), FromPrimitive::from_uint(236).unwrap()); } diff --git a/src/libnum/complex.rs b/src/libnum/complex.rs index 2dfe725ed80cd..99428e158b359 100644 --- a/src/libnum/complex.rs +++ b/src/libnum/complex.rs @@ -206,7 +206,7 @@ mod test { fn test_consts() { // check our constants are what Cmplx::new creates fn test(c : Complex64, r : f64, i: f64) { - assert_eq!(c, Cmplx::new(r,i)); + fail_unless_eq!(c, Cmplx::new(r,i)); } test(_0_0i, 0.0, 0.0); test(_1_0i, 1.0, 0.0); @@ -214,8 +214,8 @@ mod test { test(_neg1_1i, -1.0, 1.0); test(_05_05i, 0.5, 0.5); - assert_eq!(_0_0i, Zero::zero()); - assert_eq!(_1_0i, One::one()); + fail_unless_eq!(_0_0i, Zero::zero()); + fail_unless_eq!(_1_0i, One::one()); } #[test] @@ -223,8 +223,8 @@ mod test { // FIXME #7158: (maybe?) currently failing on x86. fn test_norm() { fn test(c: Complex64, ns: f64) { - assert_eq!(c.norm_sqr(), ns); - assert_eq!(c.norm(), ns.sqrt()) + fail_unless_eq!(c.norm_sqr(), ns); + fail_unless_eq!(c.norm(), ns.sqrt()) } test(_0_0i, 0.0); test(_1_0i, 1.0); @@ -235,25 +235,25 @@ mod test { #[test] fn test_scale_unscale() { - assert_eq!(_05_05i.scale(2.0), _1_1i); - assert_eq!(_1_1i.unscale(2.0), _05_05i); + fail_unless_eq!(_05_05i.scale(2.0), _1_1i); + fail_unless_eq!(_1_1i.unscale(2.0), _05_05i); for &c in all_consts.iter() { - assert_eq!(c.scale(2.0).unscale(2.0), c); + fail_unless_eq!(c.scale(2.0).unscale(2.0), c); } } #[test] fn test_conj() { for &c in all_consts.iter() { - assert_eq!(c.conj(), Cmplx::new(c.re, -c.im)); - assert_eq!(c.conj().conj(), c); + fail_unless_eq!(c.conj(), Cmplx::new(c.re, -c.im)); + fail_unless_eq!(c.conj().conj(), c); } } #[test] fn test_inv() { - assert_eq!(_1_1i.inv(), _05_05i.conj()); - assert_eq!(_1_0i.inv(), _1_0i.inv()); + fail_unless_eq!(_1_1i.inv(), _05_05i.conj()); + fail_unless_eq!(_1_0i.inv(), _1_0i.inv()); } #[test] @@ -290,57 +290,57 @@ mod test { #[test] fn test_add() { - assert_eq!(_05_05i + _05_05i, _1_1i); - assert_eq!(_0_1i + _1_0i, _1_1i); - assert_eq!(_1_0i + _neg1_1i, _0_1i); + fail_unless_eq!(_05_05i + _05_05i, _1_1i); + fail_unless_eq!(_0_1i + _1_0i, _1_1i); + fail_unless_eq!(_1_0i + _neg1_1i, _0_1i); for &c in all_consts.iter() { - assert_eq!(_0_0i + c, c); - assert_eq!(c + _0_0i, c); + fail_unless_eq!(_0_0i + c, c); + fail_unless_eq!(c + _0_0i, c); } } #[test] fn test_sub() { - assert_eq!(_05_05i - _05_05i, _0_0i); - assert_eq!(_0_1i - _1_0i, _neg1_1i); - assert_eq!(_0_1i - _neg1_1i, _1_0i); + fail_unless_eq!(_05_05i - _05_05i, _0_0i); + fail_unless_eq!(_0_1i - _1_0i, _neg1_1i); + fail_unless_eq!(_0_1i - _neg1_1i, _1_0i); for &c in all_consts.iter() { - assert_eq!(c - _0_0i, c); - assert_eq!(c - c, _0_0i); + fail_unless_eq!(c - _0_0i, c); + fail_unless_eq!(c - c, _0_0i); } } #[test] fn test_mul() { - assert_eq!(_05_05i * _05_05i, _0_1i.unscale(2.0)); - assert_eq!(_1_1i * _0_1i, _neg1_1i); + fail_unless_eq!(_05_05i * _05_05i, _0_1i.unscale(2.0)); + fail_unless_eq!(_1_1i * _0_1i, _neg1_1i); // i^2 & i^4 - assert_eq!(_0_1i * _0_1i, -_1_0i); - assert_eq!(_0_1i * _0_1i * _0_1i * _0_1i, _1_0i); + fail_unless_eq!(_0_1i * _0_1i, -_1_0i); + fail_unless_eq!(_0_1i * _0_1i * _0_1i * _0_1i, _1_0i); for &c in all_consts.iter() { - assert_eq!(c * _1_0i, c); - assert_eq!(_1_0i * c, c); + fail_unless_eq!(c * _1_0i, c); + fail_unless_eq!(_1_0i * c, c); } } #[test] fn test_div() { - assert_eq!(_neg1_1i / _0_1i, _1_1i); + fail_unless_eq!(_neg1_1i / _0_1i, _1_1i); for &c in all_consts.iter() { if c != Zero::zero() { - assert_eq!(c / c, _1_0i); + fail_unless_eq!(c / c, _1_0i); } } } #[test] fn test_neg() { - assert_eq!(-_1_0i + _0_1i, _neg1_1i); - assert_eq!((-_0_1i) * _0_1i, _1_0i); + fail_unless_eq!(-_1_0i + _0_1i, _neg1_1i); + fail_unless_eq!((-_0_1i) * _0_1i, _1_0i); for &c in all_consts.iter() { - assert_eq!(-(-c), c); + fail_unless_eq!(-(-c), c); } } } @@ -348,7 +348,7 @@ mod test { #[test] fn test_to_str() { fn test(c : Complex64, s: ~str) { - assert_eq!(c.to_str(), s); + fail_unless_eq!(c.to_str(), s); } test(_0_0i, ~"0+0i"); test(_1_0i, ~"1+0i"); diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index 298b8de3144fa..c35882fea0aa5 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -195,7 +195,7 @@ macro_rules! impl_integer_for_int { /// - `qr`: quotient and remainder #[cfg(test)] fn test_division_rule((n,d): ($T,$T), (q,r): ($T,$T)) { - assert_eq!(d * q + r, n); + fail_unless_eq!(d * q + r, n); } #[test] @@ -205,8 +205,8 @@ macro_rules! impl_integer_for_int { let separate_div_rem = (n / d, n % d); let combined_div_rem = n.div_rem(&d); - assert_eq!(separate_div_rem, qr); - assert_eq!(combined_div_rem, qr); + fail_unless_eq!(separate_div_rem, qr); + fail_unless_eq!(combined_div_rem, qr); test_division_rule(nd, separate_div_rem); test_division_rule(nd, combined_div_rem); @@ -230,8 +230,8 @@ macro_rules! impl_integer_for_int { let separate_div_mod_floor = (n.div_floor(&d), n.mod_floor(&d)); let combined_div_mod_floor = n.div_mod_floor(&d); - assert_eq!(separate_div_mod_floor, dm); - assert_eq!(combined_div_mod_floor, dm); + fail_unless_eq!(separate_div_mod_floor, dm); + fail_unless_eq!(combined_div_mod_floor, dm); test_division_rule(nd, separate_div_mod_floor); test_division_rule(nd, combined_div_mod_floor); @@ -250,52 +250,52 @@ macro_rules! impl_integer_for_int { #[test] fn test_gcd() { - assert_eq!((10 as $T).gcd(&2), 2 as $T); - assert_eq!((10 as $T).gcd(&3), 1 as $T); - assert_eq!((0 as $T).gcd(&3), 3 as $T); - assert_eq!((3 as $T).gcd(&3), 3 as $T); - assert_eq!((56 as $T).gcd(&42), 14 as $T); - assert_eq!((3 as $T).gcd(&-3), 3 as $T); - assert_eq!((-6 as $T).gcd(&3), 3 as $T); - assert_eq!((-4 as $T).gcd(&-2), 2 as $T); + fail_unless_eq!((10 as $T).gcd(&2), 2 as $T); + fail_unless_eq!((10 as $T).gcd(&3), 1 as $T); + fail_unless_eq!((0 as $T).gcd(&3), 3 as $T); + fail_unless_eq!((3 as $T).gcd(&3), 3 as $T); + fail_unless_eq!((56 as $T).gcd(&42), 14 as $T); + fail_unless_eq!((3 as $T).gcd(&-3), 3 as $T); + fail_unless_eq!((-6 as $T).gcd(&3), 3 as $T); + fail_unless_eq!((-4 as $T).gcd(&-2), 2 as $T); } #[test] fn test_lcm() { - assert_eq!((1 as $T).lcm(&0), 0 as $T); - assert_eq!((0 as $T).lcm(&1), 0 as $T); - assert_eq!((1 as $T).lcm(&1), 1 as $T); - assert_eq!((-1 as $T).lcm(&1), 1 as $T); - assert_eq!((1 as $T).lcm(&-1), 1 as $T); - assert_eq!((-1 as $T).lcm(&-1), 1 as $T); - assert_eq!((8 as $T).lcm(&9), 72 as $T); - assert_eq!((11 as $T).lcm(&5), 55 as $T); + fail_unless_eq!((1 as $T).lcm(&0), 0 as $T); + fail_unless_eq!((0 as $T).lcm(&1), 0 as $T); + fail_unless_eq!((1 as $T).lcm(&1), 1 as $T); + fail_unless_eq!((-1 as $T).lcm(&1), 1 as $T); + fail_unless_eq!((1 as $T).lcm(&-1), 1 as $T); + fail_unless_eq!((-1 as $T).lcm(&-1), 1 as $T); + fail_unless_eq!((8 as $T).lcm(&9), 72 as $T); + fail_unless_eq!((11 as $T).lcm(&5), 55 as $T); } #[test] fn test_even() { - assert_eq!((-4 as $T).is_even(), true); - assert_eq!((-3 as $T).is_even(), false); - assert_eq!((-2 as $T).is_even(), true); - assert_eq!((-1 as $T).is_even(), false); - assert_eq!((0 as $T).is_even(), true); - assert_eq!((1 as $T).is_even(), false); - assert_eq!((2 as $T).is_even(), true); - assert_eq!((3 as $T).is_even(), false); - assert_eq!((4 as $T).is_even(), true); + fail_unless_eq!((-4 as $T).is_even(), true); + fail_unless_eq!((-3 as $T).is_even(), false); + fail_unless_eq!((-2 as $T).is_even(), true); + fail_unless_eq!((-1 as $T).is_even(), false); + fail_unless_eq!((0 as $T).is_even(), true); + fail_unless_eq!((1 as $T).is_even(), false); + fail_unless_eq!((2 as $T).is_even(), true); + fail_unless_eq!((3 as $T).is_even(), false); + fail_unless_eq!((4 as $T).is_even(), true); } #[test] fn test_odd() { - assert_eq!((-4 as $T).is_odd(), false); - assert_eq!((-3 as $T).is_odd(), true); - assert_eq!((-2 as $T).is_odd(), false); - assert_eq!((-1 as $T).is_odd(), true); - assert_eq!((0 as $T).is_odd(), false); - assert_eq!((1 as $T).is_odd(), true); - assert_eq!((2 as $T).is_odd(), false); - assert_eq!((3 as $T).is_odd(), true); - assert_eq!((4 as $T).is_odd(), false); + fail_unless_eq!((-4 as $T).is_odd(), false); + fail_unless_eq!((-3 as $T).is_odd(), true); + fail_unless_eq!((-2 as $T).is_odd(), false); + fail_unless_eq!((-1 as $T).is_odd(), true); + fail_unless_eq!((0 as $T).is_odd(), false); + fail_unless_eq!((1 as $T).is_odd(), true); + fail_unless_eq!((2 as $T).is_odd(), false); + fail_unless_eq!((3 as $T).is_odd(), true); + fail_unless_eq!((4 as $T).is_odd(), false); } } ) @@ -357,34 +357,34 @@ macro_rules! impl_integer_for_uint { #[test] fn test_div_mod_floor() { - assert_eq!((10 as $T).div_floor(&(3 as $T)), 3 as $T); - assert_eq!((10 as $T).mod_floor(&(3 as $T)), 1 as $T); - assert_eq!((10 as $T).div_mod_floor(&(3 as $T)), (3 as $T, 1 as $T)); - assert_eq!((5 as $T).div_floor(&(5 as $T)), 1 as $T); - assert_eq!((5 as $T).mod_floor(&(5 as $T)), 0 as $T); - assert_eq!((5 as $T).div_mod_floor(&(5 as $T)), (1 as $T, 0 as $T)); - assert_eq!((3 as $T).div_floor(&(7 as $T)), 0 as $T); - assert_eq!((3 as $T).mod_floor(&(7 as $T)), 3 as $T); - assert_eq!((3 as $T).div_mod_floor(&(7 as $T)), (0 as $T, 3 as $T)); + fail_unless_eq!((10 as $T).div_floor(&(3 as $T)), 3 as $T); + fail_unless_eq!((10 as $T).mod_floor(&(3 as $T)), 1 as $T); + fail_unless_eq!((10 as $T).div_mod_floor(&(3 as $T)), (3 as $T, 1 as $T)); + fail_unless_eq!((5 as $T).div_floor(&(5 as $T)), 1 as $T); + fail_unless_eq!((5 as $T).mod_floor(&(5 as $T)), 0 as $T); + fail_unless_eq!((5 as $T).div_mod_floor(&(5 as $T)), (1 as $T, 0 as $T)); + fail_unless_eq!((3 as $T).div_floor(&(7 as $T)), 0 as $T); + fail_unless_eq!((3 as $T).mod_floor(&(7 as $T)), 3 as $T); + fail_unless_eq!((3 as $T).div_mod_floor(&(7 as $T)), (0 as $T, 3 as $T)); } #[test] fn test_gcd() { - assert_eq!((10 as $T).gcd(&2), 2 as $T); - assert_eq!((10 as $T).gcd(&3), 1 as $T); - assert_eq!((0 as $T).gcd(&3), 3 as $T); - assert_eq!((3 as $T).gcd(&3), 3 as $T); - assert_eq!((56 as $T).gcd(&42), 14 as $T); + fail_unless_eq!((10 as $T).gcd(&2), 2 as $T); + fail_unless_eq!((10 as $T).gcd(&3), 1 as $T); + fail_unless_eq!((0 as $T).gcd(&3), 3 as $T); + fail_unless_eq!((3 as $T).gcd(&3), 3 as $T); + fail_unless_eq!((56 as $T).gcd(&42), 14 as $T); } #[test] fn test_lcm() { - assert_eq!((1 as $T).lcm(&0), 0 as $T); - assert_eq!((0 as $T).lcm(&1), 0 as $T); - assert_eq!((1 as $T).lcm(&1), 1 as $T); - assert_eq!((8 as $T).lcm(&9), 72 as $T); - assert_eq!((11 as $T).lcm(&5), 55 as $T); - assert_eq!((99 as $T).lcm(&17), 1683 as $T); + fail_unless_eq!((1 as $T).lcm(&0), 0 as $T); + fail_unless_eq!((0 as $T).lcm(&1), 0 as $T); + fail_unless_eq!((1 as $T).lcm(&1), 1 as $T); + fail_unless_eq!((8 as $T).lcm(&9), 72 as $T); + fail_unless_eq!((11 as $T).lcm(&5), 55 as $T); + fail_unless_eq!((99 as $T).lcm(&17), 1683 as $T); } #[test] @@ -396,20 +396,20 @@ macro_rules! impl_integer_for_uint { #[test] fn test_even() { - assert_eq!((0 as $T).is_even(), true); - assert_eq!((1 as $T).is_even(), false); - assert_eq!((2 as $T).is_even(), true); - assert_eq!((3 as $T).is_even(), false); - assert_eq!((4 as $T).is_even(), true); + fail_unless_eq!((0 as $T).is_even(), true); + fail_unless_eq!((1 as $T).is_even(), false); + fail_unless_eq!((2 as $T).is_even(), true); + fail_unless_eq!((3 as $T).is_even(), false); + fail_unless_eq!((4 as $T).is_even(), true); } #[test] fn test_odd() { - assert_eq!((0 as $T).is_odd(), false); - assert_eq!((1 as $T).is_odd(), true); - assert_eq!((2 as $T).is_odd(), false); - assert_eq!((3 as $T).is_odd(), true); - assert_eq!((4 as $T).is_odd(), false); + fail_unless_eq!((0 as $T).is_odd(), false); + fail_unless_eq!((1 as $T).is_odd(), true); + fail_unless_eq!((2 as $T).is_odd(), false); + fail_unless_eq!((3 as $T).is_odd(), true); + fail_unless_eq!((4 as $T).is_odd(), false); } } ) diff --git a/src/libnum/rational.rs b/src/libnum/rational.rs index 41d6b5fc4b243..7b9e3a42340e0 100644 --- a/src/libnum/rational.rs +++ b/src/libnum/rational.rs @@ -352,19 +352,19 @@ mod test { #[test] fn test_test_constants() { // check our constants are what Ratio::new etc. would make. - assert_eq!(_0, Zero::zero()); - assert_eq!(_1, One::one()); - assert_eq!(_2, Ratio::from_integer(2)); - assert_eq!(_1_2, Ratio::new(1,2)); - assert_eq!(_3_2, Ratio::new(3,2)); - assert_eq!(_neg1_2, Ratio::new(-1,2)); + fail_unless_eq!(_0, Zero::zero()); + fail_unless_eq!(_1, One::one()); + fail_unless_eq!(_2, Ratio::from_integer(2)); + fail_unless_eq!(_1_2, Ratio::new(1,2)); + fail_unless_eq!(_3_2, Ratio::new(3,2)); + fail_unless_eq!(_neg1_2, Ratio::new(-1,2)); } #[test] fn test_new_reduce() { let one22 = Ratio::new(2i,2); - assert_eq!(one22, One::one()); + fail_unless_eq!(one22, One::one()); } #[test] #[should_fail] @@ -390,32 +390,32 @@ mod test { #[test] fn test_to_integer() { - assert_eq!(_0.to_integer(), 0); - assert_eq!(_1.to_integer(), 1); - assert_eq!(_2.to_integer(), 2); - assert_eq!(_1_2.to_integer(), 0); - assert_eq!(_3_2.to_integer(), 1); - assert_eq!(_neg1_2.to_integer(), 0); + fail_unless_eq!(_0.to_integer(), 0); + fail_unless_eq!(_1.to_integer(), 1); + fail_unless_eq!(_2.to_integer(), 2); + fail_unless_eq!(_1_2.to_integer(), 0); + fail_unless_eq!(_3_2.to_integer(), 1); + fail_unless_eq!(_neg1_2.to_integer(), 0); } #[test] fn test_numer() { - assert_eq!(_0.numer(), &0); - assert_eq!(_1.numer(), &1); - assert_eq!(_2.numer(), &2); - assert_eq!(_1_2.numer(), &1); - assert_eq!(_3_2.numer(), &3); - assert_eq!(_neg1_2.numer(), &(-1)); + fail_unless_eq!(_0.numer(), &0); + fail_unless_eq!(_1.numer(), &1); + fail_unless_eq!(_2.numer(), &2); + fail_unless_eq!(_1_2.numer(), &1); + fail_unless_eq!(_3_2.numer(), &3); + fail_unless_eq!(_neg1_2.numer(), &(-1)); } #[test] fn test_denom() { - assert_eq!(_0.denom(), &1); - assert_eq!(_1.denom(), &1); - assert_eq!(_2.denom(), &1); - assert_eq!(_1_2.denom(), &2); - assert_eq!(_3_2.denom(), &2); - assert_eq!(_neg1_2.denom(), &2); + fail_unless_eq!(_0.denom(), &1); + fail_unless_eq!(_1.denom(), &1); + fail_unless_eq!(_2.denom(), &1); + fail_unless_eq!(_1_2.denom(), &2); + fail_unless_eq!(_3_2.denom(), &2); + fail_unless_eq!(_neg1_2.denom(), &2); } @@ -437,8 +437,8 @@ mod test { #[test] fn test_add() { fn test(a: Rational, b: Rational, c: Rational) { - assert_eq!(a + b, c); - assert_eq!(to_big(a) + to_big(b), to_big(c)); + fail_unless_eq!(a + b, c); + fail_unless_eq!(to_big(a) + to_big(b), to_big(c)); } test(_1, _1_2, _3_2); @@ -450,8 +450,8 @@ mod test { #[test] fn test_sub() { fn test(a: Rational, b: Rational, c: Rational) { - assert_eq!(a - b, c); - assert_eq!(to_big(a) - to_big(b), to_big(c)) + fail_unless_eq!(a - b, c); + fail_unless_eq!(to_big(a) - to_big(b), to_big(c)) } test(_1, _1_2, _1_2); @@ -462,8 +462,8 @@ mod test { #[test] fn test_mul() { fn test(a: Rational, b: Rational, c: Rational) { - assert_eq!(a * b, c); - assert_eq!(to_big(a) * to_big(b), to_big(c)) + fail_unless_eq!(a * b, c); + fail_unless_eq!(to_big(a) * to_big(b), to_big(c)) } test(_1, _1_2, _1_2); @@ -474,8 +474,8 @@ mod test { #[test] fn test_div() { fn test(a: Rational, b: Rational, c: Rational) { - assert_eq!(a / b, c); - assert_eq!(to_big(a) / to_big(b), to_big(c)) + fail_unless_eq!(a / b, c); + fail_unless_eq!(to_big(a) / to_big(b), to_big(c)) } test(_1, _1_2, _2); @@ -486,8 +486,8 @@ mod test { #[test] fn test_rem() { fn test(a: Rational, b: Rational, c: Rational) { - assert_eq!(a % b, c); - assert_eq!(to_big(a) % to_big(b), to_big(c)) + fail_unless_eq!(a % b, c); + fail_unless_eq!(to_big(a) % to_big(b), to_big(c)) } test(_3_2, _1, _1_2); @@ -498,8 +498,8 @@ mod test { #[test] fn test_neg() { fn test(a: Rational, b: Rational) { - assert_eq!(-a, b); - assert_eq!(-to_big(a), to_big(b)) + fail_unless_eq!(-a, b); + fail_unless_eq!(-to_big(a), to_big(b)) } test(_0, _0); @@ -508,11 +508,11 @@ mod test { } #[test] fn test_zero() { - assert_eq!(_0 + _0, _0); - assert_eq!(_0 * _0, _0); - assert_eq!(_0 * _1, _0); - assert_eq!(_0 / _neg1_2, _0); - assert_eq!(_0 - _0, _0); + fail_unless_eq!(_0 + _0, _0); + fail_unless_eq!(_0 * _0, _0); + fail_unless_eq!(_0 * _1, _0); + fail_unless_eq!(_0 / _neg1_2, _0); + fail_unless_eq!(_0 - _0, _0); } #[test] #[should_fail] @@ -523,44 +523,44 @@ mod test { #[test] fn test_round() { - assert_eq!(_1_2.ceil(), _1); - assert_eq!(_1_2.floor(), _0); - assert_eq!(_1_2.round(), _1); - assert_eq!(_1_2.trunc(), _0); + fail_unless_eq!(_1_2.ceil(), _1); + fail_unless_eq!(_1_2.floor(), _0); + fail_unless_eq!(_1_2.round(), _1); + fail_unless_eq!(_1_2.trunc(), _0); - assert_eq!(_neg1_2.ceil(), _0); - assert_eq!(_neg1_2.floor(), -_1); - assert_eq!(_neg1_2.round(), -_1); - assert_eq!(_neg1_2.trunc(), _0); + fail_unless_eq!(_neg1_2.ceil(), _0); + fail_unless_eq!(_neg1_2.floor(), -_1); + fail_unless_eq!(_neg1_2.round(), -_1); + fail_unless_eq!(_neg1_2.trunc(), _0); - assert_eq!(_1.ceil(), _1); - assert_eq!(_1.floor(), _1); - assert_eq!(_1.round(), _1); - assert_eq!(_1.trunc(), _1); + fail_unless_eq!(_1.ceil(), _1); + fail_unless_eq!(_1.floor(), _1); + fail_unless_eq!(_1.round(), _1); + fail_unless_eq!(_1.trunc(), _1); } #[test] fn test_fract() { - assert_eq!(_1.fract(), _0); - assert_eq!(_neg1_2.fract(), _neg1_2); - assert_eq!(_1_2.fract(), _1_2); - assert_eq!(_3_2.fract(), _1_2); + fail_unless_eq!(_1.fract(), _0); + fail_unless_eq!(_neg1_2.fract(), _neg1_2); + fail_unless_eq!(_1_2.fract(), _1_2); + fail_unless_eq!(_3_2.fract(), _1_2); } #[test] fn test_recip() { - assert_eq!(_1 * _1.recip(), _1); - assert_eq!(_2 * _2.recip(), _1); - assert_eq!(_1_2 * _1_2.recip(), _1); - assert_eq!(_3_2 * _3_2.recip(), _1); - assert_eq!(_neg1_2 * _neg1_2.recip(), _1); + fail_unless_eq!(_1 * _1.recip(), _1); + fail_unless_eq!(_2 * _2.recip(), _1); + fail_unless_eq!(_1_2 * _1_2.recip(), _1); + fail_unless_eq!(_3_2 * _3_2.recip(), _1); + fail_unless_eq!(_neg1_2 * _neg1_2.recip(), _1); } #[test] fn test_to_from_str() { fn test(r: Rational, s: ~str) { - assert_eq!(FromStr::from_str(s), Some(r)); - assert_eq!(r.to_str(), s); + fail_unless_eq!(FromStr::from_str(s), Some(r)); + fail_unless_eq!(r.to_str(), s); } test(_1, ~"1/1"); test(_0, ~"0/1"); @@ -573,7 +573,7 @@ mod test { fn test_from_str_fail() { fn test(s: &str) { let rational: Option = FromStr::from_str(s); - assert_eq!(rational, None); + fail_unless_eq!(rational, None); } let xs = ["0 /1", "abc", "", "1/", "--1/2","3/2/1"]; @@ -585,8 +585,8 @@ mod test { #[test] fn test_to_from_str_radix() { fn test(r: Rational, s: ~str, n: uint) { - assert_eq!(FromStrRadix::from_str_radix(s, n), Some(r)); - assert_eq!(r.to_str_radix(n), s); + fail_unless_eq!(FromStrRadix::from_str_radix(s, n), Some(r)); + fail_unless_eq!(r.to_str_radix(n), s); } fn test3(r: Rational, s: ~str) { test(r, s, 3) } fn test16(r: Rational, s: ~str) { test(r, s, 16) } @@ -614,7 +614,7 @@ mod test { fn test_from_str_radix_fail() { fn test(s: &str) { let radix: Option = FromStrRadix::from_str_radix(s, 3); - assert_eq!(radix, None); + fail_unless_eq!(radix, None); } let xs = ["0 /1", "abc", "", "1/", "--1/2","3/2/1", "3/2"]; @@ -627,7 +627,7 @@ mod test { fn test_from_float() { fn test(given: T, (numer, denom): (&str, &str)) { let ratio: BigRational = Ratio::from_float(given).unwrap(); - assert_eq!(ratio, Ratio::new( + fail_unless_eq!(ratio, Ratio::new( FromStr::from_str(numer).unwrap(), FromStr::from_str(denom).unwrap())); } @@ -653,11 +653,11 @@ mod test { fn test_from_float_fail() { use std::{f32, f64}; - assert_eq!(Ratio::from_float(f32::NAN), None); - assert_eq!(Ratio::from_float(f32::INFINITY), None); - assert_eq!(Ratio::from_float(f32::NEG_INFINITY), None); - assert_eq!(Ratio::from_float(f64::NAN), None); - assert_eq!(Ratio::from_float(f64::INFINITY), None); - assert_eq!(Ratio::from_float(f64::NEG_INFINITY), None); + fail_unless_eq!(Ratio::from_float(f32::NAN), None); + fail_unless_eq!(Ratio::from_float(f32::INFINITY), None); + fail_unless_eq!(Ratio::from_float(f32::NEG_INFINITY), None); + fail_unless_eq!(Ratio::from_float(f64::NAN), None); + fail_unless_eq!(Ratio::from_float(f64::INFINITY), None); + fail_unless_eq!(Ratio::from_float(f64::NEG_INFINITY), None); } } diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 0dbb8fd8b0fc1..35a1df58389c7 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -190,7 +190,7 @@ mod test { #[test] fn test_rpaths_to_flags() { let flags = rpaths_to_flags([~"path1", ~"path2"]); - assert_eq!(flags, ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]); + fail_unless_eq!(flags, ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]); } #[test] @@ -215,7 +215,7 @@ mod test { #[test] fn test_minimize1() { let res = minimize_rpaths([~"rpath1", ~"rpath2", ~"rpath1"]); - assert_eq!(res.as_slice(), [~"rpath1", ~"rpath2"]); + fail_unless_eq!(res.as_slice(), [~"rpath1", ~"rpath2"]); } #[test] @@ -224,7 +224,7 @@ mod test { ~"1a", ~"4a", ~"1a", ~"2", ~"3", ~"4a", ~"3"]); - assert_eq!(res.as_slice(), [~"1a", ~"2", ~"4a", ~"3"]); + fail_unless_eq!(res.as_slice(), [~"1a", ~"2", ~"4a", ~"3"]); } #[test] @@ -234,7 +234,7 @@ mod test { let o = abi::OsLinux; let res = get_rpath_relative_to_output(o, &Path::new("bin/rustc"), &Path::new("lib/libstd.so")); - assert_eq!(res.as_slice(), "$ORIGIN/../lib"); + fail_unless_eq!(res.as_slice(), "$ORIGIN/../lib"); } #[test] @@ -243,7 +243,7 @@ mod test { let o = abi::OsFreebsd; let res = get_rpath_relative_to_output(o, &Path::new("bin/rustc"), &Path::new("lib/libstd.so")); - assert_eq!(res.as_slice(), "$ORIGIN/../lib"); + fail_unless_eq!(res.as_slice(), "$ORIGIN/../lib"); } #[test] @@ -253,7 +253,7 @@ mod test { let res = get_rpath_relative_to_output(o, &Path::new("bin/rustc"), &Path::new("lib/libstd.so")); - assert_eq!(res.as_slice(), "@loader_path/../lib"); + fail_unless_eq!(res.as_slice(), "@loader_path/../lib"); } #[test] @@ -264,6 +264,6 @@ mod test { res.to_str(), lib.display()); // FIXME (#9639): This needs to handle non-utf8 paths - assert_eq!(res.as_slice(), lib.as_str().expect("non-utf8 component in path")); + fail_unless_eq!(res.as_slice(), lib.as_str().expect("non-utf8 component in path")); } } diff --git a/src/librustc/front/assign_node_ids_and_map.rs b/src/librustc/front/assign_node_ids_and_map.rs index 750d09c2d1784..0b0b8720fe812 100644 --- a/src/librustc/front/assign_node_ids_and_map.rs +++ b/src/librustc/front/assign_node_ids_and_map.rs @@ -19,7 +19,7 @@ struct NodeIdAssigner { impl ast_map::FoldOps for NodeIdAssigner { fn new_id(&self, old_id: ast::NodeId) -> ast::NodeId { - assert_eq!(old_id, ast::DUMMY_NODE_ID); + fail_unless_eq!(old_id, ast::DUMMY_NODE_ID); self.sess.next_node_id() } } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 47fcc4534897c..5420afb3d0ae1 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1068,7 +1068,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::Attribute] { let meta_items = get_meta_items(attr_doc); // Currently it's only possible to have a single meta item on // an attribute - assert_eq!(meta_items.len(), 1u); + fail_unless_eq!(meta_items.len(), 1u); let meta_item = meta_items[0]; attrs.push( codemap::Spanned { diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 54b12192dc961..7d8a3374d910f 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1163,7 +1163,7 @@ fn encode_info_for_item(ecx: &EncodeContext, // Now output the method info for each method. let r = ty::trait_method_def_ids(tcx, def_id); for (i, &method_def_id) in r.iter().enumerate() { - assert_eq!(method_def_id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(method_def_id.krate, ast::LOCAL_CRATE); let method_ty = ty::method(tcx, method_def_id); @@ -1531,7 +1531,7 @@ fn encode_crate_deps(ebml_w: &mut writer::Encoder, cstore: &cstore::CStore) { // Sanity-check the crate numbers let mut expected_cnum = 1; for n in deps.iter() { - assert_eq!(n.cnum, expected_cnum); + fail_unless_eq!(n.cnum, expected_cnum); expected_cnum += 1; } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index c78721cdf4c8a..a6e84b7338a45 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -147,12 +147,12 @@ fn parse_sigil(st: &mut PState) -> ast::Sigil { } fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::vstore { - assert_eq!(next(st), '/'); + fail_unless_eq!(next(st), '/'); let c = peek(st); if '0' <= c && c <= '9' { let n = parse_uint(st); - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); return ty::vstore_fixed(n); } @@ -176,7 +176,7 @@ fn parse_substs(st: &mut PState, conv: conv_did) -> ty::substs { let self_ty = parse_opt(st, |st| parse_ty(st, |x,y| conv(x,y)) ); - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let mut params: ~[ty::t] = ~[]; while peek(st) != ']' { params.push(parse_ty(st, |x,y| conv(x,y))); } st.pos = st.pos + 1u; @@ -197,7 +197,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts { let r = parse_region(st, |x,y| conv(x,y)); regions.push(r); } - assert_eq!(next(st), '.'); + fail_unless_eq!(next(st), '.'); ty::NonerasedRegions(regions) } _ => fail!("parse_bound_region: bad input") @@ -208,7 +208,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion { match next(st) { 'a' => { let id = parse_uint(st); - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); ty::BrAnon(id) } '[' => { @@ -218,7 +218,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion { } 'f' => { let id = parse_uint(st); - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); ty::BrFresh(id) } _ => fail!("parse_bound_region: bad input") @@ -228,34 +228,34 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion { fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region { match next(st) { 'b' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let id = parse_uint(st) as ast::NodeId; - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); let br = parse_bound_region(st, |x,y| conv(x,y)); - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); ty::ReLateBound(id, br) } 'B' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let node_id = parse_uint(st) as ast::NodeId; - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); let index = parse_uint(st); - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); let nm = token::str_to_ident(parse_str(st, ']')); ty::ReEarlyBound(node_id, index, nm) } 'f' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let id = parse_uint(st) as ast::NodeId; - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); let br = parse_bound_region(st, |x,y| conv(x,y)); - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); ty::ReFree(ty::FreeRegion {scope_id: id, bound_region: br}) } 's' => { let id = parse_uint(st) as ast::NodeId; - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); ty::ReScope(id) } 't' => { @@ -317,20 +317,20 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { } 'c' => return ty::mk_char(), 't' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let def = parse_def(st, NominalType, |x,y| conv(x,y)); let substs = parse_substs(st, |x,y| conv(x,y)); - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); return ty::mk_enum(st.tcx, def, substs); } 'x' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let def = parse_def(st, NominalType, |x,y| conv(x,y)); let substs = parse_substs(st, |x,y| conv(x,y)); let store = parse_trait_store(st, |x,y| conv(x,y)); let mt = parse_mutability(st); let bounds = parse_bounds(st, |x,y| conv(x,y)); - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); return ty::mk_trait(st.tcx, def, substs, store, mt, bounds.builtin_bounds); } 'p' => { @@ -361,7 +361,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { return ty::mk_str(st.tcx, v); } 'T' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let mut params = ~[]; while peek(st) != ']' { params.push(parse_ty(st, |x,y| conv(x,y))); } st.pos = st.pos + 1u; @@ -375,9 +375,9 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { } '#' => { let pos = parse_hex(st); - assert_eq!(next(st), ':'); + fail_unless_eq!(next(st), ':'); let len = parse_hex(st); - assert_eq!(next(st), '#'); + fail_unless_eq!(next(st), '#'); let key = ty::creader_cache_key {cnum: st.krate, pos: pos, len: len }; @@ -406,10 +406,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { inner } 'a' => { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let did = parse_def(st, NominalType, |x,y| conv(x,y)); let substs = parse_substs(st, |x,y| conv(x,y)); - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); return ty::mk_struct(st.tcx, did, substs); } c => { error!("unexpected char in type string: {}", c); fail!();} @@ -467,7 +467,7 @@ fn parse_purity(c: char) -> Purity { } fn parse_abi_set(st: &mut PState) -> AbiSet { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let mut abis = AbiSet::empty(); while peek(st) != ']' { scan(st, |c| c == ',', |bytes| { @@ -476,7 +476,7 @@ fn parse_abi_set(st: &mut PState) -> AbiSet { abis.add(abi); }); } - assert_eq!(next(st), ']'); + fail_unless_eq!(next(st), ']'); return abis; } @@ -517,9 +517,9 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy { } fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig { - assert_eq!(next(st), '['); + fail_unless_eq!(next(st), '['); let id = parse_uint(st) as ast::NodeId; - assert_eq!(next(st), '|'); + fail_unless_eq!(next(st), '|'); let mut inputs = ~[]; while peek(st) != ']' { inputs.push(parse_ty(st, |x,y| conv(x,y))); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 95702a6d23be1..5b47c49877331 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -235,7 +235,7 @@ impl ExtendedDecodeContext { * refer to the current crate and to the new, inlined node-id. */ - assert_eq!(did.krate, ast::LOCAL_CRATE); + fail_unless_eq!(did.krate, ast::LOCAL_CRATE); ast::DefId { krate: ast::LOCAL_CRATE, node: self.tr_id(did.node) } } pub fn tr_span(&self, _span: Span) -> Span { @@ -1435,7 +1435,7 @@ fn roundtrip(in_item: Option<@ast::Item>) { let ebml_doc = reader::Doc(wr.get_ref()); let out_item = decode_item_ast(ebml_doc); - assert_eq!(in_item, out_item); + fail_unless_eq!(in_item, out_item); } #[test] diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index bbf52dd580db9..ef078977b520f 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -463,7 +463,7 @@ impl<'a> CheckLoanCtxt<'a> { } mc::cat_deref(_, _, mc::GcPtr) => { - assert_eq!(cmt.mutbl, mc::McImmutable); + fail_unless_eq!(cmt.mutbl, mc::McImmutable); return; } @@ -472,19 +472,19 @@ impl<'a> CheckLoanCtxt<'a> { mc::cat_copied_upvar(..) | mc::cat_deref(_, _, mc::UnsafePtr(..)) | mc::cat_deref(_, _, mc::BorrowedPtr(..)) => { - assert_eq!(cmt.mutbl, mc::McDeclared); + fail_unless_eq!(cmt.mutbl, mc::McDeclared); return; } mc::cat_discr(b, _) | mc::cat_deref(b, _, mc::OwnedPtr) => { - assert_eq!(cmt.mutbl, mc::McInherited); + fail_unless_eq!(cmt.mutbl, mc::McInherited); cmt = b; } mc::cat_downcast(b) | mc::cat_interior(b, _) => { - assert_eq!(cmt.mutbl, mc::McInherited); + fail_unless_eq!(cmt.mutbl, mc::McInherited); cmt = b; } } diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index caedb469aff6b..08a64e129cffd 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -337,7 +337,7 @@ impl<'a> GatherLoanCtxt<'a> { pub fn pop_repeating_id(&mut self, id: ast::NodeId) { let popped = self.repeating_ids.pop().unwrap(); - assert_eq!(id, popped); + fail_unless_eq!(id, popped); } pub fn guarantee_adjustments(&mut self, diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 34efcacc44b06..42f104526c91e 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -298,7 +298,7 @@ impl MoveData { index); let paths = self.paths.borrow(); - assert_eq!(index.get(), paths.get().len() - 1); + fail_unless_eq!(index.get(), paths.get().len() - 1); let mut path_map = self.path_map.borrow_mut(); path_map.get().insert(lp, index); diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 70d0d9b9ab871..b9f0151fe7f27 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -499,7 +499,7 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> { self.add_to_entry_set(expr.id, body_bits); let new_loop_scope = loop_scopes.pop().unwrap(); - assert_eq!(new_loop_scope.loop_id, expr.id); + fail_unless_eq!(new_loop_scope.loop_id, expr.id); copy_bits(new_loop_scope.break_bits, in_out); } @@ -885,7 +885,7 @@ fn join_bits(oper: &O, #[inline] fn bitwise(out_vec: &mut [uint], in_vec: &[uint], op: |uint, uint| -> uint) -> bool { - assert_eq!(out_vec.len(), in_vec.len()); + fail_unless_eq!(out_vec.len(), in_vec.len()); let mut changed = false; for (out_elt, in_elt) in out_vec.mut_iter().zip(in_vec.iter()) { let old_val = *out_elt; diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 14f046e8ddb5a..2b9f7f0547987 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -327,8 +327,8 @@ mod test { let graph = create_graph(); let expected = ["A", "B", "C", "D", "E", "F"]; graph.each_node(|idx, node| { - assert_eq!(&expected[idx.get()], graph.node_data(idx)); - assert_eq!(expected[idx.get()], node.data); + fail_unless_eq!(&expected[idx.get()], graph.node_data(idx)); + fail_unless_eq!(expected[idx.get()], node.data); true }); } @@ -338,8 +338,8 @@ mod test { let graph = create_graph(); let expected = ["AB", "BC", "BD", "DE", "EC", "FB"]; graph.each_edge(|idx, edge| { - assert_eq!(&expected[idx.get()], graph.edge_data(idx)); - assert_eq!(expected[idx.get()], edge.data); + fail_unless_eq!(&expected[idx.get()], graph.edge_data(idx)); + fail_unless_eq!(expected[idx.get()], edge.data); true }); } @@ -349,43 +349,43 @@ mod test { start_data: N, expected_incoming: &[(E,N)], expected_outgoing: &[(E,N)]) { - assert_eq!(graph.node_data(start_index), &start_data); + fail_unless_eq!(graph.node_data(start_index), &start_data); let mut counter = 0; graph.each_incoming_edge(start_index, |edge_index, edge| { - assert_eq!(graph.edge_data(edge_index), &edge.data); + fail_unless_eq!(graph.edge_data(edge_index), &edge.data); fail_unless!(counter < expected_incoming.len()); debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", counter, expected_incoming[counter], edge_index, edge); match expected_incoming[counter] { (ref e, ref n) => { - assert_eq!(e, &edge.data); - assert_eq!(n, graph.node_data(edge.source)); - assert_eq!(start_index, edge.target); + fail_unless_eq!(e, &edge.data); + fail_unless_eq!(n, graph.node_data(edge.source)); + fail_unless_eq!(start_index, edge.target); } } counter += 1; true }); - assert_eq!(counter, expected_incoming.len()); + fail_unless_eq!(counter, expected_incoming.len()); let mut counter = 0; graph.each_outgoing_edge(start_index, |edge_index, edge| { - assert_eq!(graph.edge_data(edge_index), &edge.data); + fail_unless_eq!(graph.edge_data(edge_index), &edge.data); fail_unless!(counter < expected_outgoing.len()); debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", counter, expected_outgoing[counter], edge_index, edge); match expected_outgoing[counter] { (ref e, ref n) => { - assert_eq!(e, &edge.data); - assert_eq!(start_index, edge.source); - assert_eq!(n, graph.node_data(edge.target)); + fail_unless_eq!(e, &edge.data); + fail_unless_eq!(start_index, edge.source); + fail_unless_eq!(n, graph.node_data(edge.target)); } } counter += 1; true }); - assert_eq!(counter, expected_outgoing.len()); + fail_unless_eq!(counter, expected_outgoing.len()); } #[test] diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 8062e91259b1f..c55d432d04360 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -2537,7 +2537,7 @@ impl Resolver { return Indeterminate; } - assert_eq!(containing_module.glob_count.get(), 0); + fail_unless_eq!(containing_module.glob_count.get(), 0); // Add all resolved imports from the containing module. let import_resolutions = containing_module.import_resolutions @@ -3212,7 +3212,7 @@ impl Resolver { // If this is a search of all imports, we should be done with glob // resolution at this point. if name_search_type == PathSearch { - assert_eq!(module_.glob_count.get(), 0); + fail_unless_eq!(module_.glob_count.get(), 0); } // Check the list of resolved imports. diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 9d5201940bdb1..a8e0b532b5299 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -157,7 +157,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { if cases.len() == 0 { // Uninhabitable; represent as unit // (Typechecking will reject discriminant-sizing attrs.) - assert_eq!(hint, attr::ReprAny); + fail_unless_eq!(hint, attr::ReprAny); return Univariant(mk_struct(cx, [], false), false); } @@ -185,7 +185,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { if cases.len() == 1 { // Equivalent to a struct/tuple/newtype. // (Typechecking will reject discriminant-sizing attrs.) - assert_eq!(hint, attr::ReprAny); + fail_unless_eq!(hint, attr::ReprAny); return Univariant(mk_struct(cx, cases[0].tys, false), false) } @@ -404,7 +404,7 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool Univariant(ref st, _) | NullablePointer{ nonnull: ref st, .. } => { match name { None => Type::struct_(struct_llfields(cx, st, sizing), st.packed), - Some(name) => { assert_eq!(sizing, false); Type::named_struct(name) } + Some(name) => { fail_unless_eq!(sizing, false); Type::named_struct(name) } } } General(ity, ref sts) => { @@ -436,8 +436,8 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool align_units), _ => fail!("unsupported enum alignment: {:?}", align) }; - assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align); - assert_eq!(align % discr_size, 0); + fail_unless_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align); + fail_unless_eq!(align % discr_size, 0); let fields = ~[discr_ty, Type::array(&discr_ty, align / discr_size - 1), pad_ty]; @@ -526,7 +526,7 @@ fn nullable_bitdiscr(bcx: &Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uin fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) -> ValueRef { let llty = ll_inttype(bcx.ccx(), ity); - assert_eq!(val_ty(ptr), llty.ptr_to()); + fail_unless_eq!(val_ty(ptr), llty.ptr_to()); let bits = machine::llbitsize_of_real(bcx.ccx(), llty); fail_unless!(bits <= 64); let mask = (-1u64 >> (64 - bits)) as Disr; @@ -589,12 +589,12 @@ pub fn trans_start_init(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr) { GEPi(bcx, val, [0, 0])) } Univariant(ref st, true) => { - assert_eq!(discr, 0); + fail_unless_eq!(discr, 0); Store(bcx, C_bool(true), GEPi(bcx, val, [0, st.fields.len() - 1])) } Univariant(..) => { - assert_eq!(discr, 0); + fail_unless_eq!(discr, 0); } NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => { if discr != nndiscr { @@ -621,7 +621,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint { match *r { CEnum(..) => 0, Univariant(ref st, dtor) => { - assert_eq!(discr, 0); + fail_unless_eq!(discr, 0); st.fields.len() - (if dtor { 1 } else { 0 }) } General(_, ref cases) => cases[discr].fields.len() - 1, @@ -662,7 +662,7 @@ pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr, bcx.ccx().sess.bug("element access in C-like enum") } Univariant(ref st, _dtor) => { - assert_eq!(discr, 0); + fail_unless_eq!(discr, 0); struct_field_ptr(bcx, st, val, ix, false) } General(_, ref cases) => { @@ -676,7 +676,7 @@ pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr, // The unit-like case might have a nonzero number of unit-like fields. // (e.g., Result or Either with () as one side.) let ty = type_of::type_of(bcx.ccx(), nullfields[ix]); - assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0); + fail_unless_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0); // The contents of memory at this pointer can't matter, but use // the value that's "reasonable" in case of pointer comparison. PointerCast(bcx, val, ty.ptr_to()) @@ -733,7 +733,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, vals: &[ValueRef]) -> ValueRef { match *r { CEnum(ity, min, max) => { - assert_eq!(vals.len(), 0); + fail_unless_eq!(vals.len(), 0); assert_discr_in_range(ity, min, max, discr); C_integral(ll_inttype(ccx, ity), discr as u64, true) } @@ -775,7 +775,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, */ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef]) -> ~[ValueRef] { - assert_eq!(vals.len(), st.fields.len()); + fail_unless_eq!(vals.len(), st.fields.len()); let mut offset = 0; let mut cfields = ~[]; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 7d7d582e8ecba..c828ae8ff602e 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -537,7 +537,7 @@ pub fn get_res_dtor(ccx: @CrateContext, did }; if !substs.is_empty() { - assert_eq!(did.krate, ast::LOCAL_CRATE); + fail_unless_eq!(did.krate, ast::LOCAL_CRATE); let tsubsts = ty::substs { regions: ty::ErasedRegions, self_ty: None, diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index b4efba8dd738c..7cf1e6682039d 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -734,7 +734,7 @@ impl<'a> Builder<'a> { } pub fn phi(&self, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef { - assert_eq!(vals.len(), bbs.len()); + fail_unless_eq!(vals.len(), bbs.len()); let phi = self.empty_phi(ty); self.count_insn("addincoming"); unsafe { diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 77c63be718824..4414b707f3d40 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -378,7 +378,7 @@ pub fn trans_fn_ref_with_vtables( // Create a monomorphic verison of generic functions if must_monomorphise { // Should be either intra-crate or inlined. - assert_eq!(def_id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(def_id.krate, ast::LOCAL_CRATE); let (val, must_cast) = monomorphize::monomorphic_fn(ccx, def_id, &substs, @@ -819,7 +819,7 @@ fn trans_args<'a>(cx: &'a Block<'a>, match arg2 { Some(arg2_expr) => { - assert_eq!(arg_tys.len(), 2); + fail_unless_eq!(arg_tys.len(), 2); llargs.push(unpack_result!(bcx, { trans_arg_expr(bcx, arg_tys[1], arg2_expr, @@ -827,7 +827,7 @@ fn trans_args<'a>(cx: &'a Block<'a>, DoAutorefArg) })); } - None => assert_eq!(arg_tys.len(), 1) + None => fail_unless_eq!(arg_tys.len(), 1) } } ArgVals(vs) => { diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 267c1ec7adbd4..2e1149a5a3aee 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -101,7 +101,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { // this new AST scope had better be its immediate child. let top_scope = self.top_ast_scope(); if top_scope.is_some() { - assert_eq!(self.ccx.tcx.region_maps.opt_encl_scope(id), top_scope); + fail_unless_eq!(self.ccx.tcx.region_maps.opt_encl_scope(id), top_scope); } self.push_scope(CleanupScope::new(AstScopeKind(id))); @@ -112,7 +112,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { exits: [&'a Block<'a>, ..EXIT_MAX]) { debug!("push_loop_cleanup_scope({})", self.ccx.tcx.map.node_to_str(id)); - assert_eq!(Some(id), self.top_ast_scope()); + fail_unless_eq!(Some(id), self.top_ast_scope()); self.push_scope(CleanupScope::new(LoopScopeKind(id, exits))); } @@ -396,7 +396,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { } } - assert_eq!(self.scopes_len(), orig_scopes_len); + fail_unless_eq!(self.scopes_len(), orig_scopes_len); return llbb; } @@ -630,7 +630,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { debug!("trans_cleanups_to_exit_scope: prev_llbb={}", prev_llbb); - assert_eq!(self.scopes_len(), orig_scopes_len); + fail_unless_eq!(self.scopes_len(), orig_scopes_len); prev_llbb } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 2be53b92db160..d3403dc6077d1 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -263,7 +263,7 @@ fn build_closure<'a>(bcx0: &'a Block<'a>, let datum = expr::trans_local_var(bcx, cap_var.def); match cap_var.mode { moves::CapRef => { - assert_eq!(sigil, ast::BorrowedSigil); + fail_unless_eq!(sigil, ast::BorrowedSigil); env_vals.push(EnvValue {action: EnvRef, datum: datum}); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 42f011a7e6d57..ce9a79c65e55d 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -122,7 +122,7 @@ fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef { None => v }; unsafe { - assert_eq!(llvm::LLVMIsGlobalConstant(v), True); + fail_unless_eq!(llvm::LLVMIsGlobalConstant(v), True); llvm::LLVMGetInitializer(v) } } @@ -250,8 +250,8 @@ pub fn const_expr(cx: @CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef } ty::AutoBorrowVec(ty::ReStatic, m) => { fail_unless!(m != ast::MutMutable); - assert_eq!(abi::slice_elt_base, 0); - assert_eq!(abi::slice_elt_len, 1); + fail_unless_eq!(abi::slice_elt_base, 0); + fail_unless_eq!(abi::slice_elt_len, 1); match ty::get(ty).sty { ty::ty_vec(_, ty::vstore_fixed(len)) => { diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index f84719260f4e1..49fdbabaf90b9 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -255,7 +255,7 @@ fn trans_struct_drop<'a>(bcx: &'a Block<'a>, // Class dtors have no explicit args, so the params should // just consist of the environment (self) - assert_eq!(params.len(), 1); + fail_unless_eq!(params.len(), 1); // Be sure to put all of the fields into a scope so we can use an invoke // instruction to call the user destructor but still call the field diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 8af234878fba6..fbb1e7a84c27b 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2186,7 +2186,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { // If this assertion failures, it is likely because of a // failure in the cross-crate inlining code to translate a // def-id. - assert_eq!(p.def_id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(p.def_id.krate, ast::LOCAL_CRATE); let ty_param_defs = cx.ty_param_defs.borrow(); let tp_def = ty_param_defs.get().get(&p.def_id.node); diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index c54c965558208..754947ea3b67a 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3811,7 +3811,7 @@ pub fn instantiate_path(fcx: @FnCtxt, substs.tps.push(fcx.infcx().next_ty_vars(1)[0]) } - assert_eq!(substs.tps.len(), ty_param_count) + fail_unless_eq!(substs.tps.len(), ty_param_count) let substs {tps, regions, ..} = substs; (tps, regions) diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index ea7474b634811..83511dc240634 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -99,7 +99,7 @@ fn lookup_vtables(vcx: &VtableContext, substs.repr(vcx.tcx())); // We do this backwards for reasons discussed above. - assert_eq!(substs.tps.len(), type_param_defs.len()); + fail_unless_eq!(substs.tps.len(), type_param_defs.len()); let mut result = substs.tps.rev_iter() .zip(type_param_defs.rev_iter()) @@ -109,7 +109,7 @@ fn lookup_vtables(vcx: &VtableContext, .to_owned_vec(); result.reverse(); - assert_eq!(substs.tps.len(), result.len()); + fail_unless_eq!(substs.tps.len(), result.len()); debug!("lookup_vtables result(\ location_info={:?}, \ type_param_defs={}, \ diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index b78da2eeab6f1..c7222a6a3784c 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -639,7 +639,7 @@ impl CoherenceChecker { } fn span_of_impl(&self, implementation: @Impl) -> Span { - assert_eq!(implementation.did.krate, LOCAL_CRATE); + fail_unless_eq!(implementation.did.krate, LOCAL_CRATE); self.crate_context.tcx.map.span(implementation.did.node) } @@ -691,7 +691,7 @@ impl CoherenceChecker { let crate_store = self.crate_context.tcx.sess.cstore; crate_store.iter_crate_data(|crate_number, _crate_metadata| { each_impl(crate_store, crate_number, |def_id| { - assert_eq!(crate_number, def_id.krate); + fail_unless_eq!(crate_number, def_id.krate); self.add_external_impl(&mut impls_seen, def_id) }) }) diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index eb45065952da3..9c639ffce8d81 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -157,8 +157,8 @@ pub trait Combine { b_rs.repr(tcx), region_params.repr(tcx)); - assert_eq!(num_region_params, a_rs.len()); - assert_eq!(num_region_params, b_rs.len()); + fail_unless_eq!(num_region_params, a_rs.len()); + fail_unless_eq!(num_region_params, b_rs.len()); let mut rs = opt_vec::Empty; for i in range(0, num_region_params) { let a_r = *a_rs.get(i); diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 71a091440b6cf..bc11ccc788b1c 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -164,7 +164,7 @@ impl RegionVarBindings { Snapshot => {} AddVar(vid) => { let mut var_origins = self.var_origins.borrow_mut(); - assert_eq!(var_origins.get().len(), vid.to_uint() + 1); + fail_unless_eq!(var_origins.get().len(), vid.to_uint() + 1); var_origins.get().pop().unwrap(); } AddConstraint(ref constraint) => { @@ -905,7 +905,7 @@ impl RegionVarBindings { return match a_data.value { NoValue => { - assert_eq!(a_data.classification, Contracting); + fail_unless_eq!(a_data.classification, Contracting); a_data.value = Value(b_region); true // changed } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index c55bdcd0bf99b..c479a657b412f 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -154,7 +154,7 @@ impl UnifyInferCtxtMethods for InferCtxt { } else { // If equal, redirect one to the other and increment the // other's rank. - assert_eq!(node_a.rank, node_b.rank); + fail_unless_eq!(node_a.rank, node_b.rank); self.set(node_b.root.clone(), Redirect(node_a.root.clone())); (node_a.root.clone(), node_a.rank + 1) } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 26c0f72a7bf92..ca457cdbdd4e4 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -494,7 +494,7 @@ impl<'a> Visitor<()> for ConstraintContext<'a> { ast::ItemStruct(..) => { let struct_fields = ty::lookup_struct_fields(tcx, did); for field_info in struct_fields.iter() { - assert_eq!(field_info.id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(field_info.id.krate, ast::LOCAL_CRATE); let field_ty = ty::node_id_to_type(tcx, field_info.id.node); self.add_constraints_from_ty(field_ty, self.covariant); } @@ -548,7 +548,7 @@ impl<'a> ConstraintContext<'a> { * the type/region parameter with the given id. */ - assert_eq!(param_def_id.krate, item_def_id.krate); + fail_unless_eq!(param_def_id.krate, item_def_id.krate); if self.invariant_lang_items[kind as uint] == Some(item_def_id) { self.invariant @@ -682,7 +682,7 @@ impl<'a> ConstraintContext<'a> { } ty::ty_param(ty::param_ty { def_id: ref def_id, .. }) => { - assert_eq!(def_id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(def_id.krate, ast::LOCAL_CRATE); match self.terms_cx.inferred_map.find(&def_id.node) { Some(&index) => { self.add_constraint(index, variance); @@ -696,7 +696,7 @@ impl<'a> ConstraintContext<'a> { } ty::ty_self(ref def_id) => { - assert_eq!(def_id.krate, ast::LOCAL_CRATE); + fail_unless_eq!(def_id.krate, ast::LOCAL_CRATE); let index = self.inferred_index(def_id.node); self.add_constraint(index, variance); } diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index 704f2bb10fad2..f4db1864277e2 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -619,8 +619,8 @@ mod tests { let result_str = digest.result_str(); let result_bytes = digest.result_bytes(); - assert_eq!(expected, result_str.as_slice()); - assert_eq!(expected.from_hex().unwrap(), result_bytes); + fail_unless_eq!(expected, result_str.as_slice()); + fail_unless_eq!(expected.from_hex().unwrap(), result_bytes); } #[test] diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index b8188e2a9a625..83c50b4b50fcc 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -335,14 +335,14 @@ mod unindent_tests { fn should_unindent() { let s = ~" line1\n line2"; let r = unindent(s); - assert_eq!(r, ~"line1\nline2"); + fail_unless_eq!(r, ~"line1\nline2"); } #[test] fn should_unindent_multiple_paragraphs() { let s = ~" line1\n\n line2"; let r = unindent(s); - assert_eq!(r, ~"line1\n\nline2"); + fail_unless_eq!(r, ~"line1\n\nline2"); } #[test] @@ -351,7 +351,7 @@ mod unindent_tests { // base indentation and should be preserved let s = ~" line1\n\n line2"; let r = unindent(s); - assert_eq!(r, ~"line1\n\n line2"); + fail_unless_eq!(r, ~"line1\n\n line2"); } #[test] @@ -363,13 +363,13 @@ mod unindent_tests { // and continue here"] let s = ~"line1\n line2"; let r = unindent(s); - assert_eq!(r, ~"line1\nline2"); + fail_unless_eq!(r, ~"line1\nline2"); } #[test] fn should_not_ignore_first_line_indent_in_a_single_line_para() { let s = ~"line1\n\n line2"; let r = unindent(s); - assert_eq!(r, ~"line1\n\n line2"); + fail_unless_eq!(r, ~"line1\n\n line2"); } } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ef02d73456721..b3e30764fae11 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -128,7 +128,7 @@ impl<'a> RustdocVisitor<'a> { let item = match item.node { ast::ViewItemUse(ref paths) => { // rustc no longer supports "use foo, bar;" - assert_eq!(paths.len(), 1); + fail_unless_eq!(paths.len(), 1); match self.visit_view_path(paths[0], om) { None => return, Some(path) => { diff --git a/src/librustuv/access.rs b/src/librustuv/access.rs index 173ba44ba71fa..5aae793a9e4e9 100644 --- a/src/librustuv/access.rs +++ b/src/librustuv/access.rs @@ -104,6 +104,6 @@ impl<'a> Drop for Guard<'a> { impl Drop for Inner { fn drop(&mut self) { fail_unless!(!self.held); - assert_eq!(self.queue.len(), 0); + fail_unless_eq!(self.queue.len(), 0); } } diff --git a/src/librustuv/async.rs b/src/librustuv/async.rs index ff19c46582ed4..6fa470ea9024d 100644 --- a/src/librustuv/async.rs +++ b/src/librustuv/async.rs @@ -34,7 +34,7 @@ struct Payload { impl AsyncWatcher { pub fn new(loop_: &mut Loop, cb: ~Callback) -> AsyncWatcher { let handle = UvHandle::alloc(None::, uvll::UV_ASYNC); - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_async_init(loop_.handle, handle, async_cb) }, 0); let flag = Exclusive::new(false); @@ -157,7 +157,7 @@ mod test_remote { watcher.fire(); }); - assert_eq!(port.recv(), 1); + fail_unless_eq!(port.recv(), 1); thread.join(); } } diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index b522c3d25be25..f9f77395031e1 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -379,7 +379,7 @@ impl Drop for FileWatcher { rtio::CloseAsynchronously => { unsafe { let req = uvll::malloc_req(uvll::UV_FS); - assert_eq!(uvll::uv_fs_close(self.loop_.handle, req, + fail_unless_eq!(uvll::uv_fs_close(self.loop_.handle, req, self.fd, close_cb), 0); } @@ -491,7 +491,7 @@ mod test { let nread = result.unwrap(); fail_unless!(nread > 0); let read_str = str::from_utf8(read_mem.slice_to(nread as uint)).unwrap(); - assert_eq!(read_str, "hello"); + fail_unless_eq!(read_str, "hello"); } // unlink let result = FsRequest::unlink(l(), &path_str.to_c_str()); @@ -513,7 +513,7 @@ mod test { let result = FsRequest::stat(l(), path); fail_unless!(result.is_ok()); - assert_eq!(result.unwrap().size, 5); + fail_unless_eq!(result.unwrap().size, 5); fn free(_: T) {} free(file); diff --git a/src/librustuv/homing.rs b/src/librustuv/homing.rs index 92aba67647916..ade9ad76e2a85 100644 --- a/src/librustuv/homing.rs +++ b/src/librustuv/homing.rs @@ -107,7 +107,7 @@ pub trait HomingIO { }); // Once we wake up, assert that we're in the right location - assert_eq!(local_id(), destination); + fail_unless_eq!(local_id(), destination); } return destination; @@ -203,7 +203,7 @@ mod test { let task = pool.task(TaskOpts::new(), proc() { let (mut watcher, addr) = port.recv(); let mut buf = [0, ..10]; - assert_eq!(watcher.recvfrom(buf).unwrap(), (4, addr)); + fail_unless_eq!(watcher.recvfrom(buf).unwrap(), (4, addr)); }); pool.spawn_sched().send(sched::TaskFromFriend(task)); diff --git a/src/librustuv/idle.rs b/src/librustuv/idle.rs index dcdc82e505fc2..cf619bc706970 100644 --- a/src/librustuv/idle.rs +++ b/src/librustuv/idle.rs @@ -25,7 +25,7 @@ pub struct IdleWatcher { impl IdleWatcher { pub fn new(loop_: &mut Loop, cb: ~Callback) -> ~IdleWatcher { let handle = UvHandle::alloc(None::, uvll::UV_IDLE); - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_idle_init(loop_.handle, handle) }, 0); let me = ~IdleWatcher { @@ -40,19 +40,19 @@ impl IdleWatcher { pub fn onetime(loop_: &mut Loop, f: proc()) { let handle = UvHandle::alloc(None::, uvll::UV_IDLE); unsafe { - assert_eq!(uvll::uv_idle_init(loop_.handle, handle), 0); + fail_unless_eq!(uvll::uv_idle_init(loop_.handle, handle), 0); let data: *c_void = cast::transmute(~f); uvll::set_data_for_uv_handle(handle, data); - assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0) + fail_unless_eq!(uvll::uv_idle_start(handle, onetime_cb), 0) } extern fn onetime_cb(handle: *uvll::uv_idle_t, status: c_int) { - assert_eq!(status, 0); + fail_unless_eq!(status, 0); unsafe { let data = uvll::get_data_for_uv_handle(handle); let f: ~proc() = cast::transmute(data); (*f)(); - assert_eq!(uvll::uv_idle_stop(handle), 0); + fail_unless_eq!(uvll::uv_idle_stop(handle), 0); uvll::uv_close(handle, close_cb); } } @@ -66,13 +66,13 @@ impl IdleWatcher { impl PausableIdleCallback for IdleWatcher { fn pause(&mut self) { if self.idle_flag == true { - assert_eq!(unsafe {uvll::uv_idle_stop(self.handle) }, 0); + fail_unless_eq!(unsafe {uvll::uv_idle_stop(self.handle) }, 0); self.idle_flag = false; } } fn resume(&mut self) { if self.idle_flag == false { - assert_eq!(unsafe { uvll::uv_idle_start(self.handle, idle_cb) }, 0) + fail_unless_eq!(unsafe { uvll::uv_idle_start(self.handle, idle_cb) }, 0) self.idle_flag = true; } } @@ -83,7 +83,7 @@ impl UvHandle for IdleWatcher { } extern fn idle_cb(handle: *uvll::uv_idle_t, status: c_int) { - assert_eq!(status, 0); + fail_unless_eq!(status, 0); let idle: &mut IdleWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; idle.callback.call(); } @@ -163,7 +163,7 @@ mod test { fn smoke_test() { let (mut idle, chan) = mk(1); idle.resume(); - assert_eq!(sleep(&chan), 1); + fail_unless_eq!(sleep(&chan), 1); } #[test] #[should_fail] @@ -189,15 +189,15 @@ mod test { fn fun_combinations_of_methods() { let (mut idle, chan) = mk(1); idle.resume(); - assert_eq!(sleep(&chan), 1); + fail_unless_eq!(sleep(&chan), 1); idle.pause(); idle.resume(); idle.resume(); - assert_eq!(sleep(&chan), 1); + fail_unless_eq!(sleep(&chan), 1); idle.pause(); idle.pause(); idle.resume(); - assert_eq!(sleep(&chan), 1); + fail_unless_eq!(sleep(&chan), 1); } #[test] @@ -205,9 +205,9 @@ mod test { let (mut idle1, chan1) = mk(1); let (mut idle2, chan2) = mk(2); idle2.resume(); - assert_eq!(sleep(&chan2), 2); + fail_unless_eq!(sleep(&chan2), 2); idle2.pause(); idle1.resume(); - assert_eq!(sleep(&chan1), 1); + fail_unless_eq!(sleep(&chan1), 1); } } diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 4c381a67ae6d9..a9b5f4e13e477 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -288,7 +288,7 @@ impl Loop { pub fn wrap(handle: *uvll::uv_loop_t) -> Loop { Loop { handle: handle } } pub fn run(&mut self) { - assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0); + fail_unless_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0); } pub fn close(&mut self) { @@ -348,7 +348,7 @@ impl ToStr for UvError { #[test] fn error_smoke_test() { let err: UvError = UvError(uvll::EOF); - assert_eq!(err.to_str(), ~"EOF: end of file"); + fail_unless_eq!(err.to_str(), ~"EOF: end of file"); } pub fn uv_error_to_io_error(uverr: UvError) -> IoError { @@ -442,7 +442,7 @@ mod test { let slice = [0, .. 20]; let buf = slice_to_uv_buf(slice); - assert_eq!(buf.len, 20); + fail_unless_eq!(buf.len, 20); unsafe { let base = transmute::<*u8, *mut u8>(buf.base); diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index b9856ef450981..2b5640cadf197 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -185,7 +185,7 @@ impl TcpWatcher { fn new_home(loop_: &Loop, home: HomeHandle) -> TcpWatcher { let handle = unsafe { uvll::malloc_handle(uvll::UV_TCP) }; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_tcp_init(loop_.handle, handle) }, 0); TcpWatcher { @@ -326,7 +326,7 @@ impl TcpListener { pub fn bind(io: &mut UvIoFactory, address: ip::SocketAddr) -> Result<~TcpListener, UvError> { let handle = unsafe { uvll::malloc_handle(uvll::UV_TCP) }; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_tcp_init(io.uv_loop(), handle) }, 0); let (port, chan) = Chan::new(); @@ -387,7 +387,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: c_int) { uvll::get_loop_for_uv_handle(server) }); let client = TcpWatcher::new_home(&loop_, tcp.home().clone()); - assert_eq!(unsafe { uvll::uv_accept(server, client.handle) }, 0); + fail_unless_eq!(unsafe { uvll::uv_accept(server, client.handle) }, 0); Ok(~client as ~rtio::RtioTcpStream) } n => Err(uv_error_to_io_error(UvError(n))) @@ -459,7 +459,7 @@ impl UdpWatcher { read_access: Access::new(), write_access: Access::new(), }; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_udp_init(io.uv_loop(), udp.handle) }, 0); let (addr, _len) = addr_to_sockaddr(address); @@ -551,7 +551,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { } unsafe { - assert_eq!(uvll::uv_udp_recv_stop(handle), 0) + fail_unless_eq!(uvll::uv_udp_recv_stop(handle), 0) } let cx: &mut Ctx = unsafe { @@ -711,7 +711,7 @@ mod test { fn connect_close_ip4() { match TcpWatcher::connect(local_loop(), next_test_ip4()) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.name(), ~"ECONNREFUSED"), + Err(e) => fail_unless_eq!(e.name(), ~"ECONNREFUSED"), } } @@ -719,7 +719,7 @@ mod test { fn connect_close_ip6() { match TcpWatcher::connect(local_loop(), next_test_ip6()) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.name(), ~"ECONNREFUSED"), + Err(e) => fail_unless_eq!(e.name(), ~"ECONNREFUSED"), } } @@ -759,7 +759,7 @@ mod test { Ok(10) => {} e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + fail_unless_eq!(buf[i], i + 1); } } Err(e) => fail!("{:?}", e) @@ -795,7 +795,7 @@ mod test { Ok(10) => {} e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + fail_unless_eq!(buf[i], i + 1); } } Err(e) => fail!("{:?}", e) @@ -823,11 +823,11 @@ mod test { chan.send(()); let mut buf = [0u8, ..10]; match w.recvfrom(buf) { - Ok((10, addr)) => assert_eq!(addr, client), + Ok((10, addr)) => fail_unless_eq!(addr, client), e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + fail_unless_eq!(buf[i], i + 1); } } Err(e) => fail!("{:?}", e) @@ -855,11 +855,11 @@ mod test { chan.send(()); let mut buf = [0u8, ..10]; match w.recvfrom(buf) { - Ok((10, addr)) => assert_eq!(addr, client), + Ok((10, addr)) => fail_unless_eq!(addr, client), e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + fail_unless_eq!(buf[i], i + 1); } } Err(e) => fail!("{:?}", e) @@ -903,7 +903,7 @@ mod test { let nread = stream.read(buf).unwrap(); total_bytes_read += nread; for i in range(0u, nread) { - assert_eq!(buf[i], 1); + fail_unless_eq!(buf[i], 1); } } uvdebug!("read {} bytes total", total_bytes_read); @@ -929,12 +929,12 @@ mod test { let mut buf2 = [0]; let (nread1, src1) = server.recvfrom(buf1).unwrap(); let (nread2, src2) = server.recvfrom(buf2).unwrap(); - assert_eq!(nread1, 1); - assert_eq!(nread2, 1); - assert_eq!(src1, client_addr); - assert_eq!(src2, client_addr); - assert_eq!(buf1[0], 1); - assert_eq!(buf2[0], 2); + fail_unless_eq!(nread1, 1); + fail_unless_eq!(nread2, 1); + fail_unless_eq!(src1, client_addr); + fail_unless_eq!(src2, client_addr); + fail_unless_eq!(buf1[0], 1); + fail_unless_eq!(buf2[0], 2); } #[test] @@ -966,8 +966,8 @@ mod test { let res = server_in.recvfrom(buf); fail_unless!(res.is_ok()); let (nread, src) = res.unwrap(); - assert_eq!(nread, 1); - assert_eq!(src, client_out_addr); + fail_unless_eq!(nread, 1); + fail_unless_eq!(src, client_out_addr); } fail_unless!(total_bytes_sent >= MAX); }); @@ -987,10 +987,10 @@ mod test { let res = client_in.recvfrom(buf); fail_unless!(res.is_ok()); let (nread, src) = res.unwrap(); - assert_eq!(src, server_out_addr); + fail_unless_eq!(src, server_out_addr); total_bytes_recv += nread; for i in range(0u, nread) { - assert_eq!(buf[i], 1); + fail_unless_eq!(buf[i], 1); } } // tell the server we're done @@ -1028,7 +1028,7 @@ mod test { let nread = stream.read(buf).unwrap(); for i in range(0u, nread) { let val = buf[i] as uint; - assert_eq!(val, current % 8); + fail_unless_eq!(val, current % 8); current += 1; } reads += 1; @@ -1050,9 +1050,9 @@ mod test { let mut stream = acceptor.accept().unwrap(); let mut buf = [0, .. 2048]; let nread = stream.read(buf).unwrap(); - assert_eq!(nread, 8); + fail_unless_eq!(nread, 8); for i in range(0u, nread) { - assert_eq!(buf[i], i as u8); + fail_unless_eq!(buf[i], i as u8); } }); diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs index 37525c8317fca..ac867e278ec23 100644 --- a/src/librustuv/pipe.rs +++ b/src/librustuv/pipe.rs @@ -61,7 +61,7 @@ impl PipeWatcher { let handle = uvll::malloc_handle(uvll::UV_NAMED_PIPE); fail_unless!(!handle.is_null()); let ipc = ipc as libc::c_int; - assert_eq!(uvll::uv_pipe_init(loop_.handle, handle, ipc), 0); + fail_unless_eq!(uvll::uv_pipe_init(loop_.handle, handle, ipc), 0); handle }; PipeWatcher { @@ -228,7 +228,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) { uvll::get_loop_for_uv_handle(server) }); let client = PipeWatcher::new_home(&loop_, pipe.home().clone(), false); - assert_eq!(unsafe { uvll::uv_accept(server, client.handle()) }, 0); + fail_unless_eq!(unsafe { uvll::uv_accept(server, client.handle()) }, 0); Ok(~client as ~RtioPipe) } n => Err(uv_error_to_io_error(UvError(n))) @@ -275,7 +275,7 @@ mod tests { fn bind_err() { match PipeListener::bind(local_loop(), &"path/to/nowhere".to_c_str()) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.name(), ~"EACCES"), + Err(e) => fail_unless_eq!(e.name(), ~"EACCES"), } } @@ -308,7 +308,7 @@ mod tests { let mut client = p.accept().unwrap(); let mut buf = [0]; fail_unless!(client.read(buf).unwrap() == 1); - assert_eq!(buf[0], 1); + fail_unless_eq!(buf[0], 1); fail_unless!(client.write([2]).is_ok()); }); port.recv(); @@ -316,7 +316,7 @@ mod tests { fail_unless!(c.write([1]).is_ok()); let mut buf = [0]; fail_unless!(c.read(buf).unwrap() == 1); - assert_eq!(buf[0], 2); + fail_unless_eq!(buf[0], 2); } #[test] #[should_fail] diff --git a/src/librustuv/queue.rs b/src/librustuv/queue.rs index da502ca72de57..45bc0aa8e206e 100644 --- a/src/librustuv/queue.rs +++ b/src/librustuv/queue.rs @@ -56,7 +56,7 @@ pub struct Queue { } extern fn async_cb(handle: *uvll::uv_async_t, status: c_int) { - assert_eq!(status, 0); + fail_unless_eq!(status, 0); let pool: &mut QueuePool = unsafe { cast::transmute(uvll::get_data_for_uv_handle(handle)) }; @@ -121,7 +121,7 @@ impl QueuePool { }; unsafe { - assert_eq!(uvll::uv_async_init(loop_.handle, handle, async_cb), 0); + fail_unless_eq!(uvll::uv_async_init(loop_.handle, handle, async_cb), 0); uvll::uv_unref(handle); let data: *c_void = *cast::transmute::<&~QueuePool, &*c_void>(&q); uvll::set_data_for_uv_handle(handle, data); diff --git a/src/librustuv/signal.rs b/src/librustuv/signal.rs index 0a66c3445ee42..32cef38081764 100644 --- a/src/librustuv/signal.rs +++ b/src/librustuv/signal.rs @@ -34,7 +34,7 @@ impl SignalWatcher { channel: channel, signal: signum, }; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_signal_init(io.uv_loop(), s.handle) }, 0); @@ -50,7 +50,7 @@ impl SignalWatcher { extern fn signal_cb(handle: *uvll::uv_signal_t, signum: c_int) { let s: &mut SignalWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; - assert_eq!(signum as int, s.signal as int); + fail_unless_eq!(signum as int, s.signal as int); s.channel.try_send(s.signal); } diff --git a/src/librustuv/stream.rs b/src/librustuv/stream.rs index e61dd249c7017..21cc7dde9548d 100644 --- a/src/librustuv/stream.rs +++ b/src/librustuv/stream.rs @@ -162,7 +162,7 @@ extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) { // triggered before the user calls `read` again. // FIXME: Is there a performance impact to calling // stop here? - unsafe { assert_eq!(uvll::uv_read_stop(handle), 0); } + unsafe { fail_unless_eq!(uvll::uv_read_stop(handle), 0); } rcx.result = nread; wakeup(&mut rcx.task); diff --git a/src/librustuv/timer.rs b/src/librustuv/timer.rs index 8c80cc9914504..8f7427282b9cb 100644 --- a/src/librustuv/timer.rs +++ b/src/librustuv/timer.rs @@ -35,7 +35,7 @@ pub enum NextAction { impl TimerWatcher { pub fn new(io: &mut UvIoFactory) -> ~TimerWatcher { let handle = UvHandle::alloc(None::, uvll::UV_TIMER); - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_timer_init(io.uv_loop(), handle) }, 0); let me = ~TimerWatcher { @@ -49,13 +49,13 @@ impl TimerWatcher { } fn start(&mut self, msecs: u64, period: u64) { - assert_eq!(unsafe { + fail_unless_eq!(unsafe { uvll::uv_timer_start(self.handle, timer_cb, msecs, period) }, 0) } fn stop(&mut self) { - assert_eq!(unsafe { uvll::uv_timer_stop(self.handle) }, 0) + fail_unless_eq!(unsafe { uvll::uv_timer_stop(self.handle) }, 0) } } @@ -132,7 +132,7 @@ impl RtioTimer for TimerWatcher { extern fn timer_cb(handle: *uvll::uv_timer_t, status: c_int) { let _f = ForbidSwitch::new("timer callback can't switch"); - assert_eq!(status, 0); + fail_unless_eq!(status, 0); let timer: &mut TimerWatcher = unsafe { UvHandle::from_uv_handle(&handle) }; match timer.action.take_unwrap() { @@ -196,8 +196,8 @@ mod test { let oport = timer.oneshot(1); let pport = timer.period(1); timer.sleep(1); - assert_eq!(oport.recv_opt(), None); - assert_eq!(pport.recv_opt(), None); + fail_unless_eq!(oport.recv_opt(), None); + fail_unless_eq!(pport.recv_opt(), None); timer.oneshot(1).recv(); } @@ -284,7 +284,7 @@ mod test { let mut timer = TimerWatcher::new(local_loop()); timer.oneshot(1000) }; - assert_eq!(port.recv_opt(), None); + fail_unless_eq!(port.recv_opt(), None); } #[test] @@ -293,7 +293,7 @@ mod test { let mut timer = TimerWatcher::new(local_loop()); timer.period(1000) }; - assert_eq!(port.recv_opt(), None); + fail_unless_eq!(port.recv_opt(), None); } #[test] diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 14406cb2a6a01..290bfc2d93b6d 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -122,7 +122,7 @@ fn test_callback_run_once() { unsafe { *count_ptr += 1 } }); event_loop.run(); - assert_eq!(count, 1); + fail_unless_eq!(count, 1); }); } diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index baaf3d7bb7447..3a8828ba9663c 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -350,14 +350,14 @@ pub unsafe fn free_req(v: *c_void) { #[test] fn handle_sanity_check() { unsafe { - assert_eq!(UV_HANDLE_TYPE_MAX as uint, rust_uv_handle_type_max()); + fail_unless_eq!(UV_HANDLE_TYPE_MAX as uint, rust_uv_handle_type_max()); } } #[test] fn request_sanity_check() { unsafe { - assert_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max()); + fail_unless_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max()); } } diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index 138bf1ac94b4e..1d60833a0ee27 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -277,16 +277,16 @@ pub fn parse(s: &str) -> Option { #[test] fn test_parse() { - assert_eq!(parse(""), None); - assert_eq!(parse(" "), None); - assert_eq!(parse("1"), None); - assert_eq!(parse("1.2"), None); - assert_eq!(parse("1.2"), None); - assert_eq!(parse("1"), None); - assert_eq!(parse("1.2"), None); - assert_eq!(parse("1.2.3-"), None); - assert_eq!(parse("a.b.c"), None); - assert_eq!(parse("1.2.3 abc"), None); + fail_unless_eq!(parse(""), None); + fail_unless_eq!(parse(" "), None); + fail_unless_eq!(parse("1"), None); + fail_unless_eq!(parse("1.2"), None); + fail_unless_eq!(parse("1.2"), None); + fail_unless_eq!(parse("1"), None); + fail_unless_eq!(parse("1.2"), None); + fail_unless_eq!(parse("1.2.3-"), None); + fail_unless_eq!(parse("a.b.c"), None); + fail_unless_eq!(parse("1.2.3 abc"), None); fail_unless!(parse("1.2.3") == Some(Version { major: 1u, @@ -358,10 +358,10 @@ fn test_parse() { #[test] fn test_eq() { - assert_eq!(parse("1.2.3"), parse("1.2.3")); - assert_eq!(parse("1.2.3-alpha1"), parse("1.2.3-alpha1")); - assert_eq!(parse("1.2.3+build.42"), parse("1.2.3+build.42")); - assert_eq!(parse("1.2.3-alpha1+42"), parse("1.2.3-alpha1+42")); + fail_unless_eq!(parse("1.2.3"), parse("1.2.3")); + fail_unless_eq!(parse("1.2.3-alpha1"), parse("1.2.3-alpha1")); + fail_unless_eq!(parse("1.2.3+build.42"), parse("1.2.3+build.42")); + fail_unless_eq!(parse("1.2.3-alpha1+42"), parse("1.2.3-alpha1+42")); } #[test] @@ -375,18 +375,18 @@ fn test_ne() { #[test] fn test_show() { - assert_eq!(format!("{}", parse("1.2.3").unwrap()), ~"1.2.3"); - assert_eq!(format!("{}", parse("1.2.3-alpha1").unwrap()), ~"1.2.3-alpha1"); - assert_eq!(format!("{}", parse("1.2.3+build.42").unwrap()), ~"1.2.3+build.42"); - assert_eq!(format!("{}", parse("1.2.3-alpha1+42").unwrap()), ~"1.2.3-alpha1+42"); + fail_unless_eq!(format!("{}", parse("1.2.3").unwrap()), ~"1.2.3"); + fail_unless_eq!(format!("{}", parse("1.2.3-alpha1").unwrap()), ~"1.2.3-alpha1"); + fail_unless_eq!(format!("{}", parse("1.2.3+build.42").unwrap()), ~"1.2.3+build.42"); + fail_unless_eq!(format!("{}", parse("1.2.3-alpha1+42").unwrap()), ~"1.2.3-alpha1+42"); } #[test] fn test_to_str() { - assert_eq!(parse("1.2.3").unwrap().to_str(), ~"1.2.3"); - assert_eq!(parse("1.2.3-alpha1").unwrap().to_str(), ~"1.2.3-alpha1"); - assert_eq!(parse("1.2.3+build.42").unwrap().to_str(), ~"1.2.3+build.42"); - assert_eq!(parse("1.2.3-alpha1+42").unwrap().to_str(), ~"1.2.3-alpha1+42"); + fail_unless_eq!(parse("1.2.3").unwrap().to_str(), ~"1.2.3"); + fail_unless_eq!(parse("1.2.3-alpha1").unwrap().to_str(), ~"1.2.3-alpha1"); + fail_unless_eq!(parse("1.2.3+build.42").unwrap().to_str(), ~"1.2.3+build.42"); + fail_unless_eq!(parse("1.2.3-alpha1+42").unwrap().to_str(), ~"1.2.3-alpha1+42"); } #[test] diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 6353204183389..ac4c2fa1afeff 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -267,58 +267,58 @@ mod tests { #[test] fn test_to_base64_basic() { - assert_eq!("".as_bytes().to_base64(STANDARD), ~""); - assert_eq!("f".as_bytes().to_base64(STANDARD), ~"Zg=="); - assert_eq!("fo".as_bytes().to_base64(STANDARD), ~"Zm8="); - assert_eq!("foo".as_bytes().to_base64(STANDARD), ~"Zm9v"); - assert_eq!("foob".as_bytes().to_base64(STANDARD), ~"Zm9vYg=="); - assert_eq!("fooba".as_bytes().to_base64(STANDARD), ~"Zm9vYmE="); - assert_eq!("foobar".as_bytes().to_base64(STANDARD), ~"Zm9vYmFy"); + fail_unless_eq!("".as_bytes().to_base64(STANDARD), ~""); + fail_unless_eq!("f".as_bytes().to_base64(STANDARD), ~"Zg=="); + fail_unless_eq!("fo".as_bytes().to_base64(STANDARD), ~"Zm8="); + fail_unless_eq!("foo".as_bytes().to_base64(STANDARD), ~"Zm9v"); + fail_unless_eq!("foob".as_bytes().to_base64(STANDARD), ~"Zm9vYg=="); + fail_unless_eq!("fooba".as_bytes().to_base64(STANDARD), ~"Zm9vYmE="); + fail_unless_eq!("foobar".as_bytes().to_base64(STANDARD), ~"Zm9vYmFy"); } #[test] fn test_to_base64_line_break() { fail_unless!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD}) .contains("\r\n")); - assert_eq!("foobar".as_bytes().to_base64(Config {line_length: Some(4), + fail_unless_eq!("foobar".as_bytes().to_base64(Config {line_length: Some(4), ..STANDARD}), ~"Zm9v\r\nYmFy"); } #[test] fn test_to_base64_padding() { - assert_eq!("f".as_bytes().to_base64(Config {pad: false, ..STANDARD}), ~"Zg"); - assert_eq!("fo".as_bytes().to_base64(Config {pad: false, ..STANDARD}), ~"Zm8"); + fail_unless_eq!("f".as_bytes().to_base64(Config {pad: false, ..STANDARD}), ~"Zg"); + fail_unless_eq!("fo".as_bytes().to_base64(Config {pad: false, ..STANDARD}), ~"Zm8"); } #[test] fn test_to_base64_url_safe() { - assert_eq!([251, 255].to_base64(URL_SAFE), ~"-_8"); - assert_eq!([251, 255].to_base64(STANDARD), ~"+/8="); + fail_unless_eq!([251, 255].to_base64(URL_SAFE), ~"-_8"); + fail_unless_eq!([251, 255].to_base64(STANDARD), ~"+/8="); } #[test] fn test_from_base64_basic() { - assert_eq!("".from_base64().unwrap(), "".as_bytes().to_owned()); - assert_eq!("Zg==".from_base64().unwrap(), "f".as_bytes().to_owned()); - assert_eq!("Zm8=".from_base64().unwrap(), "fo".as_bytes().to_owned()); - assert_eq!("Zm9v".from_base64().unwrap(), "foo".as_bytes().to_owned()); - assert_eq!("Zm9vYg==".from_base64().unwrap(), "foob".as_bytes().to_owned()); - assert_eq!("Zm9vYmE=".from_base64().unwrap(), "fooba".as_bytes().to_owned()); - assert_eq!("Zm9vYmFy".from_base64().unwrap(), "foobar".as_bytes().to_owned()); + fail_unless_eq!("".from_base64().unwrap(), "".as_bytes().to_owned()); + fail_unless_eq!("Zg==".from_base64().unwrap(), "f".as_bytes().to_owned()); + fail_unless_eq!("Zm8=".from_base64().unwrap(), "fo".as_bytes().to_owned()); + fail_unless_eq!("Zm9v".from_base64().unwrap(), "foo".as_bytes().to_owned()); + fail_unless_eq!("Zm9vYg==".from_base64().unwrap(), "foob".as_bytes().to_owned()); + fail_unless_eq!("Zm9vYmE=".from_base64().unwrap(), "fooba".as_bytes().to_owned()); + fail_unless_eq!("Zm9vYmFy".from_base64().unwrap(), "foobar".as_bytes().to_owned()); } #[test] fn test_from_base64_newlines() { - assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(), + fail_unless_eq!("Zm9v\r\nYmFy".from_base64().unwrap(), "foobar".as_bytes().to_owned()); - assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(), + fail_unless_eq!("Zm9vYg==\r\n".from_base64().unwrap(), "foob".as_bytes().to_owned()); } #[test] fn test_from_base64_urlsafe() { - assert_eq!("-_8".from_base64().unwrap(), "+/8=".from_base64().unwrap()); + fail_unless_eq!("-_8".from_base64().unwrap(), "+/8=".from_base64().unwrap()); } #[test] @@ -340,7 +340,7 @@ mod tests { for _ in range(0, 1000) { let times = task_rng().gen_range(1u, 100); let v = vec::from_fn(times, |_| random::()); - assert_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v); + fail_unless_eq!(v.to_base64(STANDARD).from_base64().unwrap(), v); } } diff --git a/src/libserialize/ebml.rs b/src/libserialize/ebml.rs index 316d14a93d11c..81a801edbae38 100644 --- a/src/libserialize/ebml.rs +++ b/src/libserialize/ebml.rs @@ -250,22 +250,22 @@ pub mod reader { pub fn doc_as_u8(d: Doc) -> u8 { - assert_eq!(d.end, d.start + 1u); + fail_unless_eq!(d.end, d.start + 1u); d.data[d.start] } pub fn doc_as_u16(d: Doc) -> u16 { - assert_eq!(d.end, d.start + 2u); + fail_unless_eq!(d.end, d.start + 2u); u64_from_be_bytes(d.data, d.start, 2u) as u16 } pub fn doc_as_u32(d: Doc) -> u32 { - assert_eq!(d.end, d.start + 4u); + fail_unless_eq!(d.end, d.start + 4u); u64_from_be_bytes(d.data, d.start, 4u) as u32 } pub fn doc_as_u64(d: Doc) -> u64 { - assert_eq!(d.end, d.start + 8u); + fail_unless_eq!(d.end, d.start + 8u); u64_from_be_bytes(d.data, d.start, 8u) } @@ -982,35 +982,35 @@ mod tests { // Class A res = reader::vuint_at(data, 0); - assert_eq!(res.val, 0); - assert_eq!(res.next, 1); + fail_unless_eq!(res.val, 0); + fail_unless_eq!(res.next, 1); res = reader::vuint_at(data, res.next); - assert_eq!(res.val, (1 << 7) - 1); - assert_eq!(res.next, 2); + fail_unless_eq!(res.val, (1 << 7) - 1); + fail_unless_eq!(res.next, 2); // Class B res = reader::vuint_at(data, res.next); - assert_eq!(res.val, 0); - assert_eq!(res.next, 4); + fail_unless_eq!(res.val, 0); + fail_unless_eq!(res.next, 4); res = reader::vuint_at(data, res.next); - assert_eq!(res.val, (1 << 14) - 1); - assert_eq!(res.next, 6); + fail_unless_eq!(res.val, (1 << 14) - 1); + fail_unless_eq!(res.next, 6); // Class C res = reader::vuint_at(data, res.next); - assert_eq!(res.val, 0); - assert_eq!(res.next, 9); + fail_unless_eq!(res.val, 0); + fail_unless_eq!(res.next, 9); res = reader::vuint_at(data, res.next); - assert_eq!(res.val, (1 << 21) - 1); - assert_eq!(res.next, 12); + fail_unless_eq!(res.val, (1 << 21) - 1); + fail_unless_eq!(res.next, 12); // Class D res = reader::vuint_at(data, res.next); - assert_eq!(res.val, 0); - assert_eq!(res.next, 16); + fail_unless_eq!(res.val, 0); + fail_unless_eq!(res.next, 16); res = reader::vuint_at(data, res.next); - assert_eq!(res.val, (1 << 28) - 1); - assert_eq!(res.next, 20); + fail_unless_eq!(res.val, (1 << 28) - 1); + fail_unless_eq!(res.next, 20); } #[test] @@ -1026,7 +1026,7 @@ mod tests { let mut deser = reader::Decoder(ebml_doc); let v1 = Decodable::decode(&mut deser); debug!("v1 == {:?}", v1); - assert_eq!(v, v1); + fail_unless_eq!(v, v1); } test_v(Some(22)); diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 405fbad603b4f..42bfb521e53e6 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -145,14 +145,14 @@ mod tests { #[test] pub fn test_to_hex() { - assert_eq!("foobar".as_bytes().to_hex(), ~"666f6f626172"); + fail_unless_eq!("foobar".as_bytes().to_hex(), ~"666f6f626172"); } #[test] pub fn test_from_hex_okay() { - assert_eq!("666f6f626172".from_hex().unwrap(), + fail_unless_eq!("666f6f626172".from_hex().unwrap(), "foobar".as_bytes().to_owned()); - assert_eq!("666F6F626172".from_hex().unwrap(), + fail_unless_eq!("666F6F626172".from_hex().unwrap(), "foobar".as_bytes().to_owned()); } @@ -169,22 +169,22 @@ mod tests { #[test] pub fn test_from_hex_ignores_whitespace() { - assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(), + fail_unless_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(), "foobar".as_bytes().to_owned()); } #[test] pub fn test_to_hex_all_bytes() { for i in range(0, 256) { - assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint)); + fail_unless_eq!([i as u8].to_hex(), format!("{:02x}", i as uint)); } } #[test] pub fn test_from_hex_all_bytes() { for i in range(0, 256) { - assert_eq!(format!("{:02x}", i as uint).from_hex().unwrap(), ~[i as u8]); - assert_eq!(format!("{:02X}", i as uint).from_hex().unwrap(), ~[i as u8]); + fail_unless_eq!(format!("{:02x}", i as uint).from_hex().unwrap(), ~[i as u8]); + fail_unless_eq!(format!("{:02X}", i as uint).from_hex().unwrap(), ~[i as u8]); } } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index e57e7adcf8ddb..e8e9634402e71 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -495,7 +495,7 @@ impl,T1:Encodable> Encodable for (T0, T1) { impl,T1:Decodable> Decodable for (T0, T1) { fn decode(d: &mut D) -> (T0, T1) { d.read_seq(|d, len| { - assert_eq!(len, 2); + fail_unless_eq!(len, 2); ( d.read_seq_elt(0, |d| Decodable::decode(d)), d.read_seq_elt(1, |d| Decodable::decode(d)) @@ -531,7 +531,7 @@ impl< > Decodable for (T0, T1, T2) { fn decode(d: &mut D) -> (T0, T1, T2) { d.read_seq(|d, len| { - assert_eq!(len, 3); + fail_unless_eq!(len, 3); ( d.read_seq_elt(0, |d| Decodable::decode(d)), d.read_seq_elt(1, |d| Decodable::decode(d)), @@ -571,7 +571,7 @@ impl< > Decodable for (T0, T1, T2, T3) { fn decode(d: &mut D) -> (T0, T1, T2, T3) { d.read_seq(|d, len| { - assert_eq!(len, 4); + fail_unless_eq!(len, 4); ( d.read_seq_elt(0, |d| Decodable::decode(d)), d.read_seq_elt(1, |d| Decodable::decode(d)), @@ -615,7 +615,7 @@ impl< > Decodable for (T0, T1, T2, T3, T4) { fn decode(d: &mut D) -> (T0, T1, T2, T3, T4) { d.read_seq(|d, len| { - assert_eq!(len, 5); + fail_unless_eq!(len, 5); ( d.read_seq_elt(0, |d| Decodable::decode(d)), d.read_seq_elt(1, |d| Decodable::decode(d)), diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 3ef7cf26a05c6..f7e66b6c0df21 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -188,18 +188,18 @@ mod tests { let b_r: &Any = b; let c_r: &Any = c; - assert_eq!(a.as_void_ptr(), a_r.as_void_ptr()); - assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); - assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); + fail_unless_eq!(a.as_void_ptr(), a_r.as_void_ptr()); + fail_unless_eq!(b.as_void_ptr(), b_r.as_void_ptr()); + fail_unless_eq!(c.as_void_ptr(), c_r.as_void_ptr()); let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any); let a_r: &Any = a; let b_r: &Any = b; let c_r: &Any = c; - assert_eq!(a.as_void_ptr(), a_r.as_void_ptr()); - assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); - assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); + fail_unless_eq!(a.as_void_ptr(), a_r.as_void_ptr()); + fail_unless_eq!(b.as_void_ptr(), b_r.as_void_ptr()); + fail_unless_eq!(c.as_void_ptr(), c_r.as_void_ptr()); let mut x = Test; let mut y: &'static str = "Test"; @@ -210,16 +210,16 @@ mod tests { let b_r: &Any = b; let c_r: &Any = c; - assert_eq!(a.as_void_ptr(), a_r.as_void_ptr()); - assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); - assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); + fail_unless_eq!(a.as_void_ptr(), a_r.as_void_ptr()); + fail_unless_eq!(b.as_void_ptr(), b_r.as_void_ptr()); + fail_unless_eq!(c.as_void_ptr(), c_r.as_void_ptr()); let (a, b, c) = (5u, "hello", Test); let (a_r, b_r, c_r) = (&a as &Any, &b as &Any, &c as &Any); - assert_eq!(a.as_void_ptr(), a_r.as_void_ptr()); - assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); - assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); + fail_unless_eq!(a.as_void_ptr(), a_r.as_void_ptr()); + fail_unless_eq!(b.as_void_ptr(), b_r.as_void_ptr()); + fail_unless_eq!(c.as_void_ptr(), c_r.as_void_ptr()); } #[test] @@ -237,9 +237,9 @@ mod tests { let b_r: &mut Any = b; let c_r: &mut Any = c; - assert_eq!(a_ptr, a_r.as_mut_void_ptr()); - assert_eq!(b_ptr, b_r.as_mut_void_ptr()); - assert_eq!(c_ptr, c_r.as_mut_void_ptr()); + fail_unless_eq!(a_ptr, a_r.as_mut_void_ptr()); + fail_unless_eq!(b_ptr, b_r.as_mut_void_ptr()); + fail_unless_eq!(c_ptr, c_r.as_mut_void_ptr()); let mut x = Test; let mut y: &'static str = "Test"; @@ -255,9 +255,9 @@ mod tests { let b_r: &mut Any = b; let c_r: &mut Any = c; - assert_eq!(a_ptr, a_r.as_mut_void_ptr()); - assert_eq!(b_ptr, b_r.as_mut_void_ptr()); - assert_eq!(c_ptr, c_r.as_mut_void_ptr()); + fail_unless_eq!(a_ptr, a_r.as_mut_void_ptr()); + fail_unless_eq!(b_ptr, b_r.as_mut_void_ptr()); + fail_unless_eq!(c_ptr, c_r.as_mut_void_ptr()); let y: &'static str = "Test"; let mut a = 5u; @@ -270,9 +270,9 @@ mod tests { let (a_r, b_r, c_r) = (&mut a as &mut Any, &mut b as &mut Any, &mut c as &mut Any); - assert_eq!(a_ptr, a_r.as_mut_void_ptr()); - assert_eq!(b_ptr, b_r.as_mut_void_ptr()); - assert_eq!(c_ptr, c_r.as_mut_void_ptr()); + fail_unless_eq!(a_ptr, a_r.as_mut_void_ptr()); + fail_unless_eq!(b_ptr, b_r.as_mut_void_ptr()); + fail_unless_eq!(c_ptr, c_r.as_mut_void_ptr()); } #[test] @@ -335,7 +335,7 @@ mod tests { match a_r.as_mut::() { Some(x) => { - assert_eq!(*x, 5u); + fail_unless_eq!(*x, 5u); *x = 612; } x => fail!("Unexpected value {:?}", x) @@ -343,7 +343,7 @@ mod tests { match b_r.as_mut::() { Some(x) => { - assert_eq!(*x, 7u); + fail_unless_eq!(*x, 7u); *x = 413; } x => fail!("Unexpected value {:?}", x) @@ -376,11 +376,11 @@ mod tests { let b = ~Test as ~Any; match a.move::() { - Ok(a) => { assert_eq!(a, ~8u); } + Ok(a) => { fail_unless_eq!(a, ~8u); } Err(..) => fail!() } match b.move::() { - Ok(a) => { assert_eq!(a, ~Test); } + Ok(a) => { fail_unless_eq!(a, ~Test); } Err(..) => fail!() } @@ -395,12 +395,12 @@ mod tests { fn test_show() { let a = ~8u as ~Any; let b = ~Test as ~Any; - assert_eq!(format!("{}", a), ~"~Any"); - assert_eq!(format!("{}", b), ~"~Any"); + fail_unless_eq!(format!("{}", a), ~"~Any"); + fail_unless_eq!(format!("{}", b), ~"~Any"); let a = &8u as &Any; let b = &Test as &Any; - assert_eq!(format!("{}", a), ~"&Any"); - assert_eq!(format!("{}", b), ~"&Any"); + fail_unless_eq!(format!("{}", a), ~"&Any"); + fail_unless_eq!(format!("{}", b), ~"&Any"); } } diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 58e0a165159fe..b9fcf48c73e7b 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -498,20 +498,20 @@ mod tests { #[test] fn test_ascii() { - assert_eq!(65u8.to_ascii().to_byte(), 65u8); - assert_eq!(65u8.to_ascii().to_char(), 'A'); - assert_eq!('A'.to_ascii().to_char(), 'A'); - assert_eq!('A'.to_ascii().to_byte(), 65u8); + fail_unless_eq!(65u8.to_ascii().to_byte(), 65u8); + fail_unless_eq!(65u8.to_ascii().to_char(), 'A'); + fail_unless_eq!('A'.to_ascii().to_char(), 'A'); + fail_unless_eq!('A'.to_ascii().to_byte(), 65u8); - assert_eq!('A'.to_ascii().to_lower().to_char(), 'a'); - assert_eq!('Z'.to_ascii().to_lower().to_char(), 'z'); - assert_eq!('a'.to_ascii().to_upper().to_char(), 'A'); - assert_eq!('z'.to_ascii().to_upper().to_char(), 'Z'); + fail_unless_eq!('A'.to_ascii().to_lower().to_char(), 'a'); + fail_unless_eq!('Z'.to_ascii().to_lower().to_char(), 'z'); + fail_unless_eq!('a'.to_ascii().to_upper().to_char(), 'A'); + fail_unless_eq!('z'.to_ascii().to_upper().to_char(), 'Z'); - assert_eq!('@'.to_ascii().to_lower().to_char(), '@'); - assert_eq!('['.to_ascii().to_lower().to_char(), '['); - assert_eq!('`'.to_ascii().to_upper().to_char(), '`'); - assert_eq!('{'.to_ascii().to_upper().to_char(), '{'); + fail_unless_eq!('@'.to_ascii().to_lower().to_char(), '@'); + fail_unless_eq!('['.to_ascii().to_lower().to_char(), '['); + fail_unless_eq!('`'.to_ascii().to_upper().to_char(), '`'); + fail_unless_eq!('{'.to_ascii().to_upper().to_char(), '{'); fail_unless!('0'.to_ascii().is_digit()); fail_unless!('9'.to_ascii().is_digit()); @@ -529,19 +529,19 @@ mod tests { #[test] fn test_ascii_vec() { let test = &[40u8, 32u8, 59u8]; - assert_eq!(test.to_ascii(), v2ascii!([40, 32, 59])); - assert_eq!("( ;".to_ascii(), v2ascii!([40, 32, 59])); + fail_unless_eq!(test.to_ascii(), v2ascii!([40, 32, 59])); + fail_unless_eq!("( ;".to_ascii(), v2ascii!([40, 32, 59])); // FIXME: #5475 borrowchk error, owned vectors do not live long enough // if chained-from directly - let v = ~[40u8, 32u8, 59u8]; assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); - let v = ~"( ;"; assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); + let v = ~[40u8, 32u8, 59u8]; fail_unless_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); + let v = ~"( ;"; fail_unless_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); - assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), ~"abcdef&?#"); - assert_eq!("abCDef&?#".to_ascii().to_upper().into_str(), ~"ABCDEF&?#"); + fail_unless_eq!("abCDef&?#".to_ascii().to_lower().into_str(), ~"abcdef&?#"); + fail_unless_eq!("abCDef&?#".to_ascii().to_upper().into_str(), ~"ABCDEF&?#"); - assert_eq!("".to_ascii().to_lower().into_str(), ~""); - assert_eq!("YMCA".to_ascii().to_lower().into_str(), ~"ymca"); - assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), ~"ABCDEFXYZ:.;"); + fail_unless_eq!("".to_ascii().to_lower().into_str(), ~""); + fail_unless_eq!("YMCA".to_ascii().to_lower().into_str(), ~"ymca"); + fail_unless_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_str(), ~"ABCDEFXYZ:.;"); fail_unless!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii())); @@ -553,24 +553,24 @@ mod tests { #[test] fn test_owned_ascii_vec() { - assert_eq!((~"( ;").into_ascii(), v2ascii!(~[40, 32, 59])); - assert_eq!((~[40u8, 32u8, 59u8]).into_ascii(), v2ascii!(~[40, 32, 59])); + fail_unless_eq!((~"( ;").into_ascii(), v2ascii!(~[40, 32, 59])); + fail_unless_eq!((~[40u8, 32u8, 59u8]).into_ascii(), v2ascii!(~[40, 32, 59])); } #[test] fn test_ascii_as_str() { let v = v2ascii!([40, 32, 59]); - assert_eq!(v.as_str_ascii(), "( ;"); + fail_unless_eq!(v.as_str_ascii(), "( ;"); } #[test] fn test_ascii_into_str() { - assert_eq!(v2ascii!(~[40, 32, 59]).into_str(), ~"( ;"); + fail_unless_eq!(v2ascii!(~[40, 32, 59]).into_str(), ~"( ;"); } #[test] fn test_ascii_to_bytes() { - assert_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), ~[40u8, 32u8, 59u8]); + fail_unless_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), ~[40u8, 32u8, 59u8]); } #[test] #[should_fail] @@ -587,45 +587,45 @@ mod tests { #[test] fn test_opt() { - assert_eq!(65u8.to_ascii_opt(), Some(Ascii { chr: 65u8 })); - assert_eq!(255u8.to_ascii_opt(), None); + fail_unless_eq!(65u8.to_ascii_opt(), Some(Ascii { chr: 65u8 })); + fail_unless_eq!(255u8.to_ascii_opt(), None); - assert_eq!('A'.to_ascii_opt(), Some(Ascii { chr: 65u8 })); - assert_eq!('λ'.to_ascii_opt(), None); + fail_unless_eq!('A'.to_ascii_opt(), Some(Ascii { chr: 65u8 })); + fail_unless_eq!('λ'.to_ascii_opt(), None); - assert_eq!("zoä华".to_ascii_opt(), None); + fail_unless_eq!("zoä华".to_ascii_opt(), None); let test1 = &[127u8, 128u8, 255u8]; - assert_eq!((test1).to_ascii_opt(), None); + fail_unless_eq!((test1).to_ascii_opt(), None); let v = [40u8, 32u8, 59u8]; let v2 = v2ascii!(&[40, 32, 59]); - assert_eq!(v.to_ascii_opt(), Some(v2)); + fail_unless_eq!(v.to_ascii_opt(), Some(v2)); let v = [127u8, 128u8, 255u8]; - assert_eq!(v.to_ascii_opt(), None); + fail_unless_eq!(v.to_ascii_opt(), None); let v = "( ;"; let v2 = v2ascii!(&[40, 32, 59]); - assert_eq!(v.to_ascii_opt(), Some(v2)); - assert_eq!("zoä华".to_ascii_opt(), None); + fail_unless_eq!(v.to_ascii_opt(), Some(v2)); + fail_unless_eq!("zoä华".to_ascii_opt(), None); - assert_eq!((~[40u8, 32u8, 59u8]).into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); - assert_eq!((~[127u8, 128u8, 255u8]).into_ascii_opt(), None); + fail_unless_eq!((~[40u8, 32u8, 59u8]).into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); + fail_unless_eq!((~[127u8, 128u8, 255u8]).into_ascii_opt(), None); - assert_eq!((~"( ;").into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); - assert_eq!((~"zoä华").into_ascii_opt(), None); + fail_unless_eq!((~"( ;").into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); + fail_unless_eq!((~"zoä华").into_ascii_opt(), None); } #[test] fn test_to_ascii_upper() { - assert_eq!("url()URL()uRl()ürl".to_ascii_upper(), ~"URL()URL()URL()üRL"); - assert_eq!("hıKß".to_ascii_upper(), ~"HıKß"); + fail_unless_eq!("url()URL()uRl()ürl".to_ascii_upper(), ~"URL()URL()URL()üRL"); + fail_unless_eq!("hıKß".to_ascii_upper(), ~"HıKß"); let mut i = 0; while i <= 500 { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; - assert_eq!(from_char(from_u32(i).unwrap()).to_ascii_upper(), + fail_unless_eq!(from_char(from_u32(i).unwrap()).to_ascii_upper(), from_char(from_u32(upper).unwrap())) i += 1; } @@ -633,15 +633,15 @@ mod tests { #[test] fn test_to_ascii_lower() { - assert_eq!("url()URL()uRl()Ürl".to_ascii_lower(), ~"url()url()url()Ürl"); + fail_unless_eq!("url()URL()uRl()Ürl".to_ascii_lower(), ~"url()url()url()Ürl"); // Dotted capital I, Kelvin sign, Sharp S. - assert_eq!("HİKß".to_ascii_lower(), ~"hİKß"); + fail_unless_eq!("HİKß".to_ascii_lower(), ~"hİKß"); let mut i = 0; while i <= 500 { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; - assert_eq!(from_char(from_u32(i).unwrap()).to_ascii_lower(), + fail_unless_eq!(from_char(from_u32(i).unwrap()).to_ascii_lower(), from_char(from_u32(lower).unwrap())) i += 1; } @@ -649,14 +649,14 @@ mod tests { #[test] fn test_into_ascii_upper() { - assert_eq!((~"url()URL()uRl()ürl").into_ascii_upper(), ~"URL()URL()URL()üRL"); - assert_eq!((~"hıKß").into_ascii_upper(), ~"HıKß"); + fail_unless_eq!((~"url()URL()uRl()ürl").into_ascii_upper(), ~"URL()URL()URL()üRL"); + fail_unless_eq!((~"hıKß").into_ascii_upper(), ~"HıKß"); let mut i = 0; while i <= 500 { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; - assert_eq!(from_char(from_u32(i).unwrap()).into_ascii_upper(), + fail_unless_eq!(from_char(from_u32(i).unwrap()).into_ascii_upper(), from_char(from_u32(upper).unwrap())) i += 1; } @@ -664,15 +664,15 @@ mod tests { #[test] fn test_into_ascii_lower() { - assert_eq!((~"url()URL()uRl()Ürl").into_ascii_lower(), ~"url()url()url()Ürl"); + fail_unless_eq!((~"url()URL()uRl()Ürl").into_ascii_lower(), ~"url()url()url()Ürl"); // Dotted capital I, Kelvin sign, Sharp S. - assert_eq!((~"HİKß").into_ascii_lower(), ~"hİKß"); + fail_unless_eq!((~"HİKß").into_ascii_lower(), ~"hİKß"); let mut i = 0; while i <= 500 { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; - assert_eq!(from_char(from_u32(i).unwrap()).into_ascii_lower(), + fail_unless_eq!(from_char(from_u32(i).unwrap()).into_ascii_lower(), from_char(from_u32(lower).unwrap())) i += 1; } @@ -702,12 +702,12 @@ mod tests { #[test] fn test_to_str() { let s = Ascii{ chr: 't' as u8 }.to_str(); - assert_eq!(s, ~"t"); + fail_unless_eq!(s, ~"t"); } #[test] fn test_show() { let c = Ascii { chr: 't' as u8 }; - assert_eq!(format!("{}", c), ~"t"); + fail_unless_eq!(format!("{}", c), ~"t"); } } diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index 5cb0f0f3307d1..11dbfed6543c6 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -73,10 +73,10 @@ pub trait Bool { /// # Examples /// /// ```rust - /// assert_eq!(true.and(true), true); - /// assert_eq!(true.and(false), false); - /// assert_eq!(false.and(true), false); - /// assert_eq!(false.and(false), false); + /// fail_unless_eq!(true.and(true), true); + /// fail_unless_eq!(true.and(false), false); + /// fail_unless_eq!(false.and(true), false); + /// fail_unless_eq!(false.and(false), false); /// ``` fn and(self, b: bool) -> bool; @@ -85,10 +85,10 @@ pub trait Bool { /// # Examples /// /// ```rust - /// assert_eq!(true.or(true), true); - /// assert_eq!(true.or(false), true); - /// assert_eq!(false.or(true), true); - /// assert_eq!(false.or(false), false); + /// fail_unless_eq!(true.or(true), true); + /// fail_unless_eq!(true.or(false), true); + /// fail_unless_eq!(false.or(true), true); + /// fail_unless_eq!(false.or(false), false); /// ``` fn or(self, b: bool) -> bool; @@ -99,10 +99,10 @@ pub trait Bool { /// # Examples /// /// ```rust - /// assert_eq!(true.xor(true), false); - /// assert_eq!(true.xor(false), true); - /// assert_eq!(false.xor(true), true); - /// assert_eq!(false.xor(false), false); + /// fail_unless_eq!(true.xor(true), false); + /// fail_unless_eq!(true.xor(false), true); + /// fail_unless_eq!(false.xor(true), true); + /// fail_unless_eq!(false.xor(false), false); /// ``` fn xor(self, b: bool) -> bool; @@ -115,10 +115,10 @@ pub trait Bool { /// # Examples /// /// ```rust - /// assert_eq!(true.implies(true), true); - /// assert_eq!(true.implies(false), false); - /// assert_eq!(false.implies(true), true); - /// assert_eq!(false.implies(false), true); + /// fail_unless_eq!(true.implies(true), true); + /// fail_unless_eq!(true.implies(false), false); + /// fail_unless_eq!(false.implies(true), true); + /// fail_unless_eq!(false.implies(false), true); /// ``` fn implies(self, b: bool) -> bool; @@ -127,8 +127,8 @@ pub trait Bool { /// # Examples /// /// ```rust - /// assert_eq!(true.to_bit::(), 1u8); - /// assert_eq!(false.to_bit::(), 0u8); + /// fail_unless_eq!(true.to_bit::(), 1u8); + /// fail_unless_eq!(false.to_bit::(), 0u8); /// ``` fn to_bit(self) -> N; } @@ -165,9 +165,9 @@ impl FromStr for bool { /// # Examples /// /// ```rust - /// assert_eq!(from_str::("true"), Some(true)); - /// assert_eq!(from_str::("false"), Some(false)); - /// assert_eq!(from_str::("not even a boolean"), None); + /// fail_unless_eq!(from_str::("true"), Some(true)); + /// fail_unless_eq!(from_str::("false"), Some(false)); + /// fail_unless_eq!(from_str::("not even a boolean"), None); /// ``` #[inline] fn from_str(s: &str) -> Option { @@ -185,8 +185,8 @@ impl ToStr for bool { /// # Examples /// /// ```rust - /// assert_eq!(true.to_str(), ~"true"); - /// assert_eq!(false.to_str(), ~"false"); + /// fail_unless_eq!(true.to_str(), ~"true"); + /// fail_unless_eq!(false.to_str(), ~"false"); /// ``` #[inline] fn to_str(&self) -> ~str { @@ -201,8 +201,8 @@ impl Not for bool { /// # Examples /// /// ```rust - /// assert_eq!(!true, false); - /// assert_eq!(!false, true); + /// fail_unless_eq!(!true, false); + /// fail_unless_eq!(!false, true); /// ``` #[inline] fn not(&self) -> bool { !*self } @@ -215,15 +215,15 @@ impl BitAnd for bool { /// # Examples /// /// ```rust - /// assert_eq!(false.bitand(&false), false); - /// assert_eq!(true.bitand(&false), false); - /// assert_eq!(false.bitand(&true), false); - /// assert_eq!(true.bitand(&true), true); + /// fail_unless_eq!(false.bitand(&false), false); + /// fail_unless_eq!(true.bitand(&false), false); + /// fail_unless_eq!(false.bitand(&true), false); + /// fail_unless_eq!(true.bitand(&true), true); /// - /// assert_eq!(false & false, false); - /// assert_eq!(true & false, false); - /// assert_eq!(false & true, false); - /// assert_eq!(true & true, true); + /// fail_unless_eq!(false & false, false); + /// fail_unless_eq!(true & false, false); + /// fail_unless_eq!(false & true, false); + /// fail_unless_eq!(true & true, true); /// ``` #[inline] fn bitand(&self, b: &bool) -> bool { *self & *b } @@ -236,15 +236,15 @@ impl BitOr for bool { /// # Examples /// /// ```rust - /// assert_eq!(false.bitor(&false), false); - /// assert_eq!(true.bitor(&false), true); - /// assert_eq!(false.bitor(&true), true); - /// assert_eq!(true.bitor(&true), true); + /// fail_unless_eq!(false.bitor(&false), false); + /// fail_unless_eq!(true.bitor(&false), true); + /// fail_unless_eq!(false.bitor(&true), true); + /// fail_unless_eq!(true.bitor(&true), true); /// - /// assert_eq!(false | false, false); - /// assert_eq!(true | false, true); - /// assert_eq!(false | true, true); - /// assert_eq!(true | true, true); + /// fail_unless_eq!(false | false, false); + /// fail_unless_eq!(true | false, true); + /// fail_unless_eq!(false | true, true); + /// fail_unless_eq!(true | true, true); /// ``` #[inline] fn bitor(&self, b: &bool) -> bool { *self | *b } @@ -259,15 +259,15 @@ impl BitXor for bool { /// # Examples /// /// ```rust - /// assert_eq!(false.bitxor(&false), false); - /// assert_eq!(true.bitxor(&false), true); - /// assert_eq!(false.bitxor(&true), true); - /// assert_eq!(true.bitxor(&true), false); + /// fail_unless_eq!(false.bitxor(&false), false); + /// fail_unless_eq!(true.bitxor(&false), true); + /// fail_unless_eq!(false.bitxor(&true), true); + /// fail_unless_eq!(true.bitxor(&true), false); /// - /// assert_eq!(false ^ false, false); - /// assert_eq!(true ^ false, true); - /// assert_eq!(false ^ true, true); - /// assert_eq!(true ^ true, false); + /// fail_unless_eq!(false ^ false, false); + /// fail_unless_eq!(true ^ false, true); + /// fail_unless_eq!(false ^ true, true); + /// fail_unless_eq!(true ^ true, false); /// ``` #[inline] fn bitxor(&self, b: &bool) -> bool { *self ^ *b } @@ -292,10 +292,10 @@ impl TotalOrd for bool { /// # Examples /// /// ```rust -/// assert_eq!(false.eq(&true), false); -/// assert_eq!(false == false, true); -/// assert_eq!(false != true, true); -/// assert_eq!(false.ne(&false), false); +/// fail_unless_eq!(false.eq(&true), false); +/// fail_unless_eq!(false == false, true); +/// fail_unless_eq!(false != true, true); +/// fail_unless_eq!(false.ne(&false), false); /// ``` #[cfg(not(test))] impl Eq for bool { @@ -315,73 +315,73 @@ mod tests { #[test] fn test_bool() { - assert_eq!(false.eq(&true), false); - assert_eq!(false == false, true); - assert_eq!(false != true, true); - assert_eq!(false.ne(&false), false); - - assert_eq!(false.bitand(&false), false); - assert_eq!(true.bitand(&false), false); - assert_eq!(false.bitand(&true), false); - assert_eq!(true.bitand(&true), true); - - assert_eq!(false & false, false); - assert_eq!(true & false, false); - assert_eq!(false & true, false); - assert_eq!(true & true, true); - - assert_eq!(false.bitor(&false), false); - assert_eq!(true.bitor(&false), true); - assert_eq!(false.bitor(&true), true); - assert_eq!(true.bitor(&true), true); - - assert_eq!(false | false, false); - assert_eq!(true | false, true); - assert_eq!(false | true, true); - assert_eq!(true | true, true); - - assert_eq!(false.bitxor(&false), false); - assert_eq!(true.bitxor(&false), true); - assert_eq!(false.bitxor(&true), true); - assert_eq!(true.bitxor(&true), false); - - assert_eq!(false ^ false, false); - assert_eq!(true ^ false, true); - assert_eq!(false ^ true, true); - assert_eq!(true ^ true, false); - - assert_eq!(!true, false); - assert_eq!(!false, true); - - assert_eq!(true.to_str(), ~"true"); - assert_eq!(false.to_str(), ~"false"); - - assert_eq!(from_str::("true"), Some(true)); - assert_eq!(from_str::("false"), Some(false)); - assert_eq!(from_str::("not even a boolean"), None); - - assert_eq!(true.and(true), true); - assert_eq!(true.and(false), false); - assert_eq!(false.and(true), false); - assert_eq!(false.and(false), false); - - assert_eq!(true.or(true), true); - assert_eq!(true.or(false), true); - assert_eq!(false.or(true), true); - assert_eq!(false.or(false), false); - - assert_eq!(true.xor(true), false); - assert_eq!(true.xor(false), true); - assert_eq!(false.xor(true), true); - assert_eq!(false.xor(false), false); - - assert_eq!(true.implies(true), true); - assert_eq!(true.implies(false), false); - assert_eq!(false.implies(true), true); - assert_eq!(false.implies(false), true); - - assert_eq!(true.to_bit::(), 1u8); - assert_eq!(false.to_bit::(), 0u8); + fail_unless_eq!(false.eq(&true), false); + fail_unless_eq!(false == false, true); + fail_unless_eq!(false != true, true); + fail_unless_eq!(false.ne(&false), false); + + fail_unless_eq!(false.bitand(&false), false); + fail_unless_eq!(true.bitand(&false), false); + fail_unless_eq!(false.bitand(&true), false); + fail_unless_eq!(true.bitand(&true), true); + + fail_unless_eq!(false & false, false); + fail_unless_eq!(true & false, false); + fail_unless_eq!(false & true, false); + fail_unless_eq!(true & true, true); + + fail_unless_eq!(false.bitor(&false), false); + fail_unless_eq!(true.bitor(&false), true); + fail_unless_eq!(false.bitor(&true), true); + fail_unless_eq!(true.bitor(&true), true); + + fail_unless_eq!(false | false, false); + fail_unless_eq!(true | false, true); + fail_unless_eq!(false | true, true); + fail_unless_eq!(true | true, true); + + fail_unless_eq!(false.bitxor(&false), false); + fail_unless_eq!(true.bitxor(&false), true); + fail_unless_eq!(false.bitxor(&true), true); + fail_unless_eq!(true.bitxor(&true), false); + + fail_unless_eq!(false ^ false, false); + fail_unless_eq!(true ^ false, true); + fail_unless_eq!(false ^ true, true); + fail_unless_eq!(true ^ true, false); + + fail_unless_eq!(!true, false); + fail_unless_eq!(!false, true); + + fail_unless_eq!(true.to_str(), ~"true"); + fail_unless_eq!(false.to_str(), ~"false"); + + fail_unless_eq!(from_str::("true"), Some(true)); + fail_unless_eq!(from_str::("false"), Some(false)); + fail_unless_eq!(from_str::("not even a boolean"), None); + + fail_unless_eq!(true.and(true), true); + fail_unless_eq!(true.and(false), false); + fail_unless_eq!(false.and(true), false); + fail_unless_eq!(false.and(false), false); + + fail_unless_eq!(true.or(true), true); + fail_unless_eq!(true.or(false), true); + fail_unless_eq!(false.or(true), true); + fail_unless_eq!(false.or(false), false); + + fail_unless_eq!(true.xor(true), false); + fail_unless_eq!(true.xor(false), true); + fail_unless_eq!(false.xor(true), true); + fail_unless_eq!(false.xor(false), false); + + fail_unless_eq!(true.implies(true), true); + fail_unless_eq!(true.implies(false), false); + fail_unless_eq!(false.implies(true), true); + fail_unless_eq!(false.implies(false), true); + + fail_unless_eq!(true.to_bit::(), 1u8); + fail_unless_eq!(false.to_bit::(), 0u8); } #[test] @@ -393,16 +393,16 @@ mod tests { #[test] fn test_bool_to_str() { - assert_eq!(false.to_str(), ~"false"); - assert_eq!(true.to_str(), ~"true"); + fail_unless_eq!(false.to_str(), ~"false"); + fail_unless_eq!(true.to_str(), ~"true"); } #[test] fn test_bool_to_bit() { all_values(|v| { - assert_eq!(v.to_bit::(), if v { 1u8 } else { 0u8 }); - assert_eq!(v.to_bit::(), if v { 1u } else { 0u }); - assert_eq!(v.to_bit::(), if v { 1i } else { 0i }); + fail_unless_eq!(v.to_bit::(), if v { 1u8 } else { 0u8 }); + fail_unless_eq!(v.to_bit::(), if v { 1u } else { 0u }); + fail_unless_eq!(v.to_bit::(), if v { 1i } else { 0i }); }); } @@ -427,9 +427,9 @@ mod tests { #[test] fn test_bool_totalord() { - assert_eq!(true.cmp(&true), Equal); - assert_eq!(false.cmp(&false), Equal); - assert_eq!(true.cmp(&false), Greater); - assert_eq!(false.cmp(&true), Less); + fail_unless_eq!(true.cmp(&true), Equal); + fail_unless_eq!(false.cmp(&false), Equal); + fail_unless_eq!(true.cmp(&false), Greater); + fail_unless_eq!(false.cmp(&true), Less); } } diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 6589cfb6082e9..437d6c0299607 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -433,9 +433,9 @@ mod tests { let mut it = expected.iter(); let result = from_c_multistring(ptr as *libc::c_char, None, |c| { let cbytes = c.as_bytes_no_nul(); - assert_eq!(cbytes, it.next().unwrap().as_bytes()); + fail_unless_eq!(cbytes, it.next().unwrap().as_bytes()); }); - assert_eq!(result, 2); + fail_unless_eq!(result, 2); fail_unless!(it.next().is_none()); } } @@ -444,18 +444,18 @@ mod tests { fn test_str_to_c_str() { "".to_c_str().with_ref(|buf| { unsafe { - assert_eq!(*buf.offset(0), 0); + fail_unless_eq!(*buf.offset(0), 0); } }); "hello".to_c_str().with_ref(|buf| { unsafe { - assert_eq!(*buf.offset(0), 'h' as libc::c_char); - assert_eq!(*buf.offset(1), 'e' as libc::c_char); - assert_eq!(*buf.offset(2), 'l' as libc::c_char); - assert_eq!(*buf.offset(3), 'l' as libc::c_char); - assert_eq!(*buf.offset(4), 'o' as libc::c_char); - assert_eq!(*buf.offset(5), 0); + fail_unless_eq!(*buf.offset(0), 'h' as libc::c_char); + fail_unless_eq!(*buf.offset(1), 'e' as libc::c_char); + fail_unless_eq!(*buf.offset(2), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(3), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(4), 'o' as libc::c_char); + fail_unless_eq!(*buf.offset(5), 0); } }) } @@ -465,28 +465,28 @@ mod tests { let b: &[u8] = []; b.to_c_str().with_ref(|buf| { unsafe { - assert_eq!(*buf.offset(0), 0); + fail_unless_eq!(*buf.offset(0), 0); } }); let _ = bytes!("hello").to_c_str().with_ref(|buf| { unsafe { - assert_eq!(*buf.offset(0), 'h' as libc::c_char); - assert_eq!(*buf.offset(1), 'e' as libc::c_char); - assert_eq!(*buf.offset(2), 'l' as libc::c_char); - assert_eq!(*buf.offset(3), 'l' as libc::c_char); - assert_eq!(*buf.offset(4), 'o' as libc::c_char); - assert_eq!(*buf.offset(5), 0); + fail_unless_eq!(*buf.offset(0), 'h' as libc::c_char); + fail_unless_eq!(*buf.offset(1), 'e' as libc::c_char); + fail_unless_eq!(*buf.offset(2), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(3), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(4), 'o' as libc::c_char); + fail_unless_eq!(*buf.offset(5), 0); } }); let _ = bytes!("foo", 0xff).to_c_str().with_ref(|buf| { unsafe { - assert_eq!(*buf.offset(0), 'f' as libc::c_char); - assert_eq!(*buf.offset(1), 'o' as libc::c_char); - assert_eq!(*buf.offset(2), 'o' as libc::c_char); - assert_eq!(*buf.offset(3), 0xff as i8); - assert_eq!(*buf.offset(4), 0); + fail_unless_eq!(*buf.offset(0), 'f' as libc::c_char); + fail_unless_eq!(*buf.offset(1), 'o' as libc::c_char); + fail_unless_eq!(*buf.offset(2), 'o' as libc::c_char); + fail_unless_eq!(*buf.offset(3), 0xff as i8); + fail_unless_eq!(*buf.offset(4), 0); } }); } @@ -510,7 +510,7 @@ mod tests { let len = unsafe { c_str.with_ref(|buf| libc::strlen(buf)) }; fail_unless!(!c_str.is_null()); fail_unless!(c_str.is_not_null()); - assert_eq!(len, 5); + fail_unless_eq!(len, 5); } #[test] @@ -524,16 +524,16 @@ mod tests { fn test_iterator() { let c_str = "".to_c_str(); let mut iter = c_str.iter(); - assert_eq!(iter.next(), None); + fail_unless_eq!(iter.next(), None); let c_str = "hello".to_c_str(); let mut iter = c_str.iter(); - assert_eq!(iter.next(), Some('h' as libc::c_char)); - assert_eq!(iter.next(), Some('e' as libc::c_char)); - assert_eq!(iter.next(), Some('l' as libc::c_char)); - assert_eq!(iter.next(), Some('l' as libc::c_char)); - assert_eq!(iter.next(), Some('o' as libc::c_char)); - assert_eq!(iter.next(), None); + fail_unless_eq!(iter.next(), Some('h' as libc::c_char)); + fail_unless_eq!(iter.next(), Some('e' as libc::c_char)); + fail_unless_eq!(iter.next(), Some('l' as libc::c_char)); + fail_unless_eq!(iter.next(), Some('l' as libc::c_char)); + fail_unless_eq!(iter.next(), Some('o' as libc::c_char)); + fail_unless_eq!(iter.next(), None); } #[test] @@ -546,13 +546,13 @@ mod tests { fn test_to_c_str_unchecked() { unsafe { "he\x00llo".to_c_str_unchecked().with_ref(|buf| { - assert_eq!(*buf.offset(0), 'h' as libc::c_char); - assert_eq!(*buf.offset(1), 'e' as libc::c_char); - assert_eq!(*buf.offset(2), 0); - assert_eq!(*buf.offset(3), 'l' as libc::c_char); - assert_eq!(*buf.offset(4), 'l' as libc::c_char); - assert_eq!(*buf.offset(5), 'o' as libc::c_char); - assert_eq!(*buf.offset(6), 0); + fail_unless_eq!(*buf.offset(0), 'h' as libc::c_char); + fail_unless_eq!(*buf.offset(1), 'e' as libc::c_char); + fail_unless_eq!(*buf.offset(2), 0); + fail_unless_eq!(*buf.offset(3), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(4), 'l' as libc::c_char); + fail_unless_eq!(*buf.offset(5), 'o' as libc::c_char); + fail_unless_eq!(*buf.offset(6), 0); }) } } @@ -560,22 +560,22 @@ mod tests { #[test] fn test_as_bytes() { let c_str = "hello".to_c_str(); - assert_eq!(c_str.as_bytes(), bytes!("hello", 0)); + fail_unless_eq!(c_str.as_bytes(), bytes!("hello", 0)); let c_str = "".to_c_str(); - assert_eq!(c_str.as_bytes(), bytes!(0)); + fail_unless_eq!(c_str.as_bytes(), bytes!(0)); let c_str = bytes!("foo", 0xff).to_c_str(); - assert_eq!(c_str.as_bytes(), bytes!("foo", 0xff, 0)); + fail_unless_eq!(c_str.as_bytes(), bytes!("foo", 0xff, 0)); } #[test] fn test_as_bytes_no_nul() { let c_str = "hello".to_c_str(); - assert_eq!(c_str.as_bytes_no_nul(), bytes!("hello")); + fail_unless_eq!(c_str.as_bytes_no_nul(), bytes!("hello")); let c_str = "".to_c_str(); let exp: &[u8] = []; - assert_eq!(c_str.as_bytes_no_nul(), exp); + fail_unless_eq!(c_str.as_bytes_no_nul(), exp); let c_str = bytes!("foo", 0xff).to_c_str(); - assert_eq!(c_str.as_bytes_no_nul(), bytes!("foo", 0xff)); + fail_unless_eq!(c_str.as_bytes_no_nul(), bytes!("foo", 0xff)); } #[test] @@ -595,11 +595,11 @@ mod tests { #[test] fn test_as_str() { let c_str = "hello".to_c_str(); - assert_eq!(c_str.as_str(), Some("hello")); + fail_unless_eq!(c_str.as_str(), Some("hello")); let c_str = "".to_c_str(); - assert_eq!(c_str.as_str(), Some("")); + fail_unless_eq!(c_str.as_str(), Some("")); let c_str = bytes!("foo", 0xff).to_c_str(); - assert_eq!(c_str.as_str(), None); + fail_unless_eq!(c_str.as_str(), None); } #[test] @@ -674,7 +674,7 @@ mod bench { let s_buf = s.as_ptr(); for i in range(0, s.len()) { unsafe { - assert_eq!( + fail_unless_eq!( *s_buf.offset(i as int) as libc::c_char, *c_str.offset(i as int)); } diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index 07dc9693d2697..b3385dda21d9a 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -117,7 +117,7 @@ mod tests { #[test] fn test_transmute_copy() { - assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) }); + fail_unless_eq!(1u, unsafe { ::cast::transmute_copy(&1) }); } #[test] @@ -148,7 +148,7 @@ mod tests { #[test] fn test_transmute2() { unsafe { - assert_eq!(~[76u8], transmute(~"L")); + fail_unless_eq!(~[76u8], transmute(~"L")); } } } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 0ee5895df5a89..f8de4272bd686 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -273,12 +273,12 @@ mod test { #[test] fn smoketest_cell() { let x = Cell::new(10); - assert_eq!(x.get(), 10); + fail_unless_eq!(x.get(), 10); x.set(20); - assert_eq!(x.get(), 20); + fail_unless_eq!(x.get(), 20); let y = Cell::new((30, 40)); - assert_eq!(y.get(), (30, 40)); + fail_unless_eq!(y.get(), (30, 40)); } #[test] @@ -340,7 +340,7 @@ mod test { #[test] fn with_ok() { let x = RefCell::new(0); - assert_eq!(1, x.with(|x| *x+1)); + fail_unless_eq!(1, x.with(|x| *x+1)); } #[test] @@ -355,7 +355,7 @@ mod test { fn borrow_with() { let x = RefCell::new(0); let _b1 = x.borrow(); - assert_eq!(1, x.with(|x| *x+1)); + fail_unless_eq!(1, x.with(|x| *x+1)); } #[test] @@ -363,7 +363,7 @@ mod test { let x = RefCell::new(0); x.with_mut(|x| *x += 1); let b = x.borrow(); - assert_eq!(1, *b.get()); + fail_unless_eq!(1, *b.get()); } #[test] diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 23ae516506180..3be3c50351f67 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -479,18 +479,18 @@ fn test_is_whitespace() { #[test] fn test_to_digit() { - assert_eq!('0'.to_digit(10u), Some(0u)); - assert_eq!('1'.to_digit(2u), Some(1u)); - assert_eq!('2'.to_digit(3u), Some(2u)); - assert_eq!('9'.to_digit(10u), Some(9u)); - assert_eq!('a'.to_digit(16u), Some(10u)); - assert_eq!('A'.to_digit(16u), Some(10u)); - assert_eq!('b'.to_digit(16u), Some(11u)); - assert_eq!('B'.to_digit(16u), Some(11u)); - assert_eq!('z'.to_digit(36u), Some(35u)); - assert_eq!('Z'.to_digit(36u), Some(35u)); - assert_eq!(' '.to_digit(10u), None); - assert_eq!('$'.to_digit(36u), None); + fail_unless_eq!('0'.to_digit(10u), Some(0u)); + fail_unless_eq!('1'.to_digit(2u), Some(1u)); + fail_unless_eq!('2'.to_digit(3u), Some(2u)); + fail_unless_eq!('9'.to_digit(10u), Some(9u)); + fail_unless_eq!('a'.to_digit(16u), Some(10u)); + fail_unless_eq!('A'.to_digit(16u), Some(10u)); + fail_unless_eq!('b'.to_digit(16u), Some(11u)); + fail_unless_eq!('B'.to_digit(16u), Some(11u)); + fail_unless_eq!('z'.to_digit(36u), Some(35u)); + fail_unless_eq!('Z'.to_digit(36u), Some(35u)); + fail_unless_eq!(' '.to_digit(10u), None); + fail_unless_eq!('$'.to_digit(36u), None); } #[test] @@ -523,19 +523,19 @@ fn test_escape_default() { escape_default(c, |c| { result.push_char(c); }); return result; } - assert_eq!(string('\n'), ~"\\n"); - assert_eq!(string('\r'), ~"\\r"); - assert_eq!(string('\''), ~"\\'"); - assert_eq!(string('"'), ~"\\\""); - assert_eq!(string(' '), ~" "); - assert_eq!(string('a'), ~"a"); - assert_eq!(string('~'), ~"~"); - assert_eq!(string('\x00'), ~"\\x00"); - assert_eq!(string('\x1f'), ~"\\x1f"); - assert_eq!(string('\x7f'), ~"\\x7f"); - assert_eq!(string('\xff'), ~"\\xff"); - assert_eq!(string('\u011b'), ~"\\u011b"); - assert_eq!(string('\U0001d4b6'), ~"\\U0001d4b6"); + fail_unless_eq!(string('\n'), ~"\\n"); + fail_unless_eq!(string('\r'), ~"\\r"); + fail_unless_eq!(string('\''), ~"\\'"); + fail_unless_eq!(string('"'), ~"\\\""); + fail_unless_eq!(string(' '), ~" "); + fail_unless_eq!(string('a'), ~"a"); + fail_unless_eq!(string('~'), ~"~"); + fail_unless_eq!(string('\x00'), ~"\\x00"); + fail_unless_eq!(string('\x1f'), ~"\\x1f"); + fail_unless_eq!(string('\x7f'), ~"\\x7f"); + fail_unless_eq!(string('\xff'), ~"\\xff"); + fail_unless_eq!(string('\u011b'), ~"\\u011b"); + fail_unless_eq!(string('\U0001d4b6'), ~"\\U0001d4b6"); } #[test] @@ -545,16 +545,16 @@ fn test_escape_unicode() { escape_unicode(c, |c| { result.push_char(c); }); return result; } - assert_eq!(string('\x00'), ~"\\x00"); - assert_eq!(string('\n'), ~"\\x0a"); - assert_eq!(string(' '), ~"\\x20"); - assert_eq!(string('a'), ~"\\x61"); - assert_eq!(string('\u011b'), ~"\\u011b"); - assert_eq!(string('\U0001d4b6'), ~"\\U0001d4b6"); + fail_unless_eq!(string('\x00'), ~"\\x00"); + fail_unless_eq!(string('\n'), ~"\\x0a"); + fail_unless_eq!(string(' '), ~"\\x20"); + fail_unless_eq!(string('a'), ~"\\x61"); + fail_unless_eq!(string('\u011b'), ~"\\u011b"); + fail_unless_eq!(string('\U0001d4b6'), ~"\\U0001d4b6"); } #[test] fn test_to_str() { let s = 't'.to_str(); - assert_eq!(s, ~"t"); + fail_unless_eq!(s, ~"t"); } diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index e5e79b4386a56..b5c329727e7dd 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -215,14 +215,14 @@ extern_fn_deep_clone!(A, B, C, D, E, F, G, H) fn test_owned_clone() { let a = ~5i; let b: ~int = a.clone(); - assert_eq!(a, b); + fail_unless_eq!(a, b); } #[test] fn test_managed_clone() { let a = @5i; let b: @int = a.clone(); - assert_eq!(a, b); + fail_unless_eq!(a, b); } #[test] @@ -230,7 +230,7 @@ fn test_borrowed_clone() { let x = 5i; let y: &int = &x; let z: &int = (&y).clone(); - assert_eq!(*z, 5); + fail_unless_eq!(*z, 5); } #[test] @@ -238,7 +238,7 @@ fn test_clone_from() { let a = ~5; let mut b = ~10; b.clone_from(&a); - assert_eq!(*b, 5); + fail_unless_eq!(*b, 5); } #[test] @@ -246,7 +246,7 @@ fn test_deep_clone_from() { let a = ~5; let mut b = ~10; b.deep_clone_from(&a); - assert_eq!(*b, 5); + fail_unless_eq!(*b, 5); } #[test] diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 52b553c22b589..e7f4bffe33a37 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -197,19 +197,19 @@ mod test { #[test] fn test_int_totalord() { - assert_eq!(5.cmp(&10), Less); - assert_eq!(10.cmp(&5), Greater); - assert_eq!(5.cmp(&5), Equal); - assert_eq!((-5).cmp(&12), Less); - assert_eq!(12.cmp(-5), Greater); + fail_unless_eq!(5.cmp(&10), Less); + fail_unless_eq!(10.cmp(&5), Greater); + fail_unless_eq!(5.cmp(&5), Equal); + fail_unless_eq!((-5).cmp(&12), Less); + fail_unless_eq!(12.cmp(-5), Greater); } #[test] fn test_cmp2() { - assert_eq!(cmp2(1, 2, 3, 4), Less); - assert_eq!(cmp2(3, 2, 3, 4), Less); - assert_eq!(cmp2(5, 2, 3, 4), Greater); - assert_eq!(cmp2(5, 5, 5, 4), Greater); + fail_unless_eq!(cmp2(1, 2, 3, 4), Less); + fail_unless_eq!(cmp2(3, 2, 3, 4), Less); + fail_unless_eq!(cmp2(5, 2, 3, 4), Greater); + fail_unless_eq!(cmp2(5, 5, 5, 4), Greater); } #[test] @@ -221,13 +221,13 @@ mod test { #[test] fn test_ordering_order() { fail_unless!(Less < Equal); - assert_eq!(Greater.cmp(&Less), Greater); + fail_unless_eq!(Greater.cmp(&Less), Greater); } #[test] fn test_lexical_ordering() { fn t(o1: Ordering, o2: Ordering, e: Ordering) { - assert_eq!(lexical_ordering(o1, o2), e); + fail_unless_eq!(lexical_ordering(o1, o2), e); } let xs = [Less, Equal, Greater]; diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 3b290c34c3499..d3b739fb1c5db 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -62,7 +62,7 @@ //! spawn(proc() { //! chan.send(10); //! }); -//! assert_eq!(port.recv(), 10); +//! fail_unless_eq!(port.recv(), 10); //! //! // Create a shared channel which can be sent along from many tasks //! let (port, chan) = Chan::new(); @@ -727,7 +727,7 @@ mod test { test!(fn smoke() { let (p, c) = Chan::new(); c.send(1); - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); }) test!(fn drop_full() { @@ -743,10 +743,10 @@ mod test { test!(fn smoke_shared() { let (p, c) = Chan::new(); c.send(1); - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); let c = c.clone(); c.send(1); - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); }) test!(fn smoke_threads() { @@ -754,7 +754,7 @@ mod test { spawn(proc() { c.send(1); }); - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); }) test!(fn smoke_port_gone() { @@ -826,7 +826,7 @@ mod test { for _ in range(0, 10000) { c.send(1); } }); for _ in range(0, 10000) { - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); } }) @@ -838,7 +838,7 @@ mod test { spawn(proc() { for _ in range(0, AMT * NTHREADS) { - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); } match p.try_recv() { Data(..) => fail!(), @@ -865,7 +865,7 @@ mod test { spawn(proc() { c1.send(()); for _ in range(0, 40) { - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); } chan2.send(()); }); @@ -886,7 +886,7 @@ mod test { let (dp, dc) = Chan::new(); native::task::spawn(proc() { for _ in range(0, 40) { - assert_eq!(p.recv(), 1); + fail_unless_eq!(p.recv(), 1); } dc.send(()); }); @@ -903,13 +903,13 @@ mod test { let (port, chan) = Chan::new(); let chan2 = chan.clone(); native::task::spawn(proc() { - assert_eq!(p1.recv(), 1); + fail_unless_eq!(p1.recv(), 1); c2.send(2); chan2.send(()); }); native::task::spawn(proc() { c1.send(1); - assert_eq!(p2.recv(), 2); + fail_unless_eq!(p2.recv(), 2); chan.send(()); }); port.recv(); @@ -978,21 +978,21 @@ mod test { test!(fn oneshot_single_thread_peek_data() { let (port, chan) = Chan::::new(); - assert_eq!(port.try_recv(), Empty) + fail_unless_eq!(port.try_recv(), Empty) chan.send(10); - assert_eq!(port.try_recv(), Data(10)); + fail_unless_eq!(port.try_recv(), Data(10)); }) test!(fn oneshot_single_thread_peek_close() { let (port, chan) = Chan::::new(); { let _c = chan; } - assert_eq!(port.try_recv(), Disconnected); - assert_eq!(port.try_recv(), Disconnected); + fail_unless_eq!(port.try_recv(), Disconnected); + fail_unless_eq!(port.try_recv(), Disconnected); }) test!(fn oneshot_single_thread_peek_open() { let (port, _chan) = Chan::::new(); - assert_eq!(port.try_recv(), Empty); + fail_unless_eq!(port.try_recv(), Empty); }) test!(fn oneshot_multi_task_recv_then_send() { @@ -1133,7 +1133,7 @@ mod test { chan.send(1); chan.send(2); drop(chan); - assert_eq!(total_port.recv(), 6); + fail_unless_eq!(total_port.recv(), 6); }) test!(fn test_recv_iter_break() { @@ -1157,7 +1157,7 @@ mod test { chan.send(2); chan.try_send(2); drop(chan); - assert_eq!(count_port.recv(), 4); + fail_unless_eq!(count_port.recv(), 4); }) test!(fn try_recv_states() { @@ -1173,14 +1173,14 @@ mod test { c2.send(()); }); - assert_eq!(p.try_recv(), Empty); + fail_unless_eq!(p.try_recv(), Empty); c1.send(()); p2.recv(); - assert_eq!(p.try_recv(), Data(1)); - assert_eq!(p.try_recv(), Empty); + fail_unless_eq!(p.try_recv(), Data(1)); + fail_unless_eq!(p.try_recv(), Empty); c1.send(()); p2.recv(); - assert_eq!(p.try_recv(), Disconnected); + fail_unless_eq!(p.try_recv(), Disconnected); }) // This bug used to end up in a livelock inside of the Port destructor diff --git a/src/libstd/comm/oneshot.rs b/src/libstd/comm/oneshot.rs index 7ab25b7f94308..8707f9e20c3a6 100644 --- a/src/libstd/comm/oneshot.rs +++ b/src/libstd/comm/oneshot.rs @@ -364,6 +364,6 @@ impl Packet { #[unsafe_destructor] impl Drop for Packet { fn drop(&mut self) { - assert_eq!(self.state.load(atomics::SeqCst), DISCONNECTED); + fail_unless_eq!(self.state.load(atomics::SeqCst), DISCONNECTED); } } diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index d6cd478d45b78..0ec46df89db13 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -34,10 +34,10 @@ //! //! select! ( //! val = p1.recv() => { -//! assert_eq!(val, 1); +//! fail_unless_eq!(val, 1); //! } //! val = p2.recv() => { -//! assert_eq!(val, 2); +//! fail_unless_eq!(val, 2); //! } //! ) //! ``` @@ -288,13 +288,13 @@ impl<'port, T: Send> Handle<'port, T> { let me: *mut Handle<'static, ()> = cast::transmute(&*self); if self.prev.is_null() { - assert_eq!(selector.head, me); + fail_unless_eq!(selector.head, me); selector.head = self.next; } else { (*self.prev).next = self.next; } if self.next.is_null() { - assert_eq!(selector.tail, me); + fail_unless_eq!(selector.tail, me); selector.tail = self.prev; } else { (*self.next).prev = self.prev; @@ -345,22 +345,22 @@ mod test { let (p2, c2) = Chan::::new(); c1.send(1); select! ( - foo = p1.recv() => { assert_eq!(foo, 1); }, + foo = p1.recv() => { fail_unless_eq!(foo, 1); }, _bar = p2.recv() => { fail!() } ) c2.send(2); select! ( _foo = p1.recv() => { fail!() }, - bar = p2.recv() => { assert_eq!(bar, 2) } + bar = p2.recv() => { fail_unless_eq!(bar, 2) } ) drop(c1); select! ( - foo = p1.recv_opt() => { assert_eq!(foo, None); }, + foo = p1.recv_opt() => { fail_unless_eq!(foo, None); }, _bar = p2.recv() => { fail!() } ) drop(c2); select! ( - bar = p2.recv_opt() => { assert_eq!(bar, None); } + bar = p2.recv_opt() => { fail_unless_eq!(bar, None); } ) }) @@ -376,7 +376,7 @@ mod test { _foo = p2.recv() => { fail!("2") }, _foo = p3.recv() => { fail!("3") }, _foo = p4.recv() => { fail!("4") }, - foo = p5.recv() => { assert_eq!(foo, 4); } + foo = p5.recv() => { fail_unless_eq!(foo, 4); } ) }) @@ -387,7 +387,7 @@ mod test { select! ( _a1 = p1.recv_opt() => { fail!() }, - a2 = p2.recv_opt() => { assert_eq!(a2, None); } + a2 = p2.recv_opt() => { fail_unless_eq!(a2, None); } ) }) @@ -404,12 +404,12 @@ mod test { }); select! ( - a = p1.recv() => { assert_eq!(a, 1); }, + a = p1.recv() => { fail_unless_eq!(a, 1); }, _b = p2.recv() => { fail!() } ) c3.send(1); select! ( - a = p1.recv_opt() => { assert_eq!(a, None); }, + a = p1.recv_opt() => { fail_unless_eq!(a, None); }, _b = p2.recv() => { fail!() } ) }) @@ -427,15 +427,15 @@ mod test { }); select! ( - a = p1.recv() => { assert_eq!(a, 1); }, - a = p2.recv() => { assert_eq!(a, 2); } + a = p1.recv() => { fail_unless_eq!(a, 1); }, + a = p2.recv() => { fail_unless_eq!(a, 2); } ) select! ( - a = p1.recv() => { assert_eq!(a, 1); }, - a = p2.recv() => { assert_eq!(a, 2); } + a = p1.recv() => { fail_unless_eq!(a, 1); }, + a = p2.recv() => { fail_unless_eq!(a, 2); } ) - assert_eq!(p1.try_recv(), Empty); - assert_eq!(p2.try_recv(), Empty); + fail_unless_eq!(p1.try_recv(), Empty); + fail_unless_eq!(p2.try_recv(), Empty); c3.send(()); }) @@ -473,7 +473,7 @@ mod test { spawn(proc() { p3.recv(); c1.clone(); - assert_eq!(p3.try_recv(), Empty); + fail_unless_eq!(p3.try_recv(), Empty); c1.send(2); p3.recv(); }); @@ -494,7 +494,7 @@ mod test { spawn(proc() { p3.recv(); c1.clone(); - assert_eq!(p3.try_recv(), Empty); + fail_unless_eq!(p3.try_recv(), Empty); c1.send(2); p3.recv(); }); @@ -517,7 +517,7 @@ mod test { let mut h2 = s.handle(&p2); unsafe { h2.add(); } unsafe { h1.add(); } - assert_eq!(s.wait(), h2.id); + fail_unless_eq!(s.wait(), h2.id); c.send(()); }); @@ -559,7 +559,7 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) test!(fn preflight5() { @@ -569,7 +569,7 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) test!(fn preflight6() { @@ -579,7 +579,7 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) test!(fn preflight7() { @@ -588,7 +588,7 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) test!(fn preflight8() { @@ -599,7 +599,7 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) test!(fn preflight9() { @@ -611,6 +611,6 @@ mod test { let s = Select::new(); let mut h = s.handle(&p); unsafe { h.add(); } - assert_eq!(s.wait2(false), h.id); + fail_unless_eq!(s.wait2(false), h.id); }) } diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs index a42e4b26d72ea..7c5397bb45ecc 100644 --- a/src/libstd/comm/shared.rs +++ b/src/libstd/comm/shared.rs @@ -91,8 +91,8 @@ impl Packet { pub fn inherit_blocker(&mut self, task: Option) { match task { Some(task) => { - assert_eq!(self.cnt.load(atomics::SeqCst), 0); - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.cnt.load(atomics::SeqCst), 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); self.to_wake.store(unsafe { task.cast_to_uint() }, atomics::SeqCst); self.cnt.store(-1, atomics::SeqCst); @@ -237,7 +237,7 @@ impl Packet { // Essentially the exact same thing as the stream decrement function. fn decrement(&mut self, task: BlockedTask) -> Result<(), BlockedTask> { - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); let n = unsafe { task.cast_to_uint() }; self.to_wake.store(n, atomics::SeqCst); @@ -461,7 +461,7 @@ impl Packet { let prev = self.bump(steals + 1); if prev == DISCONNECTED { - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); true } else { let cur = prev + steals + 1; @@ -490,8 +490,8 @@ impl Drop for Packet { // disconnection, but also a proper fence before the read of // `to_wake`, so this assert cannot be removed with also removing // the `to_wake` assert. - assert_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED); - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); - assert_eq!(self.channels.load(atomics::SeqCst), 0); + fail_unless_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.channels.load(atomics::SeqCst), 0); } } diff --git a/src/libstd/comm/stream.rs b/src/libstd/comm/stream.rs index d279fcb18c84a..74d2d73d16ba9 100644 --- a/src/libstd/comm/stream.rs +++ b/src/libstd/comm/stream.rs @@ -150,7 +150,7 @@ impl Packet { // back if it shouldn't sleep. Note that this is the location where we take // steals into account. fn decrement(&mut self, task: BlockedTask) -> Result<(), BlockedTask> { - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); let n = unsafe { task.cast_to_uint() }; self.to_wake.store(n, atomics::SeqCst); @@ -399,8 +399,8 @@ impl Packet { // this end. This is fine because we know it's a small bounded windows // of time until the data is actually sent. if was_upgrade { - assert_eq!(self.steals, 0); - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.steals, 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); return Ok(true) } @@ -413,7 +413,7 @@ impl Packet { // If we were previously disconnected, then we know for sure that there // is no task in to_wake, so just keep going let has_data = if prev == DISCONNECTED { - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); true // there is data, that data is that we're disconnected } else { let cur = prev + steals + 1; @@ -440,7 +440,7 @@ impl Packet { Thread::yield_now(); } } - assert_eq!(self.steals, 0); + fail_unless_eq!(self.steals, 0); self.steals = steals; // if we were previously positive, then there's surely data to @@ -475,7 +475,7 @@ impl Drop for Packet { // disconnection, but also a proper fence before the read of // `to_wake`, so this assert cannot be removed with also removing // the `to_wake` assert. - assert_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED); - assert_eq!(self.to_wake.load(atomics::SeqCst), 0); + fail_unless_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED); + fail_unless_eq!(self.to_wake.load(atomics::SeqCst), 0); } } diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 38fae798d5dde..1193774709cd4 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -727,7 +727,7 @@ pub unsafe fn write_unsafe(output: &mut io::Writer, /// use std::fmt; /// /// let s = format_args!(fmt::format, "Hello, {}!", "world"); -/// assert_eq!(s, ~"Hello, world!"); +/// fail_unless_eq!(s, ~"Hello, world!"); /// ``` pub fn format(args: &Arguments) -> ~str { unsafe { format_unsafe(args.fmt, args.args) } diff --git a/src/libstd/fmt/num.rs b/src/libstd/fmt/num.rs index 47d2cc6342040..494192762acc1 100644 --- a/src/libstd/fmt/num.rs +++ b/src/libstd/fmt/num.rs @@ -138,7 +138,7 @@ pub struct RadixFmt(T, R); /// /// ~~~ /// use std::fmt::radix; -/// assert_eq!(format!("{}", radix(55, 36)), ~"1j"); +/// fail_unless_eq!(format!("{}", radix(55, 36)), ~"1j"); /// ~~~ pub fn radix(x: T, base: u8) -> RadixFmt { RadixFmt(x, Radix::new(base)) @@ -195,41 +195,41 @@ mod tests { #[test] fn test_radix_base() { - assert_eq!(Binary.base(), 2); - assert_eq!(Octal.base(), 8); - assert_eq!(Decimal.base(), 10); - assert_eq!(LowerHex.base(), 16); - assert_eq!(UpperHex.base(), 16); - assert_eq!(Radix { base: 36 }.base(), 36); + fail_unless_eq!(Binary.base(), 2); + fail_unless_eq!(Octal.base(), 8); + fail_unless_eq!(Decimal.base(), 10); + fail_unless_eq!(LowerHex.base(), 16); + fail_unless_eq!(UpperHex.base(), 16); + fail_unless_eq!(Radix { base: 36 }.base(), 36); } #[test] fn test_radix_prefix() { - assert_eq!(Binary.prefix(), "0b"); - assert_eq!(Octal.prefix(), "0o"); - assert_eq!(Decimal.prefix(), ""); - assert_eq!(LowerHex.prefix(), "0x"); - assert_eq!(UpperHex.prefix(), "0x"); - assert_eq!(Radix { base: 36 }.prefix(), ""); + fail_unless_eq!(Binary.prefix(), "0b"); + fail_unless_eq!(Octal.prefix(), "0o"); + fail_unless_eq!(Decimal.prefix(), ""); + fail_unless_eq!(LowerHex.prefix(), "0x"); + fail_unless_eq!(UpperHex.prefix(), "0x"); + fail_unless_eq!(Radix { base: 36 }.prefix(), ""); } #[test] fn test_radix_digit() { - assert_eq!(Binary.digit(0), '0' as u8); - assert_eq!(Binary.digit(2), '2' as u8); - assert_eq!(Octal.digit(0), '0' as u8); - assert_eq!(Octal.digit(7), '7' as u8); - assert_eq!(Decimal.digit(0), '0' as u8); - assert_eq!(Decimal.digit(9), '9' as u8); - assert_eq!(LowerHex.digit(0), '0' as u8); - assert_eq!(LowerHex.digit(10), 'a' as u8); - assert_eq!(LowerHex.digit(15), 'f' as u8); - assert_eq!(UpperHex.digit(0), '0' as u8); - assert_eq!(UpperHex.digit(10), 'A' as u8); - assert_eq!(UpperHex.digit(15), 'F' as u8); - assert_eq!(Radix { base: 36 }.digit(0), '0' as u8); - assert_eq!(Radix { base: 36 }.digit(15), 'f' as u8); - assert_eq!(Radix { base: 36 }.digit(35), 'z' as u8); + fail_unless_eq!(Binary.digit(0), '0' as u8); + fail_unless_eq!(Binary.digit(2), '2' as u8); + fail_unless_eq!(Octal.digit(0), '0' as u8); + fail_unless_eq!(Octal.digit(7), '7' as u8); + fail_unless_eq!(Decimal.digit(0), '0' as u8); + fail_unless_eq!(Decimal.digit(9), '9' as u8); + fail_unless_eq!(LowerHex.digit(0), '0' as u8); + fail_unless_eq!(LowerHex.digit(10), 'a' as u8); + fail_unless_eq!(LowerHex.digit(15), 'f' as u8); + fail_unless_eq!(UpperHex.digit(0), '0' as u8); + fail_unless_eq!(UpperHex.digit(10), 'A' as u8); + fail_unless_eq!(UpperHex.digit(15), 'F' as u8); + fail_unless_eq!(Radix { base: 36 }.digit(0), '0' as u8); + fail_unless_eq!(Radix { base: 36 }.digit(15), 'f' as u8); + fail_unless_eq!(Radix { base: 36 }.digit(35), 'z' as u8); } #[test] @@ -243,143 +243,143 @@ mod tests { // Formatting integers should select the right implementation based off // the type of the argument. Also, hex/octal/binary should be defined // for integers, but they shouldn't emit the negative sign. - assert_eq!(format!("{}", 1i), ~"1"); - assert_eq!(format!("{}", 1i8), ~"1"); - assert_eq!(format!("{}", 1i16), ~"1"); - assert_eq!(format!("{}", 1i32), ~"1"); - assert_eq!(format!("{}", 1i64), ~"1"); - assert_eq!(format!("{:d}", -1i), ~"-1"); - assert_eq!(format!("{:d}", -1i8), ~"-1"); - assert_eq!(format!("{:d}", -1i16), ~"-1"); - assert_eq!(format!("{:d}", -1i32), ~"-1"); - assert_eq!(format!("{:d}", -1i64), ~"-1"); - assert_eq!(format!("{:t}", 1i), ~"1"); - assert_eq!(format!("{:t}", 1i8), ~"1"); - assert_eq!(format!("{:t}", 1i16), ~"1"); - assert_eq!(format!("{:t}", 1i32), ~"1"); - assert_eq!(format!("{:t}", 1i64), ~"1"); - assert_eq!(format!("{:x}", 1i), ~"1"); - assert_eq!(format!("{:x}", 1i8), ~"1"); - assert_eq!(format!("{:x}", 1i16), ~"1"); - assert_eq!(format!("{:x}", 1i32), ~"1"); - assert_eq!(format!("{:x}", 1i64), ~"1"); - assert_eq!(format!("{:X}", 1i), ~"1"); - assert_eq!(format!("{:X}", 1i8), ~"1"); - assert_eq!(format!("{:X}", 1i16), ~"1"); - assert_eq!(format!("{:X}", 1i32), ~"1"); - assert_eq!(format!("{:X}", 1i64), ~"1"); - assert_eq!(format!("{:o}", 1i), ~"1"); - assert_eq!(format!("{:o}", 1i8), ~"1"); - assert_eq!(format!("{:o}", 1i16), ~"1"); - assert_eq!(format!("{:o}", 1i32), ~"1"); - assert_eq!(format!("{:o}", 1i64), ~"1"); - - assert_eq!(format!("{}", 1u), ~"1"); - assert_eq!(format!("{}", 1u8), ~"1"); - assert_eq!(format!("{}", 1u16), ~"1"); - assert_eq!(format!("{}", 1u32), ~"1"); - assert_eq!(format!("{}", 1u64), ~"1"); - assert_eq!(format!("{:u}", 1u), ~"1"); - assert_eq!(format!("{:u}", 1u8), ~"1"); - assert_eq!(format!("{:u}", 1u16), ~"1"); - assert_eq!(format!("{:u}", 1u32), ~"1"); - assert_eq!(format!("{:u}", 1u64), ~"1"); - assert_eq!(format!("{:t}", 1u), ~"1"); - assert_eq!(format!("{:t}", 1u8), ~"1"); - assert_eq!(format!("{:t}", 1u16), ~"1"); - assert_eq!(format!("{:t}", 1u32), ~"1"); - assert_eq!(format!("{:t}", 1u64), ~"1"); - assert_eq!(format!("{:x}", 1u), ~"1"); - assert_eq!(format!("{:x}", 1u8), ~"1"); - assert_eq!(format!("{:x}", 1u16), ~"1"); - assert_eq!(format!("{:x}", 1u32), ~"1"); - assert_eq!(format!("{:x}", 1u64), ~"1"); - assert_eq!(format!("{:X}", 1u), ~"1"); - assert_eq!(format!("{:X}", 1u8), ~"1"); - assert_eq!(format!("{:X}", 1u16), ~"1"); - assert_eq!(format!("{:X}", 1u32), ~"1"); - assert_eq!(format!("{:X}", 1u64), ~"1"); - assert_eq!(format!("{:o}", 1u), ~"1"); - assert_eq!(format!("{:o}", 1u8), ~"1"); - assert_eq!(format!("{:o}", 1u16), ~"1"); - assert_eq!(format!("{:o}", 1u32), ~"1"); - assert_eq!(format!("{:o}", 1u64), ~"1"); + fail_unless_eq!(format!("{}", 1i), ~"1"); + fail_unless_eq!(format!("{}", 1i8), ~"1"); + fail_unless_eq!(format!("{}", 1i16), ~"1"); + fail_unless_eq!(format!("{}", 1i32), ~"1"); + fail_unless_eq!(format!("{}", 1i64), ~"1"); + fail_unless_eq!(format!("{:d}", -1i), ~"-1"); + fail_unless_eq!(format!("{:d}", -1i8), ~"-1"); + fail_unless_eq!(format!("{:d}", -1i16), ~"-1"); + fail_unless_eq!(format!("{:d}", -1i32), ~"-1"); + fail_unless_eq!(format!("{:d}", -1i64), ~"-1"); + fail_unless_eq!(format!("{:t}", 1i), ~"1"); + fail_unless_eq!(format!("{:t}", 1i8), ~"1"); + fail_unless_eq!(format!("{:t}", 1i16), ~"1"); + fail_unless_eq!(format!("{:t}", 1i32), ~"1"); + fail_unless_eq!(format!("{:t}", 1i64), ~"1"); + fail_unless_eq!(format!("{:x}", 1i), ~"1"); + fail_unless_eq!(format!("{:x}", 1i8), ~"1"); + fail_unless_eq!(format!("{:x}", 1i16), ~"1"); + fail_unless_eq!(format!("{:x}", 1i32), ~"1"); + fail_unless_eq!(format!("{:x}", 1i64), ~"1"); + fail_unless_eq!(format!("{:X}", 1i), ~"1"); + fail_unless_eq!(format!("{:X}", 1i8), ~"1"); + fail_unless_eq!(format!("{:X}", 1i16), ~"1"); + fail_unless_eq!(format!("{:X}", 1i32), ~"1"); + fail_unless_eq!(format!("{:X}", 1i64), ~"1"); + fail_unless_eq!(format!("{:o}", 1i), ~"1"); + fail_unless_eq!(format!("{:o}", 1i8), ~"1"); + fail_unless_eq!(format!("{:o}", 1i16), ~"1"); + fail_unless_eq!(format!("{:o}", 1i32), ~"1"); + fail_unless_eq!(format!("{:o}", 1i64), ~"1"); + + fail_unless_eq!(format!("{}", 1u), ~"1"); + fail_unless_eq!(format!("{}", 1u8), ~"1"); + fail_unless_eq!(format!("{}", 1u16), ~"1"); + fail_unless_eq!(format!("{}", 1u32), ~"1"); + fail_unless_eq!(format!("{}", 1u64), ~"1"); + fail_unless_eq!(format!("{:u}", 1u), ~"1"); + fail_unless_eq!(format!("{:u}", 1u8), ~"1"); + fail_unless_eq!(format!("{:u}", 1u16), ~"1"); + fail_unless_eq!(format!("{:u}", 1u32), ~"1"); + fail_unless_eq!(format!("{:u}", 1u64), ~"1"); + fail_unless_eq!(format!("{:t}", 1u), ~"1"); + fail_unless_eq!(format!("{:t}", 1u8), ~"1"); + fail_unless_eq!(format!("{:t}", 1u16), ~"1"); + fail_unless_eq!(format!("{:t}", 1u32), ~"1"); + fail_unless_eq!(format!("{:t}", 1u64), ~"1"); + fail_unless_eq!(format!("{:x}", 1u), ~"1"); + fail_unless_eq!(format!("{:x}", 1u8), ~"1"); + fail_unless_eq!(format!("{:x}", 1u16), ~"1"); + fail_unless_eq!(format!("{:x}", 1u32), ~"1"); + fail_unless_eq!(format!("{:x}", 1u64), ~"1"); + fail_unless_eq!(format!("{:X}", 1u), ~"1"); + fail_unless_eq!(format!("{:X}", 1u8), ~"1"); + fail_unless_eq!(format!("{:X}", 1u16), ~"1"); + fail_unless_eq!(format!("{:X}", 1u32), ~"1"); + fail_unless_eq!(format!("{:X}", 1u64), ~"1"); + fail_unless_eq!(format!("{:o}", 1u), ~"1"); + fail_unless_eq!(format!("{:o}", 1u8), ~"1"); + fail_unless_eq!(format!("{:o}", 1u16), ~"1"); + fail_unless_eq!(format!("{:o}", 1u32), ~"1"); + fail_unless_eq!(format!("{:o}", 1u64), ~"1"); // Test a larger number - assert_eq!(format!("{:t}", 55), ~"110111"); - assert_eq!(format!("{:o}", 55), ~"67"); - assert_eq!(format!("{:d}", 55), ~"55"); - assert_eq!(format!("{:x}", 55), ~"37"); - assert_eq!(format!("{:X}", 55), ~"37"); + fail_unless_eq!(format!("{:t}", 55), ~"110111"); + fail_unless_eq!(format!("{:o}", 55), ~"67"); + fail_unless_eq!(format!("{:d}", 55), ~"55"); + fail_unless_eq!(format!("{:x}", 55), ~"37"); + fail_unless_eq!(format!("{:X}", 55), ~"37"); } #[test] fn test_format_int_zero() { - assert_eq!(format!("{}", 0i), ~"0"); - assert_eq!(format!("{:d}", 0i), ~"0"); - assert_eq!(format!("{:t}", 0i), ~"0"); - assert_eq!(format!("{:o}", 0i), ~"0"); - assert_eq!(format!("{:x}", 0i), ~"0"); - assert_eq!(format!("{:X}", 0i), ~"0"); - - assert_eq!(format!("{}", 0u), ~"0"); - assert_eq!(format!("{:u}", 0u), ~"0"); - assert_eq!(format!("{:t}", 0u), ~"0"); - assert_eq!(format!("{:o}", 0u), ~"0"); - assert_eq!(format!("{:x}", 0u), ~"0"); - assert_eq!(format!("{:X}", 0u), ~"0"); + fail_unless_eq!(format!("{}", 0i), ~"0"); + fail_unless_eq!(format!("{:d}", 0i), ~"0"); + fail_unless_eq!(format!("{:t}", 0i), ~"0"); + fail_unless_eq!(format!("{:o}", 0i), ~"0"); + fail_unless_eq!(format!("{:x}", 0i), ~"0"); + fail_unless_eq!(format!("{:X}", 0i), ~"0"); + + fail_unless_eq!(format!("{}", 0u), ~"0"); + fail_unless_eq!(format!("{:u}", 0u), ~"0"); + fail_unless_eq!(format!("{:t}", 0u), ~"0"); + fail_unless_eq!(format!("{:o}", 0u), ~"0"); + fail_unless_eq!(format!("{:x}", 0u), ~"0"); + fail_unless_eq!(format!("{:X}", 0u), ~"0"); } #[test] fn test_format_int_flags() { - assert_eq!(format!("{:3d}", 1), ~" 1"); - assert_eq!(format!("{:>3d}", 1), ~" 1"); - assert_eq!(format!("{:>+3d}", 1), ~" +1"); - assert_eq!(format!("{:<3d}", 1), ~"1 "); - assert_eq!(format!("{:#d}", 1), ~"1"); - assert_eq!(format!("{:#x}", 10), ~"0xa"); - assert_eq!(format!("{:#X}", 10), ~"0xA"); - assert_eq!(format!("{:#5x}", 10), ~" 0xa"); - assert_eq!(format!("{:#o}", 10), ~"0o12"); - assert_eq!(format!("{:08x}", 10), ~"0000000a"); - assert_eq!(format!("{:8x}", 10), ~" a"); - assert_eq!(format!("{:<8x}", 10), ~"a "); - assert_eq!(format!("{:>8x}", 10), ~" a"); - assert_eq!(format!("{:#08x}", 10), ~"0x00000a"); - assert_eq!(format!("{:08d}", -10), ~"-0000010"); - assert_eq!(format!("{:x}", -1u8), ~"ff"); - assert_eq!(format!("{:X}", -1u8), ~"FF"); - assert_eq!(format!("{:t}", -1u8), ~"11111111"); - assert_eq!(format!("{:o}", -1u8), ~"377"); - assert_eq!(format!("{:#x}", -1u8), ~"0xff"); - assert_eq!(format!("{:#X}", -1u8), ~"0xFF"); - assert_eq!(format!("{:#t}", -1u8), ~"0b11111111"); - assert_eq!(format!("{:#o}", -1u8), ~"0o377"); + fail_unless_eq!(format!("{:3d}", 1), ~" 1"); + fail_unless_eq!(format!("{:>3d}", 1), ~" 1"); + fail_unless_eq!(format!("{:>+3d}", 1), ~" +1"); + fail_unless_eq!(format!("{:<3d}", 1), ~"1 "); + fail_unless_eq!(format!("{:#d}", 1), ~"1"); + fail_unless_eq!(format!("{:#x}", 10), ~"0xa"); + fail_unless_eq!(format!("{:#X}", 10), ~"0xA"); + fail_unless_eq!(format!("{:#5x}", 10), ~" 0xa"); + fail_unless_eq!(format!("{:#o}", 10), ~"0o12"); + fail_unless_eq!(format!("{:08x}", 10), ~"0000000a"); + fail_unless_eq!(format!("{:8x}", 10), ~" a"); + fail_unless_eq!(format!("{:<8x}", 10), ~"a "); + fail_unless_eq!(format!("{:>8x}", 10), ~" a"); + fail_unless_eq!(format!("{:#08x}", 10), ~"0x00000a"); + fail_unless_eq!(format!("{:08d}", -10), ~"-0000010"); + fail_unless_eq!(format!("{:x}", -1u8), ~"ff"); + fail_unless_eq!(format!("{:X}", -1u8), ~"FF"); + fail_unless_eq!(format!("{:t}", -1u8), ~"11111111"); + fail_unless_eq!(format!("{:o}", -1u8), ~"377"); + fail_unless_eq!(format!("{:#x}", -1u8), ~"0xff"); + fail_unless_eq!(format!("{:#X}", -1u8), ~"0xFF"); + fail_unless_eq!(format!("{:#t}", -1u8), ~"0b11111111"); + fail_unless_eq!(format!("{:#o}", -1u8), ~"0o377"); } #[test] fn test_format_int_sign_padding() { - assert_eq!(format!("{:+5d}", 1), ~" +1"); - assert_eq!(format!("{:+5d}", -1), ~" -1"); - assert_eq!(format!("{:05d}", 1), ~"00001"); - assert_eq!(format!("{:05d}", -1), ~"-0001"); - assert_eq!(format!("{:+05d}", 1), ~"+0001"); - assert_eq!(format!("{:+05d}", -1), ~"-0001"); + fail_unless_eq!(format!("{:+5d}", 1), ~" +1"); + fail_unless_eq!(format!("{:+5d}", -1), ~" -1"); + fail_unless_eq!(format!("{:05d}", 1), ~"00001"); + fail_unless_eq!(format!("{:05d}", -1), ~"-0001"); + fail_unless_eq!(format!("{:+05d}", 1), ~"+0001"); + fail_unless_eq!(format!("{:+05d}", -1), ~"-0001"); } #[test] fn test_format_int_twos_complement() { use {i8, i16, i32, i64}; - assert_eq!(format!("{}", i8::MIN), ~"-128"); - assert_eq!(format!("{}", i16::MIN), ~"-32768"); - assert_eq!(format!("{}", i32::MIN), ~"-2147483648"); - assert_eq!(format!("{}", i64::MIN), ~"-9223372036854775808"); + fail_unless_eq!(format!("{}", i8::MIN), ~"-128"); + fail_unless_eq!(format!("{}", i16::MIN), ~"-32768"); + fail_unless_eq!(format!("{}", i32::MIN), ~"-2147483648"); + fail_unless_eq!(format!("{}", i64::MIN), ~"-9223372036854775808"); } #[test] fn test_format_radix() { - assert_eq!(format!("{:04}", radix(3, 2)), ~"0011"); - assert_eq!(format!("{}", radix(55, 36)), ~"1j"); + fail_unless_eq!(format!("{:04}", radix(3, 2)), ~"0011"); + fail_unless_eq!(format!("{}", radix(55, 36)), ~"1j"); } #[test] diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 3fc13a9721e6a..94939adc02707 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -657,7 +657,7 @@ mod tests { fn same(fmt: &'static str, p: ~[Piece<'static>]) { let mut parser = Parser::new(fmt); - assert_eq!(p, parser.collect()); + fail_unless_eq!(p, parser.collect()); } fn fmtdflt() -> FormatSpec<'static> { diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index 5171cf931fd09..1949cecd8a1a7 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -101,7 +101,7 @@ mod tests { x.borrow().with_mut(|inner| { *inner = 20; }); - assert_eq!(y.borrow().with(|x| *x), 20); + fail_unless_eq!(y.borrow().with(|x| *x), 20); } #[test] @@ -111,21 +111,21 @@ mod tests { x.borrow().with_mut(|inner| { *inner = 20; }); - assert_eq!(y.borrow().with(|x| *x), 5); + fail_unless_eq!(y.borrow().with(|x| *x), 5); } #[test] fn test_simple() { let x = Gc::new(5); - assert_eq!(*x.borrow(), 5); + fail_unless_eq!(*x.borrow(), 5); } #[test] fn test_simple_clone() { let x = Gc::new(5); let y = x.clone(); - assert_eq!(*x.borrow(), 5); - assert_eq!(*y.borrow(), 5); + fail_unless_eq!(*x.borrow(), 5); + fail_unless_eq!(*y.borrow(), 5); } #[test] @@ -141,6 +141,6 @@ mod tests { #[test] fn test_destructor() { let x = Gc::new(~5); - assert_eq!(**x.borrow(), 5); + fail_unless_eq!(**x.borrow(), 5); } } diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index f8fc3ad8b31c4..a76074d40230c 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -400,7 +400,7 @@ mod tests { let vec = u8to64_le!(vecs[t], 0); let out = Bytes(buf.as_slice()).hash_keyed(k0, k1); debug!("got {:?}, expected {:?}", out, vec); - assert_eq!(vec, out); + fail_unless_eq!(vec, out); stream_full.reset(); stream_full.input(buf); @@ -422,19 +422,19 @@ mod tests { fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; fail_unless!((val as u64).hash() != (val as uint).hash()); - assert_eq!((val as u32).hash(), (val as uint).hash()); + fail_unless_eq!((val as u32).hash(), (val as uint).hash()); } #[test] #[cfg(target_arch = "x86_64")] fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert_eq!((val as u64).hash(), (val as uint).hash()); + fail_unless_eq!((val as u64).hash(), (val as uint).hash()); fail_unless!((val as u32).hash() != (val as uint).hash()); } #[test] #[cfg(target_arch = "x86")] fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; fail_unless!((val as u64).hash() != (val as uint).hash()); - assert_eq!((val as u32).hash(), (val as uint).hash()); + fail_unless_eq!((val as u32).hash(), (val as uint).hash()); } #[test] @@ -487,7 +487,7 @@ mod tests { #[test] fn test_float_hashes_of_zero() { - assert_eq!(0.0.hash(), (-0.0).hash()); + fail_unless_eq!(0.0.hash(), (-0.0).hash()); } #[test] diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 992df8df63af0..cbdeed5998a2d 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -937,8 +937,8 @@ mod test_map { let mut m = HashMap::new(); fail_unless!(m.insert(1, 2)); fail_unless!(m.insert(2, 4)); - assert_eq!(*m.get(&1), 2); - assert_eq!(*m.get(&2), 4); + fail_unless_eq!(*m.get(&1), 2); + fail_unless_eq!(*m.get(&2), 4); } #[test] @@ -951,16 +951,16 @@ mod test_map { match m.find_mut(&5) { None => fail!(), Some(x) => *x = new } - assert_eq!(m.find(&5), Some(&new)); + fail_unless_eq!(m.find(&5), Some(&new)); } #[test] fn test_insert_overwrite() { let mut m = HashMap::new(); fail_unless!(m.insert(1, 2)); - assert_eq!(*m.get(&1), 2); + fail_unless_eq!(*m.get(&1), 2); fail_unless!(!m.insert(1, 3)); - assert_eq!(*m.get(&1), 3); + fail_unless_eq!(*m.get(&1), 3); } #[test] @@ -969,9 +969,9 @@ mod test_map { fail_unless!(m.insert(1, 2)); fail_unless!(m.insert(5, 3)); fail_unless!(m.insert(9, 4)); - assert_eq!(*m.get(&9), 4); - assert_eq!(*m.get(&5), 3); - assert_eq!(*m.get(&1), 2); + fail_unless_eq!(*m.get(&9), 4); + fail_unless_eq!(*m.get(&5), 3); + fail_unless_eq!(*m.get(&1), 2); } #[test] @@ -981,8 +981,8 @@ mod test_map { fail_unless!(m.insert(5, 3)); fail_unless!(m.insert(9, 4)); fail_unless!(m.remove(&1)); - assert_eq!(*m.get(&9), 4); - assert_eq!(*m.get(&5), 3); + fail_unless_eq!(*m.get(&9), 4); + fail_unless_eq!(*m.get(&5), 3); } #[test] @@ -998,37 +998,37 @@ mod test_map { fn test_pop() { let mut m = HashMap::new(); m.insert(1, 2); - assert_eq!(m.pop(&1), Some(2)); - assert_eq!(m.pop(&1), None); + fail_unless_eq!(m.pop(&1), Some(2)); + fail_unless_eq!(m.pop(&1), None); } #[test] fn test_swap() { let mut m = HashMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + fail_unless_eq!(m.swap(1, 2), None); + fail_unless_eq!(m.swap(1, 3), Some(2)); + fail_unless_eq!(m.swap(1, 4), Some(3)); } #[test] fn test_find_or_insert() { let mut m: HashMap = HashMap::new(); - assert_eq!(*m.find_or_insert(1, 2), 2); - assert_eq!(*m.find_or_insert(1, 3), 2); + fail_unless_eq!(*m.find_or_insert(1, 2), 2); + fail_unless_eq!(*m.find_or_insert(1, 3), 2); } #[test] fn test_find_or_insert_with() { let mut m: HashMap = HashMap::new(); - assert_eq!(*m.find_or_insert_with(1, |_| 2), 2); - assert_eq!(*m.find_or_insert_with(1, |_| 3), 2); + fail_unless_eq!(*m.find_or_insert_with(1, |_| 2), 2); + fail_unless_eq!(*m.find_or_insert_with(1, |_| 3), 2); } #[test] fn test_insert_or_update_with() { let mut m: HashMap = HashMap::new(); - assert_eq!(*m.insert_or_update_with(1, 2, |_,x| *x+=1), 2); - assert_eq!(*m.insert_or_update_with(1, 2, |_,x| *x+=1), 3); + fail_unless_eq!(*m.insert_or_update_with(1, 2, |_,x| *x+=1), 2); + fail_unless_eq!(*m.insert_or_update_with(1, 2, |_,x| *x+=1), 3); } #[test] @@ -1054,10 +1054,10 @@ mod test_map { } let mut observed = 0; for (k, v) in m.iter() { - assert_eq!(*v, *k * 2); + fail_unless_eq!(*v, *k * 2); observed |= (1 << *k); } - assert_eq!(observed, 0xFFFF_FFFF); + fail_unless_eq!(observed, 0xFFFF_FFFF); } #[test] @@ -1065,7 +1065,7 @@ mod test_map { let vec = ~[(1, 'a'), (2, 'b'), (3, 'c')]; let map = vec.move_iter().collect::>(); let keys = map.keys().map(|&k| k).collect::<~[int]>(); - assert_eq!(keys.len(), 3); + fail_unless_eq!(keys.len(), 3); fail_unless!(keys.contains(&1)); fail_unless!(keys.contains(&2)); fail_unless!(keys.contains(&3)); @@ -1076,7 +1076,7 @@ mod test_map { let vec = ~[(1, 'a'), (2, 'b'), (3, 'c')]; let map = vec.move_iter().collect::>(); let values = map.values().map(|&v| v).collect::<~[char]>(); - assert_eq!(values.len(), 3); + fail_unless_eq!(values.len(), 3); fail_unless!(values.contains(&'a')); fail_unless!(values.contains(&'b')); fail_unless!(values.contains(&'c')); @@ -1108,14 +1108,14 @@ mod test_map { m2.insert(3, 4); - assert_eq!(m1, m2); + fail_unless_eq!(m1, m2); } #[test] fn test_expand() { let mut m = HashMap::new(); - assert_eq!(m.len(), 0); + fail_unless_eq!(m.len(), 0); fail_unless!(m.is_empty()); let mut i = 0u; @@ -1125,7 +1125,7 @@ mod test_map { i += 1; } - assert_eq!(m.len(), i); + fail_unless_eq!(m.len(), i); fail_unless!(!m.is_empty()); } @@ -1139,11 +1139,11 @@ mod test_map { m.insert(~"baz", baz); - assert_eq!(m.find_equiv(&("foo")), Some(&foo)); - assert_eq!(m.find_equiv(&("bar")), Some(&bar)); - assert_eq!(m.find_equiv(&("baz")), Some(&baz)); + fail_unless_eq!(m.find_equiv(&("foo")), Some(&foo)); + fail_unless_eq!(m.find_equiv(&("bar")), Some(&bar)); + fail_unless_eq!(m.find_equiv(&("baz")), Some(&baz)); - assert_eq!(m.find_equiv(&("qux")), None); + fail_unless_eq!(m.find_equiv(&("qux")), None); } #[test] @@ -1153,7 +1153,7 @@ mod test_map { let map: HashMap = xs.iter().map(|&x| x).collect(); for &(k, v) in xs.iter() { - assert_eq!(map.find(&k), Some(&v)); + fail_unless_eq!(map.find(&k), Some(&v)); } } @@ -1178,7 +1178,7 @@ mod test_map { let table_str = format!("{}", table); fail_unless!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); - assert_eq!(format!("{}", empty), ~"{}"); + fail_unless_eq!(format!("{}", empty), ~"{}"); } } @@ -1250,7 +1250,7 @@ mod test_set { for k in a.iter() { observed |= (1 << *k); } - assert_eq!(observed, 0xFFFF_FFFF); + fail_unless_eq!(observed, 0xFFFF_FFFF); } #[test] @@ -1280,7 +1280,7 @@ mod test_set { fail_unless!(expected.contains(x)); i += 1 } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1303,7 +1303,7 @@ mod test_set { fail_unless!(expected.contains(x)); i += 1 } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1329,7 +1329,7 @@ mod test_set { fail_unless!(expected.contains(x)); i += 1 } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1359,7 +1359,7 @@ mod test_set { fail_unless!(expected.contains(x)); i += 1 } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] @@ -1403,7 +1403,7 @@ mod test_set { s2.insert(3); - assert_eq!(s1, s2); + fail_unless_eq!(s1, s2); } #[test] @@ -1417,6 +1417,6 @@ mod test_set { let set_str = format!("{}", set); fail_unless!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); - assert_eq!(format!("{}", empty), ~"{}"); + fail_unless_eq!(format!("{}", empty), ~"{}"); } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 8b6cf959cd80d..ca7ec4903cef4 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -390,22 +390,22 @@ mod test { let mut buf = [0, 0, 0]; let nread = reader.read(buf); - assert_eq!(Ok(2), nread); - assert_eq!([0, 1, 0], buf); + fail_unless_eq!(Ok(2), nread); + fail_unless_eq!([0, 1, 0], buf); let mut buf = [0]; let nread = reader.read(buf); - assert_eq!(Ok(1), nread); - assert_eq!([2], buf); + fail_unless_eq!(Ok(1), nread); + fail_unless_eq!([2], buf); let mut buf = [0, 0, 0]; let nread = reader.read(buf); - assert_eq!(Ok(1), nread); - assert_eq!([3, 0, 0], buf); + fail_unless_eq!(Ok(1), nread); + fail_unless_eq!([3, 0, 0], buf); let nread = reader.read(buf); - assert_eq!(Ok(1), nread); - assert_eq!([4, 0, 0], buf); + fail_unless_eq!(Ok(1), nread); + fail_unless_eq!([4, 0, 0], buf); fail_unless!(reader.read(buf).is_err()); } @@ -416,35 +416,35 @@ mod test { let mut writer = BufferedWriter::with_capacity(2, inner); writer.write([0, 1]).unwrap(); - assert_eq!([], writer.get_ref().get_ref()); + fail_unless_eq!([], writer.get_ref().get_ref()); writer.write([2]).unwrap(); - assert_eq!([0, 1], writer.get_ref().get_ref()); + fail_unless_eq!([0, 1], writer.get_ref().get_ref()); writer.write([3]).unwrap(); - assert_eq!([0, 1], writer.get_ref().get_ref()); + fail_unless_eq!([0, 1], writer.get_ref().get_ref()); writer.flush().unwrap(); - assert_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); + fail_unless_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); writer.write([4]).unwrap(); writer.write([5]).unwrap(); - assert_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); + fail_unless_eq!([0, 1, 2, 3], writer.get_ref().get_ref()); writer.write([6]).unwrap(); - assert_eq!([0, 1, 2, 3, 4, 5], + fail_unless_eq!([0, 1, 2, 3, 4, 5], writer.get_ref().get_ref()); writer.write([7, 8]).unwrap(); - assert_eq!([0, 1, 2, 3, 4, 5, 6], + fail_unless_eq!([0, 1, 2, 3, 4, 5, 6], writer.get_ref().get_ref()); writer.write([9, 10, 11]).unwrap(); - assert_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], + fail_unless_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], writer.get_ref().get_ref()); writer.flush().unwrap(); - assert_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], + fail_unless_eq!([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], writer.get_ref().get_ref()); } @@ -452,9 +452,9 @@ mod test { fn test_buffered_writer_inner_flushes() { let mut w = BufferedWriter::with_capacity(3, MemWriter::new()); w.write([0, 1]).unwrap(); - assert_eq!([], w.get_ref().get_ref()); + fail_unless_eq!([], w.get_ref().get_ref()); let w = w.unwrap(); - assert_eq!([0, 1], w.get_ref()); + fail_unless_eq!([0, 1], w.get_ref()); } // This is just here to make sure that we don't infinite loop in the @@ -484,10 +484,10 @@ mod test { fn test_read_until() { let inner = MemReader::new(~[0, 1, 2, 1, 0]); let mut reader = BufferedReader::with_capacity(2, inner); - assert_eq!(reader.read_until(0), Ok(~[0])); - assert_eq!(reader.read_until(2), Ok(~[1, 2])); - assert_eq!(reader.read_until(1), Ok(~[1])); - assert_eq!(reader.read_until(8), Ok(~[0])); + fail_unless_eq!(reader.read_until(0), Ok(~[0])); + fail_unless_eq!(reader.read_until(2), Ok(~[1, 2])); + fail_unless_eq!(reader.read_until(1), Ok(~[1])); + fail_unless_eq!(reader.read_until(8), Ok(~[0])); fail_unless!(reader.read_until(9).is_err()); } @@ -495,19 +495,19 @@ mod test { fn test_line_buffer() { let mut writer = LineBufferedWriter::new(MemWriter::new()); writer.write([0]).unwrap(); - assert_eq!(writer.get_ref().get_ref(), []); + fail_unless_eq!(writer.get_ref().get_ref(), []); writer.write([1]).unwrap(); - assert_eq!(writer.get_ref().get_ref(), []); + fail_unless_eq!(writer.get_ref().get_ref(), []); writer.flush().unwrap(); - assert_eq!(writer.get_ref().get_ref(), [0, 1]); + fail_unless_eq!(writer.get_ref().get_ref(), [0, 1]); writer.write([0, '\n' as u8, 1, '\n' as u8, 2]).unwrap(); - assert_eq!(writer.get_ref().get_ref(), + fail_unless_eq!(writer.get_ref().get_ref(), [0, 1, 0, '\n' as u8, 1, '\n' as u8]); writer.flush().unwrap(); - assert_eq!(writer.get_ref().get_ref(), + fail_unless_eq!(writer.get_ref().get_ref(), [0, 1, 0, '\n' as u8, 1, '\n' as u8, 2]); writer.write([3, '\n' as u8]).unwrap(); - assert_eq!(writer.get_ref().get_ref(), + fail_unless_eq!(writer.get_ref().get_ref(), [0, 1, 0, '\n' as u8, 1, '\n' as u8, 2, 3, '\n' as u8]); } @@ -515,9 +515,9 @@ mod test { fn test_read_line() { let in_buf = MemReader::new(bytes!("a\nb\nc").to_owned()); let mut reader = BufferedReader::with_capacity(2, in_buf); - assert_eq!(reader.read_line(), Ok(~"a\n")); - assert_eq!(reader.read_line(), Ok(~"b\n")); - assert_eq!(reader.read_line(), Ok(~"c")); + fail_unless_eq!(reader.read_line(), Ok(~"a\n")); + fail_unless_eq!(reader.read_line(), Ok(~"b\n")); + fail_unless_eq!(reader.read_line(), Ok(~"c")); fail_unless!(reader.read_line().is_err()); } @@ -526,10 +526,10 @@ mod test { let in_buf = MemReader::new(bytes!("a\nb\nc").to_owned()); let mut reader = BufferedReader::with_capacity(2, in_buf); let mut it = reader.lines(); - assert_eq!(it.next(), Some(~"a\n")); - assert_eq!(it.next(), Some(~"b\n")); - assert_eq!(it.next(), Some(~"c")); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some(~"a\n")); + fail_unless_eq!(it.next(), Some(~"b\n")); + fail_unless_eq!(it.next(), Some(~"c")); + fail_unless_eq!(it.next(), None); } #[test] @@ -537,12 +537,12 @@ mod test { let inner = ShortReader{lengths: ~[0, 1, 2, 0, 1, 0]}; let mut reader = BufferedReader::new(inner); let mut buf = [0, 0]; - assert_eq!(reader.read(buf), Ok(0)); - assert_eq!(reader.read(buf), Ok(1)); - assert_eq!(reader.read(buf), Ok(2)); - assert_eq!(reader.read(buf), Ok(0)); - assert_eq!(reader.read(buf), Ok(1)); - assert_eq!(reader.read(buf), Ok(0)); + fail_unless_eq!(reader.read(buf), Ok(0)); + fail_unless_eq!(reader.read(buf), Ok(1)); + fail_unless_eq!(reader.read(buf), Ok(2)); + fail_unless_eq!(reader.read(buf), Ok(0)); + fail_unless_eq!(reader.read(buf), Ok(1)); + fail_unless_eq!(reader.read(buf), Ok(0)); fail_unless!(reader.read(buf).is_err()); } @@ -550,7 +550,7 @@ mod test { fn read_char_buffered() { let buf = [195u8, 159u8]; let mut reader = BufferedReader::with_capacity(1, BufReader::new(buf)); - assert_eq!(reader.read_char(), Ok('ß')); + fail_unless_eq!(reader.read_char(), Ok('ß')); } #[test] @@ -558,9 +558,9 @@ mod test { let buf = [195u8, 159u8, 'a' as u8]; let mut reader = BufferedReader::with_capacity(1, BufReader::new(buf)); let mut it = reader.chars(); - assert_eq!(it.next(), Some('ß')); - assert_eq!(it.next(), Some('a')); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some('ß')); + fail_unless_eq!(it.next(), Some('a')); + fail_unless_eq!(it.next(), None); } #[bench] diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index 10e1f88690332..3031339ed39d8 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -148,29 +148,29 @@ mod test { let mut buf = ~[0u8, ..3]; - assert_eq!(Ok(0), reader.read([])); + fail_unless_eq!(Ok(0), reader.read([])); - assert_eq!(Ok(3), reader.read(buf)); - assert_eq!(~[1,2,3], buf); + fail_unless_eq!(Ok(3), reader.read(buf)); + fail_unless_eq!(~[1,2,3], buf); - assert_eq!(Ok(3), reader.read(buf)); - assert_eq!(~[4,5,6], buf); + fail_unless_eq!(Ok(3), reader.read(buf)); + fail_unless_eq!(~[4,5,6], buf); - assert_eq!(Ok(2), reader.read(buf)); - assert_eq!(~[7,8,6], buf); + fail_unless_eq!(Ok(2), reader.read(buf)); + fail_unless_eq!(~[7,8,6], buf); match reader.read(buf) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => fail_unless_eq!(e.kind, io::EndOfFile), } - assert_eq!(~[7,8,6], buf); + fail_unless_eq!(~[7,8,6], buf); // Ensure it continues to fail in the same way. match reader.read(buf) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => fail_unless_eq!(e.kind, io::EndOfFile), } - assert_eq!(~[7,8,6], buf); + fail_unless_eq!(~[7,8,6], buf); } #[test] @@ -181,11 +181,11 @@ mod test { let wanted = ~[0u8, 0u8, 0u8, 42u8]; let got = task::try(proc() { port.recv() }).unwrap(); - assert_eq!(wanted, got); + fail_unless_eq!(wanted, got); match writer.write_u8(1) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::BrokenPipe), + Err(e) => fail_unless_eq!(e.kind, io::BrokenPipe), } } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 8e6e488f832b1..4e67900e93f98 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -431,26 +431,26 @@ mod test { let buf = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]; // Aligned access - assert_eq!(u64_from_be_bytes(buf, 0, 0), 0); - assert_eq!(u64_from_be_bytes(buf, 0, 1), 0x01); - assert_eq!(u64_from_be_bytes(buf, 0, 2), 0x0102); - assert_eq!(u64_from_be_bytes(buf, 0, 3), 0x010203); - assert_eq!(u64_from_be_bytes(buf, 0, 4), 0x01020304); - assert_eq!(u64_from_be_bytes(buf, 0, 5), 0x0102030405); - assert_eq!(u64_from_be_bytes(buf, 0, 6), 0x010203040506); - assert_eq!(u64_from_be_bytes(buf, 0, 7), 0x01020304050607); - assert_eq!(u64_from_be_bytes(buf, 0, 8), 0x0102030405060708); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 0), 0); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 1), 0x01); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 2), 0x0102); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 3), 0x010203); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 4), 0x01020304); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 5), 0x0102030405); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 6), 0x010203040506); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 7), 0x01020304050607); + fail_unless_eq!(u64_from_be_bytes(buf, 0, 8), 0x0102030405060708); // Unaligned access - assert_eq!(u64_from_be_bytes(buf, 1, 0), 0); - assert_eq!(u64_from_be_bytes(buf, 1, 1), 0x02); - assert_eq!(u64_from_be_bytes(buf, 1, 2), 0x0203); - assert_eq!(u64_from_be_bytes(buf, 1, 3), 0x020304); - assert_eq!(u64_from_be_bytes(buf, 1, 4), 0x02030405); - assert_eq!(u64_from_be_bytes(buf, 1, 5), 0x0203040506); - assert_eq!(u64_from_be_bytes(buf, 1, 6), 0x020304050607); - assert_eq!(u64_from_be_bytes(buf, 1, 7), 0x02030405060708); - assert_eq!(u64_from_be_bytes(buf, 1, 8), 0x0203040506070809); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 0), 0); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 1), 0x02); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 2), 0x0203); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 3), 0x020304); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 4), 0x02030405); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 5), 0x0203040506); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 6), 0x020304050607); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 7), 0x02030405060708); + fail_unless_eq!(u64_from_be_bytes(buf, 1, 8), 0x0203040506070809); } } diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 471c868303868..c6c4dff624e23 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -709,7 +709,7 @@ mod test { -1|0 => fail!("shouldn't happen"), n => str::from_utf8_owned(read_buf.slice_to(n).to_owned()).unwrap() }; - assert_eq!(read_str, message.to_owned()); + fail_unless_eq!(read_str, message.to_owned()); } unlink(filename).unwrap(); }) @@ -749,7 +749,7 @@ mod test { } unlink(filename).unwrap(); let read_str = str::from_utf8(read_mem).unwrap(); - assert_eq!(read_str, message); + fail_unless_eq!(read_str, message); }) iotest!(fn file_test_io_seek_and_tell_smoke_test() { @@ -773,9 +773,9 @@ mod test { } unlink(filename).unwrap(); let read_str = str::from_utf8(read_mem).unwrap(); - assert_eq!(read_str, message.slice(4, 8)); - assert_eq!(tell_pos_pre_read, set_cursor); - assert_eq!(tell_pos_post_read, message.len() as u64); + fail_unless_eq!(read_str, message.slice(4, 8)); + fail_unless_eq!(tell_pos_pre_read, set_cursor); + fail_unless_eq!(tell_pos_post_read, message.len() as u64); }) iotest!(fn file_test_io_seek_and_write() { @@ -819,15 +819,15 @@ mod test { read_stream.seek(-4, SeekEnd).unwrap(); read_stream.read(read_mem).unwrap(); - assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_three); + fail_unless_eq!(str::from_utf8(read_mem).unwrap(), chunk_three); read_stream.seek(-9, SeekCur).unwrap(); read_stream.read(read_mem).unwrap(); - assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_two); + fail_unless_eq!(str::from_utf8(read_mem).unwrap(), chunk_two); read_stream.seek(0, SeekSet).unwrap(); read_stream.read(read_mem).unwrap(); - assert_eq!(str::from_utf8(read_mem).unwrap(), chunk_one); + fail_unless_eq!(str::from_utf8(read_mem).unwrap(), chunk_one); } unlink(filename).unwrap(); }) @@ -841,7 +841,7 @@ mod test { fs.write(msg.as_bytes()).unwrap(); } let stat_res = stat(filename).unwrap(); - assert_eq!(stat_res.kind, io::TypeFile); + fail_unless_eq!(stat_res.kind, io::TypeFile); unlink(filename).unwrap(); }) @@ -906,7 +906,7 @@ mod test { None|Some("") => fail!("really shouldn't happen.."), Some(n) => prefix+n }; - assert_eq!(expected.as_slice(), read_str); + fail_unless_eq!(expected.as_slice(), read_str); } unlink(f).unwrap(); } @@ -967,9 +967,9 @@ mod test { File::create(&input).write(bytes!("hello")).unwrap(); copy(&input, &out).unwrap(); let contents = File::open(&out).read_to_end().unwrap(); - assert_eq!(contents.as_slice(), bytes!("hello")); + fail_unless_eq!(contents.as_slice(), bytes!("hello")); - assert_eq!(input.stat().unwrap().perm, out.stat().unwrap().perm); + fail_unless_eq!(input.stat().unwrap().perm, out.stat().unwrap().perm); }) iotest!(fn copy_file_dst_dir() { @@ -991,7 +991,7 @@ mod test { File::create(&output).write("bar".as_bytes()).unwrap(); copy(&input, &output).unwrap(); - assert_eq!(File::open(&output).read_to_end().unwrap(), + fail_unless_eq!(File::open(&output).read_to_end().unwrap(), (bytes!("foo")).to_owned()); }) @@ -1028,10 +1028,10 @@ mod test { File::create(&input).write("foobar".as_bytes()).unwrap(); symlink(&input, &out).unwrap(); if cfg!(not(windows)) { - assert_eq!(lstat(&out).unwrap().kind, io::TypeSymlink); + fail_unless_eq!(lstat(&out).unwrap().kind, io::TypeSymlink); } - assert_eq!(stat(&out).unwrap().size, stat(&input).unwrap().size); - assert_eq!(File::open(&out).read_to_end().unwrap(), + fail_unless_eq!(stat(&out).unwrap().size, stat(&input).unwrap().size); + fail_unless_eq!(File::open(&out).read_to_end().unwrap(), (bytes!("foobar")).to_owned()); }) @@ -1059,11 +1059,11 @@ mod test { File::create(&input).write("foobar".as_bytes()).unwrap(); link(&input, &out).unwrap(); if cfg!(not(windows)) { - assert_eq!(lstat(&out).unwrap().kind, io::TypeFile); - assert_eq!(stat(&out).unwrap().unstable.nlink, 2); + fail_unless_eq!(lstat(&out).unwrap().kind, io::TypeFile); + fail_unless_eq!(stat(&out).unwrap().unstable.nlink, 2); } - assert_eq!(stat(&out).unwrap().size, stat(&input).unwrap().size); - assert_eq!(File::open(&out).read_to_end().unwrap(), + fail_unless_eq!(stat(&out).unwrap().size, stat(&input).unwrap().size); + fail_unless_eq!(File::open(&out).read_to_end().unwrap(), (bytes!("foobar")).to_owned()); // can't link to yourself @@ -1117,24 +1117,24 @@ mod test { file.fsync().unwrap(); // Do some simple things with truncation - assert_eq!(stat(&path).unwrap().size, 3); + fail_unless_eq!(stat(&path).unwrap().size, 3); file.truncate(10).unwrap(); - assert_eq!(stat(&path).unwrap().size, 10); + fail_unless_eq!(stat(&path).unwrap().size, 10); file.write(bytes!("bar")).unwrap(); file.fsync().unwrap(); - assert_eq!(stat(&path).unwrap().size, 10); - assert_eq!(File::open(&path).read_to_end().unwrap(), + fail_unless_eq!(stat(&path).unwrap().size, 10); + fail_unless_eq!(File::open(&path).read_to_end().unwrap(), (bytes!("foobar", 0, 0, 0, 0)).to_owned()); // Truncate to a smaller length, don't seek, and then write something. // Ensure that the intermediate zeroes are all filled in (we're seeked // past the end of the file). file.truncate(2).unwrap(); - assert_eq!(stat(&path).unwrap().size, 2); + fail_unless_eq!(stat(&path).unwrap().size, 2); file.write(bytes!("wut")).unwrap(); file.fsync().unwrap(); - assert_eq!(stat(&path).unwrap().size, 9); - assert_eq!(File::open(&path).read_to_end().unwrap(), + fail_unless_eq!(stat(&path).unwrap().size, 9); + fail_unless_eq!(File::open(&path).read_to_end().unwrap(), (bytes!("fo", 0, 0, 0, 0, "wut")).to_owned()); drop(file); }) @@ -1161,19 +1161,19 @@ mod test { Ok(..) => fail!(), Err(..) => {} } } - assert_eq!(stat(&tmpdir.join("h")).unwrap().size, 3); + fail_unless_eq!(stat(&tmpdir.join("h")).unwrap().size, 3); { let mut f = File::open_mode(&tmpdir.join("h"), io::Append, io::Write).unwrap(); f.write("bar".as_bytes()).unwrap(); } - assert_eq!(stat(&tmpdir.join("h")).unwrap().size, 6); + fail_unless_eq!(stat(&tmpdir.join("h")).unwrap().size, 6); { let mut f = File::open_mode(&tmpdir.join("h"), io::Truncate, io::Write).unwrap(); f.write("bar".as_bytes()).unwrap(); } - assert_eq!(stat(&tmpdir.join("h")).unwrap().size, 3); + fail_unless_eq!(stat(&tmpdir.join("h")).unwrap().size, 3); }) #[test] @@ -1183,8 +1183,8 @@ mod test { File::create(&path).unwrap(); change_file_times(&path, 1000, 2000).unwrap(); - assert_eq!(path.stat().unwrap().accessed, 1000); - assert_eq!(path.stat().unwrap().modified, 2000); + fail_unless_eq!(path.stat().unwrap().accessed, 1000); + fail_unless_eq!(path.stat().unwrap().modified, 2000); } #[test] diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 1ce98bb597266..39facfac50bb1 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -49,7 +49,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult /// let mut w = MemWriter::new(); /// w.write([0, 1, 2]); /// -/// assert_eq!(w.unwrap(), ~[0, 1, 2]); +/// fail_unless_eq!(w.unwrap(), ~[0, 1, 2]); /// ``` pub struct MemWriter { priv buf: ~[u8], @@ -129,7 +129,7 @@ impl Seek for MemWriter { /// /// let mut r = MemReader::new(~[0, 1, 2]); /// -/// assert_eq!(r.read_to_end().unwrap(), ~[0, 1, 2]); +/// fail_unless_eq!(r.read_to_end().unwrap(), ~[0, 1, 2]); /// ``` pub struct MemReader { priv buf: ~[u8], @@ -170,7 +170,7 @@ impl Reader for MemReader { { let input = self.buf.slice(self.pos, self.pos + write_len); let output = buf.mut_slice(0, write_len); - assert_eq!(input.len(), output.len()); + fail_unless_eq!(input.len(), output.len()); vec::bytes::copy_memory(output, input); } self.pos += write_len; @@ -216,7 +216,7 @@ impl Buffer for MemReader { /// let mut w = BufWriter::new(buf); /// w.write([0, 1, 2]); /// } -/// assert_eq!(buf, [0, 1, 2, 0]); +/// fail_unless_eq!(buf, [0, 1, 2, 0]); /// ``` pub struct BufWriter<'a> { priv buf: &'a mut [u8], @@ -270,7 +270,7 @@ impl<'a> Seek for BufWriter<'a> { /// let mut buf = [0, 1, 2, 3]; /// let mut r = BufReader::new(buf); /// -/// assert_eq!(r.read_to_end().unwrap(), ~[0, 1, 2, 3]); +/// fail_unless_eq!(r.read_to_end().unwrap(), ~[0, 1, 2, 3]); /// ``` pub struct BufReader<'a> { priv buf: &'a [u8], @@ -300,7 +300,7 @@ impl<'a> Reader for BufReader<'a> { { let input = self.buf.slice(self.pos, self.pos + write_len); let output = buf.mut_slice(0, write_len); - assert_eq!(input.len(), output.len()); + fail_unless_eq!(input.len(), output.len()); vec::bytes::copy_memory(output, input); } self.pos += write_len; @@ -340,30 +340,30 @@ mod test { #[test] fn test_mem_writer() { let mut writer = MemWriter::new(); - assert_eq!(writer.tell(), Ok(0)); + fail_unless_eq!(writer.tell(), Ok(0)); writer.write([0]).unwrap(); - assert_eq!(writer.tell(), Ok(1)); + fail_unless_eq!(writer.tell(), Ok(1)); writer.write([1, 2, 3]).unwrap(); writer.write([4, 5, 6, 7]).unwrap(); - assert_eq!(writer.tell(), Ok(8)); - assert_eq!(writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7]); + fail_unless_eq!(writer.tell(), Ok(8)); + fail_unless_eq!(writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7]); writer.seek(0, SeekSet).unwrap(); - assert_eq!(writer.tell(), Ok(0)); + fail_unless_eq!(writer.tell(), Ok(0)); writer.write([3, 4]).unwrap(); - assert_eq!(writer.get_ref(), [3, 4, 2, 3, 4, 5, 6, 7]); + fail_unless_eq!(writer.get_ref(), [3, 4, 2, 3, 4, 5, 6, 7]); writer.seek(1, SeekCur).unwrap(); writer.write([0, 1]).unwrap(); - assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 7]); + fail_unless_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 7]); writer.seek(-1, SeekEnd).unwrap(); writer.write([1, 2]).unwrap(); - assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2]); + fail_unless_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2]); writer.seek(1, SeekEnd).unwrap(); writer.write([1]).unwrap(); - assert_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]); + fail_unless_eq!(writer.get_ref(), [3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]); } #[test] @@ -371,14 +371,14 @@ mod test { let mut buf = [0 as u8, ..8]; { let mut writer = BufWriter::new(buf); - assert_eq!(writer.tell(), Ok(0)); + fail_unless_eq!(writer.tell(), Ok(0)); writer.write([0]).unwrap(); - assert_eq!(writer.tell(), Ok(1)); + fail_unless_eq!(writer.tell(), Ok(1)); writer.write([1, 2, 3]).unwrap(); writer.write([4, 5, 6, 7]).unwrap(); - assert_eq!(writer.tell(), Ok(8)); + fail_unless_eq!(writer.tell(), Ok(8)); } - assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7]); + fail_unless_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7]); } #[test] @@ -386,27 +386,27 @@ mod test { let mut buf = [0 as u8, ..8]; { let mut writer = BufWriter::new(buf); - assert_eq!(writer.tell(), Ok(0)); + fail_unless_eq!(writer.tell(), Ok(0)); writer.write([1]).unwrap(); - assert_eq!(writer.tell(), Ok(1)); + fail_unless_eq!(writer.tell(), Ok(1)); writer.seek(2, SeekSet).unwrap(); - assert_eq!(writer.tell(), Ok(2)); + fail_unless_eq!(writer.tell(), Ok(2)); writer.write([2]).unwrap(); - assert_eq!(writer.tell(), Ok(3)); + fail_unless_eq!(writer.tell(), Ok(3)); writer.seek(-2, SeekCur).unwrap(); - assert_eq!(writer.tell(), Ok(1)); + fail_unless_eq!(writer.tell(), Ok(1)); writer.write([3]).unwrap(); - assert_eq!(writer.tell(), Ok(2)); + fail_unless_eq!(writer.tell(), Ok(2)); writer.seek(-1, SeekEnd).unwrap(); - assert_eq!(writer.tell(), Ok(7)); + fail_unless_eq!(writer.tell(), Ok(7)); writer.write([4]).unwrap(); - assert_eq!(writer.tell(), Ok(8)); + fail_unless_eq!(writer.tell(), Ok(8)); } - assert_eq!(buf, [1, 3, 2, 0, 0, 0, 0, 4]); + fail_unless_eq!(buf, [1, 3, 2, 0, 0, 0, 0, 4]); } #[test] @@ -417,7 +417,7 @@ mod test { match writer.write([0, 0]) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::OtherIoError), + Err(e) => fail_unless_eq!(e.kind, io::OtherIoError), } } @@ -425,22 +425,22 @@ mod test { fn test_mem_reader() { let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]); let mut buf = []; - assert_eq!(reader.read(buf), Ok(0)); - assert_eq!(reader.tell(), Ok(0)); + fail_unless_eq!(reader.read(buf), Ok(0)); + fail_unless_eq!(reader.tell(), Ok(0)); let mut buf = [0]; - assert_eq!(reader.read(buf), Ok(1)); - assert_eq!(reader.tell(), Ok(1)); - assert_eq!(buf, [0]); + fail_unless_eq!(reader.read(buf), Ok(1)); + fail_unless_eq!(reader.tell(), Ok(1)); + fail_unless_eq!(buf, [0]); let mut buf = [0, ..4]; - assert_eq!(reader.read(buf), Ok(4)); - assert_eq!(reader.tell(), Ok(5)); - assert_eq!(buf, [1, 2, 3, 4]); - assert_eq!(reader.read(buf), Ok(3)); - assert_eq!(buf.slice(0, 3), [5, 6, 7]); + fail_unless_eq!(reader.read(buf), Ok(4)); + fail_unless_eq!(reader.tell(), Ok(5)); + fail_unless_eq!(buf, [1, 2, 3, 4]); + fail_unless_eq!(reader.read(buf), Ok(3)); + fail_unless_eq!(buf.slice(0, 3), [5, 6, 7]); fail_unless!(reader.read(buf).is_err()); let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]); - assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); - assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); + fail_unless_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); + fail_unless_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); fail_unless!(reader.read(buf).is_err()); } @@ -449,22 +449,22 @@ mod test { let in_buf = ~[0, 1, 2, 3, 4, 5, 6, 7]; let mut reader = BufReader::new(in_buf); let mut buf = []; - assert_eq!(reader.read(buf), Ok(0)); - assert_eq!(reader.tell(), Ok(0)); + fail_unless_eq!(reader.read(buf), Ok(0)); + fail_unless_eq!(reader.tell(), Ok(0)); let mut buf = [0]; - assert_eq!(reader.read(buf), Ok(1)); - assert_eq!(reader.tell(), Ok(1)); - assert_eq!(buf, [0]); + fail_unless_eq!(reader.read(buf), Ok(1)); + fail_unless_eq!(reader.tell(), Ok(1)); + fail_unless_eq!(buf, [0]); let mut buf = [0, ..4]; - assert_eq!(reader.read(buf), Ok(4)); - assert_eq!(reader.tell(), Ok(5)); - assert_eq!(buf, [1, 2, 3, 4]); - assert_eq!(reader.read(buf), Ok(3)); - assert_eq!(buf.slice(0, 3), [5, 6, 7]); + fail_unless_eq!(reader.read(buf), Ok(4)); + fail_unless_eq!(reader.tell(), Ok(5)); + fail_unless_eq!(buf, [1, 2, 3, 4]); + fail_unless_eq!(reader.read(buf), Ok(3)); + fail_unless_eq!(buf.slice(0, 3), [5, 6, 7]); fail_unless!(reader.read(buf).is_err()); let mut reader = BufReader::new(in_buf); - assert_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); - assert_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); + fail_unless_eq!(reader.read_until(3).unwrap(), ~[0, 1, 2, 3]); + fail_unless_eq!(reader.read_until(3).unwrap(), ~[4, 5, 6, 7]); fail_unless!(reader.read(buf).is_err()); } @@ -472,10 +472,10 @@ mod test { fn test_read_char() { let b = bytes!("Việt"); let mut r = BufReader::new(b); - assert_eq!(r.read_char(), Ok('V')); - assert_eq!(r.read_char(), Ok('i')); - assert_eq!(r.read_char(), Ok('ệ')); - assert_eq!(r.read_char(), Ok('t')); + fail_unless_eq!(r.read_char(), Ok('V')); + fail_unless_eq!(r.read_char(), Ok('i')); + fail_unless_eq!(r.read_char(), Ok('ệ')); + fail_unless_eq!(r.read_char(), Ok('t')); fail_unless!(r.read_char().is_err()); } @@ -493,7 +493,7 @@ mod test { writer.write_line("testing").unwrap(); writer.write_str("testing").unwrap(); let mut r = BufReader::new(writer.get_ref()); - assert_eq!(r.read_to_str().unwrap(), ~"testingtesting\ntesting"); + fail_unless_eq!(r.read_to_str().unwrap(), ~"testingtesting\ntesting"); } #[test] @@ -503,7 +503,7 @@ mod test { writer.write_char('\n').unwrap(); writer.write_char('ệ').unwrap(); let mut r = BufReader::new(writer.get_ref()); - assert_eq!(r.read_to_str().unwrap(), ~"a\nệ"); + fail_unless_eq!(r.read_to_str().unwrap(), ~"a\nệ"); } #[test] diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index ef91ae191a552..bc29016ddd492 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -344,103 +344,103 @@ mod test { #[test] fn test_from_str_ipv4() { - assert_eq!(Some(Ipv4Addr(127, 0, 0, 1)), FromStr::from_str("127.0.0.1")); - assert_eq!(Some(Ipv4Addr(255, 255, 255, 255)), FromStr::from_str("255.255.255.255")); - assert_eq!(Some(Ipv4Addr(0, 0, 0, 0)), FromStr::from_str("0.0.0.0")); + fail_unless_eq!(Some(Ipv4Addr(127, 0, 0, 1)), FromStr::from_str("127.0.0.1")); + fail_unless_eq!(Some(Ipv4Addr(255, 255, 255, 255)), FromStr::from_str("255.255.255.255")); + fail_unless_eq!(Some(Ipv4Addr(0, 0, 0, 0)), FromStr::from_str("0.0.0.0")); // out of range let none: Option = FromStr::from_str("256.0.0.1"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // too short let none: Option = FromStr::from_str("255.0.0"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // too long let none: Option = FromStr::from_str("255.0.0.1.2"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // no number between dots let none: Option = FromStr::from_str("255.0..1"); - assert_eq!(None, none); + fail_unless_eq!(None, none); } #[test] fn test_from_str_ipv6() { - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("0:0:0:0:0:0:0:0")); - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("0:0:0:0:0:0:0:1")); + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("0:0:0:0:0:0:0:0")); + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("0:0:0:0:0:0:0:1")); - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("::1")); - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("::")); + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("::1")); + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("::")); - assert_eq!(Some(Ipv6Addr(0x2a02, 0x6b8, 0, 0, 0, 0, 0x11, 0x11)), + fail_unless_eq!(Some(Ipv6Addr(0x2a02, 0x6b8, 0, 0, 0, 0, 0x11, 0x11)), FromStr::from_str("2a02:6b8::11:11")); // too long group let none: Option = FromStr::from_str("::00000"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // too short let none: Option = FromStr::from_str("1:2:3:4:5:6:7"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // too long let none: Option = FromStr::from_str("1:2:3:4:5:6:7:8:9"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // triple colon let none: Option = FromStr::from_str("1:2:::6:7:8"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // two double colons let none: Option = FromStr::from_str("1:2::6::8"); - assert_eq!(None, none); + fail_unless_eq!(None, none); } #[test] fn test_from_str_ipv4_in_ipv6() { - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 49152, 545)), + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 49152, 545)), FromStr::from_str("::192.0.2.33")); - assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, 49152, 545)), + fail_unless_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, 49152, 545)), FromStr::from_str("::FFFF:192.0.2.33")); - assert_eq!(Some(Ipv6Addr(0x64, 0xff9b, 0, 0, 0, 0, 49152, 545)), + fail_unless_eq!(Some(Ipv6Addr(0x64, 0xff9b, 0, 0, 0, 0, 49152, 545)), FromStr::from_str("64:ff9b::192.0.2.33")); - assert_eq!(Some(Ipv6Addr(0x2001, 0xdb8, 0x122, 0xc000, 0x2, 0x2100, 49152, 545)), + fail_unless_eq!(Some(Ipv6Addr(0x2001, 0xdb8, 0x122, 0xc000, 0x2, 0x2100, 49152, 545)), FromStr::from_str("2001:db8:122:c000:2:2100:192.0.2.33")); // colon after v4 let none: Option = FromStr::from_str("::127.0.0.1:"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // not enought groups let none: Option = FromStr::from_str("1.2.3.4.5:127.0.0.1"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // too many groups let none: Option = FromStr::from_str("1.2.3.4.5:6:7:127.0.0.1"); - assert_eq!(None, none); + fail_unless_eq!(None, none); } #[test] fn test_from_str_socket_addr() { - assert_eq!(Some(SocketAddr { ip: Ipv4Addr(77, 88, 21, 11), port: 80 }), + fail_unless_eq!(Some(SocketAddr { ip: Ipv4Addr(77, 88, 21, 11), port: 80 }), FromStr::from_str("77.88.21.11:80")); - assert_eq!(Some(SocketAddr { ip: Ipv6Addr(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), port: 53 }), + fail_unless_eq!(Some(SocketAddr { ip: Ipv6Addr(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), port: 53 }), FromStr::from_str("[2a02:6b8:0:1::1]:53")); - assert_eq!(Some(SocketAddr { ip: Ipv6Addr(0, 0, 0, 0, 0, 0, 0x7F00, 1), port: 22 }), + fail_unless_eq!(Some(SocketAddr { ip: Ipv6Addr(0, 0, 0, 0, 0, 0, 0x7F00, 1), port: 22 }), FromStr::from_str("[::127.0.0.1]:22")); // without port let none: Option = FromStr::from_str("127.0.0.1"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // without port let none: Option = FromStr::from_str("127.0.0.1:"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // wrong brackets around v4 let none: Option = FromStr::from_str("[127.0.0.1]:22"); - assert_eq!(None, none); + fail_unless_eq!(None, none); // port out of range let none: Option = FromStr::from_str("127.0.0.1:123456"); - assert_eq!(None, none); + fail_unless_eq!(None, none); } #[test] fn ipv6_addr_to_str() { let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280); fail_unless!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128"); - assert_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), ~"8:9:a:b:c:d:e:f"); + fail_unless_eq!(Ipv6Addr(8, 9, 10, 11, 12, 13, 14, 15).to_str(), ~"8:9:a:b:c:d:e:f"); } #[test] diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 976762166976a..de8a7f941fe63 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -181,7 +181,7 @@ mod test { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match TcpListener::bind(addr) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, PermissionDenied), + Err(e) => fail_unless_eq!(e.kind, PermissionDenied), } } #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))]) @@ -189,7 +189,7 @@ mod test { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match TcpStream::connect(addr) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, ConnectionRefused), + Err(e) => fail_unless_eq!(e.kind, ConnectionRefused), } }) @@ -391,7 +391,7 @@ mod test { for ref mut stream in acceptor.incoming().take(max) { let mut buf = [0]; stream.read(buf).unwrap(); - assert_eq!(buf[0], 99); + fail_unless_eq!(buf[0], 99); } }) @@ -413,7 +413,7 @@ mod test { for ref mut stream in acceptor.incoming().take(max) { let mut buf = [0]; stream.read(buf).unwrap(); - assert_eq!(buf[0], 99); + fail_unless_eq!(buf[0], 99); } }) @@ -572,7 +572,7 @@ mod test { // us the socket we binded to. let so_name = listener.socket_name(); fail_unless!(so_name.is_ok()); - assert_eq!(addr, so_name.unwrap()); + fail_unless_eq!(addr, so_name.unwrap()); } pub fn peer_name(addr: SocketAddr) { @@ -595,7 +595,7 @@ mod test { // connected to. let peer_name = stream.peer_name(); fail_unless!(peer_name.is_ok()); - assert_eq!(addr, peer_name.unwrap()); + fail_unless_eq!(addr, peer_name.unwrap()); } iotest!(fn socket_and_peer_name_ip4() { @@ -625,7 +625,7 @@ mod test { p.recv(); let mut c = TcpStream::connect(addr).unwrap(); let mut b = [0, ..10]; - assert_eq!(c.read(b), Ok(1)); + fail_unless_eq!(c.read(b), Ok(1)); c.write([1]).unwrap(); p.recv(); }) @@ -673,8 +673,8 @@ mod test { spawn(proc() { let mut s = TcpStream::connect(addr); let mut buf = [0, 0]; - assert_eq!(s.read(buf), Ok(1)); - assert_eq!(buf[0], 1); + fail_unless_eq!(s.read(buf), Ok(1)); + fail_unless_eq!(buf[0], 1); s.write([2]).unwrap(); }); @@ -691,7 +691,7 @@ mod test { }); c1.send(()); let mut buf = [0, 0]; - assert_eq!(s1.read(buf), Ok(1)); + fail_unless_eq!(s1.read(buf), Ok(1)); p2.recv(); }) diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 8899c7a973c59..40ea715afd741 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -98,7 +98,7 @@ mod test { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match UdpSocket::bind(addr) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, PermissionDenied), + Err(e) => fail_unless_eq!(e.kind, PermissionDenied), } } #[ignore(cfg(windows))] #[ignore(cfg(target_os = "android"))]) @@ -125,9 +125,9 @@ mod test { let mut buf = [0]; match server.recvfrom(buf) { Ok((nread, src)) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); - assert_eq!(src, client_ip); + fail_unless_eq!(nread, 1); + fail_unless_eq!(buf[0], 99); + fail_unless_eq!(src, client_ip); } Err(..) => fail!() } @@ -158,9 +158,9 @@ mod test { let mut buf = [0]; match server.recvfrom(buf) { Ok((nread, src)) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); - assert_eq!(src, client_ip); + fail_unless_eq!(nread, 1); + fail_unless_eq!(buf[0], 99); + fail_unless_eq!(src, client_ip); } Err(..) => fail!() } @@ -196,8 +196,8 @@ mod test { let mut buf = [0]; match stream.read(buf) { Ok(nread) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); + fail_unless_eq!(nread, 1); + fail_unless_eq!(buf[0], 99); } Err(..) => fail!() } @@ -234,8 +234,8 @@ mod test { let mut buf = [0]; match stream.read(buf) { Ok(nread) => { - assert_eq!(nread, 1); - assert_eq!(buf[0], 99); + fail_unless_eq!(nread, 1); + fail_unless_eq!(buf[0], 99); } Err(..) => fail!() } @@ -255,7 +255,7 @@ mod test { // us the socket we binded to. let so_name = server.socket_name(); fail_unless!(so_name.is_ok()); - assert_eq!(addr, so_name.unwrap()); + fail_unless_eq!(addr, so_name.unwrap()); } iotest!(fn socket_name_ip4() { @@ -275,8 +275,8 @@ mod test { spawn(proc() { let mut sock2 = sock2; let mut buf = [0, 0]; - assert_eq!(sock2.recvfrom(buf), Ok((1, addr1))); - assert_eq!(buf[0], 1); + fail_unless_eq!(sock2.recvfrom(buf), Ok((1, addr1))); + fail_unless_eq!(buf[0], 1); sock2.sendto([2], addr1).unwrap(); }); @@ -292,7 +292,7 @@ mod test { }); c1.send(()); let mut buf = [0, 0]; - assert_eq!(sock1.recvfrom(buf), Ok((1, addr2))); + fail_unless_eq!(sock1.recvfrom(buf), Ok((1, addr2))); p2.recv(); }) diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index 7ada3044c69a0..d117bfcf67c79 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -243,7 +243,7 @@ mod tests { Ok(..) => {} Err(e) => fail!("failed read/accept: {}", e), } - assert_eq!(buf[0], 100); + fail_unless_eq!(buf[0], 100); } }) @@ -262,8 +262,8 @@ mod tests { let mut s = UnixStream::connect(&addr); let mut buf = [0, 0]; debug!("client reading"); - assert_eq!(s.read(buf), Ok(1)); - assert_eq!(buf[0], 1); + fail_unless_eq!(s.read(buf), Ok(1)); + fail_unless_eq!(buf[0], 1); debug!("client writing"); s.write([2]).unwrap(); debug!("client dropping"); @@ -285,7 +285,7 @@ mod tests { c1.send(()); let mut buf = [0, 0]; debug!("reader reading"); - assert_eq!(s1.read(buf), Ok(1)); + fail_unless_eq!(s1.read(buf), Ok(1)); debug!("reader done"); p2.recv(); }) diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 87d6c75860ae4..f3a17209720e5 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -298,7 +298,7 @@ mod tests { io: io, .. ProcessConfig::new() }; - assert_eq!(run_output(args), ~"foobar\n"); + fail_unless_eq!(run_output(args), ~"foobar\n"); }) // FIXME(#10380) @@ -313,7 +313,7 @@ mod tests { io: io, .. ProcessConfig::new() }; - assert_eq!(run_output(args), ~"/\n"); + fail_unless_eq!(run_output(args), ~"/\n"); }) // FIXME(#10380) @@ -332,7 +332,7 @@ mod tests { p.io[0] = None; // close stdin; let out = read_all(p.io[1].get_mut_ref() as &mut Reader); fail_unless!(p.wait().success()); - assert_eq!(out, ~"foobar\n"); + fail_unless_eq!(out, ~"foobar\n"); }) // FIXME(#10380) diff --git a/src/libstd/io/result.rs b/src/libstd/io/result.rs index 8e03cffd0fb24..f56e0ab847eb0 100644 --- a/src/libstd/io/result.rs +++ b/src/libstd/io/result.rs @@ -87,7 +87,7 @@ mod test { let mut writer: io::IoResult = Ok(MemWriter::new()); writer.write([0, 1, 2]).unwrap(); writer.flush().unwrap(); - assert_eq!(writer.unwrap().unwrap(), ~[0, 1, 2]); + fail_unless_eq!(writer.unwrap().unwrap(), ~[0, 1, 2]); } #[test] @@ -97,11 +97,11 @@ mod test { match writer.write([0, 0, 0]) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => fail_unless_eq!(e.kind, io::EndOfFile), } match writer.flush() { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => fail_unless_eq!(e.kind, io::EndOfFile), } } @@ -111,7 +111,7 @@ mod test { Ok(MemReader::new(~[0, 1, 2, 3])); let mut buf = [0, 0]; reader.read(buf).unwrap(); - assert_eq!(buf, [0, 1]); + fail_unless_eq!(buf, [0, 1]); } #[test] @@ -122,7 +122,7 @@ mod test { match reader.read(buf) { Ok(..) => fail!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => fail_unless_eq!(e.kind, io::EndOfFile), } } } diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 46c106234db75..cadfdbdd95d5e 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -195,7 +195,7 @@ mod test { s2.unregister(Interrupt); sigint(); timer::sleep(10); - assert_eq!(s2.port.try_recv(), Empty); + fail_unless_eq!(s2.port.try_recv(), Empty); } #[cfg(windows)] diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index c2d1f56823849..89ecf251209ec 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -359,7 +359,7 @@ mod tests { set_stdout(~w as ~Writer); println!("hello!"); }); - assert_eq!(r.read_to_str().unwrap(), ~"hello!\n"); + fail_unless_eq!(r.read_to_str().unwrap(), ~"hello!\n"); }) iotest!(fn capture_stderr() { diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index fb6862484e62a..a355d11086417 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -117,7 +117,7 @@ mod test { let port1 = timer.oneshot(10000); let port = timer.oneshot(1); port.recv(); - assert_eq!(port1.recv_opt(), None); + fail_unless_eq!(port1.recv_opt(), None); }) iotest!(fn test_io_timer_oneshot_then_sleep() { @@ -125,7 +125,7 @@ mod test { let port = timer.oneshot(100000000000); timer.sleep(1); // this should invalidate the port - assert_eq!(port.recv_opt(), None); + fail_unless_eq!(port.recv_opt(), None); }) iotest!(fn test_io_timer_sleep_periodic() { @@ -162,8 +162,8 @@ mod test { let oport = timer.oneshot(100); let pport = timer.periodic(100); timer.sleep(1); - assert_eq!(oport.recv_opt(), None); - assert_eq!(pport.recv_opt(), None); + fail_unless_eq!(oport.recv_opt(), None); + fail_unless_eq!(pport.recv_opt(), None); timer.oneshot(1).recv(); }) @@ -242,7 +242,7 @@ mod test { let mut timer = Timer::new().unwrap(); timer.oneshot(1000) }; - assert_eq!(port.recv_opt(), None); + fail_unless_eq!(port.recv_opt(), None); }) iotest!(fn sender_goes_away_period() { @@ -250,7 +250,7 @@ mod test { let mut timer = Timer::new().unwrap(); timer.periodic(1000) }; - assert_eq!(port.recv_opt(), None); + fail_unless_eq!(port.recv_opt(), None); }) iotest!(fn receiver_goes_away_oneshot() { diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 19cf69bb26912..5aa33622d0bd9 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -205,7 +205,7 @@ mod test { let mut r = MemReader::new(~[0, 1, 2]); { let mut r = LimitReader::new(r.by_ref(), 4); - assert_eq!(~[0, 1, 2], r.read_to_end().unwrap()); + fail_unless_eq!(~[0, 1, 2], r.read_to_end().unwrap()); } } @@ -214,20 +214,20 @@ mod test { let mut r = MemReader::new(~[0, 1, 2]); { let mut r = LimitReader::new(r.by_ref(), 2); - assert_eq!(~[0, 1], r.read_to_end().unwrap()); + fail_unless_eq!(~[0, 1], r.read_to_end().unwrap()); } - assert_eq!(~[2], r.read_to_end().unwrap()); + fail_unless_eq!(~[2], r.read_to_end().unwrap()); } #[test] fn test_limit_reader_limit() { let r = MemReader::new(~[0, 1, 2]); let mut r = LimitReader::new(r, 3); - assert_eq!(3, r.limit()); - assert_eq!(0, r.read_byte().unwrap()); - assert_eq!(2, r.limit()); - assert_eq!(~[1, 2], r.read_to_end().unwrap()); - assert_eq!(0, r.limit()); + fail_unless_eq!(3, r.limit()); + fail_unless_eq!(0, r.read_byte().unwrap()); + fail_unless_eq!(2, r.limit()); + fail_unless_eq!(~[1, 2], r.read_to_end().unwrap()); + fail_unless_eq!(0, r.limit()); } #[test] @@ -242,8 +242,8 @@ mod test { fn test_zero_reader() { let mut s = ZeroReader; let mut buf = ~[1, 2, 3]; - assert_eq!(s.read(buf), Ok(3)); - assert_eq!(~[0, 0, 0], buf); + fail_unless_eq!(s.read(buf), Ok(3)); + fail_unless_eq!(~[0, 0, 0], buf); } #[test] @@ -274,11 +274,11 @@ mod test { let mut multi = MultiWriter::new(~[~TestWriter as ~Writer, ~TestWriter as ~Writer]); multi.write([1, 2, 3]).unwrap(); - assert_eq!(2, unsafe { writes }); - assert_eq!(0, unsafe { flushes }); + fail_unless_eq!(2, unsafe { writes }); + fail_unless_eq!(0, unsafe { flushes }); multi.flush().unwrap(); - assert_eq!(2, unsafe { writes }); - assert_eq!(2, unsafe { flushes }); + fail_unless_eq!(2, unsafe { writes }); + fail_unless_eq!(2, unsafe { flushes }); } #[test] @@ -286,16 +286,16 @@ mod test { let rs = ~[MemReader::new(~[0, 1]), MemReader::new(~[]), MemReader::new(~[2, 3])]; let mut r = ChainedReader::new(rs.move_iter()); - assert_eq!(~[0, 1, 2, 3], r.read_to_end().unwrap()); + fail_unless_eq!(~[0, 1, 2, 3], r.read_to_end().unwrap()); } #[test] fn test_tee_reader() { let mut r = TeeReader::new(MemReader::new(~[0, 1, 2]), MemWriter::new()); - assert_eq!(~[0, 1, 2], r.read_to_end().unwrap()); + fail_unless_eq!(~[0, 1, 2], r.read_to_end().unwrap()); let (_, w) = r.unwrap(); - assert_eq!(~[0, 1, 2], w.unwrap()); + fail_unless_eq!(~[0, 1, 2], w.unwrap()); } #[test] @@ -303,6 +303,6 @@ mod test { let mut r = MemReader::new(~[0, 1, 2, 3, 4]); let mut w = MemWriter::new(); copy(&mut r, &mut w).unwrap(); - assert_eq!(~[0, 1, 2, 3, 4], w.unwrap()); + fail_unless_eq!(~[0, 1, 2, 3, 4], w.unwrap()); } } diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 0a3f308e623c1..d5a26ce1107b7 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -115,8 +115,8 @@ pub trait Iterator { /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().chain(b.iter()); - /// assert_eq!(it.next().unwrap(), &0); - /// assert_eq!(it.next().unwrap(), &1); + /// fail_unless_eq!(it.next().unwrap(), &0); + /// fail_unless_eq!(it.next().unwrap(), &1); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -135,7 +135,7 @@ pub trait Iterator { /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().zip(b.iter()); - /// assert_eq!(it.next().unwrap(), (&0, &1)); + /// fail_unless_eq!(it.next().unwrap(), (&0, &1)); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -151,8 +151,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().map(|&x| 2 * x); - /// assert_eq!(it.next().unwrap(), 2); - /// assert_eq!(it.next().unwrap(), 4); + /// fail_unless_eq!(it.next().unwrap(), 2); + /// fail_unless_eq!(it.next().unwrap(), 4); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -169,7 +169,7 @@ pub trait Iterator { /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().filter(|&x| *x > 1); - /// assert_eq!(it.next().unwrap(), &2); + /// fail_unless_eq!(it.next().unwrap(), &2); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -186,7 +186,7 @@ pub trait Iterator { /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None}); - /// assert_eq!(it.next().unwrap(), 4); + /// fail_unless_eq!(it.next().unwrap(), 4); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -202,8 +202,8 @@ pub trait Iterator { /// ```rust /// let a = [100, 200]; /// let mut it = a.iter().enumerate(); - /// assert_eq!(it.next().unwrap(), (0, &100)); - /// assert_eq!(it.next().unwrap(), (1, &200)); + /// fail_unless_eq!(it.next().unwrap(), (0, &100)); + /// fail_unless_eq!(it.next().unwrap(), (1, &200)); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -220,12 +220,12 @@ pub trait Iterator { /// ```rust /// let xs = [100, 200, 300]; /// let mut it = xs.iter().map(|x| *x).peekable(); - /// assert_eq!(it.peek().unwrap(), &100); - /// assert_eq!(it.next().unwrap(), 100); - /// assert_eq!(it.next().unwrap(), 200); - /// assert_eq!(it.peek().unwrap(), &300); - /// assert_eq!(it.peek().unwrap(), &300); - /// assert_eq!(it.next().unwrap(), 300); + /// fail_unless_eq!(it.peek().unwrap(), &100); + /// fail_unless_eq!(it.next().unwrap(), 100); + /// fail_unless_eq!(it.next().unwrap(), 200); + /// fail_unless_eq!(it.peek().unwrap(), &300); + /// fail_unless_eq!(it.peek().unwrap(), &300); + /// fail_unless_eq!(it.next().unwrap(), 300); /// fail_unless!(it.peek().is_none()); /// fail_unless!(it.next().is_none()); /// ``` @@ -243,9 +243,9 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 2, 1]; /// let mut it = a.iter().skip_while(|&a| *a < 3); - /// assert_eq!(it.next().unwrap(), &3); - /// assert_eq!(it.next().unwrap(), &2); - /// assert_eq!(it.next().unwrap(), &1); + /// fail_unless_eq!(it.next().unwrap(), &3); + /// fail_unless_eq!(it.next().unwrap(), &2); + /// fail_unless_eq!(it.next().unwrap(), &1); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -262,8 +262,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 2, 1]; /// let mut it = a.iter().take_while(|&a| *a < 3); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.next().unwrap(), &2); + /// fail_unless_eq!(it.next().unwrap(), &1); + /// fail_unless_eq!(it.next().unwrap(), &2); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -279,8 +279,8 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().skip(3); - /// assert_eq!(it.next().unwrap(), &4); - /// assert_eq!(it.next().unwrap(), &5); + /// fail_unless_eq!(it.next().unwrap(), &4); + /// fail_unless_eq!(it.next().unwrap(), &5); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -296,9 +296,9 @@ pub trait Iterator { /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().take(3); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.next().unwrap(), &2); - /// assert_eq!(it.next().unwrap(), &3); + /// fail_unless_eq!(it.next().unwrap(), &1); + /// fail_unless_eq!(it.next().unwrap(), &2); + /// fail_unless_eq!(it.next().unwrap(), &3); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -319,11 +319,11 @@ pub trait Iterator { /// *fac = *fac * x; /// Some(*fac) /// }); - /// assert_eq!(it.next().unwrap(), 1); - /// assert_eq!(it.next().unwrap(), 2); - /// assert_eq!(it.next().unwrap(), 6); - /// assert_eq!(it.next().unwrap(), 24); - /// assert_eq!(it.next().unwrap(), 120); + /// fail_unless_eq!(it.next().unwrap(), 1); + /// fail_unless_eq!(it.next().unwrap(), 2); + /// fail_unless_eq!(it.next().unwrap(), 6); + /// fail_unless_eq!(it.next().unwrap(), 24); + /// fail_unless_eq!(it.next().unwrap(), 120); /// fail_unless!(it.next().is_none()); /// ``` #[inline] @@ -346,7 +346,7 @@ pub trait Iterator { /// // Check that `it` has the same elements as `ys` /// let mut i = 0; /// for x in it { - /// assert_eq!(x, ys[i]); + /// fail_unless_eq!(x, ys[i]); /// i += 1; /// } /// ``` @@ -379,7 +379,7 @@ pub trait Iterator { /// sum /// } /// let x = ~[1,2,3,7,8,9]; - /// assert_eq!(process(x.move_iter()), 1006); + /// fail_unless_eq!(process(x.move_iter()), 1006); /// ``` #[inline] fn fuse(self) -> Fuse { @@ -623,7 +623,7 @@ pub trait Iterator { /// /// ```rust /// let xs = [-3i, 0, 1, 5, -10]; - /// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); + /// fail_unless_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); /// ``` #[inline] fn max_by(&mut self, f: |&A| -> B) -> Option { @@ -647,7 +647,7 @@ pub trait Iterator { /// /// ```rust /// let xs = [-3i, 0, 1, 5, -10]; - /// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); + /// fail_unless_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); /// ``` #[inline] fn min_by(&mut self, f: |&A| -> B) -> Option { @@ -900,7 +900,7 @@ pub trait OrdIterator { /// use std::iter::{NoElements, OneElement, MinMax}; /// /// let v: [int, ..0] = []; - /// assert_eq!(v.iter().min_max(), NoElements); + /// fail_unless_eq!(v.iter().min_max(), NoElements); /// /// let v = [1i]; /// fail_unless!(v.iter().min_max() == OneElement(&1)); @@ -1007,13 +1007,13 @@ impl MinMaxResult { /// use std::iter::{NoElements, OneElement, MinMax, MinMaxResult}; /// /// let r: MinMaxResult = NoElements; - /// assert_eq!(r.into_option(), None) + /// fail_unless_eq!(r.into_option(), None) /// /// let r = OneElement(1); - /// assert_eq!(r.into_option(), Some((1,1))); + /// fail_unless_eq!(r.into_option(), Some((1,1))); /// /// let r = MinMax(1,2); - /// assert_eq!(r.into_option(), Some((1,2))); + /// fail_unless_eq!(r.into_option(), Some((1,2))); /// ``` pub fn into_option(self) -> Option<(T,T)> { match self { @@ -1035,8 +1035,8 @@ pub trait CloneableIterator { /// /// let a = count(1,1).take(1); /// let mut cy = a.cycle(); - /// assert_eq!(cy.next(), Some(1)); - /// assert_eq!(cy.next(), Some(1)); + /// fail_unless_eq!(cy.next(), Some(1)); + /// fail_unless_eq!(cy.next(), Some(1)); /// ``` fn cycle(self) -> Cycle; } @@ -2352,7 +2352,7 @@ mod tests { fn test_counter_from_iter() { let mut it = count(0, 5).take(10); let xs: ~[int] = FromIterator::from_iterator(&mut it); - assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); + fail_unless_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); } #[test] @@ -2363,26 +2363,26 @@ mod tests { let mut it = xs.iter().chain(ys.iter()); let mut i = 0; for &x in it { - assert_eq!(x, expected[i]); + fail_unless_eq!(x, expected[i]); i += 1; } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); let ys = count(30u, 10).take(4); let mut it = xs.iter().map(|&x| x).chain(ys); let mut i = 0; for x in it { - assert_eq!(x, expected[i]); + fail_unless_eq!(x, expected[i]); i += 1; } - assert_eq!(i, expected.len()); + fail_unless_eq!(i, expected.len()); } #[test] fn test_filter_map() { let mut it = count(0u, 1u).take(10) .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None }); - assert_eq!(it.collect::<~[uint]>(), ~[0*0, 2*2, 4*4, 6*6, 8*8]); + fail_unless_eq!(it.collect::<~[uint]>(), ~[0*0, 2*2, 4*4, 6*6, 8*8]); } #[test] @@ -2390,7 +2390,7 @@ mod tests { let xs = [0u, 1, 2, 3, 4, 5]; let mut it = xs.iter().enumerate(); for (i, &x) in it { - assert_eq!(i, x); + fail_unless_eq!(i, x); } } @@ -2398,16 +2398,16 @@ mod tests { fn test_iterator_peekable() { let xs = ~[0u, 1, 2, 3, 4, 5]; let mut it = xs.iter().map(|&x|x).peekable(); - assert_eq!(it.peek().unwrap(), &0); - assert_eq!(it.next().unwrap(), 0); - assert_eq!(it.next().unwrap(), 1); - assert_eq!(it.next().unwrap(), 2); - assert_eq!(it.peek().unwrap(), &3); - assert_eq!(it.peek().unwrap(), &3); - assert_eq!(it.next().unwrap(), 3); - assert_eq!(it.next().unwrap(), 4); - assert_eq!(it.peek().unwrap(), &5); - assert_eq!(it.next().unwrap(), 5); + fail_unless_eq!(it.peek().unwrap(), &0); + fail_unless_eq!(it.next().unwrap(), 0); + fail_unless_eq!(it.next().unwrap(), 1); + fail_unless_eq!(it.next().unwrap(), 2); + fail_unless_eq!(it.peek().unwrap(), &3); + fail_unless_eq!(it.peek().unwrap(), &3); + fail_unless_eq!(it.next().unwrap(), 3); + fail_unless_eq!(it.next().unwrap(), 4); + fail_unless_eq!(it.peek().unwrap(), &5); + fail_unless_eq!(it.next().unwrap(), 5); fail_unless!(it.peek().is_none()); fail_unless!(it.next().is_none()); } @@ -2419,10 +2419,10 @@ mod tests { let mut it = xs.iter().take_while(|&x| *x < 15u); let mut i = 0; for &x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2432,10 +2432,10 @@ mod tests { let mut it = xs.iter().skip_while(|&x| *x < 15u); let mut i = 0; for &x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2445,10 +2445,10 @@ mod tests { let mut it = xs.iter().skip(5); let mut i = 0; for &x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2458,10 +2458,10 @@ mod tests { let mut it = xs.iter().take(5); let mut i = 0; for &x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2477,10 +2477,10 @@ mod tests { let mut it = xs.iter().scan(0, add); let mut i = 0; for x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2490,10 +2490,10 @@ mod tests { let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3)); let mut i = 0; for x in it { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, ys.len()); + fail_unless_eq!(i, ys.len()); } #[test] @@ -2506,8 +2506,8 @@ mod tests { .inspect(|_| n += 1) .collect::<~[uint]>(); - assert_eq!(n, xs.len()); - assert_eq!(xs, ys.as_slice()); + fail_unless_eq!(n, xs.len()); + fail_unless_eq!(xs, ys.as_slice()); } #[test] @@ -2525,79 +2525,79 @@ mod tests { let mut it = Unfold::new(0, count); let mut i = 0; for counted in it { - assert_eq!(counted, i); + fail_unless_eq!(counted, i); i += 1; } - assert_eq!(i, 10); + fail_unless_eq!(i, 10); } #[test] fn test_cycle() { let cycle_len = 3; let it = count(0u, 1).take(cycle_len).cycle(); - assert_eq!(it.size_hint(), (uint::MAX, None)); + fail_unless_eq!(it.size_hint(), (uint::MAX, None)); for (i, x) in it.take(100).enumerate() { - assert_eq!(i % cycle_len, x); + fail_unless_eq!(i % cycle_len, x); } let mut it = count(0u, 1).take(0).cycle(); - assert_eq!(it.size_hint(), (0, Some(0))); - assert_eq!(it.next(), None); + fail_unless_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.next(), None); } #[test] fn test_iterator_nth() { let v = &[0, 1, 2, 3, 4]; for i in range(0u, v.len()) { - assert_eq!(v.iter().nth(i).unwrap(), &v[i]); + fail_unless_eq!(v.iter().nth(i).unwrap(), &v[i]); } } #[test] fn test_iterator_last() { let v = &[0, 1, 2, 3, 4]; - assert_eq!(v.iter().last().unwrap(), &4); - assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0); + fail_unless_eq!(v.iter().last().unwrap(), &4); + fail_unless_eq!(v.slice(0, 1).iter().last().unwrap(), &0); } #[test] fn test_iterator_len() { let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(v.slice(0, 4).iter().len(), 4); - assert_eq!(v.slice(0, 10).iter().len(), 10); - assert_eq!(v.slice(0, 0).iter().len(), 0); + fail_unless_eq!(v.slice(0, 4).iter().len(), 4); + fail_unless_eq!(v.slice(0, 10).iter().len(), 10); + fail_unless_eq!(v.slice(0, 0).iter().len(), 0); } #[test] fn test_iterator_sum() { let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6); - assert_eq!(v.iter().map(|&x| x).sum(), 55); - assert_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0); + fail_unless_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6); + fail_unless_eq!(v.iter().map(|&x| x).sum(), 55); + fail_unless_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0); } #[test] fn test_iterator_product() { let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0); - assert_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24); - assert_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1); + fail_unless_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0); + fail_unless_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24); + fail_unless_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1); } #[test] fn test_iterator_max() { let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3)); - assert_eq!(v.iter().map(|&x| x).max(), Some(10)); - assert_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None); + fail_unless_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3)); + fail_unless_eq!(v.iter().map(|&x| x).max(), Some(10)); + fail_unless_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None); } #[test] fn test_iterator_min() { let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0)); - assert_eq!(v.iter().map(|&x| x).min(), Some(0)); - assert_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None); + fail_unless_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0)); + fail_unless_eq!(v.iter().map(|&x| x).min(), Some(0)); + fail_unless_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None); } #[test] @@ -2607,41 +2607,41 @@ mod tests { let v2 = &[10, 11, 12]; let vi = v.iter(); - assert_eq!(c.size_hint(), (uint::MAX, None)); - assert_eq!(vi.size_hint(), (10, Some(10))); - - assert_eq!(c.take(5).size_hint(), (5, Some(5))); - assert_eq!(c.skip(5).size_hint().val1(), None); - assert_eq!(c.take_while(|_| false).size_hint(), (0, None)); - assert_eq!(c.skip_while(|_| false).size_hint(), (0, None)); - assert_eq!(c.enumerate().size_hint(), (uint::MAX, None)); - assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None)); - assert_eq!(c.zip(vi).size_hint(), (10, Some(10))); - assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None)); - assert_eq!(c.filter(|_| false).size_hint(), (0, None)); - assert_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None)); - assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None)); - - assert_eq!(vi.take(5).size_hint(), (5, Some(5))); - assert_eq!(vi.take(12).size_hint(), (10, Some(10))); - assert_eq!(vi.skip(3).size_hint(), (7, Some(7))); - assert_eq!(vi.skip(12).size_hint(), (0, Some(0))); - assert_eq!(vi.take_while(|_| false).size_hint(), (0, Some(10))); - assert_eq!(vi.skip_while(|_| false).size_hint(), (0, Some(10))); - assert_eq!(vi.enumerate().size_hint(), (10, Some(10))); - assert_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13))); - assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3))); - assert_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10))); - assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10))); - assert_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10))); - assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10))); + fail_unless_eq!(c.size_hint(), (uint::MAX, None)); + fail_unless_eq!(vi.size_hint(), (10, Some(10))); + + fail_unless_eq!(c.take(5).size_hint(), (5, Some(5))); + fail_unless_eq!(c.skip(5).size_hint().val1(), None); + fail_unless_eq!(c.take_while(|_| false).size_hint(), (0, None)); + fail_unless_eq!(c.skip_while(|_| false).size_hint(), (0, None)); + fail_unless_eq!(c.enumerate().size_hint(), (uint::MAX, None)); + fail_unless_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None)); + fail_unless_eq!(c.zip(vi).size_hint(), (10, Some(10))); + fail_unless_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None)); + fail_unless_eq!(c.filter(|_| false).size_hint(), (0, None)); + fail_unless_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None)); + fail_unless_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None)); + + fail_unless_eq!(vi.take(5).size_hint(), (5, Some(5))); + fail_unless_eq!(vi.take(12).size_hint(), (10, Some(10))); + fail_unless_eq!(vi.skip(3).size_hint(), (7, Some(7))); + fail_unless_eq!(vi.skip(12).size_hint(), (0, Some(0))); + fail_unless_eq!(vi.take_while(|_| false).size_hint(), (0, Some(10))); + fail_unless_eq!(vi.skip_while(|_| false).size_hint(), (0, Some(10))); + fail_unless_eq!(vi.enumerate().size_hint(), (10, Some(10))); + fail_unless_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13))); + fail_unless_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3))); + fail_unless_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10))); + fail_unless_eq!(vi.filter(|_| false).size_hint(), (0, Some(10))); + fail_unless_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10))); + fail_unless_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10))); } #[test] fn test_collect() { let a = ~[1, 2, 3, 4, 5]; let b: ~[int] = a.iter().map(|&x| x).collect(); - assert_eq!(a, b); + fail_unless_eq!(a, b); } #[test] @@ -2665,37 +2665,37 @@ mod tests { #[test] fn test_find() { let v: &[int] = &[1, 3, 9, 27, 103, 14, 11]; - assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14); - assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3); + fail_unless_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14); + fail_unless_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3); fail_unless!(v.iter().find(|x| *x % 12 == 0).is_none()); } #[test] fn test_position() { let v = &[1, 3, 9, 27, 103, 14, 11]; - assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5); - assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1); + fail_unless_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5); + fail_unless_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1); fail_unless!(v.iter().position(|x| *x % 12 == 0).is_none()); } #[test] fn test_count() { let xs = &[1, 2, 2, 1, 5, 9, 0, 2]; - assert_eq!(xs.iter().count(|x| *x == 2), 3); - assert_eq!(xs.iter().count(|x| *x == 5), 1); - assert_eq!(xs.iter().count(|x| *x == 95), 0); + fail_unless_eq!(xs.iter().count(|x| *x == 2), 3); + fail_unless_eq!(xs.iter().count(|x| *x == 5), 1); + fail_unless_eq!(xs.iter().count(|x| *x == 95), 0); } #[test] fn test_max_by() { let xs: &[int] = &[-3, 0, 1, 5, -10]; - assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); + fail_unless_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); } #[test] fn test_min_by() { let xs: &[int] = &[-3, 0, 1, 5, -10]; - assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); + fail_unless_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); } #[test] @@ -2703,8 +2703,8 @@ mod tests { let mut xs = range(0, 10); // sum the first five values let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b); - assert_eq!(partial_sum, 10); - assert_eq!(xs.next(), Some(5)); + fail_unless_eq!(partial_sum, 10); + fail_unless_eq!(xs.next(), Some(5)); } #[test] @@ -2713,33 +2713,33 @@ mod tests { let mut it = xs.iter(); it.next(); it.next(); - assert_eq!(it.rev().map(|&x| x).collect::<~[int]>(), ~[16, 14, 12, 10, 8, 6]); + fail_unless_eq!(it.rev().map(|&x| x).collect::<~[int]>(), ~[16, 14, 12, 10, 8, 6]); } #[test] fn test_double_ended_map() { let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter().map(|&x| x * -1); - assert_eq!(it.next(), Some(-1)); - assert_eq!(it.next(), Some(-2)); - assert_eq!(it.next_back(), Some(-6)); - assert_eq!(it.next_back(), Some(-5)); - assert_eq!(it.next(), Some(-3)); - assert_eq!(it.next_back(), Some(-4)); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some(-1)); + fail_unless_eq!(it.next(), Some(-2)); + fail_unless_eq!(it.next_back(), Some(-6)); + fail_unless_eq!(it.next_back(), Some(-5)); + fail_unless_eq!(it.next(), Some(-3)); + fail_unless_eq!(it.next_back(), Some(-4)); + fail_unless_eq!(it.next(), None); } #[test] fn test_double_ended_enumerate() { let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter().map(|&x| x).enumerate(); - assert_eq!(it.next(), Some((0, 1))); - assert_eq!(it.next(), Some((1, 2))); - assert_eq!(it.next_back(), Some((5, 6))); - assert_eq!(it.next_back(), Some((4, 5))); - assert_eq!(it.next_back(), Some((3, 4))); - assert_eq!(it.next_back(), Some((2, 3))); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some((0, 1))); + fail_unless_eq!(it.next(), Some((1, 2))); + fail_unless_eq!(it.next_back(), Some((5, 6))); + fail_unless_eq!(it.next_back(), Some((4, 5))); + fail_unless_eq!(it.next_back(), Some((3, 4))); + fail_unless_eq!(it.next_back(), Some((2, 3))); + fail_unless_eq!(it.next(), None); } #[test] @@ -2749,31 +2749,31 @@ mod tests { let a = xs.iter().map(|&x| x); let b = ys.iter().map(|&x| x); let mut it = a.zip(b); - assert_eq!(it.next(), Some((1, 1))); - assert_eq!(it.next(), Some((2, 2))); - assert_eq!(it.next_back(), Some((4, 7))); - assert_eq!(it.next_back(), Some((3, 3))); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some((1, 1))); + fail_unless_eq!(it.next(), Some((2, 2))); + fail_unless_eq!(it.next_back(), Some((4, 7))); + fail_unless_eq!(it.next_back(), Some((3, 3))); + fail_unless_eq!(it.next(), None); } #[test] fn test_double_ended_filter() { let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter().filter(|&x| *x & 1 == 0); - assert_eq!(it.next_back().unwrap(), &6); - assert_eq!(it.next_back().unwrap(), &4); - assert_eq!(it.next().unwrap(), &2); - assert_eq!(it.next_back(), None); + fail_unless_eq!(it.next_back().unwrap(), &6); + fail_unless_eq!(it.next_back().unwrap(), &4); + fail_unless_eq!(it.next().unwrap(), &2); + fail_unless_eq!(it.next_back(), None); } #[test] fn test_double_ended_filter_map() { let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter().filter_map(|&x| if x & 1 == 0 { Some(x * 2) } else { None }); - assert_eq!(it.next_back().unwrap(), 12); - assert_eq!(it.next_back().unwrap(), 8); - assert_eq!(it.next().unwrap(), 4); - assert_eq!(it.next_back(), None); + fail_unless_eq!(it.next_back().unwrap(), 12); + fail_unless_eq!(it.next_back().unwrap(), 8); + fail_unless_eq!(it.next().unwrap(), 4); + fail_unless_eq!(it.next_back(), None); } #[test] @@ -2781,15 +2781,15 @@ mod tests { let xs = [1, 2, 3, 4, 5]; let ys = ~[7, 9, 11]; let mut it = xs.iter().chain(ys.iter()).rev(); - assert_eq!(it.next().unwrap(), &11) - assert_eq!(it.next().unwrap(), &9) - assert_eq!(it.next_back().unwrap(), &1) - assert_eq!(it.next_back().unwrap(), &2) - assert_eq!(it.next_back().unwrap(), &3) - assert_eq!(it.next_back().unwrap(), &4) - assert_eq!(it.next_back().unwrap(), &5) - assert_eq!(it.next_back().unwrap(), &7) - assert_eq!(it.next_back(), None) + fail_unless_eq!(it.next().unwrap(), &11) + fail_unless_eq!(it.next().unwrap(), &9) + fail_unless_eq!(it.next_back().unwrap(), &1) + fail_unless_eq!(it.next_back().unwrap(), &2) + fail_unless_eq!(it.next_back().unwrap(), &3) + fail_unless_eq!(it.next_back().unwrap(), &4) + fail_unless_eq!(it.next_back().unwrap(), &5) + fail_unless_eq!(it.next_back().unwrap(), &7) + fail_unless_eq!(it.next_back(), None) } #[test] @@ -2798,7 +2798,7 @@ mod tests { fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert_eq!(v.iter().rposition(f), Some(3u)); + fail_unless_eq!(v.iter().rposition(f), Some(3u)); fail_unless!(v.iter().rposition(g).is_none()); } @@ -2821,14 +2821,14 @@ mod tests { fn check_randacc_iter>(a: T, len: uint) { let mut b = a.clone(); - assert_eq!(len, b.indexable()); + fail_unless_eq!(len, b.indexable()); let mut n = 0; for (i, elt) in a.enumerate() { - assert_eq!(Some(elt), b.idx(i)); + fail_unless_eq!(Some(elt), b.idx(i)); n += 1; } - assert_eq!(n, len); - assert_eq!(None, b.idx(n)); + fail_unless_eq!(n, len); + fail_unless_eq!(None, b.idx(n)); // call recursively to check after picking off an element if len > 0 { b.next(); @@ -2842,16 +2842,16 @@ mod tests { let u = [0u,1]; let v = [5,6,7,8]; let mut it = u.iter().flat_map(|x| v.slice(*x, v.len()).iter()); - assert_eq!(it.next_back().unwrap(), &8); - assert_eq!(it.next().unwrap(), &5); - assert_eq!(it.next_back().unwrap(), &7); - assert_eq!(it.next_back().unwrap(), &6); - assert_eq!(it.next_back().unwrap(), &8); - assert_eq!(it.next().unwrap(), &6); - assert_eq!(it.next_back().unwrap(), &7); - assert_eq!(it.next_back(), None); - assert_eq!(it.next(), None); - assert_eq!(it.next_back(), None); + fail_unless_eq!(it.next_back().unwrap(), &8); + fail_unless_eq!(it.next().unwrap(), &5); + fail_unless_eq!(it.next_back().unwrap(), &7); + fail_unless_eq!(it.next_back().unwrap(), &6); + fail_unless_eq!(it.next_back().unwrap(), &8); + fail_unless_eq!(it.next().unwrap(), &6); + fail_unless_eq!(it.next_back().unwrap(), &7); + fail_unless_eq!(it.next_back(), None); + fail_unless_eq!(it.next(), None); + fail_unless_eq!(it.next_back(), None); } #[test] @@ -2859,17 +2859,17 @@ mod tests { let xs = [1, 2, 3, 4, 5]; let ys = ~[7, 9, 11]; let mut it = xs.iter().chain(ys.iter()); - assert_eq!(it.idx(0).unwrap(), &1); - assert_eq!(it.idx(5).unwrap(), &7); - assert_eq!(it.idx(7).unwrap(), &11); + fail_unless_eq!(it.idx(0).unwrap(), &1); + fail_unless_eq!(it.idx(5).unwrap(), &7); + fail_unless_eq!(it.idx(7).unwrap(), &11); fail_unless!(it.idx(8).is_none()); it.next(); it.next(); it.next_back(); - assert_eq!(it.idx(0).unwrap(), &3); - assert_eq!(it.idx(4).unwrap(), &9); + fail_unless_eq!(it.idx(0).unwrap(), &3); + fail_unless_eq!(it.idx(4).unwrap(), &9); fail_unless!(it.idx(6).is_none()); check_randacc_iter(it, xs.len() + ys.len() - 3); @@ -2923,9 +2923,9 @@ mod tests { // test .map and .inspect that don't implement Clone let it = xs.iter().inspect(|_| {}); - assert_eq!(xs.len(), it.indexable()); + fail_unless_eq!(xs.len(), it.indexable()); for (i, elt) in xs.iter().enumerate() { - assert_eq!(Some(elt), it.idx(i)); + fail_unless_eq!(Some(elt), it.idx(i)); } } @@ -2935,9 +2935,9 @@ mod tests { let xs = [1, 2, 3, 4, 5]; let it = xs.iter().map(|x| *x); - assert_eq!(xs.len(), it.indexable()); + fail_unless_eq!(xs.len(), it.indexable()); for (i, elt) in xs.iter().enumerate() { - assert_eq!(Some(*elt), it.idx(i)); + fail_unless_eq!(Some(*elt), it.idx(i)); } } @@ -2951,12 +2951,12 @@ mod tests { #[test] fn test_double_ended_range() { - assert_eq!(range(11i, 14).rev().collect::<~[int]>(), ~[13i, 12, 11]); + fail_unless_eq!(range(11i, 14).rev().collect::<~[int]>(), ~[13i, 12, 11]); for _ in range(10i, 0).rev() { fail!("unreachable"); } - assert_eq!(range(11u, 14).rev().collect::<~[uint]>(), ~[13u, 12, 11]); + fail_unless_eq!(range(11u, 14).rev().collect::<~[uint]>(), ~[13u, 12, 11]); for _ in range(10u, 0).rev() { fail!("unreachable"); } @@ -3002,56 +3002,56 @@ mod tests { } } - assert_eq!(range(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4]); - assert_eq!(range(-10i, -1).collect::<~[int]>(), ~[-10, -9, -8, -7, -6, -5, -4, -3, -2]); - assert_eq!(range(0i, 5).rev().collect::<~[int]>(), ~[4, 3, 2, 1, 0]); - assert_eq!(range(200, -5).collect::<~[int]>(), ~[]); - assert_eq!(range(200, -5).rev().collect::<~[int]>(), ~[]); - assert_eq!(range(200, 200).collect::<~[int]>(), ~[]); - assert_eq!(range(200, 200).rev().collect::<~[int]>(), ~[]); + fail_unless_eq!(range(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4]); + fail_unless_eq!(range(-10i, -1).collect::<~[int]>(), ~[-10, -9, -8, -7, -6, -5, -4, -3, -2]); + fail_unless_eq!(range(0i, 5).rev().collect::<~[int]>(), ~[4, 3, 2, 1, 0]); + fail_unless_eq!(range(200, -5).collect::<~[int]>(), ~[]); + fail_unless_eq!(range(200, -5).rev().collect::<~[int]>(), ~[]); + fail_unless_eq!(range(200, 200).collect::<~[int]>(), ~[]); + fail_unless_eq!(range(200, 200).rev().collect::<~[int]>(), ~[]); - assert_eq!(range(0i, 100).size_hint(), (100, Some(100))); + fail_unless_eq!(range(0i, 100).size_hint(), (100, Some(100))); // this test is only meaningful when sizeof uint < sizeof u64 - assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1))); - assert_eq!(range(-10i, -1).size_hint(), (9, Some(9))); - assert_eq!(range(Foo, Foo).size_hint(), (0, None)); + fail_unless_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1))); + fail_unless_eq!(range(-10i, -1).size_hint(), (9, Some(9))); + fail_unless_eq!(range(Foo, Foo).size_hint(), (0, None)); } #[test] fn test_range_inclusive() { - assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]); - assert_eq!(range_inclusive(0i, 5).rev().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]); - assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]); - assert_eq!(range_inclusive(200, -5).rev().collect::<~[int]>(), ~[]); - assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]); - assert_eq!(range_inclusive(200, 200).rev().collect::<~[int]>(), ~[200]); + fail_unless_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]); + fail_unless_eq!(range_inclusive(0i, 5).rev().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]); + fail_unless_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]); + fail_unless_eq!(range_inclusive(200, -5).rev().collect::<~[int]>(), ~[]); + fail_unless_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]); + fail_unless_eq!(range_inclusive(200, 200).rev().collect::<~[int]>(), ~[200]); } #[test] fn test_range_step() { - assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]); - assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]); - assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); - assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); - assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]); - assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]); + fail_unless_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]); + fail_unless_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]); + fail_unless_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); + fail_unless_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); + fail_unless_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]); + fail_unless_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]); } #[test] fn test_range_step_inclusive() { - assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]); - assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]); - assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); - assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); - assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]); - assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]); + fail_unless_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]); + fail_unless_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]); + fail_unless_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); + fail_unless_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); + fail_unless_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]); + fail_unless_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]); } #[test] fn test_reverse() { let mut ys = [1, 2, 3, 4, 5]; ys.mut_iter().reverse_(); - assert_eq!(ys, [5, 4, 3, 2, 1]); + fail_unless_eq!(ys, [5, 4, 3, 2, 1]); } #[test] @@ -3066,7 +3066,7 @@ mod tests { #[test] fn test_min_max() { let v: [int, ..0] = []; - assert_eq!(v.iter().min_max(), NoElements); + fail_unless_eq!(v.iter().min_max(), NoElements); let v = [1i]; fail_unless!(v.iter().min_max() == OneElement(&1)); @@ -3084,12 +3084,12 @@ mod tests { #[test] fn test_MinMaxResult() { let r: MinMaxResult = NoElements; - assert_eq!(r.into_option(), None) + fail_unless_eq!(r.into_option(), None) let r = OneElement(1); - assert_eq!(r.into_option(), Some((1,1))); + fail_unless_eq!(r.into_option(), Some((1,1))); let r = MinMax(1,2); - assert_eq!(r.into_option(), Some((1,2))); + fail_unless_eq!(r.into_option(), Some((1,2))); } } diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 7596039a6b02a..6c56bd2311509 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -29,10 +29,10 @@ local_data_key!(key_int: int) local_data_key!(key_vector: ~[int]) local_data::set(key_int, 3); -local_data::get(key_int, |opt| assert_eq!(opt.map(|x| *x), Some(3))); +local_data::get(key_int, |opt| fail_unless_eq!(opt.map(|x| *x), Some(3))); local_data::set(key_vector, ~[4]); -local_data::get(key_vector, |opt| assert_eq!(*opt.unwrap(), ~[4])); +local_data::get(key_vector, |opt| fail_unless_eq!(*opt.unwrap(), ~[4])); ``` */ @@ -488,15 +488,15 @@ mod tests { get(key, |v| { get(key, |v| { get(key, |v| { - assert_eq!(**v.unwrap(), 1); + fail_unless_eq!(**v.unwrap(), 1); }); - assert_eq!(**v.unwrap(), 1); + fail_unless_eq!(**v.unwrap(), 1); }); - assert_eq!(**v.unwrap(), 1); + fail_unless_eq!(**v.unwrap(), 1); }); set(key, ~2); get(key, |v| { - assert_eq!(**v.unwrap(), 2); + fail_unless_eq!(**v.unwrap(), 2); }) } @@ -510,7 +510,7 @@ mod tests { }); get(key, |v| { - assert_eq!(*v.unwrap(), 2); + fail_unless_eq!(*v.unwrap(), 2); }) } @@ -527,11 +527,11 @@ mod tests { set(key4, 4); set(key5, 5); - get(key1, |x| assert_eq!(*x.unwrap(), 1)); - get(key2, |x| assert_eq!(*x.unwrap(), 2)); - get(key3, |x| assert_eq!(*x.unwrap(), 3)); - get(key4, |x| assert_eq!(*x.unwrap(), 4)); - get(key5, |x| assert_eq!(*x.unwrap(), 5)); + get(key1, |x| fail_unless_eq!(*x.unwrap(), 1)); + get(key2, |x| fail_unless_eq!(*x.unwrap(), 2)); + get(key3, |x| fail_unless_eq!(*x.unwrap(), 3)); + get(key4, |x| fail_unless_eq!(*x.unwrap(), 4)); + get(key5, |x| fail_unless_eq!(*x.unwrap(), 5)); } #[test] diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 164e3e02fc14e..ae6b30dc24d15 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -72,8 +72,8 @@ fn refcount_test() { use clone::Clone; let x = @3; - assert_eq!(refcount(x), 1); + fail_unless_eq!(refcount(x), 1); let y = x.clone(); - assert_eq!(refcount(x), 2); - assert_eq!(refcount(y), 2); + fail_unless_eq!(refcount(x), 2); + fail_unless_eq!(refcount(y), 2); } diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs index f35372e93e658..1570fbf1585eb 100644 --- a/src/libstd/mem.rs +++ b/src/libstd/mem.rs @@ -170,10 +170,10 @@ mod tests { #[test] fn size_of_basic() { - assert_eq!(size_of::(), 1u); - assert_eq!(size_of::(), 2u); - assert_eq!(size_of::(), 4u); - assert_eq!(size_of::(), 8u); + fail_unless_eq!(size_of::(), 1u); + fail_unless_eq!(size_of::(), 2u); + fail_unless_eq!(size_of::(), 4u); + fail_unless_eq!(size_of::(), 8u); } #[test] @@ -181,46 +181,46 @@ mod tests { #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] fn size_of_32() { - assert_eq!(size_of::(), 4u); - assert_eq!(size_of::<*uint>(), 4u); + fail_unless_eq!(size_of::(), 4u); + fail_unless_eq!(size_of::<*uint>(), 4u); } #[test] #[cfg(target_arch = "x86_64")] fn size_of_64() { - assert_eq!(size_of::(), 8u); - assert_eq!(size_of::<*uint>(), 8u); + fail_unless_eq!(size_of::(), 8u); + fail_unless_eq!(size_of::<*uint>(), 8u); } #[test] fn size_of_val_basic() { - assert_eq!(size_of_val(&1u8), 1); - assert_eq!(size_of_val(&1u16), 2); - assert_eq!(size_of_val(&1u32), 4); - assert_eq!(size_of_val(&1u64), 8); + fail_unless_eq!(size_of_val(&1u8), 1); + fail_unless_eq!(size_of_val(&1u16), 2); + fail_unless_eq!(size_of_val(&1u32), 4); + fail_unless_eq!(size_of_val(&1u64), 8); } #[test] fn nonzero_size_of_basic() { type Z = [i8, ..0]; - assert_eq!(size_of::(), 0u); - assert_eq!(nonzero_size_of::(), 1u); - assert_eq!(nonzero_size_of::(), size_of::()); + fail_unless_eq!(size_of::(), 0u); + fail_unless_eq!(nonzero_size_of::(), 1u); + fail_unless_eq!(nonzero_size_of::(), size_of::()); } #[test] fn nonzero_size_of_val_basic() { let z = [0u8, ..0]; - assert_eq!(size_of_val(&z), 0u); - assert_eq!(nonzero_size_of_val(&z), 1u); - assert_eq!(nonzero_size_of_val(&1u), size_of_val(&1u)); + fail_unless_eq!(size_of_val(&z), 0u); + fail_unless_eq!(nonzero_size_of_val(&z), 1u); + fail_unless_eq!(nonzero_size_of_val(&1u), size_of_val(&1u)); } #[test] fn align_of_basic() { - assert_eq!(pref_align_of::(), 1u); - assert_eq!(pref_align_of::(), 2u); - assert_eq!(pref_align_of::(), 4u); + fail_unless_eq!(pref_align_of::(), 1u); + fail_unless_eq!(pref_align_of::(), 2u); + fail_unless_eq!(pref_align_of::(), 4u); } #[test] @@ -228,22 +228,22 @@ mod tests { #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] fn align_of_32() { - assert_eq!(pref_align_of::(), 4u); - assert_eq!(pref_align_of::<*uint>(), 4u); + fail_unless_eq!(pref_align_of::(), 4u); + fail_unless_eq!(pref_align_of::<*uint>(), 4u); } #[test] #[cfg(target_arch = "x86_64")] fn align_of_64() { - assert_eq!(pref_align_of::(), 8u); - assert_eq!(pref_align_of::<*uint>(), 8u); + fail_unless_eq!(pref_align_of::(), 8u); + fail_unless_eq!(pref_align_of::<*uint>(), 8u); } #[test] fn align_of_val_basic() { - assert_eq!(pref_align_of_val(&1u8), 1u); - assert_eq!(pref_align_of_val(&1u16), 2u); - assert_eq!(pref_align_of_val(&1u32), 4u); + fail_unless_eq!(pref_align_of_val(&1u8), 1u); + fail_unless_eq!(pref_align_of_val(&1u16), 2u); + fail_unless_eq!(pref_align_of_val(&1u32), 4u); } #[test] @@ -251,8 +251,8 @@ mod tests { let mut x = 31337; let mut y = 42; swap(&mut x, &mut y); - assert_eq!(x, 42); - assert_eq!(y, 31337); + fail_unless_eq!(x, 42); + fail_unless_eq!(y, 31337); } #[test] diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index e4a1f14ad95bb..abaa843f8e4e9 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -945,14 +945,14 @@ mod tests { #[test] fn test_asinh() { - assert_eq!(0.0f32.asinh(), 0.0f32); - assert_eq!((-0.0f32).asinh(), -0.0f32); + fail_unless_eq!(0.0f32.asinh(), 0.0f32); + fail_unless_eq!((-0.0f32).asinh(), -0.0f32); let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); - assert_eq!(inf.asinh(), inf); - assert_eq!(neg_inf.asinh(), neg_inf); + fail_unless_eq!(inf.asinh(), inf); + fail_unless_eq!(neg_inf.asinh(), neg_inf); fail_unless!(nan.asinh().is_nan()); assert_approx_eq!(2.0f32.asinh(), 1.443635475178810342493276740273105f32); assert_approx_eq!((-2.0f32).asinh(), -1.443635475178810342493276740273105f32); @@ -960,13 +960,13 @@ mod tests { #[test] fn test_acosh() { - assert_eq!(1.0f32.acosh(), 0.0f32); + fail_unless_eq!(1.0f32.acosh(), 0.0f32); fail_unless!(0.999f32.acosh().is_nan()); let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); - assert_eq!(inf.acosh(), inf); + fail_unless_eq!(inf.acosh(), inf); fail_unless!(neg_inf.acosh().is_nan()); fail_unless!(nan.acosh().is_nan()); assert_approx_eq!(2.0f32.acosh(), 1.31695789692481670862504634730796844f32); @@ -975,13 +975,13 @@ mod tests { #[test] fn test_atanh() { - assert_eq!(0.0f32.atanh(), 0.0f32); - assert_eq!((-0.0f32).atanh(), -0.0f32); + fail_unless_eq!(0.0f32.atanh(), 0.0f32); + fail_unless_eq!((-0.0f32).atanh(), -0.0f32); let inf32: f32 = Float::infinity(); let neg_inf32: f32 = Float::neg_infinity(); - assert_eq!(1.0f32.atanh(), inf32); - assert_eq!((-1.0f32).atanh(), neg_inf32); + fail_unless_eq!(1.0f32.atanh(), inf32); + fail_unless_eq!((-1.0f32).atanh(), neg_inf32); fail_unless!(2f64.atanh().atanh().is_nan()); fail_unless!((-2f64).atanh().atanh().is_nan()); @@ -1036,26 +1036,26 @@ mod tests { #[test] pub fn test_abs() { - assert_eq!(INFINITY.abs(), INFINITY); - assert_eq!(1f32.abs(), 1f32); - assert_eq!(0f32.abs(), 0f32); - assert_eq!((-0f32).abs(), 0f32); - assert_eq!((-1f32).abs(), 1f32); - assert_eq!(NEG_INFINITY.abs(), INFINITY); - assert_eq!((1f32/NEG_INFINITY).abs(), 0f32); + fail_unless_eq!(INFINITY.abs(), INFINITY); + fail_unless_eq!(1f32.abs(), 1f32); + fail_unless_eq!(0f32.abs(), 0f32); + fail_unless_eq!((-0f32).abs(), 0f32); + fail_unless_eq!((-1f32).abs(), 1f32); + fail_unless_eq!(NEG_INFINITY.abs(), INFINITY); + fail_unless_eq!((1f32/NEG_INFINITY).abs(), 0f32); fail_unless!(NAN.abs().is_nan()); } #[test] fn test_abs_sub() { - assert_eq!((-1f32).abs_sub(&1f32), 0f32); - assert_eq!(1f32.abs_sub(&1f32), 0f32); - assert_eq!(1f32.abs_sub(&0f32), 1f32); - assert_eq!(1f32.abs_sub(&-1f32), 2f32); - assert_eq!(NEG_INFINITY.abs_sub(&0f32), 0f32); - assert_eq!(INFINITY.abs_sub(&1f32), INFINITY); - assert_eq!(0f32.abs_sub(&NEG_INFINITY), INFINITY); - assert_eq!(0f32.abs_sub(&INFINITY), 0f32); + fail_unless_eq!((-1f32).abs_sub(&1f32), 0f32); + fail_unless_eq!(1f32.abs_sub(&1f32), 0f32); + fail_unless_eq!(1f32.abs_sub(&0f32), 1f32); + fail_unless_eq!(1f32.abs_sub(&-1f32), 2f32); + fail_unless_eq!(NEG_INFINITY.abs_sub(&0f32), 0f32); + fail_unless_eq!(INFINITY.abs_sub(&1f32), INFINITY); + fail_unless_eq!(0f32.abs_sub(&NEG_INFINITY), INFINITY); + fail_unless_eq!(0f32.abs_sub(&INFINITY), 0f32); } #[test] #[ignore(cfg(windows))] // FIXME #8663 @@ -1066,13 +1066,13 @@ mod tests { #[test] fn test_signum() { - assert_eq!(INFINITY.signum(), 1f32); - assert_eq!(1f32.signum(), 1f32); - assert_eq!(0f32.signum(), 1f32); - assert_eq!((-0f32).signum(), -1f32); - assert_eq!((-1f32).signum(), -1f32); - assert_eq!(NEG_INFINITY.signum(), -1f32); - assert_eq!((1f32/NEG_INFINITY).signum(), -1f32); + fail_unless_eq!(INFINITY.signum(), 1f32); + fail_unless_eq!(1f32.signum(), 1f32); + fail_unless_eq!(0f32.signum(), 1f32); + fail_unless_eq!((-0f32).signum(), -1f32); + fail_unless_eq!((-1f32).signum(), -1f32); + fail_unless_eq!(NEG_INFINITY.signum(), -1f32); + fail_unless_eq!((1f32/NEG_INFINITY).signum(), -1f32); fail_unless!(NAN.signum().is_nan()); } @@ -1124,14 +1124,14 @@ mod tests { let neg_inf: f32 = Float::neg_infinity(); let zero: f32 = Zero::zero(); let neg_zero: f32 = Float::neg_zero(); - assert_eq!(nan.classify(), FPNaN); - assert_eq!(inf.classify(), FPInfinite); - assert_eq!(neg_inf.classify(), FPInfinite); - assert_eq!(zero.classify(), FPZero); - assert_eq!(neg_zero.classify(), FPZero); - assert_eq!(1f32.classify(), FPNormal); - assert_eq!(1e-37f32.classify(), FPNormal); - assert_eq!(1e-38f32.classify(), FPSubnormal); + fail_unless_eq!(nan.classify(), FPNaN); + fail_unless_eq!(inf.classify(), FPInfinite); + fail_unless_eq!(neg_inf.classify(), FPInfinite); + fail_unless_eq!(zero.classify(), FPZero); + fail_unless_eq!(neg_zero.classify(), FPZero); + fail_unless_eq!(1f32.classify(), FPNormal); + fail_unless_eq!(1e-37f32.classify(), FPNormal); + fail_unless_eq!(1e-38f32.classify(), FPSubnormal); } #[test] @@ -1140,17 +1140,17 @@ mod tests { // are supported in floating-point literals let f1: f32 = from_str_hex("1p-123").unwrap(); let f2: f32 = from_str_hex("1p-111").unwrap(); - assert_eq!(Float::ldexp(1f32, -123), f1); - assert_eq!(Float::ldexp(1f32, -111), f2); + fail_unless_eq!(Float::ldexp(1f32, -123), f1); + fail_unless_eq!(Float::ldexp(1f32, -111), f2); - assert_eq!(Float::ldexp(0f32, -123), 0f32); - assert_eq!(Float::ldexp(-0f32, -123), -0f32); + fail_unless_eq!(Float::ldexp(0f32, -123), 0f32); + fail_unless_eq!(Float::ldexp(-0f32, -123), -0f32); let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); - assert_eq!(Float::ldexp(inf, -123), inf); - assert_eq!(Float::ldexp(neg_inf, -123), neg_inf); + fail_unless_eq!(Float::ldexp(inf, -123), inf); + fail_unless_eq!(Float::ldexp(neg_inf, -123), neg_inf); fail_unless!(Float::ldexp(nan, -123).is_nan()); } @@ -1162,13 +1162,13 @@ mod tests { let f2: f32 = from_str_hex("1p-111").unwrap(); let (x1, exp1) = f1.frexp(); let (x2, exp2) = f2.frexp(); - assert_eq!((x1, exp1), (0.5f32, -122)); - assert_eq!((x2, exp2), (0.5f32, -110)); - assert_eq!(Float::ldexp(x1, exp1), f1); - assert_eq!(Float::ldexp(x2, exp2), f2); + fail_unless_eq!((x1, exp1), (0.5f32, -122)); + fail_unless_eq!((x2, exp2), (0.5f32, -110)); + fail_unless_eq!(Float::ldexp(x1, exp1), f1); + fail_unless_eq!(Float::ldexp(x2, exp2), f2); - assert_eq!(0f32.frexp(), (0f32, 0)); - assert_eq!((-0f32).frexp(), (-0f32, 0)); + fail_unless_eq!(0f32.frexp(), (0f32, 0)); + fail_unless_eq!((-0f32).frexp(), (-0f32, 0)); } #[test] #[ignore(cfg(windows))] // FIXME #8755 @@ -1176,20 +1176,20 @@ mod tests { let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); - assert_eq!(match inf.frexp() { (x, _) => x }, inf) - assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) + fail_unless_eq!(match inf.frexp() { (x, _) => x }, inf) + fail_unless_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) fail_unless!(match nan.frexp() { (x, _) => x.is_nan() }) } #[test] fn test_integer_decode() { - assert_eq!(3.14159265359f32.integer_decode(), (13176795u64, -22i16, 1i8)); - assert_eq!((-8573.5918555f32).integer_decode(), (8779358u64, -10i16, -1i8)); - assert_eq!(2f32.powf(&100.0).integer_decode(), (8388608u64, 77i16, 1i8)); - assert_eq!(0f32.integer_decode(), (0u64, -150i16, 1i8)); - assert_eq!((-0f32).integer_decode(), (0u64, -150i16, -1i8)); - assert_eq!(INFINITY.integer_decode(), (8388608u64, 105i16, 1i8)); - assert_eq!(NEG_INFINITY.integer_decode(), (8388608u64, 105i16, -1i8)); - assert_eq!(NAN.integer_decode(), (12582912u64, 105i16, 1i8)); + fail_unless_eq!(3.14159265359f32.integer_decode(), (13176795u64, -22i16, 1i8)); + fail_unless_eq!((-8573.5918555f32).integer_decode(), (8779358u64, -10i16, -1i8)); + fail_unless_eq!(2f32.powf(&100.0).integer_decode(), (8388608u64, 77i16, 1i8)); + fail_unless_eq!(0f32.integer_decode(), (0u64, -150i16, 1i8)); + fail_unless_eq!((-0f32).integer_decode(), (0u64, -150i16, -1i8)); + fail_unless_eq!(INFINITY.integer_decode(), (8388608u64, 105i16, 1i8)); + fail_unless_eq!(NEG_INFINITY.integer_decode(), (8388608u64, 105i16, -1i8)); + fail_unless_eq!(NAN.integer_decode(), (12582912u64, 105i16, 1i8)); } } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index c94676c60b81d..63345298d850c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -947,14 +947,14 @@ mod tests { #[test] fn test_asinh() { - assert_eq!(0.0f64.asinh(), 0.0f64); - assert_eq!((-0.0f64).asinh(), -0.0f64); + fail_unless_eq!(0.0f64.asinh(), 0.0f64); + fail_unless_eq!((-0.0f64).asinh(), -0.0f64); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(inf.asinh(), inf); - assert_eq!(neg_inf.asinh(), neg_inf); + fail_unless_eq!(inf.asinh(), inf); + fail_unless_eq!(neg_inf.asinh(), neg_inf); fail_unless!(nan.asinh().is_nan()); assert_approx_eq!(2.0f64.asinh(), 1.443635475178810342493276740273105f64); assert_approx_eq!((-2.0f64).asinh(), -1.443635475178810342493276740273105f64); @@ -962,13 +962,13 @@ mod tests { #[test] fn test_acosh() { - assert_eq!(1.0f64.acosh(), 0.0f64); + fail_unless_eq!(1.0f64.acosh(), 0.0f64); fail_unless!(0.999f64.acosh().is_nan()); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(inf.acosh(), inf); + fail_unless_eq!(inf.acosh(), inf); fail_unless!(neg_inf.acosh().is_nan()); fail_unless!(nan.acosh().is_nan()); assert_approx_eq!(2.0f64.acosh(), 1.31695789692481670862504634730796844f64); @@ -977,14 +977,14 @@ mod tests { #[test] fn test_atanh() { - assert_eq!(0.0f64.atanh(), 0.0f64); - assert_eq!((-0.0f64).atanh(), -0.0f64); + fail_unless_eq!(0.0f64.atanh(), 0.0f64); + fail_unless_eq!((-0.0f64).atanh(), -0.0f64); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(1.0f64.atanh(), inf); - assert_eq!((-1.0f64).atanh(), neg_inf); + fail_unless_eq!(1.0f64.atanh(), inf); + fail_unless_eq!((-1.0f64).atanh(), neg_inf); fail_unless!(2f64.atanh().atanh().is_nan()); fail_unless!((-2f64).atanh().atanh().is_nan()); fail_unless!(inf.atanh().is_nan()); @@ -1033,26 +1033,26 @@ mod tests { #[test] pub fn test_abs() { - assert_eq!(INFINITY.abs(), INFINITY); - assert_eq!(1f64.abs(), 1f64); - assert_eq!(0f64.abs(), 0f64); - assert_eq!((-0f64).abs(), 0f64); - assert_eq!((-1f64).abs(), 1f64); - assert_eq!(NEG_INFINITY.abs(), INFINITY); - assert_eq!((1f64/NEG_INFINITY).abs(), 0f64); + fail_unless_eq!(INFINITY.abs(), INFINITY); + fail_unless_eq!(1f64.abs(), 1f64); + fail_unless_eq!(0f64.abs(), 0f64); + fail_unless_eq!((-0f64).abs(), 0f64); + fail_unless_eq!((-1f64).abs(), 1f64); + fail_unless_eq!(NEG_INFINITY.abs(), INFINITY); + fail_unless_eq!((1f64/NEG_INFINITY).abs(), 0f64); fail_unless!(NAN.abs().is_nan()); } #[test] fn test_abs_sub() { - assert_eq!((-1f64).abs_sub(&1f64), 0f64); - assert_eq!(1f64.abs_sub(&1f64), 0f64); - assert_eq!(1f64.abs_sub(&0f64), 1f64); - assert_eq!(1f64.abs_sub(&-1f64), 2f64); - assert_eq!(NEG_INFINITY.abs_sub(&0f64), 0f64); - assert_eq!(INFINITY.abs_sub(&1f64), INFINITY); - assert_eq!(0f64.abs_sub(&NEG_INFINITY), INFINITY); - assert_eq!(0f64.abs_sub(&INFINITY), 0f64); + fail_unless_eq!((-1f64).abs_sub(&1f64), 0f64); + fail_unless_eq!(1f64.abs_sub(&1f64), 0f64); + fail_unless_eq!(1f64.abs_sub(&0f64), 1f64); + fail_unless_eq!(1f64.abs_sub(&-1f64), 2f64); + fail_unless_eq!(NEG_INFINITY.abs_sub(&0f64), 0f64); + fail_unless_eq!(INFINITY.abs_sub(&1f64), INFINITY); + fail_unless_eq!(0f64.abs_sub(&NEG_INFINITY), INFINITY); + fail_unless_eq!(0f64.abs_sub(&INFINITY), 0f64); } #[test] #[ignore(cfg(windows))] // FIXME #8663 @@ -1063,13 +1063,13 @@ mod tests { #[test] fn test_signum() { - assert_eq!(INFINITY.signum(), 1f64); - assert_eq!(1f64.signum(), 1f64); - assert_eq!(0f64.signum(), 1f64); - assert_eq!((-0f64).signum(), -1f64); - assert_eq!((-1f64).signum(), -1f64); - assert_eq!(NEG_INFINITY.signum(), -1f64); - assert_eq!((1f64/NEG_INFINITY).signum(), -1f64); + fail_unless_eq!(INFINITY.signum(), 1f64); + fail_unless_eq!(1f64.signum(), 1f64); + fail_unless_eq!(0f64.signum(), 1f64); + fail_unless_eq!((-0f64).signum(), -1f64); + fail_unless_eq!((-1f64).signum(), -1f64); + fail_unless_eq!(NEG_INFINITY.signum(), -1f64); + fail_unless_eq!((1f64/NEG_INFINITY).signum(), -1f64); fail_unless!(NAN.signum().is_nan()); } @@ -1121,13 +1121,13 @@ mod tests { let neg_inf: f64 = Float::neg_infinity(); let zero: f64 = Zero::zero(); let neg_zero: f64 = Float::neg_zero(); - assert_eq!(nan.classify(), FPNaN); - assert_eq!(inf.classify(), FPInfinite); - assert_eq!(neg_inf.classify(), FPInfinite); - assert_eq!(zero.classify(), FPZero); - assert_eq!(neg_zero.classify(), FPZero); - assert_eq!(1e-307f64.classify(), FPNormal); - assert_eq!(1e-308f64.classify(), FPSubnormal); + fail_unless_eq!(nan.classify(), FPNaN); + fail_unless_eq!(inf.classify(), FPInfinite); + fail_unless_eq!(neg_inf.classify(), FPInfinite); + fail_unless_eq!(zero.classify(), FPZero); + fail_unless_eq!(neg_zero.classify(), FPZero); + fail_unless_eq!(1e-307f64.classify(), FPNormal); + fail_unless_eq!(1e-308f64.classify(), FPSubnormal); } #[test] @@ -1136,17 +1136,17 @@ mod tests { // are supported in floating-point literals let f1: f64 = from_str_hex("1p-123").unwrap(); let f2: f64 = from_str_hex("1p-111").unwrap(); - assert_eq!(Float::ldexp(1f64, -123), f1); - assert_eq!(Float::ldexp(1f64, -111), f2); + fail_unless_eq!(Float::ldexp(1f64, -123), f1); + fail_unless_eq!(Float::ldexp(1f64, -111), f2); - assert_eq!(Float::ldexp(0f64, -123), 0f64); - assert_eq!(Float::ldexp(-0f64, -123), -0f64); + fail_unless_eq!(Float::ldexp(0f64, -123), 0f64); + fail_unless_eq!(Float::ldexp(-0f64, -123), -0f64); let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(Float::ldexp(inf, -123), inf); - assert_eq!(Float::ldexp(neg_inf, -123), neg_inf); + fail_unless_eq!(Float::ldexp(inf, -123), inf); + fail_unless_eq!(Float::ldexp(neg_inf, -123), neg_inf); fail_unless!(Float::ldexp(nan, -123).is_nan()); } @@ -1158,13 +1158,13 @@ mod tests { let f2: f64 = from_str_hex("1p-111").unwrap(); let (x1, exp1) = f1.frexp(); let (x2, exp2) = f2.frexp(); - assert_eq!((x1, exp1), (0.5f64, -122)); - assert_eq!((x2, exp2), (0.5f64, -110)); - assert_eq!(Float::ldexp(x1, exp1), f1); - assert_eq!(Float::ldexp(x2, exp2), f2); + fail_unless_eq!((x1, exp1), (0.5f64, -122)); + fail_unless_eq!((x2, exp2), (0.5f64, -110)); + fail_unless_eq!(Float::ldexp(x1, exp1), f1); + fail_unless_eq!(Float::ldexp(x2, exp2), f2); - assert_eq!(0f64.frexp(), (0f64, 0)); - assert_eq!((-0f64).frexp(), (-0f64, 0)); + fail_unless_eq!(0f64.frexp(), (0f64, 0)); + fail_unless_eq!((-0f64).frexp(), (-0f64, 0)); } #[test] #[ignore(cfg(windows))] // FIXME #8755 @@ -1172,20 +1172,20 @@ mod tests { let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(match inf.frexp() { (x, _) => x }, inf) - assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) + fail_unless_eq!(match inf.frexp() { (x, _) => x }, inf) + fail_unless_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) fail_unless!(match nan.frexp() { (x, _) => x.is_nan() }) } #[test] fn test_integer_decode() { - assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906u64, -51i16, 1i8)); - assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931u64, -39i16, -1i8)); - assert_eq!(2f64.powf(&100.0).integer_decode(), (4503599627370496u64, 48i16, 1i8)); - assert_eq!(0f64.integer_decode(), (0u64, -1075i16, 1i8)); - assert_eq!((-0f64).integer_decode(), (0u64, -1075i16, -1i8)); - assert_eq!(INFINITY.integer_decode(), (4503599627370496u64, 972i16, 1i8)); - assert_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1)); - assert_eq!(NAN.integer_decode(), (6755399441055744u64, 972i16, 1i8)); + fail_unless_eq!(3.14159265359f64.integer_decode(), (7074237752028906u64, -51i16, 1i8)); + fail_unless_eq!((-8573.5918555f64).integer_decode(), (4713381968463931u64, -39i16, -1i8)); + fail_unless_eq!(2f64.powf(&100.0).integer_decode(), (4503599627370496u64, 48i16, 1i8)); + fail_unless_eq!(0f64.integer_decode(), (0u64, -1075i16, 1i8)); + fail_unless_eq!((-0f64).integer_decode(), (0u64, -1075i16, -1i8)); + fail_unless_eq!(INFINITY.integer_decode(), (4503599627370496u64, 972i16, 1i8)); + fail_unless_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1)); + fail_unless_eq!(NAN.integer_decode(), (6755399441055744u64, 972i16, 1i8)); } } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index cbd7bfc29d745..11257368e3c4a 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -310,7 +310,7 @@ mod tests { fn test_overflows() { fail_unless!(MAX > 0); fail_unless!(MIN <= 0); - assert_eq!(MIN + MAX + 1, 0); + fail_unless_eq!(MIN + MAX + 1, 0); } #[test] @@ -320,25 +320,25 @@ mod tests { #[test] pub fn test_abs() { - assert_eq!((1 as $T).abs(), 1 as $T); - assert_eq!((0 as $T).abs(), 0 as $T); - assert_eq!((-1 as $T).abs(), 1 as $T); + fail_unless_eq!((1 as $T).abs(), 1 as $T); + fail_unless_eq!((0 as $T).abs(), 0 as $T); + fail_unless_eq!((-1 as $T).abs(), 1 as $T); } #[test] fn test_abs_sub() { - assert_eq!((-1 as $T).abs_sub(&(1 as $T)), 0 as $T); - assert_eq!((1 as $T).abs_sub(&(1 as $T)), 0 as $T); - assert_eq!((1 as $T).abs_sub(&(0 as $T)), 1 as $T); - assert_eq!((1 as $T).abs_sub(&(-1 as $T)), 2 as $T); + fail_unless_eq!((-1 as $T).abs_sub(&(1 as $T)), 0 as $T); + fail_unless_eq!((1 as $T).abs_sub(&(1 as $T)), 0 as $T); + fail_unless_eq!((1 as $T).abs_sub(&(0 as $T)), 1 as $T); + fail_unless_eq!((1 as $T).abs_sub(&(-1 as $T)), 2 as $T); } #[test] fn test_signum() { - assert_eq!((1 as $T).signum(), 1 as $T); - assert_eq!((0 as $T).signum(), 0 as $T); - assert_eq!((-0 as $T).signum(), 0 as $T); - assert_eq!((-1 as $T).signum(), -1 as $T); + fail_unless_eq!((1 as $T).signum(), 1 as $T); + fail_unless_eq!((0 as $T).signum(), 0 as $T); + fail_unless_eq!((-0 as $T).signum(), 0 as $T); + fail_unless_eq!((-1 as $T).signum(), -1 as $T); } #[test] @@ -359,41 +359,41 @@ mod tests { #[test] fn test_bitwise() { - assert_eq!(0b1110 as $T, (0b1100 as $T).bitor(&(0b1010 as $T))); - assert_eq!(0b1000 as $T, (0b1100 as $T).bitand(&(0b1010 as $T))); - assert_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T))); - assert_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T))); - assert_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T))); - assert_eq!(-(0b11 as $T) - (1 as $T), (0b11 as $T).not()); + fail_unless_eq!(0b1110 as $T, (0b1100 as $T).bitor(&(0b1010 as $T))); + fail_unless_eq!(0b1000 as $T, (0b1100 as $T).bitand(&(0b1010 as $T))); + fail_unless_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T))); + fail_unless_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T))); + fail_unless_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T))); + fail_unless_eq!(-(0b11 as $T) - (1 as $T), (0b11 as $T).not()); } #[test] fn test_count_ones() { - assert_eq!((0b0101100 as $T).count_ones(), 3); - assert_eq!((0b0100001 as $T).count_ones(), 2); - assert_eq!((0b1111001 as $T).count_ones(), 5); + fail_unless_eq!((0b0101100 as $T).count_ones(), 3); + fail_unless_eq!((0b0100001 as $T).count_ones(), 2); + fail_unless_eq!((0b1111001 as $T).count_ones(), 5); } #[test] fn test_count_zeros() { - assert_eq!((0b0101100 as $T).count_zeros(), BITS as $T - 3); - assert_eq!((0b0100001 as $T).count_zeros(), BITS as $T - 2); - assert_eq!((0b1111001 as $T).count_zeros(), BITS as $T - 5); + fail_unless_eq!((0b0101100 as $T).count_zeros(), BITS as $T - 3); + fail_unless_eq!((0b0100001 as $T).count_zeros(), BITS as $T - 2); + fail_unless_eq!((0b1111001 as $T).count_zeros(), BITS as $T - 5); } #[test] fn test_from_str() { - assert_eq!(from_str::<$T>("0"), Some(0 as $T)); - assert_eq!(from_str::<$T>("3"), Some(3 as $T)); - assert_eq!(from_str::<$T>("10"), Some(10 as $T)); - assert_eq!(from_str::("123456789"), Some(123456789 as i32)); - assert_eq!(from_str::<$T>("00100"), Some(100 as $T)); - - assert_eq!(from_str::<$T>("-1"), Some(-1 as $T)); - assert_eq!(from_str::<$T>("-3"), Some(-3 as $T)); - assert_eq!(from_str::<$T>("-10"), Some(-10 as $T)); - assert_eq!(from_str::("-123456789"), Some(-123456789 as i32)); - assert_eq!(from_str::<$T>("-00100"), Some(-100 as $T)); + fail_unless_eq!(from_str::<$T>("0"), Some(0 as $T)); + fail_unless_eq!(from_str::<$T>("3"), Some(3 as $T)); + fail_unless_eq!(from_str::<$T>("10"), Some(10 as $T)); + fail_unless_eq!(from_str::("123456789"), Some(123456789 as i32)); + fail_unless_eq!(from_str::<$T>("00100"), Some(100 as $T)); + + fail_unless_eq!(from_str::<$T>("-1"), Some(-1 as $T)); + fail_unless_eq!(from_str::<$T>("-3"), Some(-3 as $T)); + fail_unless_eq!(from_str::<$T>("-10"), Some(-10 as $T)); + fail_unless_eq!(from_str::("-123456789"), Some(-123456789 as i32)); + fail_unless_eq!(from_str::<$T>("-00100"), Some(-100 as $T)); fail_unless!(from_str::<$T>(" ").is_none()); fail_unless!(from_str::<$T>("x").is_none()); @@ -402,23 +402,23 @@ mod tests { #[test] fn test_parse_bytes() { use str::StrSlice; - assert_eq!(parse_bytes("123".as_bytes(), 10u), Some(123 as $T)); - assert_eq!(parse_bytes("1001".as_bytes(), 2u), Some(9 as $T)); - assert_eq!(parse_bytes("123".as_bytes(), 8u), Some(83 as $T)); - assert_eq!(i32::parse_bytes("123".as_bytes(), 16u), Some(291 as i32)); - assert_eq!(i32::parse_bytes("ffff".as_bytes(), 16u), Some(65535 as i32)); - assert_eq!(i32::parse_bytes("FFFF".as_bytes(), 16u), Some(65535 as i32)); - assert_eq!(parse_bytes("z".as_bytes(), 36u), Some(35 as $T)); - assert_eq!(parse_bytes("Z".as_bytes(), 36u), Some(35 as $T)); - - assert_eq!(parse_bytes("-123".as_bytes(), 10u), Some(-123 as $T)); - assert_eq!(parse_bytes("-1001".as_bytes(), 2u), Some(-9 as $T)); - assert_eq!(parse_bytes("-123".as_bytes(), 8u), Some(-83 as $T)); - assert_eq!(i32::parse_bytes("-123".as_bytes(), 16u), Some(-291 as i32)); - assert_eq!(i32::parse_bytes("-ffff".as_bytes(), 16u), Some(-65535 as i32)); - assert_eq!(i32::parse_bytes("-FFFF".as_bytes(), 16u), Some(-65535 as i32)); - assert_eq!(parse_bytes("-z".as_bytes(), 36u), Some(-35 as $T)); - assert_eq!(parse_bytes("-Z".as_bytes(), 36u), Some(-35 as $T)); + fail_unless_eq!(parse_bytes("123".as_bytes(), 10u), Some(123 as $T)); + fail_unless_eq!(parse_bytes("1001".as_bytes(), 2u), Some(9 as $T)); + fail_unless_eq!(parse_bytes("123".as_bytes(), 8u), Some(83 as $T)); + fail_unless_eq!(i32::parse_bytes("123".as_bytes(), 16u), Some(291 as i32)); + fail_unless_eq!(i32::parse_bytes("ffff".as_bytes(), 16u), Some(65535 as i32)); + fail_unless_eq!(i32::parse_bytes("FFFF".as_bytes(), 16u), Some(65535 as i32)); + fail_unless_eq!(parse_bytes("z".as_bytes(), 36u), Some(35 as $T)); + fail_unless_eq!(parse_bytes("Z".as_bytes(), 36u), Some(35 as $T)); + + fail_unless_eq!(parse_bytes("-123".as_bytes(), 10u), Some(-123 as $T)); + fail_unless_eq!(parse_bytes("-1001".as_bytes(), 2u), Some(-9 as $T)); + fail_unless_eq!(parse_bytes("-123".as_bytes(), 8u), Some(-83 as $T)); + fail_unless_eq!(i32::parse_bytes("-123".as_bytes(), 16u), Some(-291 as i32)); + fail_unless_eq!(i32::parse_bytes("-ffff".as_bytes(), 16u), Some(-65535 as i32)); + fail_unless_eq!(i32::parse_bytes("-FFFF".as_bytes(), 16u), Some(-65535 as i32)); + fail_unless_eq!(parse_bytes("-z".as_bytes(), 36u), Some(-35 as $T)); + fail_unless_eq!(parse_bytes("-Z".as_bytes(), 36u), Some(-35 as $T)); fail_unless!(parse_bytes("Z".as_bytes(), 35u).is_none()); fail_unless!(parse_bytes("-9".as_bytes(), 2u).is_none()); @@ -426,81 +426,81 @@ mod tests { #[test] fn test_to_str() { - assert_eq!((0 as $T).to_str_radix(10u), ~"0"); - assert_eq!((1 as $T).to_str_radix(10u), ~"1"); - assert_eq!((-1 as $T).to_str_radix(10u), ~"-1"); - assert_eq!((127 as $T).to_str_radix(16u), ~"7f"); - assert_eq!((100 as $T).to_str_radix(10u), ~"100"); + fail_unless_eq!((0 as $T).to_str_radix(10u), ~"0"); + fail_unless_eq!((1 as $T).to_str_radix(10u), ~"1"); + fail_unless_eq!((-1 as $T).to_str_radix(10u), ~"-1"); + fail_unless_eq!((127 as $T).to_str_radix(16u), ~"7f"); + fail_unless_eq!((100 as $T).to_str_radix(10u), ~"100"); } #[test] fn test_int_to_str_overflow() { let mut i8_val: i8 = 127_i8; - assert_eq!(i8_val.to_str(), ~"127"); + fail_unless_eq!(i8_val.to_str(), ~"127"); i8_val += 1 as i8; - assert_eq!(i8_val.to_str(), ~"-128"); + fail_unless_eq!(i8_val.to_str(), ~"-128"); let mut i16_val: i16 = 32_767_i16; - assert_eq!(i16_val.to_str(), ~"32767"); + fail_unless_eq!(i16_val.to_str(), ~"32767"); i16_val += 1 as i16; - assert_eq!(i16_val.to_str(), ~"-32768"); + fail_unless_eq!(i16_val.to_str(), ~"-32768"); let mut i32_val: i32 = 2_147_483_647_i32; - assert_eq!(i32_val.to_str(), ~"2147483647"); + fail_unless_eq!(i32_val.to_str(), ~"2147483647"); i32_val += 1 as i32; - assert_eq!(i32_val.to_str(), ~"-2147483648"); + fail_unless_eq!(i32_val.to_str(), ~"-2147483648"); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert_eq!(i64_val.to_str(), ~"9223372036854775807"); + fail_unless_eq!(i64_val.to_str(), ~"9223372036854775807"); i64_val += 1 as i64; - assert_eq!(i64_val.to_str(), ~"-9223372036854775808"); + fail_unless_eq!(i64_val.to_str(), ~"-9223372036854775808"); } #[test] fn test_int_from_str_overflow() { let mut i8_val: i8 = 127_i8; - assert_eq!(from_str::("127"), Some(i8_val)); + fail_unless_eq!(from_str::("127"), Some(i8_val)); fail_unless!(from_str::("128").is_none()); i8_val += 1 as i8; - assert_eq!(from_str::("-128"), Some(i8_val)); + fail_unless_eq!(from_str::("-128"), Some(i8_val)); fail_unless!(from_str::("-129").is_none()); let mut i16_val: i16 = 32_767_i16; - assert_eq!(from_str::("32767"), Some(i16_val)); + fail_unless_eq!(from_str::("32767"), Some(i16_val)); fail_unless!(from_str::("32768").is_none()); i16_val += 1 as i16; - assert_eq!(from_str::("-32768"), Some(i16_val)); + fail_unless_eq!(from_str::("-32768"), Some(i16_val)); fail_unless!(from_str::("-32769").is_none()); let mut i32_val: i32 = 2_147_483_647_i32; - assert_eq!(from_str::("2147483647"), Some(i32_val)); + fail_unless_eq!(from_str::("2147483647"), Some(i32_val)); fail_unless!(from_str::("2147483648").is_none()); i32_val += 1 as i32; - assert_eq!(from_str::("-2147483648"), Some(i32_val)); + fail_unless_eq!(from_str::("-2147483648"), Some(i32_val)); fail_unless!(from_str::("-2147483649").is_none()); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert_eq!(from_str::("9223372036854775807"), Some(i64_val)); + fail_unless_eq!(from_str::("9223372036854775807"), Some(i64_val)); fail_unless!(from_str::("9223372036854775808").is_none()); i64_val += 1 as i64; - assert_eq!(from_str::("-9223372036854775808"), Some(i64_val)); + fail_unless_eq!(from_str::("-9223372036854775808"), Some(i64_val)); fail_unless!(from_str::("-9223372036854775809").is_none()); } #[test] fn test_signed_checked_div() { - assert_eq!(10i.checked_div(&2), Some(5)); - assert_eq!(5i.checked_div(&0), None); - assert_eq!(int::MIN.checked_div(&-1), None); + fail_unless_eq!(10i.checked_div(&2), Some(5)); + fail_unless_eq!(5i.checked_div(&0), None); + fail_unless_eq!(int::MIN.checked_div(&-1), None); } } diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index ef4cf9d4b29e8..debcdef6caed1 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -156,7 +156,7 @@ pub trait Round { /// ```rust /// use std::num; /// -/// assert_eq!(num::pow(2, 4), 16); +/// fail_unless_eq!(num::pow(2, 4), 16); /// ``` #[inline] pub fn pow>(mut base: T, mut exp: uint) -> T { @@ -196,7 +196,7 @@ pub trait Bitwise: Bounded /// use std::num::Bitwise; /// /// let n = 0b01001100u8; - /// assert_eq!(n.count_ones(), 3); + /// fail_unless_eq!(n.count_ones(), 3); /// ``` fn count_ones(&self) -> Self; @@ -208,7 +208,7 @@ pub trait Bitwise: Bounded /// use std::num::Bitwise; /// /// let n = 0b01001100u8; - /// assert_eq!(n.count_zeros(), 5); + /// fail_unless_eq!(n.count_zeros(), 5); /// ``` #[inline] fn count_zeros(&self) -> Self { @@ -224,7 +224,7 @@ pub trait Bitwise: Bounded /// use std::num::Bitwise; /// /// let n = 0b0101000u16; - /// assert_eq!(n.leading_zeros(), 10); + /// fail_unless_eq!(n.leading_zeros(), 10); /// ``` fn leading_zeros(&self) -> Self; @@ -237,7 +237,7 @@ pub trait Bitwise: Bounded /// use std::num::Bitwise; /// /// let n = 0b0101000u16; - /// assert_eq!(n.trailing_zeros(), 3); + /// fail_unless_eq!(n.trailing_zeros(), 3); /// ``` fn trailing_zeros(&self) -> Self; } @@ -468,7 +468,7 @@ pub trait Float: Signed /// use std::num; /// /// let sixteen: f64 = num::powf(2.0, 4.0); -/// assert_eq!(sixteen, 16.0); +/// fail_unless_eq!(sixteen, 16.0); /// ``` #[inline(always)] pub fn powf(value: T, n: T) -> T { value.powf(&n) } /// Take the square root of a number. @@ -968,7 +968,7 @@ impl_from_primitive!(f64, n.to_f64()) /// use std::num; /// /// let twenty: f32 = num::cast(0x14).unwrap(); -/// assert_eq!(twenty, 20f32); +/// fail_unless_eq!(twenty, 20f32); /// ``` /// #[inline] @@ -1076,17 +1076,17 @@ pub trait CheckedDiv: Div { /// Helper function for testing numeric operations #[cfg(test)] pub fn test_num(ten: T, two: T) { - assert_eq!(ten.add(&two), cast(12).unwrap()); - assert_eq!(ten.sub(&two), cast(8).unwrap()); - assert_eq!(ten.mul(&two), cast(20).unwrap()); - assert_eq!(ten.div(&two), cast(5).unwrap()); - assert_eq!(ten.rem(&two), cast(0).unwrap()); - - assert_eq!(ten.add(&two), ten + two); - assert_eq!(ten.sub(&two), ten - two); - assert_eq!(ten.mul(&two), ten * two); - assert_eq!(ten.div(&two), ten / two); - assert_eq!(ten.rem(&two), ten % two); + fail_unless_eq!(ten.add(&two), cast(12).unwrap()); + fail_unless_eq!(ten.sub(&two), cast(8).unwrap()); + fail_unless_eq!(ten.mul(&two), cast(20).unwrap()); + fail_unless_eq!(ten.div(&two), cast(5).unwrap()); + fail_unless_eq!(ten.rem(&two), cast(0).unwrap()); + + fail_unless_eq!(ten.add(&two), ten + two); + fail_unless_eq!(ten.sub(&two), ten - two); + fail_unless_eq!(ten.mul(&two), ten * two); + fail_unless_eq!(ten.div(&two), ten / two); + fail_unless_eq!(ten.rem(&two), ten % two); } #[cfg(test)] @@ -1108,44 +1108,44 @@ mod tests { ($_20:expr) => ({ let _20 = $_20; - assert_eq!(20u, _20.to_uint().unwrap()); - assert_eq!(20u8, _20.to_u8().unwrap()); - assert_eq!(20u16, _20.to_u16().unwrap()); - assert_eq!(20u32, _20.to_u32().unwrap()); - assert_eq!(20u64, _20.to_u64().unwrap()); - assert_eq!(20i, _20.to_int().unwrap()); - assert_eq!(20i8, _20.to_i8().unwrap()); - assert_eq!(20i16, _20.to_i16().unwrap()); - assert_eq!(20i32, _20.to_i32().unwrap()); - assert_eq!(20i64, _20.to_i64().unwrap()); - assert_eq!(20f32, _20.to_f32().unwrap()); - assert_eq!(20f64, _20.to_f64().unwrap()); - - assert_eq!(_20, NumCast::from(20u).unwrap()); - assert_eq!(_20, NumCast::from(20u8).unwrap()); - assert_eq!(_20, NumCast::from(20u16).unwrap()); - assert_eq!(_20, NumCast::from(20u32).unwrap()); - assert_eq!(_20, NumCast::from(20u64).unwrap()); - assert_eq!(_20, NumCast::from(20i).unwrap()); - assert_eq!(_20, NumCast::from(20i8).unwrap()); - assert_eq!(_20, NumCast::from(20i16).unwrap()); - assert_eq!(_20, NumCast::from(20i32).unwrap()); - assert_eq!(_20, NumCast::from(20i64).unwrap()); - assert_eq!(_20, NumCast::from(20f32).unwrap()); - assert_eq!(_20, NumCast::from(20f64).unwrap()); - - assert_eq!(_20, cast(20u).unwrap()); - assert_eq!(_20, cast(20u8).unwrap()); - assert_eq!(_20, cast(20u16).unwrap()); - assert_eq!(_20, cast(20u32).unwrap()); - assert_eq!(_20, cast(20u64).unwrap()); - assert_eq!(_20, cast(20i).unwrap()); - assert_eq!(_20, cast(20i8).unwrap()); - assert_eq!(_20, cast(20i16).unwrap()); - assert_eq!(_20, cast(20i32).unwrap()); - assert_eq!(_20, cast(20i64).unwrap()); - assert_eq!(_20, cast(20f32).unwrap()); - assert_eq!(_20, cast(20f64).unwrap()); + fail_unless_eq!(20u, _20.to_uint().unwrap()); + fail_unless_eq!(20u8, _20.to_u8().unwrap()); + fail_unless_eq!(20u16, _20.to_u16().unwrap()); + fail_unless_eq!(20u32, _20.to_u32().unwrap()); + fail_unless_eq!(20u64, _20.to_u64().unwrap()); + fail_unless_eq!(20i, _20.to_int().unwrap()); + fail_unless_eq!(20i8, _20.to_i8().unwrap()); + fail_unless_eq!(20i16, _20.to_i16().unwrap()); + fail_unless_eq!(20i32, _20.to_i32().unwrap()); + fail_unless_eq!(20i64, _20.to_i64().unwrap()); + fail_unless_eq!(20f32, _20.to_f32().unwrap()); + fail_unless_eq!(20f64, _20.to_f64().unwrap()); + + fail_unless_eq!(_20, NumCast::from(20u).unwrap()); + fail_unless_eq!(_20, NumCast::from(20u8).unwrap()); + fail_unless_eq!(_20, NumCast::from(20u16).unwrap()); + fail_unless_eq!(_20, NumCast::from(20u32).unwrap()); + fail_unless_eq!(_20, NumCast::from(20u64).unwrap()); + fail_unless_eq!(_20, NumCast::from(20i).unwrap()); + fail_unless_eq!(_20, NumCast::from(20i8).unwrap()); + fail_unless_eq!(_20, NumCast::from(20i16).unwrap()); + fail_unless_eq!(_20, NumCast::from(20i32).unwrap()); + fail_unless_eq!(_20, NumCast::from(20i64).unwrap()); + fail_unless_eq!(_20, NumCast::from(20f32).unwrap()); + fail_unless_eq!(_20, NumCast::from(20f64).unwrap()); + + fail_unless_eq!(_20, cast(20u).unwrap()); + fail_unless_eq!(_20, cast(20u8).unwrap()); + fail_unless_eq!(_20, cast(20u16).unwrap()); + fail_unless_eq!(_20, cast(20u32).unwrap()); + fail_unless_eq!(_20, cast(20u64).unwrap()); + fail_unless_eq!(_20, cast(20i).unwrap()); + fail_unless_eq!(_20, cast(20i8).unwrap()); + fail_unless_eq!(_20, cast(20i16).unwrap()); + fail_unless_eq!(_20, cast(20i32).unwrap()); + fail_unless_eq!(_20, cast(20i64).unwrap()); + fail_unless_eq!(_20, cast(20f32).unwrap()); + fail_unless_eq!(_20, cast(20f64).unwrap()); }) ) @@ -1164,25 +1164,25 @@ mod tests { #[test] fn test_cast_range_int_min() { - assert_eq!(int::MIN.to_int(), Some(int::MIN as int)); - assert_eq!(int::MIN.to_i8(), None); - assert_eq!(int::MIN.to_i16(), None); + fail_unless_eq!(int::MIN.to_int(), Some(int::MIN as int)); + fail_unless_eq!(int::MIN.to_i8(), None); + fail_unless_eq!(int::MIN.to_i16(), None); // int::MIN.to_i32() is word-size specific - assert_eq!(int::MIN.to_i64(), Some(int::MIN as i64)); - assert_eq!(int::MIN.to_uint(), None); - assert_eq!(int::MIN.to_u8(), None); - assert_eq!(int::MIN.to_u16(), None); - assert_eq!(int::MIN.to_u32(), None); - assert_eq!(int::MIN.to_u64(), None); + fail_unless_eq!(int::MIN.to_i64(), Some(int::MIN as i64)); + fail_unless_eq!(int::MIN.to_uint(), None); + fail_unless_eq!(int::MIN.to_u8(), None); + fail_unless_eq!(int::MIN.to_u16(), None); + fail_unless_eq!(int::MIN.to_u32(), None); + fail_unless_eq!(int::MIN.to_u64(), None); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(int::MIN.to_i32(), Some(int::MIN as i32)); + fail_unless_eq!(int::MIN.to_i32(), Some(int::MIN as i32)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(int::MIN.to_i32(), None); + fail_unless_eq!(int::MIN.to_i32(), None); } check_word_size(); @@ -1190,67 +1190,67 @@ mod tests { #[test] fn test_cast_range_i8_min() { - assert_eq!(i8::MIN.to_int(), Some(i8::MIN as int)); - assert_eq!(i8::MIN.to_i8(), Some(i8::MIN as i8)); - assert_eq!(i8::MIN.to_i16(), Some(i8::MIN as i16)); - assert_eq!(i8::MIN.to_i32(), Some(i8::MIN as i32)); - assert_eq!(i8::MIN.to_i64(), Some(i8::MIN as i64)); - assert_eq!(i8::MIN.to_uint(), None); - assert_eq!(i8::MIN.to_u8(), None); - assert_eq!(i8::MIN.to_u16(), None); - assert_eq!(i8::MIN.to_u32(), None); - assert_eq!(i8::MIN.to_u64(), None); + fail_unless_eq!(i8::MIN.to_int(), Some(i8::MIN as int)); + fail_unless_eq!(i8::MIN.to_i8(), Some(i8::MIN as i8)); + fail_unless_eq!(i8::MIN.to_i16(), Some(i8::MIN as i16)); + fail_unless_eq!(i8::MIN.to_i32(), Some(i8::MIN as i32)); + fail_unless_eq!(i8::MIN.to_i64(), Some(i8::MIN as i64)); + fail_unless_eq!(i8::MIN.to_uint(), None); + fail_unless_eq!(i8::MIN.to_u8(), None); + fail_unless_eq!(i8::MIN.to_u16(), None); + fail_unless_eq!(i8::MIN.to_u32(), None); + fail_unless_eq!(i8::MIN.to_u64(), None); } #[test] fn test_cast_range_i16_min() { - assert_eq!(i16::MIN.to_int(), Some(i16::MIN as int)); - assert_eq!(i16::MIN.to_i8(), None); - assert_eq!(i16::MIN.to_i16(), Some(i16::MIN as i16)); - assert_eq!(i16::MIN.to_i32(), Some(i16::MIN as i32)); - assert_eq!(i16::MIN.to_i64(), Some(i16::MIN as i64)); - assert_eq!(i16::MIN.to_uint(), None); - assert_eq!(i16::MIN.to_u8(), None); - assert_eq!(i16::MIN.to_u16(), None); - assert_eq!(i16::MIN.to_u32(), None); - assert_eq!(i16::MIN.to_u64(), None); + fail_unless_eq!(i16::MIN.to_int(), Some(i16::MIN as int)); + fail_unless_eq!(i16::MIN.to_i8(), None); + fail_unless_eq!(i16::MIN.to_i16(), Some(i16::MIN as i16)); + fail_unless_eq!(i16::MIN.to_i32(), Some(i16::MIN as i32)); + fail_unless_eq!(i16::MIN.to_i64(), Some(i16::MIN as i64)); + fail_unless_eq!(i16::MIN.to_uint(), None); + fail_unless_eq!(i16::MIN.to_u8(), None); + fail_unless_eq!(i16::MIN.to_u16(), None); + fail_unless_eq!(i16::MIN.to_u32(), None); + fail_unless_eq!(i16::MIN.to_u64(), None); } #[test] fn test_cast_range_i32_min() { - assert_eq!(i32::MIN.to_int(), Some(i32::MIN as int)); - assert_eq!(i32::MIN.to_i8(), None); - assert_eq!(i32::MIN.to_i16(), None); - assert_eq!(i32::MIN.to_i32(), Some(i32::MIN as i32)); - assert_eq!(i32::MIN.to_i64(), Some(i32::MIN as i64)); - assert_eq!(i32::MIN.to_uint(), None); - assert_eq!(i32::MIN.to_u8(), None); - assert_eq!(i32::MIN.to_u16(), None); - assert_eq!(i32::MIN.to_u32(), None); - assert_eq!(i32::MIN.to_u64(), None); + fail_unless_eq!(i32::MIN.to_int(), Some(i32::MIN as int)); + fail_unless_eq!(i32::MIN.to_i8(), None); + fail_unless_eq!(i32::MIN.to_i16(), None); + fail_unless_eq!(i32::MIN.to_i32(), Some(i32::MIN as i32)); + fail_unless_eq!(i32::MIN.to_i64(), Some(i32::MIN as i64)); + fail_unless_eq!(i32::MIN.to_uint(), None); + fail_unless_eq!(i32::MIN.to_u8(), None); + fail_unless_eq!(i32::MIN.to_u16(), None); + fail_unless_eq!(i32::MIN.to_u32(), None); + fail_unless_eq!(i32::MIN.to_u64(), None); } #[test] fn test_cast_range_i64_min() { // i64::MIN.to_int() is word-size specific - assert_eq!(i64::MIN.to_i8(), None); - assert_eq!(i64::MIN.to_i16(), None); - assert_eq!(i64::MIN.to_i32(), None); - assert_eq!(i64::MIN.to_i64(), Some(i64::MIN as i64)); - assert_eq!(i64::MIN.to_uint(), None); - assert_eq!(i64::MIN.to_u8(), None); - assert_eq!(i64::MIN.to_u16(), None); - assert_eq!(i64::MIN.to_u32(), None); - assert_eq!(i64::MIN.to_u64(), None); + fail_unless_eq!(i64::MIN.to_i8(), None); + fail_unless_eq!(i64::MIN.to_i16(), None); + fail_unless_eq!(i64::MIN.to_i32(), None); + fail_unless_eq!(i64::MIN.to_i64(), Some(i64::MIN as i64)); + fail_unless_eq!(i64::MIN.to_uint(), None); + fail_unless_eq!(i64::MIN.to_u8(), None); + fail_unless_eq!(i64::MIN.to_u16(), None); + fail_unless_eq!(i64::MIN.to_u32(), None); + fail_unless_eq!(i64::MIN.to_u64(), None); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(i64::MIN.to_int(), None); + fail_unless_eq!(i64::MIN.to_int(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(i64::MIN.to_int(), Some(i64::MIN as int)); + fail_unless_eq!(i64::MIN.to_int(), Some(i64::MIN as int)); } check_word_size(); @@ -1258,26 +1258,26 @@ mod tests { #[test] fn test_cast_range_int_max() { - assert_eq!(int::MAX.to_int(), Some(int::MAX as int)); - assert_eq!(int::MAX.to_i8(), None); - assert_eq!(int::MAX.to_i16(), None); + fail_unless_eq!(int::MAX.to_int(), Some(int::MAX as int)); + fail_unless_eq!(int::MAX.to_i8(), None); + fail_unless_eq!(int::MAX.to_i16(), None); // int::MAX.to_i32() is word-size specific - assert_eq!(int::MAX.to_i64(), Some(int::MAX as i64)); - assert_eq!(int::MAX.to_u8(), None); - assert_eq!(int::MAX.to_u16(), None); + fail_unless_eq!(int::MAX.to_i64(), Some(int::MAX as i64)); + fail_unless_eq!(int::MAX.to_u8(), None); + fail_unless_eq!(int::MAX.to_u16(), None); // int::MAX.to_u32() is word-size specific - assert_eq!(int::MAX.to_u64(), Some(int::MAX as u64)); + fail_unless_eq!(int::MAX.to_u64(), Some(int::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(int::MAX.to_i32(), Some(int::MAX as i32)); - assert_eq!(int::MAX.to_u32(), Some(int::MAX as u32)); + fail_unless_eq!(int::MAX.to_i32(), Some(int::MAX as i32)); + fail_unless_eq!(int::MAX.to_u32(), Some(int::MAX as u32)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(int::MAX.to_i32(), None); - assert_eq!(int::MAX.to_u32(), None); + fail_unless_eq!(int::MAX.to_i32(), None); + fail_unless_eq!(int::MAX.to_u32(), None); } check_word_size(); @@ -1285,69 +1285,69 @@ mod tests { #[test] fn test_cast_range_i8_max() { - assert_eq!(i8::MAX.to_int(), Some(i8::MAX as int)); - assert_eq!(i8::MAX.to_i8(), Some(i8::MAX as i8)); - assert_eq!(i8::MAX.to_i16(), Some(i8::MAX as i16)); - assert_eq!(i8::MAX.to_i32(), Some(i8::MAX as i32)); - assert_eq!(i8::MAX.to_i64(), Some(i8::MAX as i64)); - assert_eq!(i8::MAX.to_uint(), Some(i8::MAX as uint)); - assert_eq!(i8::MAX.to_u8(), Some(i8::MAX as u8)); - assert_eq!(i8::MAX.to_u16(), Some(i8::MAX as u16)); - assert_eq!(i8::MAX.to_u32(), Some(i8::MAX as u32)); - assert_eq!(i8::MAX.to_u64(), Some(i8::MAX as u64)); + fail_unless_eq!(i8::MAX.to_int(), Some(i8::MAX as int)); + fail_unless_eq!(i8::MAX.to_i8(), Some(i8::MAX as i8)); + fail_unless_eq!(i8::MAX.to_i16(), Some(i8::MAX as i16)); + fail_unless_eq!(i8::MAX.to_i32(), Some(i8::MAX as i32)); + fail_unless_eq!(i8::MAX.to_i64(), Some(i8::MAX as i64)); + fail_unless_eq!(i8::MAX.to_uint(), Some(i8::MAX as uint)); + fail_unless_eq!(i8::MAX.to_u8(), Some(i8::MAX as u8)); + fail_unless_eq!(i8::MAX.to_u16(), Some(i8::MAX as u16)); + fail_unless_eq!(i8::MAX.to_u32(), Some(i8::MAX as u32)); + fail_unless_eq!(i8::MAX.to_u64(), Some(i8::MAX as u64)); } #[test] fn test_cast_range_i16_max() { - assert_eq!(i16::MAX.to_int(), Some(i16::MAX as int)); - assert_eq!(i16::MAX.to_i8(), None); - assert_eq!(i16::MAX.to_i16(), Some(i16::MAX as i16)); - assert_eq!(i16::MAX.to_i32(), Some(i16::MAX as i32)); - assert_eq!(i16::MAX.to_i64(), Some(i16::MAX as i64)); - assert_eq!(i16::MAX.to_uint(), Some(i16::MAX as uint)); - assert_eq!(i16::MAX.to_u8(), None); - assert_eq!(i16::MAX.to_u16(), Some(i16::MAX as u16)); - assert_eq!(i16::MAX.to_u32(), Some(i16::MAX as u32)); - assert_eq!(i16::MAX.to_u64(), Some(i16::MAX as u64)); + fail_unless_eq!(i16::MAX.to_int(), Some(i16::MAX as int)); + fail_unless_eq!(i16::MAX.to_i8(), None); + fail_unless_eq!(i16::MAX.to_i16(), Some(i16::MAX as i16)); + fail_unless_eq!(i16::MAX.to_i32(), Some(i16::MAX as i32)); + fail_unless_eq!(i16::MAX.to_i64(), Some(i16::MAX as i64)); + fail_unless_eq!(i16::MAX.to_uint(), Some(i16::MAX as uint)); + fail_unless_eq!(i16::MAX.to_u8(), None); + fail_unless_eq!(i16::MAX.to_u16(), Some(i16::MAX as u16)); + fail_unless_eq!(i16::MAX.to_u32(), Some(i16::MAX as u32)); + fail_unless_eq!(i16::MAX.to_u64(), Some(i16::MAX as u64)); } #[test] fn test_cast_range_i32_max() { - assert_eq!(i32::MAX.to_int(), Some(i32::MAX as int)); - assert_eq!(i32::MAX.to_i8(), None); - assert_eq!(i32::MAX.to_i16(), None); - assert_eq!(i32::MAX.to_i32(), Some(i32::MAX as i32)); - assert_eq!(i32::MAX.to_i64(), Some(i32::MAX as i64)); - assert_eq!(i32::MAX.to_uint(), Some(i32::MAX as uint)); - assert_eq!(i32::MAX.to_u8(), None); - assert_eq!(i32::MAX.to_u16(), None); - assert_eq!(i32::MAX.to_u32(), Some(i32::MAX as u32)); - assert_eq!(i32::MAX.to_u64(), Some(i32::MAX as u64)); + fail_unless_eq!(i32::MAX.to_int(), Some(i32::MAX as int)); + fail_unless_eq!(i32::MAX.to_i8(), None); + fail_unless_eq!(i32::MAX.to_i16(), None); + fail_unless_eq!(i32::MAX.to_i32(), Some(i32::MAX as i32)); + fail_unless_eq!(i32::MAX.to_i64(), Some(i32::MAX as i64)); + fail_unless_eq!(i32::MAX.to_uint(), Some(i32::MAX as uint)); + fail_unless_eq!(i32::MAX.to_u8(), None); + fail_unless_eq!(i32::MAX.to_u16(), None); + fail_unless_eq!(i32::MAX.to_u32(), Some(i32::MAX as u32)); + fail_unless_eq!(i32::MAX.to_u64(), Some(i32::MAX as u64)); } #[test] fn test_cast_range_i64_max() { // i64::MAX.to_int() is word-size specific - assert_eq!(i64::MAX.to_i8(), None); - assert_eq!(i64::MAX.to_i16(), None); - assert_eq!(i64::MAX.to_i32(), None); - assert_eq!(i64::MAX.to_i64(), Some(i64::MAX as i64)); + fail_unless_eq!(i64::MAX.to_i8(), None); + fail_unless_eq!(i64::MAX.to_i16(), None); + fail_unless_eq!(i64::MAX.to_i32(), None); + fail_unless_eq!(i64::MAX.to_i64(), Some(i64::MAX as i64)); // i64::MAX.to_uint() is word-size specific - assert_eq!(i64::MAX.to_u8(), None); - assert_eq!(i64::MAX.to_u16(), None); - assert_eq!(i64::MAX.to_u32(), None); - assert_eq!(i64::MAX.to_u64(), Some(i64::MAX as u64)); + fail_unless_eq!(i64::MAX.to_u8(), None); + fail_unless_eq!(i64::MAX.to_u16(), None); + fail_unless_eq!(i64::MAX.to_u32(), None); + fail_unless_eq!(i64::MAX.to_u64(), Some(i64::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(i64::MAX.to_int(), None); - assert_eq!(i64::MAX.to_uint(), None); + fail_unless_eq!(i64::MAX.to_int(), None); + fail_unless_eq!(i64::MAX.to_uint(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(i64::MAX.to_int(), Some(i64::MAX as int)); - assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as uint)); + fail_unless_eq!(i64::MAX.to_int(), Some(i64::MAX as int)); + fail_unless_eq!(i64::MAX.to_uint(), Some(i64::MAX as uint)); } check_word_size(); @@ -1355,96 +1355,96 @@ mod tests { #[test] fn test_cast_range_uint_min() { - assert_eq!(uint::MIN.to_int(), Some(uint::MIN as int)); - assert_eq!(uint::MIN.to_i8(), Some(uint::MIN as i8)); - assert_eq!(uint::MIN.to_i16(), Some(uint::MIN as i16)); - assert_eq!(uint::MIN.to_i32(), Some(uint::MIN as i32)); - assert_eq!(uint::MIN.to_i64(), Some(uint::MIN as i64)); - assert_eq!(uint::MIN.to_uint(), Some(uint::MIN as uint)); - assert_eq!(uint::MIN.to_u8(), Some(uint::MIN as u8)); - assert_eq!(uint::MIN.to_u16(), Some(uint::MIN as u16)); - assert_eq!(uint::MIN.to_u32(), Some(uint::MIN as u32)); - assert_eq!(uint::MIN.to_u64(), Some(uint::MIN as u64)); + fail_unless_eq!(uint::MIN.to_int(), Some(uint::MIN as int)); + fail_unless_eq!(uint::MIN.to_i8(), Some(uint::MIN as i8)); + fail_unless_eq!(uint::MIN.to_i16(), Some(uint::MIN as i16)); + fail_unless_eq!(uint::MIN.to_i32(), Some(uint::MIN as i32)); + fail_unless_eq!(uint::MIN.to_i64(), Some(uint::MIN as i64)); + fail_unless_eq!(uint::MIN.to_uint(), Some(uint::MIN as uint)); + fail_unless_eq!(uint::MIN.to_u8(), Some(uint::MIN as u8)); + fail_unless_eq!(uint::MIN.to_u16(), Some(uint::MIN as u16)); + fail_unless_eq!(uint::MIN.to_u32(), Some(uint::MIN as u32)); + fail_unless_eq!(uint::MIN.to_u64(), Some(uint::MIN as u64)); } #[test] fn test_cast_range_u8_min() { - assert_eq!(u8::MIN.to_int(), Some(u8::MIN as int)); - assert_eq!(u8::MIN.to_i8(), Some(u8::MIN as i8)); - assert_eq!(u8::MIN.to_i16(), Some(u8::MIN as i16)); - assert_eq!(u8::MIN.to_i32(), Some(u8::MIN as i32)); - assert_eq!(u8::MIN.to_i64(), Some(u8::MIN as i64)); - assert_eq!(u8::MIN.to_uint(), Some(u8::MIN as uint)); - assert_eq!(u8::MIN.to_u8(), Some(u8::MIN as u8)); - assert_eq!(u8::MIN.to_u16(), Some(u8::MIN as u16)); - assert_eq!(u8::MIN.to_u32(), Some(u8::MIN as u32)); - assert_eq!(u8::MIN.to_u64(), Some(u8::MIN as u64)); + fail_unless_eq!(u8::MIN.to_int(), Some(u8::MIN as int)); + fail_unless_eq!(u8::MIN.to_i8(), Some(u8::MIN as i8)); + fail_unless_eq!(u8::MIN.to_i16(), Some(u8::MIN as i16)); + fail_unless_eq!(u8::MIN.to_i32(), Some(u8::MIN as i32)); + fail_unless_eq!(u8::MIN.to_i64(), Some(u8::MIN as i64)); + fail_unless_eq!(u8::MIN.to_uint(), Some(u8::MIN as uint)); + fail_unless_eq!(u8::MIN.to_u8(), Some(u8::MIN as u8)); + fail_unless_eq!(u8::MIN.to_u16(), Some(u8::MIN as u16)); + fail_unless_eq!(u8::MIN.to_u32(), Some(u8::MIN as u32)); + fail_unless_eq!(u8::MIN.to_u64(), Some(u8::MIN as u64)); } #[test] fn test_cast_range_u16_min() { - assert_eq!(u16::MIN.to_int(), Some(u16::MIN as int)); - assert_eq!(u16::MIN.to_i8(), Some(u16::MIN as i8)); - assert_eq!(u16::MIN.to_i16(), Some(u16::MIN as i16)); - assert_eq!(u16::MIN.to_i32(), Some(u16::MIN as i32)); - assert_eq!(u16::MIN.to_i64(), Some(u16::MIN as i64)); - assert_eq!(u16::MIN.to_uint(), Some(u16::MIN as uint)); - assert_eq!(u16::MIN.to_u8(), Some(u16::MIN as u8)); - assert_eq!(u16::MIN.to_u16(), Some(u16::MIN as u16)); - assert_eq!(u16::MIN.to_u32(), Some(u16::MIN as u32)); - assert_eq!(u16::MIN.to_u64(), Some(u16::MIN as u64)); + fail_unless_eq!(u16::MIN.to_int(), Some(u16::MIN as int)); + fail_unless_eq!(u16::MIN.to_i8(), Some(u16::MIN as i8)); + fail_unless_eq!(u16::MIN.to_i16(), Some(u16::MIN as i16)); + fail_unless_eq!(u16::MIN.to_i32(), Some(u16::MIN as i32)); + fail_unless_eq!(u16::MIN.to_i64(), Some(u16::MIN as i64)); + fail_unless_eq!(u16::MIN.to_uint(), Some(u16::MIN as uint)); + fail_unless_eq!(u16::MIN.to_u8(), Some(u16::MIN as u8)); + fail_unless_eq!(u16::MIN.to_u16(), Some(u16::MIN as u16)); + fail_unless_eq!(u16::MIN.to_u32(), Some(u16::MIN as u32)); + fail_unless_eq!(u16::MIN.to_u64(), Some(u16::MIN as u64)); } #[test] fn test_cast_range_u32_min() { - assert_eq!(u32::MIN.to_int(), Some(u32::MIN as int)); - assert_eq!(u32::MIN.to_i8(), Some(u32::MIN as i8)); - assert_eq!(u32::MIN.to_i16(), Some(u32::MIN as i16)); - assert_eq!(u32::MIN.to_i32(), Some(u32::MIN as i32)); - assert_eq!(u32::MIN.to_i64(), Some(u32::MIN as i64)); - assert_eq!(u32::MIN.to_uint(), Some(u32::MIN as uint)); - assert_eq!(u32::MIN.to_u8(), Some(u32::MIN as u8)); - assert_eq!(u32::MIN.to_u16(), Some(u32::MIN as u16)); - assert_eq!(u32::MIN.to_u32(), Some(u32::MIN as u32)); - assert_eq!(u32::MIN.to_u64(), Some(u32::MIN as u64)); + fail_unless_eq!(u32::MIN.to_int(), Some(u32::MIN as int)); + fail_unless_eq!(u32::MIN.to_i8(), Some(u32::MIN as i8)); + fail_unless_eq!(u32::MIN.to_i16(), Some(u32::MIN as i16)); + fail_unless_eq!(u32::MIN.to_i32(), Some(u32::MIN as i32)); + fail_unless_eq!(u32::MIN.to_i64(), Some(u32::MIN as i64)); + fail_unless_eq!(u32::MIN.to_uint(), Some(u32::MIN as uint)); + fail_unless_eq!(u32::MIN.to_u8(), Some(u32::MIN as u8)); + fail_unless_eq!(u32::MIN.to_u16(), Some(u32::MIN as u16)); + fail_unless_eq!(u32::MIN.to_u32(), Some(u32::MIN as u32)); + fail_unless_eq!(u32::MIN.to_u64(), Some(u32::MIN as u64)); } #[test] fn test_cast_range_u64_min() { - assert_eq!(u64::MIN.to_int(), Some(u64::MIN as int)); - assert_eq!(u64::MIN.to_i8(), Some(u64::MIN as i8)); - assert_eq!(u64::MIN.to_i16(), Some(u64::MIN as i16)); - assert_eq!(u64::MIN.to_i32(), Some(u64::MIN as i32)); - assert_eq!(u64::MIN.to_i64(), Some(u64::MIN as i64)); - assert_eq!(u64::MIN.to_uint(), Some(u64::MIN as uint)); - assert_eq!(u64::MIN.to_u8(), Some(u64::MIN as u8)); - assert_eq!(u64::MIN.to_u16(), Some(u64::MIN as u16)); - assert_eq!(u64::MIN.to_u32(), Some(u64::MIN as u32)); - assert_eq!(u64::MIN.to_u64(), Some(u64::MIN as u64)); + fail_unless_eq!(u64::MIN.to_int(), Some(u64::MIN as int)); + fail_unless_eq!(u64::MIN.to_i8(), Some(u64::MIN as i8)); + fail_unless_eq!(u64::MIN.to_i16(), Some(u64::MIN as i16)); + fail_unless_eq!(u64::MIN.to_i32(), Some(u64::MIN as i32)); + fail_unless_eq!(u64::MIN.to_i64(), Some(u64::MIN as i64)); + fail_unless_eq!(u64::MIN.to_uint(), Some(u64::MIN as uint)); + fail_unless_eq!(u64::MIN.to_u8(), Some(u64::MIN as u8)); + fail_unless_eq!(u64::MIN.to_u16(), Some(u64::MIN as u16)); + fail_unless_eq!(u64::MIN.to_u32(), Some(u64::MIN as u32)); + fail_unless_eq!(u64::MIN.to_u64(), Some(u64::MIN as u64)); } #[test] fn test_cast_range_uint_max() { - assert_eq!(uint::MAX.to_int(), None); - assert_eq!(uint::MAX.to_i8(), None); - assert_eq!(uint::MAX.to_i16(), None); - assert_eq!(uint::MAX.to_i32(), None); + fail_unless_eq!(uint::MAX.to_int(), None); + fail_unless_eq!(uint::MAX.to_i8(), None); + fail_unless_eq!(uint::MAX.to_i16(), None); + fail_unless_eq!(uint::MAX.to_i32(), None); // uint::MAX.to_i64() is word-size specific - assert_eq!(uint::MAX.to_u8(), None); - assert_eq!(uint::MAX.to_u16(), None); + fail_unless_eq!(uint::MAX.to_u8(), None); + fail_unless_eq!(uint::MAX.to_u16(), None); // uint::MAX.to_u32() is word-size specific - assert_eq!(uint::MAX.to_u64(), Some(uint::MAX as u64)); + fail_unless_eq!(uint::MAX.to_u64(), Some(uint::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(uint::MAX.to_u32(), Some(uint::MAX as u32)); - assert_eq!(uint::MAX.to_i64(), Some(uint::MAX as i64)); + fail_unless_eq!(uint::MAX.to_u32(), Some(uint::MAX as u32)); + fail_unless_eq!(uint::MAX.to_i64(), Some(uint::MAX as i64)); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(uint::MAX.to_u32(), None); - assert_eq!(uint::MAX.to_i64(), None); + fail_unless_eq!(uint::MAX.to_u32(), None); + fail_unless_eq!(uint::MAX.to_i64(), None); } check_word_size(); @@ -1452,53 +1452,53 @@ mod tests { #[test] fn test_cast_range_u8_max() { - assert_eq!(u8::MAX.to_int(), Some(u8::MAX as int)); - assert_eq!(u8::MAX.to_i8(), None); - assert_eq!(u8::MAX.to_i16(), Some(u8::MAX as i16)); - assert_eq!(u8::MAX.to_i32(), Some(u8::MAX as i32)); - assert_eq!(u8::MAX.to_i64(), Some(u8::MAX as i64)); - assert_eq!(u8::MAX.to_uint(), Some(u8::MAX as uint)); - assert_eq!(u8::MAX.to_u8(), Some(u8::MAX as u8)); - assert_eq!(u8::MAX.to_u16(), Some(u8::MAX as u16)); - assert_eq!(u8::MAX.to_u32(), Some(u8::MAX as u32)); - assert_eq!(u8::MAX.to_u64(), Some(u8::MAX as u64)); + fail_unless_eq!(u8::MAX.to_int(), Some(u8::MAX as int)); + fail_unless_eq!(u8::MAX.to_i8(), None); + fail_unless_eq!(u8::MAX.to_i16(), Some(u8::MAX as i16)); + fail_unless_eq!(u8::MAX.to_i32(), Some(u8::MAX as i32)); + fail_unless_eq!(u8::MAX.to_i64(), Some(u8::MAX as i64)); + fail_unless_eq!(u8::MAX.to_uint(), Some(u8::MAX as uint)); + fail_unless_eq!(u8::MAX.to_u8(), Some(u8::MAX as u8)); + fail_unless_eq!(u8::MAX.to_u16(), Some(u8::MAX as u16)); + fail_unless_eq!(u8::MAX.to_u32(), Some(u8::MAX as u32)); + fail_unless_eq!(u8::MAX.to_u64(), Some(u8::MAX as u64)); } #[test] fn test_cast_range_u16_max() { - assert_eq!(u16::MAX.to_int(), Some(u16::MAX as int)); - assert_eq!(u16::MAX.to_i8(), None); - assert_eq!(u16::MAX.to_i16(), None); - assert_eq!(u16::MAX.to_i32(), Some(u16::MAX as i32)); - assert_eq!(u16::MAX.to_i64(), Some(u16::MAX as i64)); - assert_eq!(u16::MAX.to_uint(), Some(u16::MAX as uint)); - assert_eq!(u16::MAX.to_u8(), None); - assert_eq!(u16::MAX.to_u16(), Some(u16::MAX as u16)); - assert_eq!(u16::MAX.to_u32(), Some(u16::MAX as u32)); - assert_eq!(u16::MAX.to_u64(), Some(u16::MAX as u64)); + fail_unless_eq!(u16::MAX.to_int(), Some(u16::MAX as int)); + fail_unless_eq!(u16::MAX.to_i8(), None); + fail_unless_eq!(u16::MAX.to_i16(), None); + fail_unless_eq!(u16::MAX.to_i32(), Some(u16::MAX as i32)); + fail_unless_eq!(u16::MAX.to_i64(), Some(u16::MAX as i64)); + fail_unless_eq!(u16::MAX.to_uint(), Some(u16::MAX as uint)); + fail_unless_eq!(u16::MAX.to_u8(), None); + fail_unless_eq!(u16::MAX.to_u16(), Some(u16::MAX as u16)); + fail_unless_eq!(u16::MAX.to_u32(), Some(u16::MAX as u32)); + fail_unless_eq!(u16::MAX.to_u64(), Some(u16::MAX as u64)); } #[test] fn test_cast_range_u32_max() { // u32::MAX.to_int() is word-size specific - assert_eq!(u32::MAX.to_i8(), None); - assert_eq!(u32::MAX.to_i16(), None); - assert_eq!(u32::MAX.to_i32(), None); - assert_eq!(u32::MAX.to_i64(), Some(u32::MAX as i64)); - assert_eq!(u32::MAX.to_uint(), Some(u32::MAX as uint)); - assert_eq!(u32::MAX.to_u8(), None); - assert_eq!(u32::MAX.to_u16(), None); - assert_eq!(u32::MAX.to_u32(), Some(u32::MAX as u32)); - assert_eq!(u32::MAX.to_u64(), Some(u32::MAX as u64)); + fail_unless_eq!(u32::MAX.to_i8(), None); + fail_unless_eq!(u32::MAX.to_i16(), None); + fail_unless_eq!(u32::MAX.to_i32(), None); + fail_unless_eq!(u32::MAX.to_i64(), Some(u32::MAX as i64)); + fail_unless_eq!(u32::MAX.to_uint(), Some(u32::MAX as uint)); + fail_unless_eq!(u32::MAX.to_u8(), None); + fail_unless_eq!(u32::MAX.to_u16(), None); + fail_unless_eq!(u32::MAX.to_u32(), Some(u32::MAX as u32)); + fail_unless_eq!(u32::MAX.to_u64(), Some(u32::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(u32::MAX.to_int(), None); + fail_unless_eq!(u32::MAX.to_int(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(u32::MAX.to_int(), Some(u32::MAX as int)); + fail_unless_eq!(u32::MAX.to_int(), Some(u32::MAX as int)); } check_word_size(); @@ -1506,25 +1506,25 @@ mod tests { #[test] fn test_cast_range_u64_max() { - assert_eq!(u64::MAX.to_int(), None); - assert_eq!(u64::MAX.to_i8(), None); - assert_eq!(u64::MAX.to_i16(), None); - assert_eq!(u64::MAX.to_i32(), None); - assert_eq!(u64::MAX.to_i64(), None); + fail_unless_eq!(u64::MAX.to_int(), None); + fail_unless_eq!(u64::MAX.to_i8(), None); + fail_unless_eq!(u64::MAX.to_i16(), None); + fail_unless_eq!(u64::MAX.to_i32(), None); + fail_unless_eq!(u64::MAX.to_i64(), None); // u64::MAX.to_uint() is word-size specific - assert_eq!(u64::MAX.to_u8(), None); - assert_eq!(u64::MAX.to_u16(), None); - assert_eq!(u64::MAX.to_u32(), None); - assert_eq!(u64::MAX.to_u64(), Some(u64::MAX as u64)); + fail_unless_eq!(u64::MAX.to_u8(), None); + fail_unless_eq!(u64::MAX.to_u16(), None); + fail_unless_eq!(u64::MAX.to_u32(), None); + fail_unless_eq!(u64::MAX.to_u64(), Some(u64::MAX as u64)); #[cfg(target_word_size = "32")] fn check_word_size() { - assert_eq!(u64::MAX.to_uint(), None); + fail_unless_eq!(u64::MAX.to_uint(), None); } #[cfg(target_word_size = "64")] fn check_word_size() { - assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as uint)); + fail_unless_eq!(u64::MAX.to_uint(), Some(u64::MAX as uint)); } check_word_size(); @@ -1533,88 +1533,88 @@ mod tests { #[test] fn test_saturating_add_uint() { use uint::MAX; - assert_eq!(3u.saturating_add(5u), 8u); - assert_eq!(3u.saturating_add(MAX-1), MAX); - assert_eq!(MAX.saturating_add(MAX), MAX); - assert_eq!((MAX-2).saturating_add(1), MAX-1); + fail_unless_eq!(3u.saturating_add(5u), 8u); + fail_unless_eq!(3u.saturating_add(MAX-1), MAX); + fail_unless_eq!(MAX.saturating_add(MAX), MAX); + fail_unless_eq!((MAX-2).saturating_add(1), MAX-1); } #[test] fn test_saturating_sub_uint() { use uint::MAX; - assert_eq!(5u.saturating_sub(3u), 2u); - assert_eq!(3u.saturating_sub(5u), 0u); - assert_eq!(0u.saturating_sub(1u), 0u); - assert_eq!((MAX-1).saturating_sub(MAX), 0); + fail_unless_eq!(5u.saturating_sub(3u), 2u); + fail_unless_eq!(3u.saturating_sub(5u), 0u); + fail_unless_eq!(0u.saturating_sub(1u), 0u); + fail_unless_eq!((MAX-1).saturating_sub(MAX), 0); } #[test] fn test_saturating_add_int() { use int::{MIN,MAX}; - assert_eq!(3i.saturating_add(5i), 8i); - assert_eq!(3i.saturating_add(MAX-1), MAX); - assert_eq!(MAX.saturating_add(MAX), MAX); - assert_eq!((MAX-2).saturating_add(1), MAX-1); - assert_eq!(3i.saturating_add(-5i), -2i); - assert_eq!(MIN.saturating_add(-1i), MIN); - assert_eq!((-2i).saturating_add(-MAX), MIN); + fail_unless_eq!(3i.saturating_add(5i), 8i); + fail_unless_eq!(3i.saturating_add(MAX-1), MAX); + fail_unless_eq!(MAX.saturating_add(MAX), MAX); + fail_unless_eq!((MAX-2).saturating_add(1), MAX-1); + fail_unless_eq!(3i.saturating_add(-5i), -2i); + fail_unless_eq!(MIN.saturating_add(-1i), MIN); + fail_unless_eq!((-2i).saturating_add(-MAX), MIN); } #[test] fn test_saturating_sub_int() { use int::{MIN,MAX}; - assert_eq!(3i.saturating_sub(5i), -2i); - assert_eq!(MIN.saturating_sub(1i), MIN); - assert_eq!((-2i).saturating_sub(MAX), MIN); - assert_eq!(3i.saturating_sub(-5i), 8i); - assert_eq!(3i.saturating_sub(-(MAX-1)), MAX); - assert_eq!(MAX.saturating_sub(-MAX), MAX); - assert_eq!((MAX-2).saturating_sub(-1), MAX-1); + fail_unless_eq!(3i.saturating_sub(5i), -2i); + fail_unless_eq!(MIN.saturating_sub(1i), MIN); + fail_unless_eq!((-2i).saturating_sub(MAX), MIN); + fail_unless_eq!(3i.saturating_sub(-5i), 8i); + fail_unless_eq!(3i.saturating_sub(-(MAX-1)), MAX); + fail_unless_eq!(MAX.saturating_sub(-MAX), MAX); + fail_unless_eq!((MAX-2).saturating_sub(-1), MAX-1); } #[test] fn test_checked_add() { let five_less = uint::MAX - 5; - assert_eq!(five_less.checked_add(&0), Some(uint::MAX - 5)); - assert_eq!(five_less.checked_add(&1), Some(uint::MAX - 4)); - assert_eq!(five_less.checked_add(&2), Some(uint::MAX - 3)); - assert_eq!(five_less.checked_add(&3), Some(uint::MAX - 2)); - assert_eq!(five_less.checked_add(&4), Some(uint::MAX - 1)); - assert_eq!(five_less.checked_add(&5), Some(uint::MAX)); - assert_eq!(five_less.checked_add(&6), None); - assert_eq!(five_less.checked_add(&7), None); + fail_unless_eq!(five_less.checked_add(&0), Some(uint::MAX - 5)); + fail_unless_eq!(five_less.checked_add(&1), Some(uint::MAX - 4)); + fail_unless_eq!(five_less.checked_add(&2), Some(uint::MAX - 3)); + fail_unless_eq!(five_less.checked_add(&3), Some(uint::MAX - 2)); + fail_unless_eq!(five_less.checked_add(&4), Some(uint::MAX - 1)); + fail_unless_eq!(five_less.checked_add(&5), Some(uint::MAX)); + fail_unless_eq!(five_less.checked_add(&6), None); + fail_unless_eq!(five_less.checked_add(&7), None); } #[test] fn test_checked_sub() { - assert_eq!(5u.checked_sub(&0), Some(5)); - assert_eq!(5u.checked_sub(&1), Some(4)); - assert_eq!(5u.checked_sub(&2), Some(3)); - assert_eq!(5u.checked_sub(&3), Some(2)); - assert_eq!(5u.checked_sub(&4), Some(1)); - assert_eq!(5u.checked_sub(&5), Some(0)); - assert_eq!(5u.checked_sub(&6), None); - assert_eq!(5u.checked_sub(&7), None); + fail_unless_eq!(5u.checked_sub(&0), Some(5)); + fail_unless_eq!(5u.checked_sub(&1), Some(4)); + fail_unless_eq!(5u.checked_sub(&2), Some(3)); + fail_unless_eq!(5u.checked_sub(&3), Some(2)); + fail_unless_eq!(5u.checked_sub(&4), Some(1)); + fail_unless_eq!(5u.checked_sub(&5), Some(0)); + fail_unless_eq!(5u.checked_sub(&6), None); + fail_unless_eq!(5u.checked_sub(&7), None); } #[test] fn test_checked_mul() { let third = uint::MAX / 3; - assert_eq!(third.checked_mul(&0), Some(0)); - assert_eq!(third.checked_mul(&1), Some(third)); - assert_eq!(third.checked_mul(&2), Some(third * 2)); - assert_eq!(third.checked_mul(&3), Some(third * 3)); - assert_eq!(third.checked_mul(&4), None); + fail_unless_eq!(third.checked_mul(&0), Some(0)); + fail_unless_eq!(third.checked_mul(&1), Some(third)); + fail_unless_eq!(third.checked_mul(&2), Some(third * 2)); + fail_unless_eq!(third.checked_mul(&3), Some(third * 3)); + fail_unless_eq!(third.checked_mul(&4), None); } macro_rules! test_next_power_of_two( ($test_name:ident, $T:ident) => ( fn $test_name() { #[test]; - assert_eq!(next_power_of_two::<$T>(0), 0); + fail_unless_eq!(next_power_of_two::<$T>(0), 0); let mut next_power = 1; for i in range::<$T>(1, 40) { - assert_eq!(next_power_of_two(i), next_power); + fail_unless_eq!(next_power_of_two(i), next_power); if i == next_power { next_power *= 2 } } } @@ -1631,15 +1631,15 @@ mod tests { ($test_name:ident, $T:ident) => ( fn $test_name() { #[test]; - assert_eq!(checked_next_power_of_two::<$T>(0), None); + fail_unless_eq!(checked_next_power_of_two::<$T>(0), None); let mut next_power = 1; for i in range::<$T>(1, 40) { - assert_eq!(checked_next_power_of_two(i), Some(next_power)); + fail_unless_eq!(checked_next_power_of_two(i), Some(next_power)); if i == next_power { next_power *= 2 } } fail_unless!(checked_next_power_of_two::<$T>($T::MAX / 2).is_some()); - assert_eq!(checked_next_power_of_two::<$T>($T::MAX - 1), None); - assert_eq!(checked_next_power_of_two::<$T>($T::MAX), None); + fail_unless_eq!(checked_next_power_of_two::<$T>($T::MAX - 1), None); + fail_unless_eq!(checked_next_power_of_two::<$T>($T::MAX), None); } ) ) @@ -1666,34 +1666,34 @@ mod tests { #[test] fn test_to_primitive() { let value = Value { x: 5 }; - assert_eq!(value.to_int(), Some(5)); - assert_eq!(value.to_i8(), Some(5)); - assert_eq!(value.to_i16(), Some(5)); - assert_eq!(value.to_i32(), Some(5)); - assert_eq!(value.to_i64(), Some(5)); - assert_eq!(value.to_uint(), Some(5)); - assert_eq!(value.to_u8(), Some(5)); - assert_eq!(value.to_u16(), Some(5)); - assert_eq!(value.to_u32(), Some(5)); - assert_eq!(value.to_u64(), Some(5)); - assert_eq!(value.to_f32(), Some(5f32)); - assert_eq!(value.to_f64(), Some(5f64)); + fail_unless_eq!(value.to_int(), Some(5)); + fail_unless_eq!(value.to_i8(), Some(5)); + fail_unless_eq!(value.to_i16(), Some(5)); + fail_unless_eq!(value.to_i32(), Some(5)); + fail_unless_eq!(value.to_i64(), Some(5)); + fail_unless_eq!(value.to_uint(), Some(5)); + fail_unless_eq!(value.to_u8(), Some(5)); + fail_unless_eq!(value.to_u16(), Some(5)); + fail_unless_eq!(value.to_u32(), Some(5)); + fail_unless_eq!(value.to_u64(), Some(5)); + fail_unless_eq!(value.to_f32(), Some(5f32)); + fail_unless_eq!(value.to_f64(), Some(5f64)); } #[test] fn test_from_primitive() { - assert_eq!(from_int(5), Some(Value { x: 5 })); - assert_eq!(from_i8(5), Some(Value { x: 5 })); - assert_eq!(from_i16(5), Some(Value { x: 5 })); - assert_eq!(from_i32(5), Some(Value { x: 5 })); - assert_eq!(from_i64(5), Some(Value { x: 5 })); - assert_eq!(from_uint(5), Some(Value { x: 5 })); - assert_eq!(from_u8(5), Some(Value { x: 5 })); - assert_eq!(from_u16(5), Some(Value { x: 5 })); - assert_eq!(from_u32(5), Some(Value { x: 5 })); - assert_eq!(from_u64(5), Some(Value { x: 5 })); - assert_eq!(from_f32(5f32), Some(Value { x: 5 })); - assert_eq!(from_f64(5f64), Some(Value { x: 5 })); + fail_unless_eq!(from_int(5), Some(Value { x: 5 })); + fail_unless_eq!(from_i8(5), Some(Value { x: 5 })); + fail_unless_eq!(from_i16(5), Some(Value { x: 5 })); + fail_unless_eq!(from_i32(5), Some(Value { x: 5 })); + fail_unless_eq!(from_i64(5), Some(Value { x: 5 })); + fail_unless_eq!(from_uint(5), Some(Value { x: 5 })); + fail_unless_eq!(from_u8(5), Some(Value { x: 5 })); + fail_unless_eq!(from_u16(5), Some(Value { x: 5 })); + fail_unless_eq!(from_u32(5), Some(Value { x: 5 })); + fail_unless_eq!(from_u64(5), Some(Value { x: 5 })); + fail_unless_eq!(from_f32(5f32), Some(Value { x: 5 })); + fail_unless_eq!(from_f64(5f64), Some(Value { x: 5 })); } #[test] @@ -1704,8 +1704,8 @@ mod tests { macro_rules! assert_pow( (($num:expr, $exp:expr) => $expected:expr) => {{ let result = pow($num, $exp); - assert_eq!(result, $expected); - assert_eq!(result, naive_pow($num, $exp)); + fail_unless_eq!(result, $expected); + fail_unless_eq!(result, naive_pow($num, $exp)); }} ) assert_pow!((3, 0 ) => 1); diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index cd07024d280d0..aff4e8a03709e 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -750,15 +750,15 @@ mod test { fn from_str_ignore_underscores() { let s : Option = from_str_common("__1__", 2, false, false, false, ExpNone, false, true); - assert_eq!(s, Some(1u8)); + fail_unless_eq!(s, Some(1u8)); let n : Option = from_str_common("__1__", 2, false, false, false, ExpNone, false, false); - assert_eq!(n, None); + fail_unless_eq!(n, None); let f : Option = from_str_common("_1_._5_e_1_", 10, false, true, false, ExpDec, false, true); - assert_eq!(f, Some(1.5e1f32)); + fail_unless_eq!(f, Some(1.5e1f32)); } #[test] @@ -768,24 +768,24 @@ mod test { // detected. let n : Option = from_str_common("111111111", 2, false, false, false, ExpNone, false, false); - assert_eq!(n, None); + fail_unless_eq!(n, None); } #[test] fn from_str_issue7588() { let u : Option = from_str_common("1000", 10, false, false, false, ExpNone, false, false); - assert_eq!(u, None); + fail_unless_eq!(u, None); let s : Option = from_str_common("80000", 10, false, false, false, ExpNone, false, false); - assert_eq!(s, None); + fail_unless_eq!(s, None); let f : Option = from_str_common( "10000000000000000000000000000000000000000", 10, false, false, false, ExpNone, false, false); - assert_eq!(f, NumStrConv::inf()) + fail_unless_eq!(f, NumStrConv::inf()) let fe : Option = from_str_common("1e40", 10, false, false, false, ExpDec, false, false); - assert_eq!(fe, NumStrConv::inf()) + fail_unless_eq!(fe, NumStrConv::inf()) } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 5d45aa0f335e3..5b9bf43b95bb0 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -247,7 +247,7 @@ mod tests { fn test_overflows() { fail_unless!(MAX > 0); fail_unless!(MIN <= 0); - assert_eq!(MIN + MAX + 1, 0); + fail_unless_eq!(MIN + MAX + 1, 0); } #[test] @@ -257,46 +257,46 @@ mod tests { #[test] fn test_bitwise() { - assert_eq!(0b1110 as $T, (0b1100 as $T).bitor(&(0b1010 as $T))); - assert_eq!(0b1000 as $T, (0b1100 as $T).bitand(&(0b1010 as $T))); - assert_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T))); - assert_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T))); - assert_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T))); - assert_eq!(MAX - (0b1011 as $T), (0b1011 as $T).not()); + fail_unless_eq!(0b1110 as $T, (0b1100 as $T).bitor(&(0b1010 as $T))); + fail_unless_eq!(0b1000 as $T, (0b1100 as $T).bitand(&(0b1010 as $T))); + fail_unless_eq!(0b0110 as $T, (0b1100 as $T).bitxor(&(0b1010 as $T))); + fail_unless_eq!(0b1110 as $T, (0b0111 as $T).shl(&(1 as $T))); + fail_unless_eq!(0b0111 as $T, (0b1110 as $T).shr(&(1 as $T))); + fail_unless_eq!(MAX - (0b1011 as $T), (0b1011 as $T).not()); } #[test] fn test_count_ones() { - assert_eq!((0b0101100 as $T).count_ones(), 3); - assert_eq!((0b0100001 as $T).count_ones(), 2); - assert_eq!((0b1111001 as $T).count_ones(), 5); + fail_unless_eq!((0b0101100 as $T).count_ones(), 3); + fail_unless_eq!((0b0100001 as $T).count_ones(), 2); + fail_unless_eq!((0b1111001 as $T).count_ones(), 5); } #[test] fn test_count_zeros() { - assert_eq!((0b0101100 as $T).count_zeros(), BITS as $T - 3); - assert_eq!((0b0100001 as $T).count_zeros(), BITS as $T - 2); - assert_eq!((0b1111001 as $T).count_zeros(), BITS as $T - 5); + fail_unless_eq!((0b0101100 as $T).count_zeros(), BITS as $T - 3); + fail_unless_eq!((0b0100001 as $T).count_zeros(), BITS as $T - 2); + fail_unless_eq!((0b1111001 as $T).count_zeros(), BITS as $T - 5); } #[test] pub fn test_to_str() { - assert_eq!((0 as $T).to_str_radix(10u), ~"0"); - assert_eq!((1 as $T).to_str_radix(10u), ~"1"); - assert_eq!((2 as $T).to_str_radix(10u), ~"2"); - assert_eq!((11 as $T).to_str_radix(10u), ~"11"); - assert_eq!((11 as $T).to_str_radix(16u), ~"b"); - assert_eq!((255 as $T).to_str_radix(16u), ~"ff"); - assert_eq!((0xff as $T).to_str_radix(10u), ~"255"); + fail_unless_eq!((0 as $T).to_str_radix(10u), ~"0"); + fail_unless_eq!((1 as $T).to_str_radix(10u), ~"1"); + fail_unless_eq!((2 as $T).to_str_radix(10u), ~"2"); + fail_unless_eq!((11 as $T).to_str_radix(10u), ~"11"); + fail_unless_eq!((11 as $T).to_str_radix(16u), ~"b"); + fail_unless_eq!((255 as $T).to_str_radix(16u), ~"ff"); + fail_unless_eq!((0xff as $T).to_str_radix(10u), ~"255"); } #[test] pub fn test_from_str() { - assert_eq!(from_str::<$T>("0"), Some(0u as $T)); - assert_eq!(from_str::<$T>("3"), Some(3u as $T)); - assert_eq!(from_str::<$T>("10"), Some(10u as $T)); - assert_eq!(from_str::("123456789"), Some(123456789 as u32)); - assert_eq!(from_str::<$T>("00100"), Some(100u as $T)); + fail_unless_eq!(from_str::<$T>("0"), Some(0u as $T)); + fail_unless_eq!(from_str::<$T>("3"), Some(3u as $T)); + fail_unless_eq!(from_str::<$T>("10"), Some(10u as $T)); + fail_unless_eq!(from_str::("123456789"), Some(123456789 as u32)); + fail_unless_eq!(from_str::<$T>("00100"), Some(100u as $T)); fail_unless!(from_str::<$T>("").is_none()); fail_unless!(from_str::<$T>(" ").is_none()); @@ -306,12 +306,12 @@ mod tests { #[test] pub fn test_parse_bytes() { use str::StrSlice; - assert_eq!(parse_bytes("123".as_bytes(), 10u), Some(123u as $T)); - assert_eq!(parse_bytes("1001".as_bytes(), 2u), Some(9u as $T)); - assert_eq!(parse_bytes("123".as_bytes(), 8u), Some(83u as $T)); - assert_eq!(u16::parse_bytes("123".as_bytes(), 16u), Some(291u as u16)); - assert_eq!(u16::parse_bytes("ffff".as_bytes(), 16u), Some(65535u as u16)); - assert_eq!(parse_bytes("z".as_bytes(), 36u), Some(35u as $T)); + fail_unless_eq!(parse_bytes("123".as_bytes(), 10u), Some(123u as $T)); + fail_unless_eq!(parse_bytes("1001".as_bytes(), 2u), Some(9u as $T)); + fail_unless_eq!(parse_bytes("123".as_bytes(), 8u), Some(83u as $T)); + fail_unless_eq!(u16::parse_bytes("123".as_bytes(), 16u), Some(291u as u16)); + fail_unless_eq!(u16::parse_bytes("ffff".as_bytes(), 16u), Some(65535u as u16)); + fail_unless_eq!(parse_bytes("z".as_bytes(), 36u), Some(35u as $T)); fail_unless!(parse_bytes("Z".as_bytes(), 10u).is_none()); fail_unless!(parse_bytes("_".as_bytes(), 2u).is_none()); @@ -320,62 +320,62 @@ mod tests { #[test] fn test_uint_to_str_overflow() { let mut u8_val: u8 = 255_u8; - assert_eq!(u8_val.to_str(), ~"255"); + fail_unless_eq!(u8_val.to_str(), ~"255"); u8_val += 1 as u8; - assert_eq!(u8_val.to_str(), ~"0"); + fail_unless_eq!(u8_val.to_str(), ~"0"); let mut u16_val: u16 = 65_535_u16; - assert_eq!(u16_val.to_str(), ~"65535"); + fail_unless_eq!(u16_val.to_str(), ~"65535"); u16_val += 1 as u16; - assert_eq!(u16_val.to_str(), ~"0"); + fail_unless_eq!(u16_val.to_str(), ~"0"); let mut u32_val: u32 = 4_294_967_295_u32; - assert_eq!(u32_val.to_str(), ~"4294967295"); + fail_unless_eq!(u32_val.to_str(), ~"4294967295"); u32_val += 1 as u32; - assert_eq!(u32_val.to_str(), ~"0"); + fail_unless_eq!(u32_val.to_str(), ~"0"); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert_eq!(u64_val.to_str(), ~"18446744073709551615"); + fail_unless_eq!(u64_val.to_str(), ~"18446744073709551615"); u64_val += 1 as u64; - assert_eq!(u64_val.to_str(), ~"0"); + fail_unless_eq!(u64_val.to_str(), ~"0"); } #[test] fn test_uint_from_str_overflow() { let mut u8_val: u8 = 255_u8; - assert_eq!(from_str::("255"), Some(u8_val)); + fail_unless_eq!(from_str::("255"), Some(u8_val)); fail_unless!(from_str::("256").is_none()); u8_val += 1 as u8; - assert_eq!(from_str::("0"), Some(u8_val)); + fail_unless_eq!(from_str::("0"), Some(u8_val)); fail_unless!(from_str::("-1").is_none()); let mut u16_val: u16 = 65_535_u16; - assert_eq!(from_str::("65535"), Some(u16_val)); + fail_unless_eq!(from_str::("65535"), Some(u16_val)); fail_unless!(from_str::("65536").is_none()); u16_val += 1 as u16; - assert_eq!(from_str::("0"), Some(u16_val)); + fail_unless_eq!(from_str::("0"), Some(u16_val)); fail_unless!(from_str::("-1").is_none()); let mut u32_val: u32 = 4_294_967_295_u32; - assert_eq!(from_str::("4294967295"), Some(u32_val)); + fail_unless_eq!(from_str::("4294967295"), Some(u32_val)); fail_unless!(from_str::("4294967296").is_none()); u32_val += 1 as u32; - assert_eq!(from_str::("0"), Some(u32_val)); + fail_unless_eq!(from_str::("0"), Some(u32_val)); fail_unless!(from_str::("-1").is_none()); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert_eq!(from_str::("18446744073709551615"), Some(u64_val)); + fail_unless_eq!(from_str::("18446744073709551615"), Some(u64_val)); fail_unless!(from_str::("18446744073709551616").is_none()); u64_val += 1 as u64; - assert_eq!(from_str::("0"), Some(u64_val)); + fail_unless_eq!(from_str::("0"), Some(u64_val)); fail_unless!(from_str::("-1").is_none()); } @@ -393,8 +393,8 @@ mod tests { #[test] fn test_unsigned_checked_div() { - assert_eq!(10u.checked_div(&2), Some(5)); - assert_eq!(5u.checked_div(&0), None); + fail_unless_eq!(10u.checked_div(&2), Some(5)); + fail_unless_eq!(5u.checked_div(&0), None); } } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 83fd360a108c5..6896f5c8d3414 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -491,7 +491,7 @@ mod tests { let opt = Some(x); let y = opt.unwrap(); let addr_y: *int = ::cast::transmute(&*y); - assert_eq!(addr_x, addr_y); + fail_unless_eq!(addr_x, addr_y); } } @@ -502,7 +502,7 @@ mod tests { let opt = Some(x); let y = opt.unwrap(); let addr_y = y.as_ptr(); - assert_eq!(addr_x, addr_y); + fail_unless_eq!(addr_x, addr_y); } #[test] @@ -534,7 +534,7 @@ mod tests { let opt = Some(x); let _y = opt.unwrap(); } - assert_eq!(i.borrow().get(), 1); + fail_unless_eq!(i.borrow().get(), 1); } #[test] @@ -545,7 +545,7 @@ mod tests { for _x in x.iter() { y2 = y.take_unwrap(); } - assert_eq!(y2, 5); + fail_unless_eq!(y2, 5); fail_unless!(y.is_none()); } @@ -559,45 +559,45 @@ mod tests { #[test] fn test_and() { let x: Option = Some(1); - assert_eq!(x.and(Some(2)), Some(2)); - assert_eq!(x.and(None::), None); + fail_unless_eq!(x.and(Some(2)), Some(2)); + fail_unless_eq!(x.and(None::), None); let x: Option = None; - assert_eq!(x.and(Some(2)), None); - assert_eq!(x.and(None::), None); + fail_unless_eq!(x.and(Some(2)), None); + fail_unless_eq!(x.and(None::), None); } #[test] fn test_and_then() { let x: Option = Some(1); - assert_eq!(x.and_then(|x| Some(x + 1)), Some(2)); - assert_eq!(x.and_then(|_| None::), None); + fail_unless_eq!(x.and_then(|x| Some(x + 1)), Some(2)); + fail_unless_eq!(x.and_then(|_| None::), None); let x: Option = None; - assert_eq!(x.and_then(|x| Some(x + 1)), None); - assert_eq!(x.and_then(|_| None::), None); + fail_unless_eq!(x.and_then(|x| Some(x + 1)), None); + fail_unless_eq!(x.and_then(|_| None::), None); } #[test] fn test_or() { let x: Option = Some(1); - assert_eq!(x.or(Some(2)), Some(1)); - assert_eq!(x.or(None), Some(1)); + fail_unless_eq!(x.or(Some(2)), Some(1)); + fail_unless_eq!(x.or(None), Some(1)); let x: Option = None; - assert_eq!(x.or(Some(2)), Some(2)); - assert_eq!(x.or(None), None); + fail_unless_eq!(x.or(Some(2)), Some(2)); + fail_unless_eq!(x.or(None), None); } #[test] fn test_or_else() { let x: Option = Some(1); - assert_eq!(x.or_else(|| Some(2)), Some(1)); - assert_eq!(x.or_else(|| None), Some(1)); + fail_unless_eq!(x.or_else(|| Some(2)), Some(1)); + fail_unless_eq!(x.or_else(|| None), Some(1)); let x: Option = None; - assert_eq!(x.or_else(|| Some(2)), Some(2)); - assert_eq!(x.or_else(|| None), None); + fail_unless_eq!(x.or_else(|| Some(2)), Some(2)); + fail_unless_eq!(x.or_else(|| None), None); } #[test] @@ -611,13 +611,13 @@ mod tests { None } }); - assert_eq!(i, 11); + fail_unless_eq!(i, 11); } #[test] fn test_unwrap() { - assert_eq!(Some(1).unwrap(), 1); - assert_eq!(Some(~"hello").unwrap(), ~"hello"); + fail_unless_eq!(Some(1).unwrap(), 1); + fail_unless_eq!(Some(~"hello").unwrap(), ~"hello"); } #[test] @@ -637,26 +637,26 @@ mod tests { #[test] fn test_unwrap_or() { let x: Option = Some(1); - assert_eq!(x.unwrap_or(2), 1); + fail_unless_eq!(x.unwrap_or(2), 1); let x: Option = None; - assert_eq!(x.unwrap_or(2), 2); + fail_unless_eq!(x.unwrap_or(2), 2); } #[test] fn test_unwrap_or_else() { let x: Option = Some(1); - assert_eq!(x.unwrap_or_else(|| 2), 1); + fail_unless_eq!(x.unwrap_or_else(|| 2), 1); let x: Option = None; - assert_eq!(x.unwrap_or_else(|| 2), 2); + fail_unless_eq!(x.unwrap_or_else(|| 2), 2); } #[test] fn test_filtered() { let some_stuff = Some(42); let modified_stuff = some_stuff.filtered(|&x| {x < 10}); - assert_eq!(some_stuff.unwrap(), 42); + fail_unless_eq!(some_stuff.unwrap(), 42); fail_unless!(modified_stuff.is_none()); } @@ -667,9 +667,9 @@ mod tests { let x = Some(val); let mut it = x.iter(); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(it.next(), Some(&val)); - assert_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.next(), Some(&val)); + fail_unless_eq!(it.size_hint(), (0, Some(0))); fail_unless!(it.next().is_none()); } @@ -682,20 +682,20 @@ mod tests { { let mut it = x.mut_iter(); - assert_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.size_hint(), (1, Some(1))); match it.next() { Some(interior) => { - assert_eq!(*interior, val); + fail_unless_eq!(*interior, val); *interior = new_val; } None => fail_unless!(false), } - assert_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.size_hint(), (0, Some(0))); fail_unless!(it.next().is_none()); } - assert_eq!(x, Some(new_val)); + fail_unless_eq!(x, Some(new_val)); } #[test] @@ -714,35 +714,35 @@ mod tests { fn test_mutate() { let mut x = Some(3i); fail_unless!(x.mutate(|i| i+1)); - assert_eq!(x, Some(4i)); + fail_unless_eq!(x, Some(4i)); fail_unless!(x.mutate_or_set(0, |i| i+1)); - assert_eq!(x, Some(5i)); + fail_unless_eq!(x, Some(5i)); x = None; fail_unless!(!x.mutate(|i| i+1)); - assert_eq!(x, None); + fail_unless_eq!(x, None); fail_unless!(!x.mutate_or_set(0i, |i| i+1)); - assert_eq!(x, Some(0i)); + fail_unless_eq!(x, Some(0i)); } #[test] fn test_collect() { let v: Option<~[int]> = collect(range(0, 0) .map(|_| Some(0))); - assert_eq!(v, Some(~[])); + fail_unless_eq!(v, Some(~[])); let v: Option<~[int]> = collect(range(0, 3) .map(|x| Some(x))); - assert_eq!(v, Some(~[0, 1, 2])); + fail_unless_eq!(v, Some(~[0, 1, 2])); let v: Option<~[int]> = collect(range(0, 3) .map(|x| if x > 1 { None } else { Some(x) })); - assert_eq!(v, None); + fail_unless_eq!(v, None); // test that it does not take more elements than it needs let functions = [|| Some(()), || None, || fail!()]; let v: Option<~[()]> = collect(functions.iter().map(|f| (*f)())); - assert_eq!(v, None); + fail_unless_eq!(v, None); } } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index ba35a317537af..54a19d8bd5d0d 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -374,7 +374,7 @@ pub fn pipe() -> Pipe { unsafe { let mut fds = Pipe {input: 0, out: 0}; - assert_eq!(libc::pipe(&mut fds.input), 0); + fail_unless_eq!(libc::pipe(&mut fds.input), 0); return Pipe {input: fds.input, out: fds.out}; } } @@ -391,7 +391,7 @@ pub fn pipe() -> Pipe { out: 0}; let res = libc::pipe(&mut fds.input, 1024 as ::libc::c_uint, (libc::O_BINARY | libc::O_NOINHERIT) as c_int); - assert_eq!(res, 0); + fail_unless_eq!(res, 0); fail_unless!((fds.input != -1 && fds.input != 0 )); fail_unless!((fds.out != -1 && fds.input != 0)); return Pipe {input: fds.input, out: fds.out}; @@ -1419,7 +1419,7 @@ mod tests { fn test_setenv() { let n = make_rand_name(); setenv(n, "VALUE"); - assert_eq!(getenv(n), option::Some(~"VALUE")); + fail_unless_eq!(getenv(n), option::Some(~"VALUE")); } #[test] @@ -1427,7 +1427,7 @@ mod tests { let n = make_rand_name(); setenv(n, "VALUE"); unsetenv(n); - assert_eq!(getenv(n), option::None); + fail_unless_eq!(getenv(n), option::None); } #[test] @@ -1436,9 +1436,9 @@ mod tests { let n = make_rand_name(); setenv(n, "1"); setenv(n, "2"); - assert_eq!(getenv(n), option::Some(~"2")); + fail_unless_eq!(getenv(n), option::Some(~"2")); setenv(n, ""); - assert_eq!(getenv(n), option::Some(~"")); + fail_unless_eq!(getenv(n), option::Some(~"")); } // Windows GetEnvironmentVariable requires some extra work to make sure @@ -1455,7 +1455,7 @@ mod tests { let n = make_rand_name(); setenv(n, s); debug!("{}", s.clone()); - assert_eq!(getenv(n), option::Some(s)); + fail_unless_eq!(getenv(n), option::Some(s)); } #[test] @@ -1501,9 +1501,9 @@ mod tests { let n = make_rand_name(); let s = "x".repeat(10000); setenv(n, s); - assert_eq!(getenv(n), Some(s)); + fail_unless_eq!(getenv(n), Some(s)); unsetenv(n); - assert_eq!(getenv(n), None); + fail_unless_eq!(getenv(n), None); } #[test] @@ -1535,7 +1535,7 @@ mod tests { let oldhome = getenv("HOME"); setenv("HOME", "/home/MountainView"); - assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); + fail_unless_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); setenv("HOME", ""); fail_unless!(os::homedir().is_none()); @@ -1556,16 +1556,16 @@ mod tests { fail_unless!(os::homedir().is_none()); setenv("HOME", "/home/MountainView"); - assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); + fail_unless_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); setenv("HOME", ""); setenv("USERPROFILE", "/home/MountainView"); - assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); + fail_unless_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); setenv("HOME", "/home/MountainView"); setenv("USERPROFILE", "/home/PaloAlto"); - assert_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); + fail_unless_eq!(os::homedir(), Some(Path::new("/home/MountainView"))); for s in oldhome.iter() { setenv("HOME", *s) } for s in olduserprofile.iter() { setenv("USERPROFILE", *s) } diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index a2ae35b920972..ef20eba2fd926 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -614,10 +614,10 @@ mod tests { fn test_cstring() { let input = "/foo/bar/baz"; let path: PosixPath = PosixPath::new(input.to_c_str()); - assert_eq!(path.as_vec(), input.as_bytes()); + fail_unless_eq!(path.as_vec(), input.as_bytes()); let input = r"\foo\bar\baz"; let path: WindowsPath = WindowsPath::new(input.to_c_str()); - assert_eq!(path.as_str().unwrap(), input.as_slice()); + fail_unless_eq!(path.as_str().unwrap(), input.as_slice()); } } diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index a994a8094c1a4..b28c9c809854a 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -455,13 +455,13 @@ mod tests { (s: $path:expr, $exp:expr) => ( { let path = $path; - assert_eq!(path.as_str(), Some($exp)); + fail_unless_eq!(path.as_str(), Some($exp)); } ); (v: $path:expr, $exp:expr) => ( { let path = $path; - assert_eq!(path.as_vec(), $exp); + fail_unless_eq!(path.as_vec(), $exp); } ) ) @@ -484,7 +484,7 @@ mod tests { t!(v: Path::new(b!("a/b/c", 0xff)), b!("a/b/c", 0xff)); t!(v: Path::new(b!(0xff, "/../foo", 0x80)), b!("foo", 0x80)); let p = Path::new(b!("a/b/c", 0xff)); - assert_eq!(p.as_str(), None); + fail_unless_eq!(p.as_str(), None); t!(s: Path::new(""), "."); t!(s: Path::new("/"), "/"); @@ -509,19 +509,19 @@ mod tests { t!(s: Path::new("foo/../../.."), "../.."); t!(s: Path::new("foo/../../bar"), "../bar"); - assert_eq!(Path::new(b!("foo/bar")).into_vec(), b!("foo/bar").to_owned()); - assert_eq!(Path::new(b!("/foo/../../bar")).into_vec(), + fail_unless_eq!(Path::new(b!("foo/bar")).into_vec(), b!("foo/bar").to_owned()); + fail_unless_eq!(Path::new(b!("/foo/../../bar")).into_vec(), b!("/bar").to_owned()); let p = Path::new(b!("foo/bar", 0x80)); - assert_eq!(p.as_str(), None); + fail_unless_eq!(p.as_str(), None); } #[test] fn test_opt_paths() { - assert_eq!(Path::new_opt(b!("foo/bar", 0)), None); + fail_unless_eq!(Path::new_opt(b!("foo/bar", 0)), None); t!(v: Path::new_opt(b!("foo/bar")).unwrap(), b!("foo/bar")); - assert_eq!(Path::new_opt("foo/bar\0"), None); + fail_unless_eq!(Path::new_opt("foo/bar\0"), None); t!(s: Path::new_opt("foo/bar").unwrap(), "foo/bar"); } @@ -550,7 +550,7 @@ mod tests { ($path:expr, $disp:ident, $exp:expr) => ( { let path = Path::new($path); - assert_eq!(path.$disp().to_str(), ~$exp); + fail_unless_eq!(path.$disp().to_str(), ~$exp); } ) ) @@ -566,14 +566,14 @@ mod tests { { let path = Path::new($path); let mo = path.display().as_maybe_owned(); - assert_eq!(mo.as_slice(), $exp); + fail_unless_eq!(mo.as_slice(), $exp); } ); ($path:expr, $exp:expr, filename) => ( { let path = Path::new($path); let mo = path.filename_display().as_maybe_owned(); - assert_eq!(mo.as_slice(), $exp); + fail_unless_eq!(mo.as_slice(), $exp); } ) ) @@ -593,9 +593,9 @@ mod tests { { let path = Path::new($path); let f = format!("{}", path.display()); - assert_eq!(f.as_slice(), $exp); + fail_unless_eq!(f.as_slice(), $exp); let f = format!("{}", path.filename_display()); - assert_eq!(f.as_slice(), $expf); + fail_unless_eq!(f.as_slice(), $expf); } ) ) @@ -615,21 +615,21 @@ mod tests { (s: $path:expr, $op:ident, $exp:expr) => ( { let path = Path::new($path); - assert_eq!(path.$op(), ($exp).as_bytes()); + fail_unless_eq!(path.$op(), ($exp).as_bytes()); } ); (s: $path:expr, $op:ident, $exp:expr, opt) => ( { let path = Path::new($path); let left = path.$op().map(|x| str::from_utf8(x).unwrap()); - assert_eq!(left, $exp); + fail_unless_eq!(left, $exp); } ); (v: $path:expr, $op:ident, $exp:expr) => ( { let arg = $path; let path = Path::new(arg); - assert_eq!(path.$op(), $exp); + fail_unless_eq!(path.$op(), $exp); } ); ) @@ -703,7 +703,7 @@ mod tests { let mut p1 = Path::new(path); let p2 = p1.clone(); p1.push(join); - assert_eq!(p1, p2.join(join)); + fail_unless_eq!(p1, p2.join(join)); } ) ) @@ -722,7 +722,7 @@ mod tests { let mut p = Path::new($path); let push = Path::new($push); p.push(&push); - assert_eq!(p.as_str(), Some($exp)); + fail_unless_eq!(p.as_str(), Some($exp)); } ) ) @@ -742,14 +742,14 @@ mod tests { { let mut p = Path::new($path); p.push_many($push); - assert_eq!(p.as_str(), Some($exp)); + fail_unless_eq!(p.as_str(), Some($exp)); } ); (v: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); p.push_many($push); - assert_eq!(p.as_vec(), $exp); + fail_unless_eq!(p.as_vec(), $exp); } ) ) @@ -770,16 +770,16 @@ mod tests { { let mut p = Path::new($path); let result = p.pop(); - assert_eq!(p.as_str(), Some($left)); - assert_eq!(result, $right); + fail_unless_eq!(p.as_str(), Some($left)); + fail_unless_eq!(result, $right); } ); (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => ( { let mut p = Path::new(b!($($path),+)); let result = p.pop(); - assert_eq!(p.as_vec(), b!($($left),+)); - assert_eq!(result, $right); + fail_unless_eq!(p.as_vec(), b!($($left),+)); + fail_unless_eq!(result, $right); } ) ) @@ -802,8 +802,8 @@ mod tests { #[test] fn test_root_path() { - assert_eq!(Path::new(b!("a/b/c")).root_path(), None); - assert_eq!(Path::new(b!("/a/b/c")).root_path(), Some(Path::new("/"))); + fail_unless_eq!(Path::new(b!("a/b/c")).root_path(), None); + fail_unless_eq!(Path::new(b!("/a/b/c")).root_path(), Some(Path::new("/"))); } #[test] @@ -827,7 +827,7 @@ mod tests { let path = Path::new($path); let join = Path::new($join); let res = path.join(&join); - assert_eq!(res.as_str(), Some($exp)); + fail_unless_eq!(res.as_str(), Some($exp)); } ) ) @@ -847,14 +847,14 @@ mod tests { { let path = Path::new($path); let res = path.join_many($join); - assert_eq!(res.as_str(), Some($exp)); + fail_unless_eq!(res.as_str(), Some($exp)); } ); (v: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); let res = path.join_many($join); - assert_eq!(res.as_vec(), $exp); + fail_unless_eq!(res.as_vec(), $exp); } ) ) @@ -928,7 +928,7 @@ mod tests { let mut p1 = Path::new(path); p1.$set(arg); let p2 = Path::new(path); - assert_eq!(p1, p2.$with(arg)); + fail_unless_eq!(p1, p2.$with(arg)); } ); (v: $path:expr, $set:ident, $with:ident, $arg:expr) => ( @@ -938,7 +938,7 @@ mod tests { let mut p1 = Path::new(path); p1.$set(arg); let p2 = Path::new(path); - assert_eq!(p1, p2.$with(arg)); + fail_unless_eq!(p1, p2.$with(arg)); } ) ) @@ -989,10 +989,10 @@ mod tests { (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( { let path = $path; - assert_eq!(path.filename(), $filename); - assert_eq!(path.dirname(), $dirname); - assert_eq!(path.filestem(), $filestem); - assert_eq!(path.extension(), $ext); + fail_unless_eq!(path.filename(), $filename); + fail_unless_eq!(path.dirname(), $dirname); + fail_unless_eq!(path.filestem(), $filestem); + fail_unless_eq!(path.extension(), $ext); } ) ) @@ -1038,8 +1038,8 @@ mod tests { (s: $path:expr, $abs:expr, $rel:expr) => ( { let path = Path::new($path); - assert_eq!(path.is_absolute(), $abs); - assert_eq!(path.is_relative(), $rel); + fail_unless_eq!(path.is_absolute(), $abs); + fail_unless_eq!(path.is_relative(), $rel); } ) ) @@ -1060,7 +1060,7 @@ mod tests { { let path = Path::new($path); let dest = Path::new($dest); - assert_eq!(path.is_ancestor_of(&dest), $exp); + fail_unless_eq!(path.is_ancestor_of(&dest), $exp); } ) ) @@ -1094,14 +1094,14 @@ mod tests { { let path = Path::new($path); let child = Path::new($child); - assert_eq!(path.ends_with_path(&child), $exp); + fail_unless_eq!(path.ends_with_path(&child), $exp); } ); (v: $path:expr, $child:expr, $exp:expr) => ( { let path = Path::new($path); let child = Path::new($child); - assert_eq!(path.ends_with_path(&child), $exp); + fail_unless_eq!(path.ends_with_path(&child), $exp); } ) ) @@ -1134,7 +1134,7 @@ mod tests { let path = Path::new($path); let other = Path::new($other); let res = path.path_relative_from(&other); - assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp); + fail_unless_eq!(res.as_ref().and_then(|x| x.as_str()), $exp); } ) ) diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 0d222869cd0ad..1d0559635ffd2 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1066,13 +1066,13 @@ mod tests { (s: $path:expr, $exp:expr) => ( { let path = $path; - assert_eq!(path.as_str(), Some($exp)); + fail_unless_eq!(path.as_str(), Some($exp)); } ); (v: $path:expr, $exp:expr) => ( { let path = $path; - assert_eq!(path.as_vec(), $exp); + fail_unless_eq!(path.as_vec(), $exp); } ) ) @@ -1184,8 +1184,8 @@ mod tests { t!(s: Path::new("foo\\..\\..\\.."), "..\\.."); t!(s: Path::new("foo\\..\\..\\bar"), "..\\bar"); - assert_eq!(Path::new(b!("foo\\bar")).into_vec(), b!("foo\\bar").to_owned()); - assert_eq!(Path::new(b!("\\foo\\..\\..\\bar")).into_vec(), + fail_unless_eq!(Path::new(b!("foo\\bar")).into_vec(), b!("foo\\bar").to_owned()); + fail_unless_eq!(Path::new(b!("\\foo\\..\\..\\bar")).into_vec(), b!("\\bar").to_owned()); t!(s: Path::new("\\\\a"), "\\a"); @@ -1239,10 +1239,10 @@ mod tests { #[test] fn test_opt_paths() { - assert_eq!(Path::new_opt(b!("foo\\bar", 0)), None); - assert_eq!(Path::new_opt(b!("foo\\bar", 0x80)), None); + fail_unless_eq!(Path::new_opt(b!("foo\\bar", 0)), None); + fail_unless_eq!(Path::new_opt(b!("foo\\bar", 0x80)), None); t!(v: Path::new_opt(b!("foo\\bar")).unwrap(), b!("foo\\bar")); - assert_eq!(Path::new_opt("foo\\bar\0"), None); + fail_unless_eq!(Path::new_opt("foo\\bar\0"), None); t!(s: Path::new_opt("foo\\bar").unwrap(), "foo\\bar"); } @@ -1274,16 +1274,16 @@ mod tests { #[test] fn test_display_str() { let path = Path::new("foo"); - assert_eq!(path.display().to_str(), ~"foo"); + fail_unless_eq!(path.display().to_str(), ~"foo"); let path = Path::new(b!("\\")); - assert_eq!(path.filename_display().to_str(), ~""); + fail_unless_eq!(path.filename_display().to_str(), ~""); let path = Path::new("foo"); let mo = path.display().as_maybe_owned(); - assert_eq!(mo.as_slice(), "foo"); + fail_unless_eq!(mo.as_slice(), "foo"); let path = Path::new(b!("\\")); let mo = path.filename_display().as_maybe_owned(); - assert_eq!(mo.as_slice(), ""); + fail_unless_eq!(mo.as_slice(), ""); } #[test] @@ -1293,9 +1293,9 @@ mod tests { { let path = Path::new($path); let f = format!("{}", path.display()); - assert_eq!(f.as_slice(), $exp); + fail_unless_eq!(f.as_slice(), $exp); let f = format!("{}", path.filename_display()); - assert_eq!(f.as_slice(), $expf); + fail_unless_eq!(f.as_slice(), $expf); } ) ) @@ -1312,7 +1312,7 @@ mod tests { { let path = $path; let path = Path::new(path); - assert_eq!(path.$op(), Some($exp)); + fail_unless_eq!(path.$op(), Some($exp)); } ); (s: $path:expr, $op:ident, $exp:expr, opt) => ( @@ -1320,14 +1320,14 @@ mod tests { let path = $path; let path = Path::new(path); let left = path.$op(); - assert_eq!(left, $exp); + fail_unless_eq!(left, $exp); } ); (v: $path:expr, $op:ident, $exp:expr) => ( { let path = $path; let path = Path::new(path); - assert_eq!(path.$op(), $exp); + fail_unless_eq!(path.$op(), $exp); } ) ) @@ -1438,7 +1438,7 @@ mod tests { let mut p1 = Path::new(path); let p2 = p1.clone(); p1.push(join); - assert_eq!(p1, p2.join(join)); + fail_unless_eq!(p1, p2.join(join)); } ) ) @@ -1452,15 +1452,15 @@ mod tests { // we do want to check one odd case though to ensure the prefix is re-parsed let mut p = Path::new("\\\\?\\C:"); - assert_eq!(prefix(&p), Some(VerbatimPrefix(2))); + fail_unless_eq!(prefix(&p), Some(VerbatimPrefix(2))); p.push("foo"); - assert_eq!(prefix(&p), Some(VerbatimDiskPrefix)); - assert_eq!(p.as_str(), Some("\\\\?\\C:\\foo")); + fail_unless_eq!(prefix(&p), Some(VerbatimDiskPrefix)); + fail_unless_eq!(p.as_str(), Some("\\\\?\\C:\\foo")); // and another with verbatim non-normalized paths let mut p = Path::new("\\\\?\\C:\\a\\"); p.push("foo"); - assert_eq!(p.as_str(), Some("\\\\?\\C:\\a\\foo")); + fail_unless_eq!(p.as_str(), Some("\\\\?\\C:\\a\\foo")); } #[test] @@ -1471,7 +1471,7 @@ mod tests { let mut p = Path::new($path); let push = Path::new($push); p.push(&push); - assert_eq!(p.as_str(), Some($exp)); + fail_unless_eq!(p.as_str(), Some($exp)); } ) ) @@ -1522,14 +1522,14 @@ mod tests { { let mut p = Path::new($path); p.push_many($push); - assert_eq!(p.as_str(), Some($exp)); + fail_unless_eq!(p.as_str(), Some($exp)); } ); (v: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); p.push_many($push); - assert_eq!(p.as_vec(), $exp); + fail_unless_eq!(p.as_vec(), $exp); } ) ) @@ -1555,15 +1555,15 @@ mod tests { fail_unless!(p.as_str() == Some(left), "`{}`.pop() failed; expected remainder `{}`, found `{}`", pstr, left, p.as_str().unwrap()); - assert_eq!(result, $right); + fail_unless_eq!(result, $right); } ); (v: [$($path:expr),+], [$($left:expr),+], $right:expr) => ( { let mut p = Path::new(b!($($path),+)); let result = p.pop(); - assert_eq!(p.as_vec(), b!($($left),+)); - assert_eq!(result, $right); + fail_unless_eq!(p.as_vec(), b!($($left),+)); + fail_unless_eq!(result, $right); } ) ) @@ -1606,16 +1606,16 @@ mod tests { #[test] fn test_root_path() { - assert_eq!(Path::new("a\\b\\c").root_path(), None); - assert_eq!(Path::new("\\a\\b\\c").root_path(), Some(Path::new("\\"))); - assert_eq!(Path::new("C:a").root_path(), Some(Path::new("C:"))); - assert_eq!(Path::new("C:\\a").root_path(), Some(Path::new("C:\\"))); - assert_eq!(Path::new("\\\\a\\b\\c").root_path(), Some(Path::new("\\\\a\\b"))); - assert_eq!(Path::new("\\\\?\\a\\b").root_path(), Some(Path::new("\\\\?\\a"))); - assert_eq!(Path::new("\\\\?\\C:\\a").root_path(), Some(Path::new("\\\\?\\C:\\"))); - assert_eq!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path(), + fail_unless_eq!(Path::new("a\\b\\c").root_path(), None); + fail_unless_eq!(Path::new("\\a\\b\\c").root_path(), Some(Path::new("\\"))); + fail_unless_eq!(Path::new("C:a").root_path(), Some(Path::new("C:"))); + fail_unless_eq!(Path::new("C:\\a").root_path(), Some(Path::new("C:\\"))); + fail_unless_eq!(Path::new("\\\\a\\b\\c").root_path(), Some(Path::new("\\\\a\\b"))); + fail_unless_eq!(Path::new("\\\\?\\a\\b").root_path(), Some(Path::new("\\\\?\\a"))); + fail_unless_eq!(Path::new("\\\\?\\C:\\a").root_path(), Some(Path::new("\\\\?\\C:\\"))); + fail_unless_eq!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path(), Some(Path::new("\\\\?\\UNC\\a\\b"))); - assert_eq!(Path::new("\\\\.\\a\\b").root_path(), Some(Path::new("\\\\.\\a"))); + fail_unless_eq!(Path::new("\\\\.\\a\\b").root_path(), Some(Path::new("\\\\.\\a"))); } #[test] @@ -1640,7 +1640,7 @@ mod tests { let path = Path::new($path); let join = Path::new($join); let res = path.join(&join); - assert_eq!(res.as_str(), Some($exp)); + fail_unless_eq!(res.as_str(), Some($exp)); } ) ) @@ -1662,14 +1662,14 @@ mod tests { { let path = Path::new($path); let res = path.join_many($join); - assert_eq!(res.as_str(), Some($exp)); + fail_unless_eq!(res.as_str(), Some($exp)); } ); (v: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); let res = path.join_many($join); - assert_eq!(res.as_vec(), $exp); + fail_unless_eq!(res.as_vec(), $exp); } ) ) @@ -1777,7 +1777,7 @@ mod tests { let mut p1 = Path::new(path); p1.$set(arg); let p2 = Path::new(path); - assert_eq!(p1, p2.$with(arg)); + fail_unless_eq!(p1, p2.$with(arg)); } ); (v: $path:expr, $set:ident, $with:ident, $arg:expr) => ( @@ -1787,7 +1787,7 @@ mod tests { let mut p1 = Path::new(path); p1.$set(arg); let p2 = Path::new(path); - assert_eq!(p1, p2.$with(arg)); + fail_unless_eq!(p1, p2.$with(arg)); } ) ) @@ -1839,10 +1839,10 @@ mod tests { (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( { let path = $path; - assert_eq!(path.filename(), $filename); - assert_eq!(path.dirname(), $dirname); - assert_eq!(path.filestem(), $filestem); - assert_eq!(path.extension(), $ext); + fail_unless_eq!(path.filename(), $filename); + fail_unless_eq!(path.dirname(), $dirname); + fail_unless_eq!(path.filestem(), $filestem); + fail_unless_eq!(path.extension(), $ext); } ) ) @@ -2028,7 +2028,7 @@ mod tests { { let path = Path::new($path); let child = Path::new($child); - assert_eq!(path.ends_with_path(&child), $exp); + fail_unless_eq!(path.ends_with_path(&child), $exp); } ); ) diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index cdc7d2ad4f2f9..af1c995f57256 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -403,15 +403,15 @@ pub mod ptr_tests { let mut p = Pair {fst: 10, snd: 20}; let pptr: *mut Pair = &mut p; let iptr: *mut int = cast::transmute(pptr); - assert_eq!(*iptr, 10); + fail_unless_eq!(*iptr, 10); *iptr = 30; - assert_eq!(*iptr, 30); - assert_eq!(p.fst, 30); + fail_unless_eq!(*iptr, 30); + fail_unless_eq!(p.fst, 30); *pptr = Pair {fst: 50, snd: 60}; - assert_eq!(*iptr, 50); - assert_eq!(p.fst, 50); - assert_eq!(p.snd, 60); + fail_unless_eq!(*iptr, 50); + fail_unless_eq!(p.fst, 50); + fail_unless_eq!(p.snd, 60); let v0 = ~[32000u16, 32001u16, 32002u16]; let mut v1 = ~[0u16, 0u16, 0u16]; @@ -450,7 +450,7 @@ pub mod ptr_tests { "thing".with_c_str(|p2| { let v = ~[p0, p1, p2, null()]; unsafe { - assert_eq!(buf_len(v.as_ptr()), 3u); + fail_unless_eq!(buf_len(v.as_ptr()), 3u); } }) }) @@ -480,16 +480,16 @@ pub mod ptr_tests { fn test_to_option() { unsafe { let p: *int = null(); - assert_eq!(p.to_option(), None); + fail_unless_eq!(p.to_option(), None); let q: *int = &2; - assert_eq!(q.to_option().unwrap(), &2); + fail_unless_eq!(q.to_option().unwrap(), &2); let p: *mut int = mut_null(); - assert_eq!(p.to_option(), None); + fail_unless_eq!(p.to_option(), None); let q: *mut int = &mut 2; - assert_eq!(q.to_option().unwrap(), &2); + fail_unless_eq!(q.to_option().unwrap(), &2); } } @@ -501,7 +501,7 @@ pub mod ptr_tests { let end = ptr.offset(16); while ptr < end { - assert_eq!(*ptr, 5); + fail_unless_eq!(*ptr, 5); ptr = ptr.offset(1); } @@ -514,7 +514,7 @@ pub mod ptr_tests { m_ptr = m_ptr.offset(1); } - assert_eq!(xs_mut, ~[10, ..16]); + fail_unless_eq!(xs_mut, ~[10, ..16]); } } @@ -526,7 +526,7 @@ pub mod ptr_tests { let ptr = xs.as_ptr(); while idx >= 0i8 { - assert_eq!(*(ptr.offset(idx as int)), idx as int); + fail_unless_eq!(*(ptr.offset(idx as int)), idx as int); idx = idx - 1i8; } @@ -539,7 +539,7 @@ pub mod ptr_tests { m_ptr = m_ptr.offset(-1); } - assert_eq!(xs_mut, ~[0,2,4,6,8,10,12,14,16,18]); + fail_unless_eq!(xs_mut, ~[0,2,4,6,8,10,12,14,16,18]); } } @@ -568,11 +568,11 @@ pub mod ptr_tests { debug!( "test_ptr_array_each_with_len e: {}, a: {}", expected, actual); - assert_eq!(actual, expected); + fail_unless_eq!(actual, expected); ctr += 1; iteration_count += 1; }); - assert_eq!(iteration_count, 3u); + fail_unless_eq!(iteration_count, 3u); } } @@ -604,11 +604,11 @@ pub mod ptr_tests { debug!( "test_ptr_array_each e: {}, a: {}", expected, actual); - assert_eq!(actual, expected); + fail_unless_eq!(actual, expected); ctr += 1; iteration_count += 1; }); - assert_eq!(iteration_count, 3); + fail_unless_eq!(iteration_count, 3); } } @@ -636,6 +636,6 @@ pub mod ptr_tests { let mut xs = [0u8, ..20]; let ptr = xs.as_mut_ptr(); unsafe { set_memory(ptr, 5u8, xs.len()); } - assert_eq!(xs, [5u8, ..20]); + fail_unless_eq!(xs, [5u8, ..20]); } } diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index b34f2dde5bc69..40742afb7bf65 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -281,8 +281,8 @@ mod tests { fn test_rand_sample() { let mut rand_sample = RandSample::; - assert_eq!(rand_sample.sample(&mut task_rng()), ConstRand(0)); - assert_eq!(rand_sample.ind_sample(&mut task_rng()), ConstRand(0)); + fail_unless_eq!(rand_sample.sample(&mut task_rng()), ConstRand(0)); + fail_unless_eq!(rand_sample.ind_sample(&mut task_rng()), ConstRand(0)); } #[test] fn test_weighted_choice() { @@ -299,7 +299,7 @@ mod tests { let mut rng = CountingRng { i: 0 }; for &val in expected.iter() { - assert_eq!(wc.ind_sample(&mut rng), val) + fail_unless_eq!(wc.ind_sample(&mut rng), val) } }} ); diff --git a/src/libstd/rand/isaac.rs b/src/libstd/rand/isaac.rs index 9871207a91e6a..64d6e569badbd 100644 --- a/src/libstd/rand/isaac.rs +++ b/src/libstd/rand/isaac.rs @@ -440,14 +440,14 @@ mod test { let s = OSRng::new().gen_vec::(256); let mut ra: IsaacRng = SeedableRng::from_seed(s.as_slice()); let mut rb: IsaacRng = SeedableRng::from_seed(s.as_slice()); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] fn test_rng_64_rand_seeded() { let s = OSRng::new().gen_vec::(256); let mut ra: Isaac64Rng = SeedableRng::from_seed(s.as_slice()); let mut rb: Isaac64Rng = SeedableRng::from_seed(s.as_slice()); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] @@ -455,14 +455,14 @@ mod test { let seed = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut rb: IsaacRng = SeedableRng::from_seed(seed); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] fn test_rng_64_seeded() { let seed = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] @@ -474,7 +474,7 @@ mod test { r.reseed(s); let string2 = r.gen_ascii_str(100); - assert_eq!(string1, string2); + fail_unless_eq!(string1, string2); } #[test] fn test_rng_64_reseed() { @@ -485,7 +485,7 @@ mod test { r.reseed(s); let string2 = r.gen_ascii_str(100); - assert_eq!(string1, string2); + fail_unless_eq!(string1, string2); } #[test] @@ -494,7 +494,7 @@ mod test { let mut ra: IsaacRng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector let v = vec::from_fn(10, |_| ra.next_u32()); - assert_eq!(v, + fail_unless_eq!(v, ~[2558573138, 873787463, 263499565, 2103644246, 3595684709, 4203127393, 264982119, 2765226902, 2737944514, 3900253796]); @@ -504,7 +504,7 @@ mod test { for _ in range(0, 10000) { rb.next_u32(); } let v = vec::from_fn(10, |_| rb.next_u32()); - assert_eq!(v, + fail_unless_eq!(v, ~[3676831399, 3183332890, 2834741178, 3854698763, 2717568474, 1576568959, 3507990155, 179069555, 141456972, 2478885421]); } @@ -514,7 +514,7 @@ mod test { let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector let v = vec::from_fn(10, |_| ra.next_u64()); - assert_eq!(v, + fail_unless_eq!(v, ~[547121783600835980, 14377643087320773276, 17351601304698403469, 1238879483818134882, 11952566807690396487, 13970131091560099343, 4469761996653280935, 15552757044682284409, 6860251611068737823, @@ -526,7 +526,7 @@ mod test { for _ in range(0, 10000) { rb.next_u64(); } let v = vec::from_fn(10, |_| rb.next_u64()); - assert_eq!(v, + fail_unless_eq!(v, ~[18143823860592706164, 8491801882678285927, 2699425367717515619, 17196852593171130876, 2606123525235546165, 15790932315217671084, 596345674630742204, 9947027391921273664, 11788097613744130851, diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 261ea11000dcf..a33315efc370e 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -695,15 +695,15 @@ mod test { for _ in range(0, 1000) { let a = r.gen_range(-3i, 42); fail_unless!(a >= -3 && a < 42); - assert_eq!(r.gen_range(0, 1), 0); - assert_eq!(r.gen_range(-12, -11), -12); + fail_unless_eq!(r.gen_range(0, 1), 0); + fail_unless_eq!(r.gen_range(-12, -11), -12); } for _ in range(0, 1000) { let a = r.gen_range(10, 42); fail_unless!(a >= 10 && a < 42); - assert_eq!(r.gen_range(0, 1), 0); - assert_eq!(r.gen_range(3_000_000u, 3_000_001), 3_000_000); + fail_unless_eq!(r.gen_range(0, 1), 0); + fail_unless_eq!(r.gen_range(3_000_000u, 3_000_001), 3_000_000); } } @@ -733,8 +733,8 @@ mod test { #[test] fn test_gen_weighted_bool() { let mut r = rng(); - assert_eq!(r.gen_weighted_bool(0u), true); - assert_eq!(r.gen_weighted_bool(1u), true); + fail_unless_eq!(r.gen_weighted_bool(0u), true); + fail_unless_eq!(r.gen_weighted_bool(1u), true); } #[test] @@ -743,23 +743,23 @@ mod test { debug!("{}", r.gen_ascii_str(10u)); debug!("{}", r.gen_ascii_str(10u)); debug!("{}", r.gen_ascii_str(10u)); - assert_eq!(r.gen_ascii_str(0u).len(), 0u); - assert_eq!(r.gen_ascii_str(10u).len(), 10u); - assert_eq!(r.gen_ascii_str(16u).len(), 16u); + fail_unless_eq!(r.gen_ascii_str(0u).len(), 0u); + fail_unless_eq!(r.gen_ascii_str(10u).len(), 10u); + fail_unless_eq!(r.gen_ascii_str(16u).len(), 16u); } #[test] fn test_gen_vec() { let mut r = rng(); - assert_eq!(r.gen_vec::(0u).len(), 0u); - assert_eq!(r.gen_vec::(10u).len(), 10u); - assert_eq!(r.gen_vec::(16u).len(), 16u); + fail_unless_eq!(r.gen_vec::(0u).len(), 0u); + fail_unless_eq!(r.gen_vec::(10u).len(), 10u); + fail_unless_eq!(r.gen_vec::(16u).len(), 16u); } #[test] fn test_choose() { let mut r = rng(); - assert_eq!(r.choose([1, 1, 1]), 1); + fail_unless_eq!(r.choose([1, 1, 1]), 1); } #[test] @@ -770,23 +770,23 @@ mod test { let i = 1; let v = [1,1,1]; - assert_eq!(r.choose_option(v), Some(&i)); + fail_unless_eq!(r.choose_option(v), Some(&i)); } #[test] fn test_shuffle() { let mut r = rng(); let empty: ~[int] = ~[]; - assert_eq!(r.shuffle(~[]), empty); - assert_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); + fail_unless_eq!(r.shuffle(~[]), empty); + fail_unless_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); } #[test] fn test_task_rng() { let mut r = task_rng(); r.gen::(); - assert_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); - assert_eq!(r.gen_range(0u, 1u), 0u); + fail_unless_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); + fail_unless_eq!(r.gen_range(0u, 1u), 0u); } #[test] @@ -811,8 +811,8 @@ mod test { let small_sample = r.sample(vals.iter(), 5); let large_sample = r.sample(vals.iter(), vals.len() + 5); - assert_eq!(small_sample.len(), 5); - assert_eq!(large_sample.len(), vals.len()); + fail_unless_eq!(small_sample.len(), 5); + fail_unless_eq!(large_sample.len(), vals.len()); fail_unless!(small_sample.iter().all(|e| { **e >= MIN_VAL && **e <= MAX_VAL @@ -824,7 +824,7 @@ mod test { let s = OSRng::new().gen_vec::(256); let mut ra: StdRng = SeedableRng::from_seed(s.as_slice()); let mut rb: StdRng = SeedableRng::from_seed(s.as_slice()); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] @@ -836,7 +836,7 @@ mod test { r.reseed(s); let string2 = r.gen_ascii_str(100); - assert_eq!(string1, string2); + fail_unless_eq!(string1, string2); } } diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 621d70970f02f..c0d6ee17ae26c 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -88,9 +88,9 @@ mod test { let bytes: ~[u8] = unsafe {cast::transmute(v)}; let mut rng = ReaderRng::new(MemReader::new(bytes)); - assert_eq!(rng.next_u64(), 1); - assert_eq!(rng.next_u64(), 2); - assert_eq!(rng.next_u64(), 3); + fail_unless_eq!(rng.next_u64(), 1); + fail_unless_eq!(rng.next_u64(), 2); + fail_unless_eq!(rng.next_u64(), 3); } #[test] fn test_reader_rng_u32() { @@ -99,9 +99,9 @@ mod test { let bytes: ~[u8] = unsafe {cast::transmute(v)}; let mut rng = ReaderRng::new(MemReader::new(bytes)); - assert_eq!(rng.next_u32(), 1); - assert_eq!(rng.next_u32(), 2); - assert_eq!(rng.next_u32(), 3); + fail_unless_eq!(rng.next_u32(), 1); + fail_unless_eq!(rng.next_u32(), 2); + fail_unless_eq!(rng.next_u32(), 3); } #[test] fn test_reader_rng_fill_bytes() { @@ -111,7 +111,7 @@ mod test { let mut rng = ReaderRng::new(MemReader::new(v.to_owned())); rng.fill_bytes(w); - assert_eq!(v, w); + fail_unless_eq!(v, w); } #[test] diff --git a/src/libstd/rand/reseeding.rs b/src/libstd/rand/reseeding.rs index 395af27debc8c..194862076d310 100644 --- a/src/libstd/rand/reseeding.rs +++ b/src/libstd/rand/reseeding.rs @@ -178,7 +178,7 @@ mod test { let mut i = 0; for _ in range(0, 1000) { - assert_eq!(rs.next_u32(), i % 100); + fail_unless_eq!(rs.next_u32(), i % 100); i += 1; } } @@ -187,7 +187,7 @@ mod test { fn test_rng_seeded() { let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); - assert_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); + fail_unless_eq!(ra.gen_ascii_str(100u), rb.gen_ascii_str(100u)); } #[test] @@ -198,7 +198,7 @@ mod test { r.reseed((ReseedWithDefault, 3)); let string2 = r.gen_ascii_str(100); - assert_eq!(string1, string2); + fail_unless_eq!(string1, string2); } static fill_bytes_v_len: uint = 13579; @@ -210,7 +210,7 @@ mod test { // Sanity test: if we've gotten here, `fill_bytes` has not infinitely // recursed. - assert_eq!(v.len(), fill_bytes_v_len); + fail_unless_eq!(v.len(), fill_bytes_v_len); // To test that `fill_bytes` actually did something, check that the // average of `v` is not 0. diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index ff45c94a288ce..b0e5c069c25e5 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -199,7 +199,7 @@ mod tests { x.borrow().with_mut(|inner| { *inner = 20; }); - assert_eq!(y.borrow().with(|v| *v), 20); + fail_unless_eq!(y.borrow().with(|v| *v), 20); } #[test] @@ -209,27 +209,27 @@ mod tests { x.borrow().with_mut(|inner| { *inner = 20; }); - assert_eq!(y.borrow().with(|v| *v), 5); + fail_unless_eq!(y.borrow().with(|v| *v), 5); } #[test] fn test_simple() { let x = Rc::new(5); - assert_eq!(*x.borrow(), 5); + fail_unless_eq!(*x.borrow(), 5); } #[test] fn test_simple_clone() { let x = Rc::new(5); let y = x.clone(); - assert_eq!(*x.borrow(), 5); - assert_eq!(*y.borrow(), 5); + fail_unless_eq!(*x.borrow(), 5); + fail_unless_eq!(*y.borrow(), 5); } #[test] fn test_destructor() { let x = Rc::new(~5); - assert_eq!(**x.borrow(), 5); + fail_unless_eq!(**x.borrow(), 5); } #[test] diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 680ac11230021..0e936a1d44f2d 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -636,7 +636,7 @@ fn test_repr() { let mut m = io::MemWriter::new(); write_repr(&mut m as &mut io::Writer, t).unwrap(); let s = str::from_utf8_owned(m.unwrap()).unwrap(); - assert_eq!(s.as_slice(), e); + fail_unless_eq!(s.as_slice(), e); } exact_test(&10, "10"); diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 0cfe338ac32d8..0eb5918d2aa7e 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -303,88 +303,88 @@ mod tests { #[test] pub fn test_and() { - assert_eq!(op1().and(Ok(667)).unwrap(), 667); - assert_eq!(op1().and(Err::<(), ~str>(~"bad")).unwrap_err(), ~"bad"); + fail_unless_eq!(op1().and(Ok(667)).unwrap(), 667); + fail_unless_eq!(op1().and(Err::<(), ~str>(~"bad")).unwrap_err(), ~"bad"); - assert_eq!(op2().and(Ok(667)).unwrap_err(), ~"sadface"); - assert_eq!(op2().and(Err::<(), ~str>(~"bad")).unwrap_err(), ~"sadface"); + fail_unless_eq!(op2().and(Ok(667)).unwrap_err(), ~"sadface"); + fail_unless_eq!(op2().and(Err::<(), ~str>(~"bad")).unwrap_err(), ~"sadface"); } #[test] pub fn test_and_then() { - assert_eq!(op1().and_then(|i| Ok::(i + 1)).unwrap(), 667); - assert_eq!(op1().and_then(|_| Err::(~"bad")).unwrap_err(), ~"bad"); + fail_unless_eq!(op1().and_then(|i| Ok::(i + 1)).unwrap(), 667); + fail_unless_eq!(op1().and_then(|_| Err::(~"bad")).unwrap_err(), ~"bad"); - assert_eq!(op2().and_then(|i| Ok::(i + 1)).unwrap_err(), ~"sadface"); - assert_eq!(op2().and_then(|_| Err::(~"bad")).unwrap_err(), ~"sadface"); + fail_unless_eq!(op2().and_then(|i| Ok::(i + 1)).unwrap_err(), ~"sadface"); + fail_unless_eq!(op2().and_then(|_| Err::(~"bad")).unwrap_err(), ~"sadface"); } #[test] pub fn test_or() { - assert_eq!(op1().or(Ok(667)).unwrap(), 666); - assert_eq!(op1().or(Err(~"bad")).unwrap(), 666); + fail_unless_eq!(op1().or(Ok(667)).unwrap(), 666); + fail_unless_eq!(op1().or(Err(~"bad")).unwrap(), 666); - assert_eq!(op2().or(Ok(667)).unwrap(), 667); - assert_eq!(op2().or(Err(~"bad")).unwrap_err(), ~"bad"); + fail_unless_eq!(op2().or(Ok(667)).unwrap(), 667); + fail_unless_eq!(op2().or(Err(~"bad")).unwrap_err(), ~"bad"); } #[test] pub fn test_or_else() { - assert_eq!(op1().or_else(|_| Ok::(667)).unwrap(), 666); - assert_eq!(op1().or_else(|e| Err::(e + "!")).unwrap(), 666); + fail_unless_eq!(op1().or_else(|_| Ok::(667)).unwrap(), 666); + fail_unless_eq!(op1().or_else(|e| Err::(e + "!")).unwrap(), 666); - assert_eq!(op2().or_else(|_| Ok::(667)).unwrap(), 667); - assert_eq!(op2().or_else(|e| Err::(e + "!")).unwrap_err(), ~"sadface!"); + fail_unless_eq!(op2().or_else(|_| Ok::(667)).unwrap(), 667); + fail_unless_eq!(op2().or_else(|e| Err::(e + "!")).unwrap_err(), ~"sadface!"); } #[test] pub fn test_impl_map() { - assert_eq!(Ok::<~str, ~str>(~"a").map(|x| x + "b"), Ok(~"ab")); - assert_eq!(Err::<~str, ~str>(~"a").map(|x| x + "b"), Err(~"a")); + fail_unless_eq!(Ok::<~str, ~str>(~"a").map(|x| x + "b"), Ok(~"ab")); + fail_unless_eq!(Err::<~str, ~str>(~"a").map(|x| x + "b"), Err(~"a")); } #[test] pub fn test_impl_map_err() { - assert_eq!(Ok::<~str, ~str>(~"a").map_err(|x| x + "b"), Ok(~"a")); - assert_eq!(Err::<~str, ~str>(~"a").map_err(|x| x + "b"), Err(~"ab")); + fail_unless_eq!(Ok::<~str, ~str>(~"a").map_err(|x| x + "b"), Ok(~"a")); + fail_unless_eq!(Err::<~str, ~str>(~"a").map_err(|x| x + "b"), Err(~"ab")); } #[test] fn test_collect() { let v: Result<~[int], ()> = collect(range(0, 0).map(|_| Ok::(0))); - assert_eq!(v, Ok(~[])); + fail_unless_eq!(v, Ok(~[])); let v: Result<~[int], ()> = collect(range(0, 3).map(|x| Ok::(x))); - assert_eq!(v, Ok(~[0, 1, 2])); + fail_unless_eq!(v, Ok(~[0, 1, 2])); let v: Result<~[int], int> = collect(range(0, 3) .map(|x| if x > 1 { Err(x) } else { Ok(x) })); - assert_eq!(v, Err(2)); + fail_unless_eq!(v, Err(2)); // test that it does not take more elements than it needs let functions = [|| Ok(()), || Err(1), || fail!()]; let v: Result<~[()], int> = collect(functions.iter().map(|f| (*f)())); - assert_eq!(v, Err(1)); + fail_unless_eq!(v, Err(1)); } #[test] fn test_fold() { - assert_eq!(fold_(range(0, 0) + fail_unless_eq!(fold_(range(0, 0) .map(|_| Ok::<(), ()>(()))), Ok(())); - assert_eq!(fold(range(0, 3) + fail_unless_eq!(fold(range(0, 3) .map(|x| Ok::(x)), 0, |a, b| a + b), Ok(3)); - assert_eq!(fold_(range(0, 3) + fail_unless_eq!(fold_(range(0, 3) .map(|x| if x > 1 { Err(x) } else { Ok(()) })), Err(2)); // test that it does not take more elements than it needs let functions = [|| Ok(()), || Err(1), || fail!()]; - assert_eq!(fold_(functions.iter() + fail_unless_eq!(fold_(functions.iter() .map(|f| (*f)())), Err(1)); } @@ -394,8 +394,8 @@ mod tests { let ok: Result = Ok(100); let err: Result = Err(~"Err"); - assert_eq!(ok.to_str(), ~"Ok(100)"); - assert_eq!(err.to_str(), ~"Err(Err)"); + fail_unless_eq!(ok.to_str(), ~"Ok(100)"); + fail_unless_eq!(err.to_str(), ~"Err(Err)"); } #[test] @@ -403,7 +403,7 @@ mod tests { let ok: Result = Ok(100); let err: Result = Err(~"Err"); - assert_eq!(format!("{}", ok), ~"Ok(100)"); - assert_eq!(format!("{}", err), ~"Err(Err)"); + fail_unless_eq!(format!("{}", ok), ~"Ok(100)"); + fail_unless_eq!(format!("{}", err), ~"Err(Err)"); } } diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index 9140bc900a751..afc3d4362ac2c 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -198,53 +198,53 @@ pub fn init() { #[test] fn parse_logging_spec_valid() { let dirs = parse_logging_spec(~"crate1::mod1=1,crate1::mod2,crate2=4"); - assert_eq!(dirs.len(), 3); + fail_unless_eq!(dirs.len(), 3); fail_unless!(dirs[0].name == Some(~"crate1::mod1")); - assert_eq!(dirs[0].level, 1); + fail_unless_eq!(dirs[0].level, 1); fail_unless!(dirs[1].name == Some(~"crate1::mod2")); - assert_eq!(dirs[1].level, MAX_LOG_LEVEL); + fail_unless_eq!(dirs[1].level, MAX_LOG_LEVEL); fail_unless!(dirs[2].name == Some(~"crate2")); - assert_eq!(dirs[2].level, 4); + fail_unless_eq!(dirs[2].level, 4); } #[test] fn parse_logging_spec_invalid_crate() { // test parse_logging_spec with multiple = in specification let dirs = parse_logging_spec(~"crate1::mod1=1=2,crate2=4"); - assert_eq!(dirs.len(), 1); + fail_unless_eq!(dirs.len(), 1); fail_unless!(dirs[0].name == Some(~"crate2")); - assert_eq!(dirs[0].level, 4); + fail_unless_eq!(dirs[0].level, 4); } #[test] fn parse_logging_spec_invalid_log_level() { // test parse_logging_spec with 'noNumber' as log level let dirs = parse_logging_spec(~"crate1::mod1=noNumber,crate2=4"); - assert_eq!(dirs.len(), 1); + fail_unless_eq!(dirs.len(), 1); fail_unless!(dirs[0].name == Some(~"crate2")); - assert_eq!(dirs[0].level, 4); + fail_unless_eq!(dirs[0].level, 4); } #[test] fn parse_logging_spec_string_log_level() { // test parse_logging_spec with 'warn' as log level let dirs = parse_logging_spec(~"crate1::mod1=wrong,crate2=warn"); - assert_eq!(dirs.len(), 1); + fail_unless_eq!(dirs.len(), 1); fail_unless!(dirs[0].name == Some(~"crate2")); - assert_eq!(dirs[0].level, 2); + fail_unless_eq!(dirs[0].level, 2); } #[test] fn parse_logging_spec_global() { // test parse_logging_spec with no crate let dirs = parse_logging_spec(~"warn,crate2=4"); - assert_eq!(dirs.len(), 2); + fail_unless_eq!(dirs.len(), 2); fail_unless!(dirs[0].name == None); - assert_eq!(dirs[0].level, 2); + fail_unless_eq!(dirs[0].level, 2); fail_unless!(dirs[1].name == Some(~"crate2")); - assert_eq!(dirs[1].level, 4); + fail_unless_eq!(dirs[1].level, 4); } // Tests for update_entry diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index 89ca08d739795..6acc8f68ae7da 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -216,8 +216,8 @@ mod imp { pub unsafe fn create(stack: uint, p: ~proc()) -> rust_thread { let mut native: libc::pthread_t = mem::uninit(); let mut attr: libc::pthread_attr_t = mem::uninit(); - assert_eq!(pthread_attr_init(&mut attr), 0); - assert_eq!(pthread_attr_setdetachstate(&mut attr, + fail_unless_eq!(pthread_attr_init(&mut attr), 0); + fail_unless_eq!(pthread_attr_setdetachstate(&mut attr, PTHREAD_CREATE_JOINABLE), 0); // Reserve room for the red zone, the runtime's stack of last resort. @@ -232,7 +232,7 @@ mod imp { // Round up to the neareast page and try again. let page_size = os::page_size(); let stack_size = (stack_size + page_size - 1) & (-(page_size - 1) - 1); - assert_eq!(pthread_attr_setstacksize(&mut attr, stack_size as libc::size_t), 0); + fail_unless_eq!(pthread_attr_setstacksize(&mut attr, stack_size as libc::size_t), 0); }, errno => { // This cannot really happen. @@ -241,25 +241,25 @@ mod imp { }; let arg: *libc::c_void = cast::transmute(p); - assert_eq!(pthread_create(&mut native, &attr, + fail_unless_eq!(pthread_create(&mut native, &attr, super::thread_start, arg), 0); native } pub unsafe fn join(native: rust_thread) { - assert_eq!(pthread_join(native, ptr::null()), 0); + fail_unless_eq!(pthread_join(native, ptr::null()), 0); } pub unsafe fn detach(native: rust_thread) { - assert_eq!(pthread_detach(native), 0); + fail_unless_eq!(pthread_detach(native), 0); } #[cfg(target_os = "macos")] #[cfg(target_os = "android")] - pub unsafe fn yield_now() { assert_eq!(sched_yield(), 0); } + pub unsafe fn yield_now() { fail_unless_eq!(sched_yield(), 0); } #[cfg(not(target_os = "macos"), not(target_os = "android"))] - pub unsafe fn yield_now() { assert_eq!(pthread_yield(), 0); } + pub unsafe fn yield_now() { fail_unless_eq!(pthread_yield(), 0); } #[cfg(not(target_os = "linux"))] unsafe fn __pthread_get_minstack(_: *libc::pthread_attr_t) -> libc::size_t { @@ -336,14 +336,14 @@ mod tests { fn smoke() { Thread::start(proc (){}).join(); } #[test] - fn data() { assert_eq!(Thread::start(proc () { 1 }).join(), 1); } + fn data() { fail_unless_eq!(Thread::start(proc () { 1 }).join(), 1); } #[test] fn detached() { Thread::spawn(proc () {}) } #[test] fn small_stacks() { - assert_eq!(42, Thread::start_stack(0, proc () 42).join()); - assert_eq!(42, Thread::start_stack(1, proc () 42).join()); + fail_unless_eq!(42, Thread::start_stack(0, proc () 42).join()); + fail_unless_eq!(42, Thread::start_stack(1, proc () 42).join()); } } diff --git a/src/libstd/rt/thread_local_storage.rs b/src/libstd/rt/thread_local_storage.rs index 18f07607f6804..9a6eceb2bfe46 100644 --- a/src/libstd/rt/thread_local_storage.rs +++ b/src/libstd/rt/thread_local_storage.rs @@ -22,12 +22,12 @@ pub type Key = pthread_key_t; #[cfg(unix)] pub unsafe fn create(key: &mut Key) { - assert_eq!(0, pthread_key_create(key, null())); + fail_unless_eq!(0, pthread_key_create(key, null())); } #[cfg(unix)] pub unsafe fn set(key: Key, value: *mut u8) { - assert_eq!(0, pthread_setspecific(key, value)); + fail_unless_eq!(0, pthread_setspecific(key, value)); } #[cfg(unix)] @@ -37,7 +37,7 @@ pub unsafe fn get(key: Key) -> *mut u8 { #[cfg(unix)] pub unsafe fn destroy(key: Key) { - assert_eq!(0, pthread_key_delete(key)); + fail_unless_eq!(0, pthread_key_delete(key)); } #[cfg(target_os="macos")] @@ -100,10 +100,10 @@ fn tls_smoke_test() { create(&mut key); set(key, transmute(value)); let value: ~int = transmute(get(key)); - assert_eq!(value, ~20); + fail_unless_eq!(value, ~20); let value = ~30; set(key, transmute(value)); let value: ~int = transmute(get(key)); - assert_eq!(value, ~30); + fail_unless_eq!(value, ~30); } } diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 7dabba9eebc13..848e796dc5d65 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -375,7 +375,7 @@ mod tests { #[test] fn test_process_output_fail_to_start() { match run::process_output("/no-binary-by-this-name-should-exist", []) { - Err(e) => assert_eq!(e.kind, FileNotFound), + Err(e) => fail_unless_eq!(e.kind, FileNotFound), Ok(..) => fail!() } } @@ -389,10 +389,10 @@ mod tests { let output_str = str::from_utf8_owned(output).unwrap(); fail_unless!(status.success()); - assert_eq!(output_str.trim().to_owned(), ~"hello"); + fail_unless_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { - assert_eq!(error, ~[]); + fail_unless_eq!(error, ~[]); } } @@ -404,7 +404,7 @@ mod tests { = run::process_output("mkdir", [~"."]).unwrap(); fail_unless!(status.matches_exit_status(1)); - assert_eq!(output, ~[]); + fail_unless_eq!(output, ~[]); fail_unless!(!error.is_empty()); } @@ -434,7 +434,7 @@ mod tests { readclose(pipe_err.input); process.finish(); - assert_eq!(~"test", actual); + fail_unless_eq!(~"test", actual); } fn writeclose(fd: c_int, s: &str) { @@ -474,10 +474,10 @@ mod tests { let output_str = str::from_utf8_owned(output).unwrap(); fail_unless!(status.success()); - assert_eq!(output_str.trim().to_owned(), ~"hello"); + fail_unless_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { - assert_eq!(error, ~[]); + fail_unless_eq!(error, ~[]); } } @@ -493,20 +493,20 @@ mod tests { let output_str = str::from_utf8_owned(output).unwrap(); fail_unless!(status.success()); - assert_eq!(output_str.trim().to_owned(), ~"hello"); + fail_unless_eq!(output_str.trim().to_owned(), ~"hello"); // FIXME #7224 if !running_on_valgrind() { - assert_eq!(error, ~[]); + fail_unless_eq!(error, ~[]); } let run::ProcessOutput {status, output, error} = prog.finish_with_output(); fail_unless!(status.success()); - assert_eq!(output, ~[]); + fail_unless_eq!(output, ~[]); // FIXME #7224 if !running_on_valgrind() { - assert_eq!(error, ~[]); + fail_unless_eq!(error, ~[]); } } @@ -544,8 +544,8 @@ mod tests { let parent_stat = parent_dir.stat().unwrap(); let child_stat = child_dir.stat().unwrap(); - assert_eq!(parent_stat.unstable.device, child_stat.unstable.device); - assert_eq!(parent_stat.unstable.inode, child_stat.unstable.inode); + fail_unless_eq!(parent_stat.unstable.device, child_stat.unstable.device); + fail_unless_eq!(parent_stat.unstable.inode, child_stat.unstable.inode); } #[test] @@ -561,8 +561,8 @@ mod tests { let parent_stat = parent_dir.stat().unwrap(); let child_stat = child_dir.stat().unwrap(); - assert_eq!(parent_stat.unstable.device, child_stat.unstable.device); - assert_eq!(parent_stat.unstable.inode, child_stat.unstable.inode); + fail_unless_eq!(parent_stat.unstable.device, child_stat.unstable.device); + fail_unless_eq!(parent_stat.unstable.inode, child_stat.unstable.inode); } #[cfg(unix,not(target_os="android"))] diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 4233e364d9993..9117d19b4004b 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -64,7 +64,7 @@ other languages. let mut buf = ~"testing"; buf.push_char(' '); buf.push_str("123"); -assert_eq!(buf, ~"testing 123"); +fail_unless_eq!(buf, ~"testing 123"); ``` # Representation @@ -947,7 +947,7 @@ impl<'a> Iterator for UTF16Items<'a> { /// 0x0073, 0xDD1E, 0x0069, 0x0063, /// 0xD834]; /// -/// assert_eq!(str::utf16_items(v).to_owned_vec(), +/// fail_unless_eq!(str::utf16_items(v).to_owned_vec(), /// ~[ScalarValue('𝄞'), /// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'), /// LoneSurrogate(0xDD1E), @@ -969,11 +969,11 @@ pub fn utf16_items<'a>(v: &'a [u16]) -> UTF16Items<'a> { /// // "abcd" /// let mut v = ['a' as u16, 'b' as u16, 'c' as u16, 'd' as u16]; /// // no NULs so no change -/// assert_eq!(str::truncate_utf16_at_nul(v), v.as_slice()); +/// fail_unless_eq!(str::truncate_utf16_at_nul(v), v.as_slice()); /// /// // "ab\0d" /// v[2] = 0; -/// assert_eq!(str::truncate_utf16_at_nul(v), +/// fail_unless_eq!(str::truncate_utf16_at_nul(v), /// &['a' as u16, 'b' as u16]); /// ``` pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { @@ -995,11 +995,11 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { /// // 𝄞music /// let mut v = [0xD834, 0xDD1E, 0x006d, 0x0075, /// 0x0073, 0x0069, 0x0063]; -/// assert_eq!(str::from_utf16(v), Some(~"𝄞music")); +/// fail_unless_eq!(str::from_utf16(v), Some(~"𝄞music")); /// /// // 𝄞muic /// v[4] = 0xD800; -/// assert_eq!(str::from_utf16(v), None); +/// fail_unless_eq!(str::from_utf16(v), None); /// ``` pub fn from_utf16(v: &[u16]) -> Option<~str> { let mut s = with_capacity(v.len() / 2); @@ -1024,7 +1024,7 @@ pub fn from_utf16(v: &[u16]) -> Option<~str> { /// 0x0073, 0xDD1E, 0x0069, 0x0063, /// 0xD834]; /// -/// assert_eq!(str::from_utf16_lossy(v), +/// fail_unless_eq!(str::from_utf16_lossy(v), /// ~"𝄞mus\uFFFDic\uFFFD"); /// ``` pub fn from_utf16_lossy(v: &[u16]) -> ~str { @@ -1097,7 +1097,7 @@ static TAG_CONT_U8: u8 = 128u8; /// ```rust /// let input = bytes!("Hello ", 0xF0, 0x90, 0x80, "World"); /// let output = std::str::from_utf8_lossy(input); -/// assert_eq!(output.as_slice(), "Hello \uFFFDWorld"); +/// fail_unless_eq!(output.as_slice(), "Hello \uFFFDWorld"); /// ``` pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> { let firstbad = match first_non_utf8_index(v) { @@ -1529,7 +1529,7 @@ pub mod raw { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = a.as_ptr(); let c = from_buf_len(b, 3u); - assert_eq!(c, ~"AAA"); + fail_unless_eq!(c, ~"AAA"); } } } @@ -1703,7 +1703,7 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[char] = "abc åäö".chars().collect(); - /// assert_eq!(v, ~['a', 'b', 'c', ' ', 'å', 'ä', 'ö']); + /// fail_unless_eq!(v, ~['a', 'b', 'c', ' ', 'å', 'ä', 'ö']); /// ``` fn chars(&self) -> Chars<'a>; @@ -1730,13 +1730,13 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "Mary had a little lamb".split(' ').collect(); - /// assert_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); + /// fail_unless_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); /// /// let v: ~[&str] = "abc1def2ghi".split(|c: char| c.is_digit()).collect(); - /// assert_eq!(v, ~["abc", "def", "ghi"]); + /// fail_unless_eq!(v, ~["abc", "def", "ghi"]); /// /// let v: ~[&str] = "lionXXtigerXleopard".split('X').collect(); - /// assert_eq!(v, ~["lion", "", "tiger", "leopard"]); + /// fail_unless_eq!(v, ~["lion", "", "tiger", "leopard"]); /// ``` fn split(&self, sep: Sep) -> CharSplits<'a, Sep>; @@ -1748,13 +1748,13 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "Mary had a little lambda".splitn(' ', 2).collect(); - /// assert_eq!(v, ~["Mary", "had", "a little lambda"]); + /// fail_unless_eq!(v, ~["Mary", "had", "a little lambda"]); /// /// let v: ~[&str] = "abc1def2ghi".splitn(|c: char| c.is_digit(), 1).collect(); - /// assert_eq!(v, ~["abc", "def2ghi"]); + /// fail_unless_eq!(v, ~["abc", "def2ghi"]); /// /// let v: ~[&str] = "lionXXtigerXleopard".splitn('X', 2).collect(); - /// assert_eq!(v, ~["lion", "", "tigerXleopard"]); + /// fail_unless_eq!(v, ~["lion", "", "tigerXleopard"]); /// ``` fn splitn(&self, sep: Sep, count: uint) -> CharSplitsN<'a, Sep>; @@ -1768,10 +1768,10 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "A.B.".split_terminator('.').collect(); - /// assert_eq!(v, ~["A", "B"]); + /// fail_unless_eq!(v, ~["A", "B"]); /// /// let v: ~[&str] = "A..B..".split_terminator('.').collect(); - /// assert_eq!(v, ~["A", "", "B", ""]); + /// fail_unless_eq!(v, ~["A", "", "B", ""]); /// ``` fn split_terminator(&self, sep: Sep) -> CharSplits<'a, Sep>; @@ -1782,13 +1782,13 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "Mary had a little lamb".rsplit(' ').collect(); - /// assert_eq!(v, ~["lamb", "little", "a", "had", "Mary"]); + /// fail_unless_eq!(v, ~["lamb", "little", "a", "had", "Mary"]); /// /// let v: ~[&str] = "abc1def2ghi".rsplit(|c: char| c.is_digit()).collect(); - /// assert_eq!(v, ~["ghi", "def", "abc"]); + /// fail_unless_eq!(v, ~["ghi", "def", "abc"]); /// /// let v: ~[&str] = "lionXXtigerXleopard".rsplit('X').collect(); - /// assert_eq!(v, ~["leopard", "tiger", "", "lion"]); + /// fail_unless_eq!(v, ~["leopard", "tiger", "", "lion"]); /// ``` fn rsplit(&self, sep: Sep) -> RevCharSplits<'a, Sep>; @@ -1800,13 +1800,13 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "Mary had a little lamb".rsplitn(' ', 2).collect(); - /// assert_eq!(v, ~["lamb", "little", "Mary had a"]); + /// fail_unless_eq!(v, ~["lamb", "little", "Mary had a"]); /// /// let v: ~[&str] = "abc1def2ghi".rsplitn(|c: char| c.is_digit(), 1).collect(); - /// assert_eq!(v, ~["ghi", "abc1def"]); + /// fail_unless_eq!(v, ~["ghi", "abc1def"]); /// /// let v: ~[&str] = "lionXXtigerXleopard".rsplitn('X', 2).collect(); - /// assert_eq!(v, ~["leopard", "tiger", "lionX"]); + /// fail_unless_eq!(v, ~["leopard", "tiger", "lionX"]); /// ``` fn rsplitn(&self, sep: Sep, count: uint) -> CharSplitsN<'a, Sep>; @@ -1822,13 +1822,13 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[(uint, uint)] = "abcXXXabcYYYabc".match_indices("abc").collect(); - /// assert_eq!(v, ~[(0,3), (6,9), (12,15)]); + /// fail_unless_eq!(v, ~[(0,3), (6,9), (12,15)]); /// /// let v: ~[(uint, uint)] = "1abcabc2".match_indices("abc").collect(); - /// assert_eq!(v, ~[(1,4), (4,7)]); + /// fail_unless_eq!(v, ~[(1,4), (4,7)]); /// /// let v: ~[(uint, uint)] = "ababa".match_indices("aba").collect(); - /// assert_eq!(v, ~[(0, 3)]); // only the first `aba` + /// fail_unless_eq!(v, ~[(0, 3)]); // only the first `aba` /// ``` fn match_indices(&self, sep: &'a str) -> MatchIndices<'a>; @@ -1838,10 +1838,10 @@ pub trait StrSlice<'a> { /// /// ```rust /// let v: ~[&str] = "abcXXXabcYYYabc".split_str("abc").collect(); - /// assert_eq!(v, ~["", "XXX", "YYY", ""]); + /// fail_unless_eq!(v, ~["", "XXX", "YYY", ""]); /// /// let v: ~[&str] = "1abcabc2".split_str("abc").collect(); - /// assert_eq!(v, ~["1", "", "2"]); + /// fail_unless_eq!(v, ~["1", "", "2"]); /// ``` fn split_str(&self, &'a str) -> StrSplits<'a>; @@ -1854,7 +1854,7 @@ pub trait StrSlice<'a> { /// ```rust /// let four_lines = "foo\nbar\n\nbaz\n"; /// let v: ~[&str] = four_lines.lines().collect(); - /// assert_eq!(v, ~["foo", "bar", "", "baz"]); + /// fail_unless_eq!(v, ~["foo", "bar", "", "baz"]); /// ``` fn lines(&self) -> CharSplits<'a, char>; @@ -1867,7 +1867,7 @@ pub trait StrSlice<'a> { /// ```rust /// let four_lines = "foo\r\nbar\n\r\nbaz\n"; /// let v: ~[&str] = four_lines.lines_any().collect(); - /// assert_eq!(v, ~["foo", "bar", "", "baz"]); + /// fail_unless_eq!(v, ~["foo", "bar", "", "baz"]); /// ``` fn lines_any(&self) -> AnyLines<'a>; @@ -1880,7 +1880,7 @@ pub trait StrSlice<'a> { /// ```rust /// let some_words = " Mary had\ta little \n\t lamb"; /// let v: ~[&str] = some_words.words().collect(); - /// assert_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); + /// fail_unless_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); /// ``` fn words(&self) -> Words<'a>; @@ -1942,11 +1942,11 @@ pub trait StrSlice<'a> { /// // decomposed forms of `ö` and `é` /// let d = "Lo\u0308we 老虎 Le\u0301opard"; /// - /// assert_eq!(c.char_len(), 15); - /// assert_eq!(d.char_len(), 17); + /// fail_unless_eq!(c.char_len(), 15); + /// fail_unless_eq!(d.char_len(), 17); /// - /// assert_eq!(c.len(), 21); - /// assert_eq!(d.len(), 23); + /// fail_unless_eq!(c.len(), 21); + /// fail_unless_eq!(d.len(), 23); /// /// // the two strings *look* the same /// println!("{}", c); @@ -1970,9 +1970,9 @@ pub trait StrSlice<'a> { /// /// ```rust /// let s = "Löwe 老虎 Léopard"; - /// assert_eq!(s.slice(0, 1), "L"); + /// fail_unless_eq!(s.slice(0, 1), "L"); /// - /// assert_eq!(s.slice(1, 9), "öwe 老"); + /// fail_unless_eq!(s.slice(1, 9), "öwe 老"); /// /// // these will fail: /// // byte 2 lies within `ö`: @@ -2027,8 +2027,8 @@ pub trait StrSlice<'a> { /// /// ```rust /// let s = "Löwe 老虎 Léopard"; - /// assert_eq!(s.slice_chars(0, 4), "Löwe"); - /// assert_eq!(s.slice_chars(5, 7), "老虎"); + /// fail_unless_eq!(s.slice_chars(0, 4), "Löwe"); + /// fail_unless_eq!(s.slice_chars(5, 7), "老虎"); /// ``` fn slice_chars(&self, begin: uint, end: uint) -> &'a str; @@ -2062,9 +2062,9 @@ pub trait StrSlice<'a> { /// # Example /// /// ```rust - /// assert_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar") - /// assert_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar") - /// assert_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar") + /// fail_unless_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar") + /// fail_unless_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar") + /// fail_unless_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar") /// ``` fn trim_chars(&self, to_trim: &C) -> &'a str; @@ -2077,9 +2077,9 @@ pub trait StrSlice<'a> { /// # Example /// /// ```rust - /// assert_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11") - /// assert_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12") - /// assert_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123") + /// fail_unless_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11") + /// fail_unless_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12") + /// fail_unless_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123") /// ``` fn trim_left_chars(&self, to_trim: &C) -> &'a str; @@ -2092,9 +2092,9 @@ pub trait StrSlice<'a> { /// # Example /// /// ```rust - /// assert_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar") - /// assert_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar") - /// assert_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar") + /// fail_unless_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar") + /// fail_unless_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar") + /// fail_unless_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar") /// ``` fn trim_right_chars(&self, to_trim: &C) -> &'a str; @@ -2115,12 +2115,12 @@ pub trait StrSlice<'a> { /// let s = ~"Do you know the muffin man, /// The muffin man, the muffin man, ..."; /// - /// assert_eq!(s.replace("muffin man", "little lamb"), + /// fail_unless_eq!(s.replace("muffin man", "little lamb"), /// ~"Do you know the little lamb, /// The little lamb, the little lamb, ..."); /// /// // not found, so no change. - /// assert_eq!(s.replace("cookie monster", "little lamb"), s); + /// fail_unless_eq!(s.replace("cookie monster", "little lamb"), s); /// ``` fn replace(&self, from: &str, to: &str) -> ~str; @@ -2239,14 +2239,14 @@ pub trait StrSlice<'a> { /// ```rust /// let s = "Löwe 老虎 Léopard"; /// - /// assert_eq!(s.find('L'), Some(0)); - /// assert_eq!(s.find('é'), Some(14)); + /// fail_unless_eq!(s.find('L'), Some(0)); + /// fail_unless_eq!(s.find('é'), Some(14)); /// /// // the first space - /// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5)); + /// fail_unless_eq!(s.find(|c: char| c.is_whitespace()), Some(5)); /// /// // neither are found - /// assert_eq!(s.find(&['1', '2']), None); + /// fail_unless_eq!(s.find(&['1', '2']), None); /// ``` fn find(&self, search: C) -> Option; @@ -2263,14 +2263,14 @@ pub trait StrSlice<'a> { /// ```rust /// let s = "Löwe 老虎 Léopard"; /// - /// assert_eq!(s.rfind('L'), Some(13)); - /// assert_eq!(s.rfind('é'), Some(14)); + /// fail_unless_eq!(s.rfind('L'), Some(13)); + /// fail_unless_eq!(s.rfind('é'), Some(14)); /// /// // the second space - /// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12)); + /// fail_unless_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12)); /// /// // searches for an occurrence of either `1` or `2`, but neither are found - /// assert_eq!(s.rfind(&['1', '2']), None); + /// fail_unless_eq!(s.rfind(&['1', '2']), None); /// ``` fn rfind(&self, search: C) -> Option; @@ -2290,8 +2290,8 @@ pub trait StrSlice<'a> { /// ```rust /// let s = "Löwe 老虎 Léopard"; /// - /// assert_eq!(s.find_str("老虎 L"), Some(6)); - /// assert_eq!(s.find_str("muffin man"), None); + /// fail_unless_eq!(s.find_str("老虎 L"), Some(6)); + /// fail_unless_eq!(s.find_str("muffin man"), None); /// ``` fn find_str(&self, &str) -> Option; @@ -2312,12 +2312,12 @@ pub trait StrSlice<'a> { /// ```rust /// let s = "Löwe 老虎 Léopard"; /// let (c, s1) = s.slice_shift_char(); - /// assert_eq!(c, 'L'); - /// assert_eq!(s1, "öwe 老虎 Léopard"); + /// fail_unless_eq!(c, 'L'); + /// fail_unless_eq!(s1, "öwe 老虎 Léopard"); /// /// let (c, s2) = s1.slice_shift_char(); - /// assert_eq!(c, 'ö'); - /// assert_eq!(s2, "we 老虎 Léopard"); + /// fail_unless_eq!(c, 'ö'); + /// fail_unless_eq!(s2, "we 老虎 Léopard"); /// ``` fn slice_shift_char(&self) -> (char, &'a str); @@ -3117,80 +3117,80 @@ mod tests { #[test] fn test_len() { - assert_eq!("".len(), 0u); - assert_eq!("hello world".len(), 11u); - assert_eq!("\x63".len(), 1u); - assert_eq!("\xa2".len(), 2u); - assert_eq!("\u03c0".len(), 2u); - assert_eq!("\u2620".len(), 3u); - assert_eq!("\U0001d11e".len(), 4u); - - assert_eq!("".char_len(), 0u); - assert_eq!("hello world".char_len(), 11u); - assert_eq!("\x63".char_len(), 1u); - assert_eq!("\xa2".char_len(), 1u); - assert_eq!("\u03c0".char_len(), 1u); - assert_eq!("\u2620".char_len(), 1u); - assert_eq!("\U0001d11e".char_len(), 1u); - assert_eq!("ประเทศไทย中华Việt Nam".char_len(), 19u); + fail_unless_eq!("".len(), 0u); + fail_unless_eq!("hello world".len(), 11u); + fail_unless_eq!("\x63".len(), 1u); + fail_unless_eq!("\xa2".len(), 2u); + fail_unless_eq!("\u03c0".len(), 2u); + fail_unless_eq!("\u2620".len(), 3u); + fail_unless_eq!("\U0001d11e".len(), 4u); + + fail_unless_eq!("".char_len(), 0u); + fail_unless_eq!("hello world".char_len(), 11u); + fail_unless_eq!("\x63".char_len(), 1u); + fail_unless_eq!("\xa2".char_len(), 1u); + fail_unless_eq!("\u03c0".char_len(), 1u); + fail_unless_eq!("\u2620".char_len(), 1u); + fail_unless_eq!("\U0001d11e".char_len(), 1u); + fail_unless_eq!("ประเทศไทย中华Việt Nam".char_len(), 19u); } #[test] fn test_find() { - assert_eq!("hello".find('l'), Some(2u)); - assert_eq!("hello".find(|c:char| c == 'o'), Some(4u)); + fail_unless_eq!("hello".find('l'), Some(2u)); + fail_unless_eq!("hello".find(|c:char| c == 'o'), Some(4u)); fail_unless!("hello".find('x').is_none()); fail_unless!("hello".find(|c:char| c == 'x').is_none()); - assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u)); - assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u)); + fail_unless_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u)); + fail_unless_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u)); } #[test] fn test_rfind() { - assert_eq!("hello".rfind('l'), Some(3u)); - assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u)); + fail_unless_eq!("hello".rfind('l'), Some(3u)); + fail_unless_eq!("hello".rfind(|c:char| c == 'o'), Some(4u)); fail_unless!("hello".rfind('x').is_none()); fail_unless!("hello".rfind(|c:char| c == 'x').is_none()); - assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u)); - assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u)); + fail_unless_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u)); + fail_unless_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u)); } #[test] fn test_push_str() { let mut s = ~""; s.push_str(""); - assert_eq!(s.slice_from(0), ""); + fail_unless_eq!(s.slice_from(0), ""); s.push_str("abc"); - assert_eq!(s.slice_from(0), "abc"); + fail_unless_eq!(s.slice_from(0), "abc"); s.push_str("ประเทศไทย中华Việt Nam"); - assert_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam"); + fail_unless_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam"); } #[test] fn test_append() { let mut s = ~""; s = s.append(""); - assert_eq!(s.slice_from(0), ""); + fail_unless_eq!(s.slice_from(0), ""); s = s.append("abc"); - assert_eq!(s.slice_from(0), "abc"); + fail_unless_eq!(s.slice_from(0), "abc"); s = s.append("ประเทศไทย中华Việt Nam"); - assert_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam"); + fail_unless_eq!(s.slice_from(0), "abcประเทศไทย中华Việt Nam"); } #[test] fn test_pop_char() { let mut data = ~"ประเทศไทย中华"; let cc = data.pop_char(); - assert_eq!(~"ประเทศไทย中", data); - assert_eq!('华', cc); + fail_unless_eq!(~"ประเทศไทย中", data); + fail_unless_eq!('华', cc); } #[test] fn test_pop_char_2() { let mut data2 = ~"华"; let cc2 = data2.pop_char(); - assert_eq!(~"", data2); - assert_eq!('华', cc2); + fail_unless_eq!(~"", data2); + fail_unless_eq!('华', cc2); } #[test] @@ -3208,46 +3208,46 @@ mod tests { data.push_char('¢'); // 2 byte data.push_char('€'); // 3 byte data.push_char('𤭢'); // 4 byte - assert_eq!(~"ประเทศไทย中华b¢€𤭢", data); + fail_unless_eq!(~"ประเทศไทย中华b¢€𤭢", data); } #[test] fn test_shift_char() { let mut data = ~"ประเทศไทย中"; let cc = data.shift_char(); - assert_eq!(~"ระเทศไทย中", data); - assert_eq!('ป', cc); + fail_unless_eq!(~"ระเทศไทย中", data); + fail_unless_eq!('ป', cc); } #[test] fn test_unshift_char() { let mut data = ~"ประเทศไทย中"; data.unshift_char('华'); - assert_eq!(~"华ประเทศไทย中", data); + fail_unless_eq!(~"华ประเทศไทย中", data); } #[test] fn test_insert_char() { let mut data = ~"ประเทศไทย中"; data.insert_char(15, '华'); - assert_eq!(~"ประเท华ศไทย中", data); + fail_unless_eq!(~"ประเท华ศไทย中", data); } #[test] fn test_insert() { let mut data = ~"ประเทศไทย中"; data.insert(15, "华中"); - assert_eq!(~"ประเท华中ศไทย中", data); + fail_unless_eq!(~"ประเท华中ศไทย中", data); } #[test] fn test_collect() { let empty = ~""; let s: ~str = empty.chars().collect(); - assert_eq!(empty, s); + fail_unless_eq!(empty, s); let data = ~"ประเทศไทย中"; let s: ~str = data.chars().collect(); - assert_eq!(data, s); + fail_unless_eq!(data, s); } #[test] @@ -3257,75 +3257,75 @@ mod tests { let other = "abc"; let mut it = other.chars(); cpy.extend(&mut it); - assert_eq!(cpy, data + other); + fail_unless_eq!(cpy, data + other); } #[test] fn test_clear() { let mut empty = ~""; empty.clear(); - assert_eq!("", empty.as_slice()); + fail_unless_eq!("", empty.as_slice()); let mut data = ~"ประเทศไทย中"; data.clear(); - assert_eq!("", data.as_slice()); + fail_unless_eq!("", data.as_slice()); data.push_char('华'); - assert_eq!("华", data.as_slice()); + fail_unless_eq!("华", data.as_slice()); } #[test] fn test_into_bytes() { let data = ~"asdf"; let buf = data.into_bytes(); - assert_eq!(bytes!("asdf"), buf.as_slice()); + fail_unless_eq!(bytes!("asdf"), buf.as_slice()); } #[test] fn test_find_str() { // byte positions - assert_eq!("".find_str(""), Some(0u)); + fail_unless_eq!("".find_str(""), Some(0u)); fail_unless!("banana".find_str("apple pie").is_none()); let data = "abcabc"; - assert_eq!(data.slice(0u, 6u).find_str("ab"), Some(0u)); - assert_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u - 2u)); + fail_unless_eq!(data.slice(0u, 6u).find_str("ab"), Some(0u)); + fail_unless_eq!(data.slice(2u, 6u).find_str("ab"), Some(3u - 2u)); fail_unless!(data.slice(2u, 4u).find_str("ab").is_none()); let mut data = ~"ประเทศไทย中华Việt Nam"; data = data + data; fail_unless!(data.find_str("ไท华").is_none()); - assert_eq!(data.slice(0u, 43u).find_str(""), Some(0u)); - assert_eq!(data.slice(6u, 43u).find_str(""), Some(6u - 6u)); + fail_unless_eq!(data.slice(0u, 43u).find_str(""), Some(0u)); + fail_unless_eq!(data.slice(6u, 43u).find_str(""), Some(6u - 6u)); - assert_eq!(data.slice(0u, 43u).find_str("ประ"), Some( 0u)); - assert_eq!(data.slice(0u, 43u).find_str("ทศไ"), Some(12u)); - assert_eq!(data.slice(0u, 43u).find_str("ย中"), Some(24u)); - assert_eq!(data.slice(0u, 43u).find_str("iệt"), Some(34u)); - assert_eq!(data.slice(0u, 43u).find_str("Nam"), Some(40u)); + fail_unless_eq!(data.slice(0u, 43u).find_str("ประ"), Some( 0u)); + fail_unless_eq!(data.slice(0u, 43u).find_str("ทศไ"), Some(12u)); + fail_unless_eq!(data.slice(0u, 43u).find_str("ย中"), Some(24u)); + fail_unless_eq!(data.slice(0u, 43u).find_str("iệt"), Some(34u)); + fail_unless_eq!(data.slice(0u, 43u).find_str("Nam"), Some(40u)); - assert_eq!(data.slice(43u, 86u).find_str("ประ"), Some(43u - 43u)); - assert_eq!(data.slice(43u, 86u).find_str("ทศไ"), Some(55u - 43u)); - assert_eq!(data.slice(43u, 86u).find_str("ย中"), Some(67u - 43u)); - assert_eq!(data.slice(43u, 86u).find_str("iệt"), Some(77u - 43u)); - assert_eq!(data.slice(43u, 86u).find_str("Nam"), Some(83u - 43u)); + fail_unless_eq!(data.slice(43u, 86u).find_str("ประ"), Some(43u - 43u)); + fail_unless_eq!(data.slice(43u, 86u).find_str("ทศไ"), Some(55u - 43u)); + fail_unless_eq!(data.slice(43u, 86u).find_str("ย中"), Some(67u - 43u)); + fail_unless_eq!(data.slice(43u, 86u).find_str("iệt"), Some(77u - 43u)); + fail_unless_eq!(data.slice(43u, 86u).find_str("Nam"), Some(83u - 43u)); } #[test] fn test_slice_chars() { fn t(a: &str, b: &str, start: uint) { - assert_eq!(a.slice_chars(start, start + b.char_len()), b); + fail_unless_eq!(a.slice_chars(start, start + b.char_len()), b); } t("", "", 0); t("hello", "llo", 2); t("hello", "el", 1); t("αβλ", "β", 1); t("αβλ", "", 3); - assert_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8)); + fail_unless_eq!("ะเทศไท", "ประเทศไทย中华Việt Nam".slice_chars(2, 8)); } #[test] fn test_concat() { fn t(v: &[~str], s: &str) { - assert_eq!(v.concat(), s.to_str()); + fail_unless_eq!(v.concat(), s.to_str()); } t([~"you", ~"know", ~"I'm", ~"no", ~"good"], "youknowI'mnogood"); let v: &[~str] = []; @@ -3336,7 +3336,7 @@ mod tests { #[test] fn test_connect() { fn t(v: &[~str], sep: &str, s: &str) { - assert_eq!(v.connect(sep), s.to_str()); + fail_unless_eq!(v.connect(sep), s.to_str()); } t([~"you", ~"know", ~"I'm", ~"no", ~"good"], " ", "you know I'm no good"); @@ -3348,7 +3348,7 @@ mod tests { #[test] fn test_concat_slices() { fn t(v: &[&str], s: &str) { - assert_eq!(v.concat(), s.to_str()); + fail_unless_eq!(v.concat(), s.to_str()); } t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); let v: &[&str] = []; @@ -3359,7 +3359,7 @@ mod tests { #[test] fn test_connect_slices() { fn t(v: &[&str], sep: &str, s: &str) { - assert_eq!(v.connect(sep), s.to_str()); + fail_unless_eq!(v.connect(sep), s.to_str()); } t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); @@ -3369,18 +3369,18 @@ mod tests { #[test] fn test_repeat() { - assert_eq!("x".repeat(4), ~"xxxx"); - assert_eq!("hi".repeat(4), ~"hihihihi"); - assert_eq!("ไท华".repeat(3), ~"ไท华ไท华ไท华"); - assert_eq!("".repeat(4), ~""); - assert_eq!("hi".repeat(0), ~""); + fail_unless_eq!("x".repeat(4), ~"xxxx"); + fail_unless_eq!("hi".repeat(4), ~"hihihihi"); + fail_unless_eq!("ไท华".repeat(3), ~"ไท华ไท华ไท华"); + fail_unless_eq!("".repeat(4), ~""); + fail_unless_eq!("hi".repeat(0), ~""); } #[test] fn test_unsafe_slice() { - assert_eq!("ab", unsafe {raw::slice_bytes("abc", 0, 2)}); - assert_eq!("bc", unsafe {raw::slice_bytes("abc", 1, 3)}); - assert_eq!("", unsafe {raw::slice_bytes("abc", 1, 1)}); + fail_unless_eq!("ab", unsafe {raw::slice_bytes("abc", 0, 2)}); + fail_unless_eq!("bc", unsafe {raw::slice_bytes("abc", 1, 3)}); + fail_unless_eq!("", unsafe {raw::slice_bytes("abc", 1, 1)}); fn a_million_letter_a() -> ~str { let mut i = 0; let mut rs = ~""; @@ -3429,13 +3429,13 @@ mod tests { #[test] fn test_replace() { let a = "a"; - assert_eq!("".replace(a, "b"), ~""); - assert_eq!("a".replace(a, "b"), ~"b"); - assert_eq!("ab".replace(a, "b"), ~"bb"); + fail_unless_eq!("".replace(a, "b"), ~""); + fail_unless_eq!("a".replace(a, "b"), ~"b"); + fail_unless_eq!("ab".replace(a, "b"), ~"bb"); let test = "test"; fail_unless!(" test test ".replace(test, "toast") == ~" toast toast "); - assert_eq!(" test test ".replace(test, ""), ~" "); + fail_unless_eq!(" test test ".replace(test, ""), ~" "); } #[test] @@ -3445,7 +3445,7 @@ mod tests { let a = ~"ประเ"; let A = ~"دولة الكويتทศไทย中华"; - assert_eq!(data.replace(a, repl), A); + fail_unless_eq!(data.replace(a, repl), A); } #[test] @@ -3455,7 +3455,7 @@ mod tests { let b = ~"ะเ"; let B = ~"ปรدولة الكويتทศไทย中华"; - assert_eq!(data.replace(b, repl), B); + fail_unless_eq!(data.replace(b, repl), B); } #[test] @@ -3465,7 +3465,7 @@ mod tests { let c = ~"中华"; let C = ~"ประเทศไทยدولة الكويت"; - assert_eq!(data.replace(c, repl), C); + fail_unless_eq!(data.replace(c, repl), C); } #[test] @@ -3474,21 +3474,21 @@ mod tests { let repl = ~"دولة الكويت"; let d = ~"ไท华"; - assert_eq!(data.replace(d, repl), data); + fail_unless_eq!(data.replace(d, repl), data); } #[test] fn test_slice() { - assert_eq!("ab", "abc".slice(0, 2)); - assert_eq!("bc", "abc".slice(1, 3)); - assert_eq!("", "abc".slice(1, 1)); - assert_eq!("\u65e5", "\u65e5\u672c".slice(0, 3)); + fail_unless_eq!("ab", "abc".slice(0, 2)); + fail_unless_eq!("bc", "abc".slice(1, 3)); + fail_unless_eq!("", "abc".slice(1, 1)); + fail_unless_eq!("\u65e5", "\u65e5\u672c".slice(0, 3)); let data = "ประเทศไทย中华"; - assert_eq!("ป", data.slice(0, 3)); - assert_eq!("ร", data.slice(3, 6)); - assert_eq!("", data.slice(3, 3)); - assert_eq!("华", data.slice(30, 33)); + fail_unless_eq!("ป", data.slice(0, 3)); + fail_unless_eq!("ร", data.slice(3, 6)); + fail_unless_eq!("", data.slice(3, 3)); + fail_unless_eq!("华", data.slice(30, 33)); fn a_million_letter_X() -> ~str { let mut i = 0; @@ -3514,16 +3514,16 @@ mod tests { fn test_slice_2() { let ss = "中华Việt Nam"; - assert_eq!("华", ss.slice(3u, 6u)); - assert_eq!("Việt Nam", ss.slice(6u, 16u)); + fail_unless_eq!("华", ss.slice(3u, 6u)); + fail_unless_eq!("Việt Nam", ss.slice(6u, 16u)); - assert_eq!("ab", "abc".slice(0u, 2u)); - assert_eq!("bc", "abc".slice(1u, 3u)); - assert_eq!("", "abc".slice(1u, 1u)); + fail_unless_eq!("ab", "abc".slice(0u, 2u)); + fail_unless_eq!("bc", "abc".slice(1u, 3u)); + fail_unless_eq!("", "abc".slice(1u, 1u)); - assert_eq!("中", ss.slice(0u, 3u)); - assert_eq!("华V", ss.slice(3u, 7u)); - assert_eq!("", ss.slice(3u, 3u)); + fail_unless_eq!("中", ss.slice(0u, 3u)); + fail_unless_eq!("华V", ss.slice(3u, 7u)); + fail_unless_eq!("", ss.slice(3u, 3u)); /*0: 中 3: 华 6: V @@ -3544,84 +3544,84 @@ mod tests { #[test] fn test_slice_from() { - assert_eq!("abcd".slice_from(0), "abcd"); - assert_eq!("abcd".slice_from(2), "cd"); - assert_eq!("abcd".slice_from(4), ""); + fail_unless_eq!("abcd".slice_from(0), "abcd"); + fail_unless_eq!("abcd".slice_from(2), "cd"); + fail_unless_eq!("abcd".slice_from(4), ""); } #[test] fn test_slice_to() { - assert_eq!("abcd".slice_to(0), ""); - assert_eq!("abcd".slice_to(2), "ab"); - assert_eq!("abcd".slice_to(4), "abcd"); + fail_unless_eq!("abcd".slice_to(0), ""); + fail_unless_eq!("abcd".slice_to(2), "ab"); + fail_unless_eq!("abcd".slice_to(4), "abcd"); } #[test] fn test_trim_left_chars() { let v: &[char] = &[]; - assert_eq!(" *** foo *** ".trim_left_chars(&v), " *** foo *** "); - assert_eq!(" *** foo *** ".trim_left_chars(& &['*', ' ']), "foo *** "); - assert_eq!(" *** *** ".trim_left_chars(& &['*', ' ']), ""); - assert_eq!("foo *** ".trim_left_chars(& &['*', ' ']), "foo *** "); + fail_unless_eq!(" *** foo *** ".trim_left_chars(&v), " *** foo *** "); + fail_unless_eq!(" *** foo *** ".trim_left_chars(& &['*', ' ']), "foo *** "); + fail_unless_eq!(" *** *** ".trim_left_chars(& &['*', ' ']), ""); + fail_unless_eq!("foo *** ".trim_left_chars(& &['*', ' ']), "foo *** "); - assert_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11"); - assert_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12"); - assert_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123"); + fail_unless_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11"); + fail_unless_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12"); + fail_unless_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123"); } #[test] fn test_trim_right_chars() { let v: &[char] = &[]; - assert_eq!(" *** foo *** ".trim_right_chars(&v), " *** foo *** "); - assert_eq!(" *** foo *** ".trim_right_chars(& &['*', ' ']), " *** foo"); - assert_eq!(" *** *** ".trim_right_chars(& &['*', ' ']), ""); - assert_eq!(" *** foo".trim_right_chars(& &['*', ' ']), " *** foo"); + fail_unless_eq!(" *** foo *** ".trim_right_chars(&v), " *** foo *** "); + fail_unless_eq!(" *** foo *** ".trim_right_chars(& &['*', ' ']), " *** foo"); + fail_unless_eq!(" *** *** ".trim_right_chars(& &['*', ' ']), ""); + fail_unless_eq!(" *** foo".trim_right_chars(& &['*', ' ']), " *** foo"); - assert_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar"); - assert_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar"); - assert_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar"); + fail_unless_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar"); + fail_unless_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar"); + fail_unless_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar"); } #[test] fn test_trim_chars() { let v: &[char] = &[]; - assert_eq!(" *** foo *** ".trim_chars(&v), " *** foo *** "); - assert_eq!(" *** foo *** ".trim_chars(& &['*', ' ']), "foo"); - assert_eq!(" *** *** ".trim_chars(& &['*', ' ']), ""); - assert_eq!("foo".trim_chars(& &['*', ' ']), "foo"); + fail_unless_eq!(" *** foo *** ".trim_chars(&v), " *** foo *** "); + fail_unless_eq!(" *** foo *** ".trim_chars(& &['*', ' ']), "foo"); + fail_unless_eq!(" *** *** ".trim_chars(& &['*', ' ']), ""); + fail_unless_eq!("foo".trim_chars(& &['*', ' ']), "foo"); - assert_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar"); - assert_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar"); - assert_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar"); + fail_unless_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar"); + fail_unless_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar"); + fail_unless_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar"); } #[test] fn test_trim_left() { - assert_eq!("".trim_left(), ""); - assert_eq!("a".trim_left(), "a"); - assert_eq!(" ".trim_left(), ""); - assert_eq!(" blah".trim_left(), "blah"); - assert_eq!(" \u3000 wut".trim_left(), "wut"); - assert_eq!("hey ".trim_left(), "hey "); + fail_unless_eq!("".trim_left(), ""); + fail_unless_eq!("a".trim_left(), "a"); + fail_unless_eq!(" ".trim_left(), ""); + fail_unless_eq!(" blah".trim_left(), "blah"); + fail_unless_eq!(" \u3000 wut".trim_left(), "wut"); + fail_unless_eq!("hey ".trim_left(), "hey "); } #[test] fn test_trim_right() { - assert_eq!("".trim_right(), ""); - assert_eq!("a".trim_right(), "a"); - assert_eq!(" ".trim_right(), ""); - assert_eq!("blah ".trim_right(), "blah"); - assert_eq!("wut \u3000 ".trim_right(), "wut"); - assert_eq!(" hey".trim_right(), " hey"); + fail_unless_eq!("".trim_right(), ""); + fail_unless_eq!("a".trim_right(), "a"); + fail_unless_eq!(" ".trim_right(), ""); + fail_unless_eq!("blah ".trim_right(), "blah"); + fail_unless_eq!("wut \u3000 ".trim_right(), "wut"); + fail_unless_eq!(" hey".trim_right(), " hey"); } #[test] fn test_trim() { - assert_eq!("".trim(), ""); - assert_eq!("a".trim(), "a"); - assert_eq!(" ".trim(), ""); - assert_eq!(" blah ".trim(), "blah"); - assert_eq!("\nwut \u3000 ".trim(), "wut"); - assert_eq!(" hey dude ".trim(), "hey dude"); + fail_unless_eq!("".trim(), ""); + fail_unless_eq!("a".trim(), "a"); + fail_unless_eq!(" ".trim(), ""); + fail_unless_eq!(" blah ".trim(), "blah"); + fail_unless_eq!("\nwut \u3000 ".trim(), "wut"); + fail_unless_eq!(" hey dude ".trim(), "hey dude"); } #[test] @@ -3637,23 +3637,23 @@ mod tests { fn test_push_byte() { let mut s = ~"ABC"; unsafe{raw::push_byte(&mut s, 'D' as u8)}; - assert_eq!(s, ~"ABCD"); + fail_unless_eq!(s, ~"ABCD"); } #[test] fn test_shift_byte() { let mut s = ~"ABC"; let b = unsafe{raw::shift_byte(&mut s)}; - assert_eq!(s, ~"BC"); - assert_eq!(b, 65u8); + fail_unless_eq!(s, ~"BC"); + fail_unless_eq!(b, 65u8); } #[test] fn test_pop_byte() { let mut s = ~"ABC"; let b = unsafe{raw::pop_byte(&mut s)}; - assert_eq!(s, ~"AB"); - assert_eq!(b, 67u8); + fail_unless_eq!(s, ~"AB"); + fail_unless_eq!(b, 67u8); } #[test] @@ -3746,7 +3746,7 @@ mod tests { let a = ~[65, 65, 65, 65, 65, 65, 65, 0]; let b = a.as_ptr(); let c = raw::from_c_str(b); - assert_eq!(c, ~"AAAAAAA"); + fail_unless_eq!(c, ~"AAAAAAA"); } } @@ -3758,9 +3758,9 @@ mod tests { 184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97, 109 ]; - assert_eq!("".as_bytes(), &[]); - assert_eq!("abc".as_bytes(), &['a' as u8, 'b' as u8, 'c' as u8]); - assert_eq!("ศไทย中华Việt Nam".as_bytes(), v); + fail_unless_eq!("".as_bytes(), &[]); + fail_unless_eq!("abc".as_bytes(), &['a' as u8, 'b' as u8, 'c' as u8]); + fail_unless_eq!("ศไทย中华Việt Nam".as_bytes(), v); } #[test] @@ -3777,11 +3777,11 @@ mod tests { fn test_as_ptr() { let buf = "hello".as_ptr(); unsafe { - assert_eq!(*buf.offset(0), 'h' as u8); - assert_eq!(*buf.offset(1), 'e' as u8); - assert_eq!(*buf.offset(2), 'l' as u8); - assert_eq!(*buf.offset(3), 'l' as u8); - assert_eq!(*buf.offset(4), 'o' as u8); + fail_unless_eq!(*buf.offset(0), 'h' as u8); + fail_unless_eq!(*buf.offset(1), 'e' as u8); + fail_unless_eq!(*buf.offset(2), 'l' as u8); + fail_unless_eq!(*buf.offset(3), 'l' as u8); + fail_unless_eq!(*buf.offset(4), 'o' as u8); } } @@ -3790,15 +3790,15 @@ mod tests { let a = "kernelsprite"; let b = a.slice(7, a.len()); let c = a.slice(0, a.len() - 6); - assert_eq!(a.subslice_offset(b), 7); - assert_eq!(a.subslice_offset(c), 0); + fail_unless_eq!(a.subslice_offset(b), 7); + fail_unless_eq!(a.subslice_offset(c), 0); let string = "a\nb\nc"; let mut lines = ~[]; for line in string.lines() { lines.push(line) } - assert_eq!(string.subslice_offset(lines[0]), 0); - assert_eq!(string.subslice_offset(lines[1]), 2); - assert_eq!(string.subslice_offset(lines[2]), 4); + fail_unless_eq!(string.subslice_offset(lines[0]), 0); + fail_unless_eq!(string.subslice_offset(lines[1]), 2); + fail_unless_eq!(string.subslice_offset(lines[2]), 4); } #[test] @@ -3818,13 +3818,13 @@ mod tests { let mut i: uint = 0u; let n1: uint = s1.len(); let n2: uint = v.len(); - assert_eq!(n1, n2); + fail_unless_eq!(n1, n2); while i < n1 { let a: u8 = s1[i]; let b: u8 = s2[i]; debug!("{}", a); debug!("{}", b); - assert_eq!(a, b); + fail_unless_eq!(a, b); i += 1u; } } @@ -3899,13 +3899,13 @@ mod tests { for p in pairs.iter() { let (s, u) = (*p).clone(); fail_unless!(is_utf16(u)); - assert_eq!(s.to_utf16(), u); + fail_unless_eq!(s.to_utf16(), u); - assert_eq!(from_utf16(u).unwrap(), s); - assert_eq!(from_utf16_lossy(u), s); + fail_unless_eq!(from_utf16(u).unwrap(), s); + fail_unless_eq!(from_utf16_lossy(u), s); - assert_eq!(from_utf16(s.to_utf16()).unwrap(), s); - assert_eq!(from_utf16(u).unwrap().to_utf16(), u); + fail_unless_eq!(from_utf16(s.to_utf16()).unwrap(), s); + fail_unless_eq!(from_utf16(u).unwrap().to_utf16(), u); } } @@ -3913,48 +3913,48 @@ mod tests { fn test_utf16_invalid() { // completely positive cases tested above. // lead + eof - assert_eq!(from_utf16([0xD800]), None); + fail_unless_eq!(from_utf16([0xD800]), None); // lead + lead - assert_eq!(from_utf16([0xD800, 0xD800]), None); + fail_unless_eq!(from_utf16([0xD800, 0xD800]), None); // isolated trail - assert_eq!(from_utf16([0x0061, 0xDC00]), None); + fail_unless_eq!(from_utf16([0x0061, 0xDC00]), None); // general - assert_eq!(from_utf16([0xD800, 0xd801, 0xdc8b, 0xD800]), None); + fail_unless_eq!(from_utf16([0xD800, 0xd801, 0xdc8b, 0xD800]), None); } #[test] fn test_utf16_lossy() { // completely positive cases tested above. // lead + eof - assert_eq!(from_utf16_lossy([0xD800]), ~"\uFFFD"); + fail_unless_eq!(from_utf16_lossy([0xD800]), ~"\uFFFD"); // lead + lead - assert_eq!(from_utf16_lossy([0xD800, 0xD800]), ~"\uFFFD\uFFFD"); + fail_unless_eq!(from_utf16_lossy([0xD800, 0xD800]), ~"\uFFFD\uFFFD"); // isolated trail - assert_eq!(from_utf16_lossy([0x0061, 0xDC00]), ~"a\uFFFD"); + fail_unless_eq!(from_utf16_lossy([0x0061, 0xDC00]), ~"a\uFFFD"); // general - assert_eq!(from_utf16_lossy([0xD800, 0xd801, 0xdc8b, 0xD800]), ~"\uFFFD𐒋\uFFFD"); + fail_unless_eq!(from_utf16_lossy([0xD800, 0xd801, 0xdc8b, 0xD800]), ~"\uFFFD𐒋\uFFFD"); } #[test] fn test_truncate_utf16_at_nul() { let v = []; - assert_eq!(truncate_utf16_at_nul(v), &[]); + fail_unless_eq!(truncate_utf16_at_nul(v), &[]); let v = [0, 2, 3]; - assert_eq!(truncate_utf16_at_nul(v), &[]); + fail_unless_eq!(truncate_utf16_at_nul(v), &[]); let v = [1, 0, 3]; - assert_eq!(truncate_utf16_at_nul(v), &[1]); + fail_unless_eq!(truncate_utf16_at_nul(v), &[1]); let v = [1, 2, 0]; - assert_eq!(truncate_utf16_at_nul(v), &[1, 2]); + fail_unless_eq!(truncate_utf16_at_nul(v), &[1, 2]); let v = [1, 2, 3]; - assert_eq!(truncate_utf16_at_nul(v), &[1, 2, 3]); + fail_unless_eq!(truncate_utf16_at_nul(v), &[1, 2, 3]); } #[test] @@ -3981,27 +3981,27 @@ mod tests { #[test] fn test_escape_unicode() { - assert_eq!("abc".escape_unicode(), ~"\\x61\\x62\\x63"); - assert_eq!("a c".escape_unicode(), ~"\\x61\\x20\\x63"); - assert_eq!("\r\n\t".escape_unicode(), ~"\\x0d\\x0a\\x09"); - assert_eq!("'\"\\".escape_unicode(), ~"\\x27\\x22\\x5c"); - assert_eq!("\x00\x01\xfe\xff".escape_unicode(), ~"\\x00\\x01\\xfe\\xff"); - assert_eq!("\u0100\uffff".escape_unicode(), ~"\\u0100\\uffff"); - assert_eq!("\U00010000\U0010ffff".escape_unicode(), ~"\\U00010000\\U0010ffff"); - assert_eq!("ab\ufb00".escape_unicode(), ~"\\x61\\x62\\ufb00"); - assert_eq!("\U0001d4ea\r".escape_unicode(), ~"\\U0001d4ea\\x0d"); + fail_unless_eq!("abc".escape_unicode(), ~"\\x61\\x62\\x63"); + fail_unless_eq!("a c".escape_unicode(), ~"\\x61\\x20\\x63"); + fail_unless_eq!("\r\n\t".escape_unicode(), ~"\\x0d\\x0a\\x09"); + fail_unless_eq!("'\"\\".escape_unicode(), ~"\\x27\\x22\\x5c"); + fail_unless_eq!("\x00\x01\xfe\xff".escape_unicode(), ~"\\x00\\x01\\xfe\\xff"); + fail_unless_eq!("\u0100\uffff".escape_unicode(), ~"\\u0100\\uffff"); + fail_unless_eq!("\U00010000\U0010ffff".escape_unicode(), ~"\\U00010000\\U0010ffff"); + fail_unless_eq!("ab\ufb00".escape_unicode(), ~"\\x61\\x62\\ufb00"); + fail_unless_eq!("\U0001d4ea\r".escape_unicode(), ~"\\U0001d4ea\\x0d"); } #[test] fn test_escape_default() { - assert_eq!("abc".escape_default(), ~"abc"); - assert_eq!("a c".escape_default(), ~"a c"); - assert_eq!("\r\n\t".escape_default(), ~"\\r\\n\\t"); - assert_eq!("'\"\\".escape_default(), ~"\\'\\\"\\\\"); - assert_eq!("\u0100\uffff".escape_default(), ~"\\u0100\\uffff"); - assert_eq!("\U00010000\U0010ffff".escape_default(), ~"\\U00010000\\U0010ffff"); - assert_eq!("ab\ufb00".escape_default(), ~"ab\\ufb00"); - assert_eq!("\U0001d4ea\r".escape_default(), ~"\\U0001d4ea\\r"); + fail_unless_eq!("abc".escape_default(), ~"abc"); + fail_unless_eq!("a c".escape_default(), ~"a c"); + fail_unless_eq!("\r\n\t".escape_default(), ~"\\r\\n\\t"); + fail_unless_eq!("'\"\\".escape_default(), ~"\\'\\\"\\\\"); + fail_unless_eq!("\u0100\uffff".escape_default(), ~"\\u0100\\uffff"); + fail_unless_eq!("\U00010000\U0010ffff".escape_default(), ~"\\U00010000\\U0010ffff"); + fail_unless_eq!("ab\ufb00".escape_default(), ~"ab\\ufb00"); + fail_unless_eq!("\U0001d4ea\r".escape_default(), ~"\\U0001d4ea\\r"); } #[test] @@ -4016,19 +4016,19 @@ mod tests { #[test] fn test_char_range_at() { let data = ~"b¢€𤭢𤭢€¢b"; - assert_eq!('b', data.char_range_at(0).ch); - assert_eq!('¢', data.char_range_at(1).ch); - assert_eq!('€', data.char_range_at(3).ch); - assert_eq!('𤭢', data.char_range_at(6).ch); - assert_eq!('𤭢', data.char_range_at(10).ch); - assert_eq!('€', data.char_range_at(14).ch); - assert_eq!('¢', data.char_range_at(17).ch); - assert_eq!('b', data.char_range_at(19).ch); + fail_unless_eq!('b', data.char_range_at(0).ch); + fail_unless_eq!('¢', data.char_range_at(1).ch); + fail_unless_eq!('€', data.char_range_at(3).ch); + fail_unless_eq!('𤭢', data.char_range_at(6).ch); + fail_unless_eq!('𤭢', data.char_range_at(10).ch); + fail_unless_eq!('€', data.char_range_at(14).ch); + fail_unless_eq!('¢', data.char_range_at(17).ch); + fail_unless_eq!('b', data.char_range_at(19).ch); } #[test] fn test_char_range_at_reverse_underflow() { - assert_eq!("abc".char_range_at_reverse(0).next, 0); + fail_unless_eq!("abc".char_range_at_reverse(0).next, 0); } #[test] @@ -4039,8 +4039,8 @@ mod tests { let s1 = $s1; let s2 = $s2; let e = $e; - assert_eq!(s1 + s2, e.to_owned()); - assert_eq!(s1.to_owned() + s2, e.to_owned()); + fail_unless_eq!(s1 + s2, e.to_owned()); + fail_unless_eq!(s1.to_owned() + s2, e.to_owned()); } } ); @@ -4060,10 +4060,10 @@ mod tests { let mut it = s.chars(); for c in it { - assert_eq!(c, v[pos]); + fail_unless_eq!(c, v[pos]); pos += 1; } - assert_eq!(pos, v.len()); + fail_unless_eq!(pos, v.len()); } #[test] @@ -4076,10 +4076,10 @@ mod tests { let mut it = s.chars_rev(); for c in it { - assert_eq!(c, v[pos]); + fail_unless_eq!(c, v[pos]); pos += 1; } - assert_eq!(pos, v.len()); + fail_unless_eq!(pos, v.len()); } #[test] @@ -4101,7 +4101,7 @@ mod tests { let mut pos = 0; for b in s.bytes() { - assert_eq!(b, v[pos]); + fail_unless_eq!(b, v[pos]); pos += 1; } } @@ -4118,7 +4118,7 @@ mod tests { for b in s.bytes_rev() { pos -= 1; - assert_eq!(b, v[pos]); + fail_unless_eq!(b, v[pos]); } } @@ -4133,11 +4133,11 @@ mod tests { let mut it = s.char_indices(); for c in it { - assert_eq!(c, (p[pos], v[pos])); + fail_unless_eq!(c, (p[pos], v[pos])); pos += 1; } - assert_eq!(pos, v.len()); - assert_eq!(pos, p.len()); + fail_unless_eq!(pos, v.len()); + fail_unless_eq!(pos, p.len()); } #[test] @@ -4151,11 +4151,11 @@ mod tests { let mut it = s.char_indices_rev(); for c in it { - assert_eq!(c, (p[pos], v[pos])); + fail_unless_eq!(c, (p[pos], v[pos])); pos += 1; } - assert_eq!(pos, v.len()); - assert_eq!(pos, p.len()); + fail_unless_eq!(pos, v.len()); + fail_unless_eq!(pos, p.len()); } #[test] @@ -4163,33 +4163,33 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.split(' ').collect(); - assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let mut rsplit: ~[&str] = data.rsplit(' ').collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let split: ~[&str] = data.split(|c: char| c == ' ').collect(); - assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let mut rsplit: ~[&str] = data.rsplit(|c: char| c == ' ').collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); // Unicode let split: ~[&str] = data.split('ä').collect(); - assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let mut rsplit: ~[&str] = data.rsplit('ä').collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let split: ~[&str] = data.split(|c: char| c == 'ä').collect(); - assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let mut rsplit: ~[&str] = data.rsplit(|c: char| c == 'ä').collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); } #[test] @@ -4197,17 +4197,17 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.splitn(' ', 3).collect(); - assert_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); + fail_unless_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); let split: ~[&str] = data.splitn(|c: char| c == ' ', 3).collect(); - assert_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); + fail_unless_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); // Unicode let split: ~[&str] = data.splitn('ä', 3).collect(); - assert_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); + fail_unless_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); let split: ~[&str] = data.splitn(|c: char| c == 'ä', 3).collect(); - assert_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); + fail_unless_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); } #[test] @@ -4216,20 +4216,20 @@ mod tests { let mut split: ~[&str] = data.rsplitn(' ', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); let mut split: ~[&str] = data.rsplitn(|c: char| c == ' ', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); + fail_unless_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); // Unicode let mut split: ~[&str] = data.rsplitn('ä', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); let mut split: ~[&str] = data.rsplitn(|c: char| c == 'ä', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); + fail_unless_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); } #[test] @@ -4237,10 +4237,10 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.split('\n').collect(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); + fail_unless_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); let split: ~[&str] = data.split_terminator('\n').collect(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); + fail_unless_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); } #[test] @@ -4249,64 +4249,64 @@ mod tests { let mut split: ~[&str] = data.split('\n').rev().collect(); split.reverse(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); + fail_unless_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); let mut split: ~[&str] = data.split_terminator('\n').rev().collect(); split.reverse(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); + fail_unless_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); } #[test] fn test_words() { let data = "\n \tMäry häd\tä little lämb\nLittle lämb\n"; let words: ~[&str] = data.words().collect(); - assert_eq!(words, ~["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"]) + fail_unless_eq!(words, ~["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"]) } #[test] fn test_nfd_chars() { - assert_eq!("abc".nfd_chars().collect::<~str>(), ~"abc"); - assert_eq!("\u1e0b\u01c4".nfd_chars().collect::<~str>(), ~"d\u0307\u01c4"); - assert_eq!("\u2026".nfd_chars().collect::<~str>(), ~"\u2026"); - assert_eq!("\u2126".nfd_chars().collect::<~str>(), ~"\u03a9"); - assert_eq!("\u1e0b\u0323".nfd_chars().collect::<~str>(), ~"d\u0323\u0307"); - assert_eq!("\u1e0d\u0307".nfd_chars().collect::<~str>(), ~"d\u0323\u0307"); - assert_eq!("a\u0301".nfd_chars().collect::<~str>(), ~"a\u0301"); - assert_eq!("\u0301a".nfd_chars().collect::<~str>(), ~"\u0301a"); - assert_eq!("\ud4db".nfd_chars().collect::<~str>(), ~"\u1111\u1171\u11b6"); - assert_eq!("\uac1c".nfd_chars().collect::<~str>(), ~"\u1100\u1162"); + fail_unless_eq!("abc".nfd_chars().collect::<~str>(), ~"abc"); + fail_unless_eq!("\u1e0b\u01c4".nfd_chars().collect::<~str>(), ~"d\u0307\u01c4"); + fail_unless_eq!("\u2026".nfd_chars().collect::<~str>(), ~"\u2026"); + fail_unless_eq!("\u2126".nfd_chars().collect::<~str>(), ~"\u03a9"); + fail_unless_eq!("\u1e0b\u0323".nfd_chars().collect::<~str>(), ~"d\u0323\u0307"); + fail_unless_eq!("\u1e0d\u0307".nfd_chars().collect::<~str>(), ~"d\u0323\u0307"); + fail_unless_eq!("a\u0301".nfd_chars().collect::<~str>(), ~"a\u0301"); + fail_unless_eq!("\u0301a".nfd_chars().collect::<~str>(), ~"\u0301a"); + fail_unless_eq!("\ud4db".nfd_chars().collect::<~str>(), ~"\u1111\u1171\u11b6"); + fail_unless_eq!("\uac1c".nfd_chars().collect::<~str>(), ~"\u1100\u1162"); } #[test] fn test_nfkd_chars() { - assert_eq!("abc".nfkd_chars().collect::<~str>(), ~"abc"); - assert_eq!("\u1e0b\u01c4".nfkd_chars().collect::<~str>(), ~"d\u0307DZ\u030c"); - assert_eq!("\u2026".nfkd_chars().collect::<~str>(), ~"..."); - assert_eq!("\u2126".nfkd_chars().collect::<~str>(), ~"\u03a9"); - assert_eq!("\u1e0b\u0323".nfkd_chars().collect::<~str>(), ~"d\u0323\u0307"); - assert_eq!("\u1e0d\u0307".nfkd_chars().collect::<~str>(), ~"d\u0323\u0307"); - assert_eq!("a\u0301".nfkd_chars().collect::<~str>(), ~"a\u0301"); - assert_eq!("\u0301a".nfkd_chars().collect::<~str>(), ~"\u0301a"); - assert_eq!("\ud4db".nfkd_chars().collect::<~str>(), ~"\u1111\u1171\u11b6"); - assert_eq!("\uac1c".nfkd_chars().collect::<~str>(), ~"\u1100\u1162"); + fail_unless_eq!("abc".nfkd_chars().collect::<~str>(), ~"abc"); + fail_unless_eq!("\u1e0b\u01c4".nfkd_chars().collect::<~str>(), ~"d\u0307DZ\u030c"); + fail_unless_eq!("\u2026".nfkd_chars().collect::<~str>(), ~"..."); + fail_unless_eq!("\u2126".nfkd_chars().collect::<~str>(), ~"\u03a9"); + fail_unless_eq!("\u1e0b\u0323".nfkd_chars().collect::<~str>(), ~"d\u0323\u0307"); + fail_unless_eq!("\u1e0d\u0307".nfkd_chars().collect::<~str>(), ~"d\u0323\u0307"); + fail_unless_eq!("a\u0301".nfkd_chars().collect::<~str>(), ~"a\u0301"); + fail_unless_eq!("\u0301a".nfkd_chars().collect::<~str>(), ~"\u0301a"); + fail_unless_eq!("\ud4db".nfkd_chars().collect::<~str>(), ~"\u1111\u1171\u11b6"); + fail_unless_eq!("\uac1c".nfkd_chars().collect::<~str>(), ~"\u1100\u1162"); } #[test] fn test_lines() { let data = "\nMäry häd ä little lämb\n\nLittle lämb\n"; let lines: ~[&str] = data.lines().collect(); - assert_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); + fail_unless_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); let data = "\nMäry häd ä little lämb\n\nLittle lämb"; // no trailing \n let lines: ~[&str] = data.lines().collect(); - assert_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); + fail_unless_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); } #[test] fn test_split_strator() { fn t<'a>(s: &str, sep: &'a str, u: ~[&str]) { let v: ~[&str] = s.split_str(sep).collect(); - assert_eq!(v, u); + fail_unless_eq!(v, u); } t("--1233345--", "12345", ~["--1233345--"]); t("abc::hello::there", "::", ~["abc", "hello", "there"]); @@ -4329,7 +4329,7 @@ mod tests { use default::Default; fn t() { let s: S = Default::default(); - assert_eq!(s.as_slice(), ""); + fail_unless_eq!(s.as_slice(), ""); } t::<&str>(); @@ -4343,27 +4343,27 @@ mod tests { } let s = ~"01234"; - assert_eq!(5, sum_len(["012", "", "34"])); - assert_eq!(5, sum_len([~"01", ~"2", ~"34", ~""])); - assert_eq!(5, sum_len([s.as_slice()])); + fail_unless_eq!(5, sum_len(["012", "", "34"])); + fail_unless_eq!(5, sum_len([~"01", ~"2", ~"34", ~""])); + fail_unless_eq!(5, sum_len([s.as_slice()])); } #[test] fn test_str_truncate() { let mut s = ~"12345"; s.truncate(5); - assert_eq!(s.as_slice(), "12345"); + fail_unless_eq!(s.as_slice(), "12345"); s.truncate(3); - assert_eq!(s.as_slice(), "123"); + fail_unless_eq!(s.as_slice(), "123"); s.truncate(0); - assert_eq!(s.as_slice(), ""); + fail_unless_eq!(s.as_slice(), ""); let mut s = ~"12345"; let p = s.as_ptr(); s.truncate(3); s.push_str("6"); let p_ = s.as_ptr(); - assert_eq!(p_, p); + fail_unless_eq!(p_, p); } #[test] @@ -4383,87 +4383,87 @@ mod tests { #[test] fn test_str_from_utf8() { let xs = bytes!("hello"); - assert_eq!(from_utf8(xs), Some("hello")); + fail_unless_eq!(from_utf8(xs), Some("hello")); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_utf8(xs), Some("ศไทย中华Việt Nam")); + fail_unless_eq!(from_utf8(xs), Some("ศไทย中华Việt Nam")); let xs = bytes!("hello", 0xff); - assert_eq!(from_utf8(xs), None); + fail_unless_eq!(from_utf8(xs), None); } #[test] fn test_str_from_utf8_owned() { let xs = bytes!("hello").to_owned(); - assert_eq!(from_utf8_owned(xs), Some(~"hello")); + fail_unless_eq!(from_utf8_owned(xs), Some(~"hello")); let xs = bytes!("ศไทย中华Việt Nam").to_owned(); - assert_eq!(from_utf8_owned(xs), Some(~"ศไทย中华Việt Nam")); + fail_unless_eq!(from_utf8_owned(xs), Some(~"ศไทย中华Việt Nam")); let xs = bytes!("hello", 0xff).to_owned(); - assert_eq!(from_utf8_owned(xs), None); + fail_unless_eq!(from_utf8_owned(xs), None); } #[test] fn test_str_from_utf8_lossy() { let xs = bytes!("hello"); - assert_eq!(from_utf8_lossy(xs), Slice("hello")); + fail_unless_eq!(from_utf8_lossy(xs), Slice("hello")); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam")); + fail_unless_eq!(from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam")); let xs = bytes!("Hello", 0xC2, " There", 0xFF, " Goodbye"); - assert_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD There\uFFFD Goodbye")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD There\uFFFD Goodbye")); let xs = bytes!("Hello", 0xC0, 0x80, " There", 0xE6, 0x83, " Goodbye"); - assert_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD\uFFFD There\uFFFD Goodbye")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD\uFFFD There\uFFFD Goodbye")); let xs = bytes!(0xF5, "foo", 0xF5, 0x80, "bar"); - assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFD\uFFFDbar")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFD\uFFFDbar")); let xs = bytes!(0xF1, "foo", 0xF1, 0x80, "bar", 0xF1, 0x80, 0x80, "baz"); - assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFDbaz")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFDbaz")); let xs = bytes!(0xF4, "foo", 0xF4, 0x80, "bar", 0xF4, 0xBF, "baz"); - assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFD\uFFFDbaz")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFD\uFFFDbaz")); let xs = bytes!(0xF0, 0x80, 0x80, 0x80, "foo", 0xF0, 0x90, 0x80, 0x80, "bar"); - assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFD\uFFFDfoo\U00010000bar")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFD\uFFFDfoo\U00010000bar")); // surrogates let xs = bytes!(0xED, 0xA0, 0x80, "foo", 0xED, 0xBF, 0xBF, "bar"); - assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFDfoo\uFFFD\uFFFD\uFFFDbar")); + fail_unless_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFDfoo\uFFFD\uFFFD\uFFFDbar")); } #[test] fn test_from_str() { let owned: Option<~str> = from_str(&"string"); - assert_eq!(owned, Some(~"string")); + fail_unless_eq!(owned, Some(~"string")); } #[test] fn test_maybe_owned_traits() { let s = Slice("abcde"); - assert_eq!(s.len(), 5); - assert_eq!(s.as_slice(), "abcde"); - assert_eq!(s.to_str(), ~"abcde"); - assert_eq!(format!("{}", s), ~"abcde"); + fail_unless_eq!(s.len(), 5); + fail_unless_eq!(s.as_slice(), "abcde"); + fail_unless_eq!(s.to_str(), ~"abcde"); + fail_unless_eq!(format!("{}", s), ~"abcde"); fail_unless!(s.lt(&Owned(~"bcdef"))); - assert_eq!(Slice(""), Default::default()); + fail_unless_eq!(Slice(""), Default::default()); let o = Owned(~"abcde"); - assert_eq!(o.len(), 5); - assert_eq!(o.as_slice(), "abcde"); - assert_eq!(o.to_str(), ~"abcde"); - assert_eq!(format!("{}", o), ~"abcde"); + fail_unless_eq!(o.len(), 5); + fail_unless_eq!(o.as_slice(), "abcde"); + fail_unless_eq!(o.to_str(), ~"abcde"); + fail_unless_eq!(format!("{}", o), ~"abcde"); fail_unless!(o.lt(&Slice("bcdef"))); - assert_eq!(Owned(~""), Default::default()); + fail_unless_eq!(Owned(~""), Default::default()); - assert_eq!(s.cmp(&o), Equal); + fail_unless_eq!(s.cmp(&o), Equal); fail_unless!(s.equals(&o)); fail_unless!(s.equiv(&o)); - assert_eq!(o.cmp(&s), Equal); + fail_unless_eq!(o.cmp(&s), Equal); fail_unless!(o.equals(&s)); fail_unless!(o.equiv(&s)); } @@ -4481,31 +4481,31 @@ mod tests { #[test] fn test_maybe_owned_clone() { - assert_eq!(Owned(~"abcde"), Slice("abcde").clone()); - assert_eq!(Owned(~"abcde"), Slice("abcde").deep_clone()); + fail_unless_eq!(Owned(~"abcde"), Slice("abcde").clone()); + fail_unless_eq!(Owned(~"abcde"), Slice("abcde").deep_clone()); - assert_eq!(Owned(~"abcde"), Owned(~"abcde").clone()); - assert_eq!(Owned(~"abcde"), Owned(~"abcde").deep_clone()); + fail_unless_eq!(Owned(~"abcde"), Owned(~"abcde").clone()); + fail_unless_eq!(Owned(~"abcde"), Owned(~"abcde").deep_clone()); - assert_eq!(Slice("abcde"), Slice("abcde").clone()); - assert_eq!(Slice("abcde"), Slice("abcde").deep_clone()); + fail_unless_eq!(Slice("abcde"), Slice("abcde").clone()); + fail_unless_eq!(Slice("abcde"), Slice("abcde").deep_clone()); - assert_eq!(Slice("abcde"), Owned(~"abcde").clone()); - assert_eq!(Slice("abcde"), Owned(~"abcde").deep_clone()); + fail_unless_eq!(Slice("abcde"), Owned(~"abcde").clone()); + fail_unless_eq!(Slice("abcde"), Owned(~"abcde").deep_clone()); } #[test] fn test_maybe_owned_into_owned() { - assert_eq!(Slice("abcde").into_owned(), ~"abcde"); - assert_eq!(Owned(~"abcde").into_owned(), ~"abcde"); + fail_unless_eq!(Slice("abcde").into_owned(), ~"abcde"); + fail_unless_eq!(Owned(~"abcde").into_owned(), ~"abcde"); } #[test] fn test_into_maybe_owned() { - assert_eq!("abcde".into_maybe_owned(), Slice("abcde")); - assert_eq!((~"abcde").into_maybe_owned(), Slice("abcde")); - assert_eq!("abcde".into_maybe_owned(), Owned(~"abcde")); - assert_eq!((~"abcde").into_maybe_owned(), Owned(~"abcde")); + fail_unless_eq!("abcde".into_maybe_owned(), Slice("abcde")); + fail_unless_eq!((~"abcde").into_maybe_owned(), Slice("abcde")); + fail_unless_eq!("abcde".into_maybe_owned(), Owned(~"abcde")); + fail_unless_eq!((~"abcde").into_maybe_owned(), Owned(~"abcde")); } } @@ -4521,7 +4521,7 @@ mod bench { let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb"; let len = s.char_len(); - bh.iter(|| assert_eq!(s.chars().len(), len)); + bh.iter(|| fail_unless_eq!(s.chars().len(), len)); } #[bench] @@ -4534,7 +4534,7 @@ mod bench { Mary had a little lamb, Little lamb"; let len = s.char_len(); - bh.iter(|| assert_eq!(s.chars().len(), len)); + bh.iter(|| fail_unless_eq!(s.chars().len(), len)); } #[bench] @@ -4542,7 +4542,7 @@ mod bench { let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb"; let len = s.char_len(); - bh.iter(|| assert_eq!(s.chars_rev().len(), len)); + bh.iter(|| fail_unless_eq!(s.chars_rev().len(), len)); } #[bench] @@ -4550,7 +4550,7 @@ mod bench { let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb"; let len = s.char_len(); - bh.iter(|| assert_eq!(s.char_indices().len(), len)); + bh.iter(|| fail_unless_eq!(s.char_indices().len(), len)); } #[bench] @@ -4558,14 +4558,14 @@ mod bench { let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb"; let len = s.char_len(); - bh.iter(|| assert_eq!(s.char_indices_rev().len(), len)); + bh.iter(|| fail_unless_eq!(s.char_indices_rev().len(), len)); } #[bench] fn split_unicode_ascii(bh: &mut BenchHarness) { let s = "ประเทศไทย中华Việt Namประเทศไทย中华Việt Nam"; - bh.iter(|| assert_eq!(s.split('V').len(), 3)); + bh.iter(|| fail_unless_eq!(s.split('V').len(), 3)); } #[bench] @@ -4580,7 +4580,7 @@ mod bench { } let s = "ประเทศไทย中华Việt Namประเทศไทย中华Việt Nam"; - bh.iter(|| assert_eq!(s.split(NotAscii('V')).len(), 3)); + bh.iter(|| fail_unless_eq!(s.split(NotAscii('V')).len(), 3)); } @@ -4589,7 +4589,7 @@ mod bench { let s = "Mary had a little lamb, Little lamb, little-lamb."; let len = s.split(' ').len(); - bh.iter(|| assert_eq!(s.split(' ').len(), len)); + bh.iter(|| fail_unless_eq!(s.split(' ').len(), len)); } #[bench] @@ -4606,7 +4606,7 @@ mod bench { let s = "Mary had a little lamb, Little lamb, little-lamb."; let len = s.split(' ').len(); - bh.iter(|| assert_eq!(s.split(NotAscii(' ')).len(), len)); + bh.iter(|| fail_unless_eq!(s.split(NotAscii(' ')).len(), len)); } #[bench] @@ -4615,7 +4615,7 @@ mod bench { let len = s.split(' ').len(); fn pred(c: char) -> bool { c == ' ' } - bh.iter(|| assert_eq!(s.split(pred).len(), len)); + bh.iter(|| fail_unless_eq!(s.split(pred).len(), len)); } #[bench] @@ -4623,7 +4623,7 @@ mod bench { let s = "Mary had a little lamb, Little lamb, little-lamb."; let len = s.split(' ').len(); - bh.iter(|| assert_eq!(s.split(|c: char| c == ' ').len(), len)); + bh.iter(|| fail_unless_eq!(s.split(|c: char| c == ' ').len(), len)); } #[bench] @@ -4631,7 +4631,7 @@ mod bench { let s = "Mary had a little lamb, Little lamb, little-lamb."; let len = s.split(' ').len(); - bh.iter(|| assert_eq!(s.split(&[' ']).len(), len)); + bh.iter(|| fail_unless_eq!(s.split(&[' ']).len(), len)); } #[bench] @@ -4640,7 +4640,7 @@ mod bench { let s = bytes!("Hello there, the quick brown fox jumped over the lazy dog! \ Lorem ipsum dolor sit amet, consectetur. "); - assert_eq!(100, s.len()); + fail_unless_eq!(100, s.len()); bh.iter(|| { is_utf8(s) }); @@ -4649,7 +4649,7 @@ mod bench { #[bench] fn is_utf8_100_multibyte(bh: &mut BenchHarness) { let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰"); - assert_eq!(100, s.len()); + fail_unless_eq!(100, s.len()); bh.iter(|| { is_utf8(s) }); @@ -4660,7 +4660,7 @@ mod bench { let s = bytes!("Hello there, the quick brown fox jumped over the lazy dog! \ Lorem ipsum dolor sit amet, consectetur. "); - assert_eq!(100, s.len()); + fail_unless_eq!(100, s.len()); bh.iter(|| { let _ = from_utf8_lossy(s); }); @@ -4669,7 +4669,7 @@ mod bench { #[bench] fn from_utf8_lossy_100_multibyte(bh: &mut BenchHarness) { let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰"); - assert_eq!(100, s.len()); + fail_unless_eq!(100, s.len()); bh.iter(|| { let _ = from_utf8_lossy(s); }); @@ -4713,7 +4713,7 @@ mod bench { let sep = "→"; let v = [s, s, s, s, s, s, s, s, s, s]; bh.iter(|| { - assert_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9); + fail_unless_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9); }) } } diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs index e9d5c72b7a263..60e2e9bdcbb0d 100644 --- a/src/libstd/sync/arc.rs +++ b/src/libstd/sync/arc.rs @@ -143,7 +143,7 @@ mod tests { #[test] fn test_size() { - assert_eq!(size_of::>(), size_of::<*[int, ..10]>()); + fail_unless_eq!(size_of::>(), size_of::<*[int, ..10]>()); } #[test] @@ -151,10 +151,10 @@ mod tests { // Tests that the many-refcounts-at-once constructors don't leak. let _ = UnsafeArc::new2(~~"hello"); let x = UnsafeArc::newN(~~"hello", 0); - assert_eq!(x.len(), 0) + fail_unless_eq!(x.len(), 0) let x = UnsafeArc::newN(~~"hello", 1); - assert_eq!(x.len(), 1) + fail_unless_eq!(x.len(), 1) let x = UnsafeArc::newN(~~"hello", 10); - assert_eq!(x.len(), 10) + fail_unless_eq!(x.len(), 10) } } diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index 2c4296092cf92..ebaeeeb2171d0 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -557,38 +557,38 @@ mod test { let b = p.swap(a, SeqCst); - assert_eq!(b, Some(~1)); - assert_eq!(p.take(SeqCst), Some(~2)); + fail_unless_eq!(b, Some(~1)); + fail_unless_eq!(p.take(SeqCst), Some(~2)); } #[test] fn option_take() { let mut p = AtomicOption::new(~1); - assert_eq!(p.take(SeqCst), Some(~1)); - assert_eq!(p.take(SeqCst), None); + fail_unless_eq!(p.take(SeqCst), Some(~1)); + fail_unless_eq!(p.take(SeqCst), None); let p2 = ~2; p.swap(p2, SeqCst); - assert_eq!(p.take(SeqCst), Some(~2)); + fail_unless_eq!(p.take(SeqCst), Some(~2)); } #[test] fn option_fill() { let mut p = AtomicOption::new(~1); fail_unless!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak! - assert_eq!(p.take(SeqCst), Some(~1)); + fail_unless_eq!(p.take(SeqCst), Some(~1)); fail_unless!(p.fill(~2, SeqCst).is_none()); // shouldn't fail - assert_eq!(p.take(SeqCst), Some(~2)); + fail_unless_eq!(p.take(SeqCst), Some(~2)); } #[test] fn bool_and() { let mut a = AtomicBool::new(true); - assert_eq!(a.fetch_and(false, SeqCst),true); - assert_eq!(a.load(SeqCst),false); + fail_unless_eq!(a.fetch_and(false, SeqCst),true); + fail_unless_eq!(a.load(SeqCst),false); } static mut S_FLAG : AtomicFlag = INIT_ATOMIC_FLAG; @@ -610,13 +610,13 @@ mod test { fn different_sizes() { unsafe { let mut slot = 0u16; - assert_eq!(super::atomic_swap(&mut slot, 1, SeqCst), 0); + fail_unless_eq!(super::atomic_swap(&mut slot, 1, SeqCst), 0); let mut slot = 0u8; - assert_eq!(super::atomic_compare_and_swap(&mut slot, 1, 2, SeqCst), 0); + fail_unless_eq!(super::atomic_compare_and_swap(&mut slot, 1, 2, SeqCst), 0); let mut slot = 0u32; - assert_eq!(super::atomic_load(&mut slot, SeqCst), 0); + fail_unless_eq!(super::atomic_load(&mut slot, SeqCst), 0); let mut slot = 0u64; super::atomic_store(&mut slot, 2, SeqCst); diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index 9a2650231df63..13c864aa01ca9 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -410,14 +410,14 @@ mod tests { fn smoke() { let mut pool = BufferPool::new(); let (mut w, mut s) = pool.deque(); - assert_eq!(w.pop(), None); - assert_eq!(s.steal(), Empty); + fail_unless_eq!(w.pop(), None); + fail_unless_eq!(s.steal(), Empty); w.push(1); - assert_eq!(w.pop(), Some(1)); + fail_unless_eq!(w.pop(), Some(1)); w.push(1); - assert_eq!(s.steal(), Data(1)); + fail_unless_eq!(s.steal(), Data(1)); w.push(1); - assert_eq!(s.clone().steal(), Data(1)); + fail_unless_eq!(s.clone().steal(), Data(1)); } #[test] @@ -431,7 +431,7 @@ mod tests { while left > 0 { match s.steal() { Data(i) => { - assert_eq!(i, 1); + fail_unless_eq!(i, 1); left -= 1; } Abort | Empty => {} @@ -588,7 +588,7 @@ mod tests { thread.join(); } - assert_eq!(unsafe { HITS.load(SeqCst) }, expected as uint); + fail_unless_eq!(unsafe { HITS.load(SeqCst) }, expected as uint); } #[test] diff --git a/src/libstd/sync/mpmc_bounded_queue.rs b/src/libstd/sync/mpmc_bounded_queue.rs index df6a78eda3e6c..a24b60ca12878 100644 --- a/src/libstd/sync/mpmc_bounded_queue.rs +++ b/src/libstd/sync/mpmc_bounded_queue.rs @@ -171,7 +171,7 @@ mod tests { let nthreads = 8u; let nmsgs = 1000u; let mut q = Queue::with_capacity(nthreads*nmsgs); - assert_eq!(None, q.pop()); + fail_unless_eq!(None, q.pop()); let (port, chan) = Chan::new(); for _ in range(0, nthreads) { @@ -208,7 +208,7 @@ mod tests { } for completion_port in completion_ports.mut_iter() { - assert_eq!(nmsgs, completion_port.recv()); + fail_unless_eq!(nmsgs, completion_port.recv()); } for _ in range(0, nthreads) { port.recv(); diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs index 7be75ceccf078..4908c3d5f8bd2 100644 --- a/src/libstd/sync/spsc_queue.rs +++ b/src/libstd/sync/spsc_queue.rs @@ -234,14 +234,14 @@ mod test { let mut q = Queue::new(0); q.push(1); q.push(2); - assert_eq!(q.pop(), Some(1)); - assert_eq!(q.pop(), Some(2)); - assert_eq!(q.pop(), None); + fail_unless_eq!(q.pop(), Some(1)); + fail_unless_eq!(q.pop(), Some(2)); + fail_unless_eq!(q.pop(), None); q.push(3); q.push(4); - assert_eq!(q.pop(), Some(3)); - assert_eq!(q.pop(), Some(4)); - assert_eq!(q.pop(), None); + fail_unless_eq!(q.pop(), Some(3)); + fail_unless_eq!(q.pop(), Some(4)); + fail_unless_eq!(q.pop(), None); } #[test] @@ -256,14 +256,14 @@ mod test { let mut q = Queue::new(1); q.push(1); q.push(2); - assert_eq!(q.pop(), Some(1)); - assert_eq!(q.pop(), Some(2)); - assert_eq!(q.pop(), None); + fail_unless_eq!(q.pop(), Some(1)); + fail_unless_eq!(q.pop(), Some(2)); + fail_unless_eq!(q.pop(), None); q.push(3); q.push(4); - assert_eq!(q.pop(), Some(3)); - assert_eq!(q.pop(), Some(4)); - assert_eq!(q.pop(), None); + fail_unless_eq!(q.pop(), Some(3)); + fail_unless_eq!(q.pop(), Some(4)); + fail_unless_eq!(q.pop(), None); } #[test] diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 6b2bf57e89e31..d47124bb80c93 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -451,7 +451,7 @@ fn avoid_copying_the_body(spawnfn: |v: proc()|) { }); let x_in_child = p.recv(); - assert_eq!(x_in_parent, x_in_child); + fail_unless_eq!(x_in_parent, x_in_child); } #[test] @@ -508,7 +508,7 @@ fn test_try_fail_message_static_str() { Err(e) => { type T = &'static str; fail_unless!(e.is::()); - assert_eq!(*e.move::().unwrap(), "static string"); + fail_unless_eq!(*e.move::().unwrap(), "static string"); } Ok(()) => fail!() } @@ -522,7 +522,7 @@ fn test_try_fail_message_owned_str() { Err(e) => { type T = ~str; fail_unless!(e.is::()); - assert_eq!(*e.move::().unwrap(), ~"owned string"); + fail_unless_eq!(*e.move::().unwrap(), ~"owned string"); } Ok(()) => fail!() } @@ -538,7 +538,7 @@ fn test_try_fail_message_any() { fail_unless!(e.is::()); let any = e.move::().unwrap(); fail_unless!(any.is::()); - assert_eq!(*any.move::().unwrap(), 413u16); + fail_unless_eq!(*any.move::().unwrap(), 413u16); } Ok(()) => fail!() } diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index a75340c4ae606..2252c4ce7af5e 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -127,22 +127,22 @@ mod tests { #[test] fn test_simple_types() { - assert_eq!(1i.to_str(), ~"1"); - assert_eq!((-1i).to_str(), ~"-1"); - assert_eq!(200u.to_str(), ~"200"); - assert_eq!(2u8.to_str(), ~"2"); - assert_eq!(true.to_str(), ~"true"); - assert_eq!(false.to_str(), ~"false"); - assert_eq!(().to_str(), ~"()"); - assert_eq!((~"hi").to_str(), ~"hi"); + fail_unless_eq!(1i.to_str(), ~"1"); + fail_unless_eq!((-1i).to_str(), ~"-1"); + fail_unless_eq!(200u.to_str(), ~"200"); + fail_unless_eq!(2u8.to_str(), ~"2"); + fail_unless_eq!(true.to_str(), ~"true"); + fail_unless_eq!(false.to_str(), ~"false"); + fail_unless_eq!(().to_str(), ~"()"); + fail_unless_eq!((~"hi").to_str(), ~"hi"); } #[test] fn test_vectors() { let x: ~[int] = ~[]; - assert_eq!(x.to_str(), ~"[]"); - assert_eq!((~[1]).to_str(), ~"[1]"); - assert_eq!((~[1, 2, 3]).to_str(), ~"[1, 2, 3]"); + fail_unless_eq!(x.to_str(), ~"[]"); + fail_unless_eq!((~[1]).to_str(), ~"[1]"); + fail_unless_eq!((~[1, 2, 3]).to_str(), ~"[1, 2, 3]"); fail_unless!((~[~[], ~[1], ~[1, 1]]).to_str() == ~"[[], [1], [1, 1]]"); } @@ -168,7 +168,7 @@ mod tests { let table_str = table.to_str(); fail_unless!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}"); - assert_eq!(empty.to_str(), ~"{}"); + fail_unless_eq!(empty.to_str(), ~"{}"); } #[test] @@ -182,6 +182,6 @@ mod tests { let set_str = set.to_str(); fail_unless!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}"); - assert_eq!(empty_set.to_str(), ~"{}"); + fail_unless_eq!(empty_set.to_str(), ~"{}"); } } diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 59ef20771a72f..fa0a644159f85 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -639,7 +639,7 @@ pub fn check_integrity(trie: &TrieNode) { } } - assert_eq!(sum, trie.count); + fail_unless_eq!(sum, trie.count); } #[cfg(test)] @@ -659,7 +659,7 @@ mod test_map { match m.find_mut(&5) { None => fail!(), Some(x) => *x = new } - assert_eq!(m.find(&5), Some(&new)); + fail_unless_eq!(m.find(&5), Some(&new)); } #[test] @@ -720,8 +720,8 @@ mod test_map { let mut n = 4; m.each_reverse(|k, v| { - assert_eq!(*k, n); - assert_eq!(*v, n * 2); + fail_unless_eq!(*k, n); + fail_unless_eq!(*v, n * 2); n -= 1; true }); @@ -740,8 +740,8 @@ mod test_map { if n == uint::MAX - 5000 { false } else { fail_unless!(n > uint::MAX - 5000); - assert_eq!(*k, n); - assert_eq!(*v, n / 2); + fail_unless_eq!(*k, n); + fail_unless_eq!(*v, n / 2); n -= 1; true } @@ -751,17 +751,17 @@ mod test_map { #[test] fn test_swap() { let mut m = TrieMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + fail_unless_eq!(m.swap(1, 2), None); + fail_unless_eq!(m.swap(1, 3), Some(2)); + fail_unless_eq!(m.swap(1, 4), Some(3)); } #[test] fn test_pop() { let mut m = TrieMap::new(); m.insert(1, 2); - assert_eq!(m.pop(&1), Some(2)); - assert_eq!(m.pop(&1), None); + fail_unless_eq!(m.pop(&1), Some(2)); + fail_unless_eq!(m.pop(&1), None); } #[test] @@ -771,14 +771,14 @@ mod test_map { let map: TrieMap = xs.iter().map(|&x| x).collect(); for &(k, v) in xs.iter() { - assert_eq!(map.find(&k), Some(&v)); + fail_unless_eq!(map.find(&k), Some(&v)); } } #[test] fn test_iteration() { let empty_map : TrieMap = TrieMap::new(); - assert_eq!(empty_map.iter().next(), None); + fail_unless_eq!(empty_map.iter().next(), None); let first = uint::MAX - 10000; let last = uint::MAX; @@ -790,11 +790,11 @@ mod test_map { let mut i = 0; for (k, &v) in map.iter() { - assert_eq!(k, first + i); - assert_eq!(v, k / 2); + fail_unless_eq!(k, first + i); + fail_unless_eq!(v, k / 2); i += 1; } - assert_eq!(i, last - first); + fail_unless_eq!(i, last - first); } #[test] @@ -812,11 +812,11 @@ mod test_map { let mut i = 0; for (k, v) in map.mut_iter() { - assert_eq!(k, first + i); + fail_unless_eq!(k, first + i); *v -= k / 2; i += 1; } - assert_eq!(i, last - first); + fail_unless_eq!(i, last - first); fail_unless!(map.iter().all(|(_, &v)| v == 0)); } @@ -824,8 +824,8 @@ mod test_map { #[test] fn test_bound() { let empty_map : TrieMap = TrieMap::new(); - assert_eq!(empty_map.lower_bound(0).next(), None); - assert_eq!(empty_map.upper_bound(0).next(), None); + fail_unless_eq!(empty_map.lower_bound(0).next(), None); + fail_unless_eq!(empty_map.upper_bound(0).next(), None); let last = 999u; let step = 3u; @@ -843,31 +843,31 @@ mod test_map { let next_key = i - i % step + step; let next_pair = (next_key, &value); if i % step == 0 { - assert_eq!(lb.next(), Some((i, &value))); + fail_unless_eq!(lb.next(), Some((i, &value))); } else { - assert_eq!(lb.next(), Some(next_pair)); + fail_unless_eq!(lb.next(), Some(next_pair)); } - assert_eq!(ub.next(), Some(next_pair)); + fail_unless_eq!(ub.next(), Some(next_pair)); } let mut lb = map.lower_bound(last - step); - assert_eq!(lb.next(), Some((last - step, &value))); + fail_unless_eq!(lb.next(), Some((last - step, &value))); let mut ub = map.upper_bound(last - step); - assert_eq!(ub.next(), None); + fail_unless_eq!(ub.next(), None); for i in range(last - step + 1, last) { let mut lb = map.lower_bound(i); - assert_eq!(lb.next(), None); + fail_unless_eq!(lb.next(), None); let mut ub = map.upper_bound(i); - assert_eq!(ub.next(), None); + fail_unless_eq!(ub.next(), None); } } #[test] fn test_mut_bound() { let empty_map : TrieMap = TrieMap::new(); - assert_eq!(empty_map.lower_bound(0).next(), None); - assert_eq!(empty_map.upper_bound(0).next(), None); + fail_unless_eq!(empty_map.lower_bound(0).next(), None); + fail_unless_eq!(empty_map.upper_bound(0).next(), None); let mut m_lower = TrieMap::new(); let mut m_upper = TrieMap::new(); @@ -880,7 +880,7 @@ mod test_map { let mut lb_it = m_lower.mut_lower_bound(i); let (k, v) = lb_it.next().unwrap(); let lb = i + i % 2; - assert_eq!(lb, k); + fail_unless_eq!(lb, k); *v -= k; } @@ -888,7 +888,7 @@ mod test_map { let mut ub_it = m_upper.mut_upper_bound(i); let (k, v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; - assert_eq!(ub, k); + fail_unless_eq!(ub, k); *v -= k; } @@ -1025,12 +1025,12 @@ mod test_set { fail_unless!(trie.insert(x)); fail_unless!(trie.insert(y)); - assert_eq!(trie.len(), 2); + fail_unless_eq!(trie.len(), 2); let expected = [x, y]; for (i, x) in trie.iter().enumerate() { - assert_eq!(expected[i], x); + fail_unless_eq!(expected[i], x); } } diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index c1887ef004b96..24fe6c55c0304 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -283,7 +283,7 @@ mod tests { fn test_clone() { let a = (1, ~"2"); let b = a.clone(); - assert_eq!(a, b); + fail_unless_eq!(a, b); } #[test] @@ -291,10 +291,10 @@ mod tests { macro_rules! test_getter( ($x:expr, $valN:ident, $refN:ident, $mutN:ident, $init:expr, $incr:expr, $result:expr) => ({ - assert_eq!($x.$valN(), $init); - assert_eq!(*$x.$refN(), $init); + fail_unless_eq!($x.$valN(), $init); + fail_unless_eq!(*$x.$refN(), $init); *$x.$mutN() += $incr; - assert_eq!(*$x.$refN(), $result); + fail_unless_eq!(*$x.$refN(), $result); }) ) let mut x = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64); @@ -319,8 +319,8 @@ mod tests { let nan = 0.0/0.0; // Eq - assert_eq!(small, small); - assert_eq!(big, big); + fail_unless_eq!(small, small); + fail_unless_eq!(big, big); fail_unless!(small != big); fail_unless!(big != small); @@ -352,16 +352,16 @@ mod tests { fail_unless!(!big.equals(&small)); // TotalOrd - assert_eq!(small.cmp(&small), Equal); - assert_eq!(big.cmp(&big), Equal); - assert_eq!(small.cmp(&big), Less); - assert_eq!(big.cmp(&small), Greater); + fail_unless_eq!(small.cmp(&small), Equal); + fail_unless_eq!(big.cmp(&big), Equal); + fail_unless_eq!(small.cmp(&big), Less); + fail_unless_eq!(big.cmp(&small), Greater); } #[test] fn test_show() { - assert_eq!(format!("{}", (1,)), ~"(1,)"); - assert_eq!(format!("{}", (1, true)), ~"(1, true)"); - assert_eq!(format!("{}", (1, ~"hi", true)), ~"(1, hi, true)"); + fail_unless_eq!(format!("{}", (1,)), ~"(1,)"); + fail_unless_eq!(format!("{}", (1, true)), ~"(1, true)"); + fail_unless_eq!(format!("{}", (1, ~"hi", true)), ~"(1, hi, true)"); } } diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 8195e4a737f2a..0ade2b2b0b4ec 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -122,10 +122,10 @@ fn test_success() { }, |i| { fail_unless!(!failing()); - assert_eq!(*i, 10); + fail_unless_eq!(*i, 10); *i = 20; }); - assert_eq!(i, 20); + fail_unless_eq!(i, 20); } #[test] @@ -140,7 +140,7 @@ fn test_fail() { }, |i| { fail_unless!(failing()); - assert_eq!(*i, 10); + fail_unless_eq!(*i, 10); }) } @@ -148,7 +148,7 @@ fn test_fail() { fn test_retval() { let closure: || -> int = || 10; let i = closure.finally(|| { }); - assert_eq!(i, 10); + fail_unless_eq!(i, 10); } #[test] diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 18a088893cd81..3241dd134924b 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -42,7 +42,7 @@ pub fn run_in_bare_thread(f: proc()) { fn test_run_in_bare_thread() { let i = 100; run_in_bare_thread(proc() { - assert_eq!(i, 100); + fail_unless_eq!(i, 100); }); } diff --git a/src/libstd/unstable/raw.rs b/src/libstd/unstable/raw.rs index c25422d24e911..a3a87e16360d9 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/unstable/raw.rs @@ -76,7 +76,7 @@ mod tests { let x = 10; let f: |int| -> int = |y| x + y; - assert_eq!(f(20), 30); + fail_unless_eq!(f(20), 30); let original_closure: Closure = cast::transmute(f); @@ -89,7 +89,7 @@ mod tests { }; let new_f: |int| -> int = cast::transmute(new_closure); - assert_eq!(new_f(20), 30); + fail_unless_eq!(new_f(20), 30); } } } diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index 85a18a0eb0758..b3d17788c9aac 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -149,9 +149,9 @@ mod tests { let x = Exclusive::new(1); let x2 = x.clone(); let _ = task::try(proc() { - x2.with(|one| assert_eq!(*one, 2)) + x2.with(|one| fail_unless_eq!(*one, 2)) }); - x.with(|one| assert_eq!(*one, 1)); + x.with(|one| fail_unless_eq!(*one, 1)); } } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index b0ef974209726..61a699a7ecd41 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1359,12 +1359,12 @@ pub trait OwnedVector { /// # Example /// ```rust /// let mut v = ~[1, 2, 3]; - /// assert_eq!(v.remove(1), Some(2)); - /// assert_eq!(v, ~[1, 3]); + /// fail_unless_eq!(v.remove(1), Some(2)); + /// fail_unless_eq!(v, ~[1, 3]); /// - /// assert_eq!(v.remove(4), None); + /// fail_unless_eq!(v.remove(4), None); /// // v is unchanged: - /// assert_eq!(v, ~[1, 3]); + /// fail_unless_eq!(v, ~[1, 3]); /// ``` fn remove(&mut self, i: uint) -> Option; @@ -2118,7 +2118,7 @@ pub trait MutableVector<'a, T> { /// ```rust /// let mut v = ["a", "b", "c", "d"]; /// v.swap(1, 3); - /// assert_eq!(v, ["a", "d", "c", "b"]); + /// fail_unless_eq!(v, ["a", "d", "c", "b"]); /// ``` fn swap(self, a: uint, b: uint); @@ -2139,20 +2139,20 @@ pub trait MutableVector<'a, T> { /// // scoped to restrict the lifetime of the borrows /// { /// let (left, right) = v.mut_split_at(0); - /// assert_eq!(left, &mut []); - /// assert_eq!(right, &mut [1, 2, 3, 4, 5, 6]); + /// fail_unless_eq!(left, &mut []); + /// fail_unless_eq!(right, &mut [1, 2, 3, 4, 5, 6]); /// } /// /// { /// let (left, right) = v.mut_split_at(2); - /// assert_eq!(left, &mut [1, 2]); - /// assert_eq!(right, &mut [3, 4, 5, 6]); + /// fail_unless_eq!(left, &mut [1, 2]); + /// fail_unless_eq!(right, &mut [3, 4, 5, 6]); /// } /// /// { /// let (left, right) = v.mut_split_at(6); - /// assert_eq!(left, &mut [1, 2, 3, 4, 5, 6]); - /// assert_eq!(right, &mut []); + /// fail_unless_eq!(left, &mut [1, 2, 3, 4, 5, 6]); + /// fail_unless_eq!(right, &mut []); /// } /// ``` fn mut_split_at(self, mid: uint) -> (&'a mut [T], @@ -2165,7 +2165,7 @@ pub trait MutableVector<'a, T> { /// ```rust /// let mut v = [1, 2, 3]; /// v.reverse(); - /// assert_eq!(v, [3, 2, 1]); + /// fail_unless_eq!(v, [3, 2, 1]); /// ``` fn reverse(self); @@ -2180,11 +2180,11 @@ pub trait MutableVector<'a, T> { /// ```rust /// let mut v = [5i, 4, 1, 3, 2]; /// v.sort_by(|a, b| a.cmp(b)); - /// assert_eq!(v, [1, 2, 3, 4, 5]); + /// fail_unless_eq!(v, [1, 2, 3, 4, 5]); /// /// // reverse sorting /// v.sort_by(|a, b| b.cmp(a)); - /// assert_eq!(v, [5, 4, 3, 2, 1]); + /// fail_unless_eq!(v, [5, 4, 3, 2, 1]); /// ``` fn sort_by(self, compare: |&T, &T| -> Ordering); @@ -2425,12 +2425,12 @@ pub trait MutableCloneableVector { /// let mut dst = [0, 0, 0]; /// let src = [1, 2]; /// - /// assert_eq!(dst.copy_from(src), 2); - /// assert_eq!(dst, [1, 2, 0]); + /// fail_unless_eq!(dst.copy_from(src), 2); + /// fail_unless_eq!(dst, [1, 2, 0]); /// /// let src2 = [3, 4, 5, 6]; - /// assert_eq!(dst.copy_from(src2), 3); - /// assert_eq!(dst, [3, 4, 5]); + /// fail_unless_eq!(dst.copy_from(src2), 3); + /// fail_unless_eq!(dst, [3, 4, 5]); /// ``` fn copy_from(self, &[T]) -> uint; } @@ -2458,7 +2458,7 @@ pub trait MutableTotalOrdVector { /// let mut v = [-5, 4, 1, -3, 2]; /// /// v.sort(); - /// assert_eq!(v, [-5, -3, 1, 2, 4]); + /// fail_unless_eq!(v, [-5, -3, 1, 2, 4]); /// ``` fn sort(self); } @@ -2969,21 +2969,21 @@ mod tests { let a = ~[1, 2, 3]; let mut ptr = a.as_ptr(); let b = from_buf(ptr, 3u); - assert_eq!(b.len(), 3u); - assert_eq!(b[0], 1); - assert_eq!(b[1], 2); - assert_eq!(b[2], 3); + fail_unless_eq!(b.len(), 3u); + fail_unless_eq!(b[0], 1); + fail_unless_eq!(b[1], 2); + fail_unless_eq!(b[2], 3); // Test on-heap copy-from-buf. let c = ~[1, 2, 3, 4, 5]; ptr = c.as_ptr(); let d = from_buf(ptr, 5u); - assert_eq!(d.len(), 5u); - assert_eq!(d[0], 1); - assert_eq!(d[1], 2); - assert_eq!(d[2], 3); - assert_eq!(d[3], 4); - assert_eq!(d[4], 5); + fail_unless_eq!(d.len(), 5u); + fail_unless_eq!(d[0], 1); + fail_unless_eq!(d[1], 2); + fail_unless_eq!(d[2], 3); + fail_unless_eq!(d[3], 4); + fail_unless_eq!(d[4], 5); } } @@ -2991,37 +2991,37 @@ mod tests { fn test_from_fn() { // Test on-stack from_fn. let mut v = from_fn(3u, square); - assert_eq!(v.len(), 3u); - assert_eq!(v[0], 0u); - assert_eq!(v[1], 1u); - assert_eq!(v[2], 4u); + fail_unless_eq!(v.len(), 3u); + fail_unless_eq!(v[0], 0u); + fail_unless_eq!(v[1], 1u); + fail_unless_eq!(v[2], 4u); // Test on-heap from_fn. v = from_fn(5u, square); - assert_eq!(v.len(), 5u); - assert_eq!(v[0], 0u); - assert_eq!(v[1], 1u); - assert_eq!(v[2], 4u); - assert_eq!(v[3], 9u); - assert_eq!(v[4], 16u); + fail_unless_eq!(v.len(), 5u); + fail_unless_eq!(v[0], 0u); + fail_unless_eq!(v[1], 1u); + fail_unless_eq!(v[2], 4u); + fail_unless_eq!(v[3], 9u); + fail_unless_eq!(v[4], 16u); } #[test] fn test_from_elem() { // Test on-stack from_elem. let mut v = from_elem(2u, 10u); - assert_eq!(v.len(), 2u); - assert_eq!(v[0], 10u); - assert_eq!(v[1], 10u); + fail_unless_eq!(v.len(), 2u); + fail_unless_eq!(v[0], 10u); + fail_unless_eq!(v[1], 10u); // Test on-heap from_elem. v = from_elem(6u, 20u); - assert_eq!(v[0], 20u); - assert_eq!(v[1], 20u); - assert_eq!(v[2], 20u); - assert_eq!(v[3], 20u); - assert_eq!(v[4], 20u); - assert_eq!(v[5], 20u); + fail_unless_eq!(v[0], 20u); + fail_unless_eq!(v[1], 20u); + fail_unless_eq!(v[2], 20u); + fail_unless_eq!(v[3], 20u); + fail_unless_eq!(v[4], 20u); + fail_unless_eq!(v[5], 20u); } #[test] @@ -3037,38 +3037,38 @@ mod tests { let v0 : &[Z] = &[]; let v1 : &[Z] = &[[]]; let v2 : &[Z] = &[[], []]; - assert_eq!(mem::size_of::(), 0); - assert_eq!(v0.len(), 0); - assert_eq!(v1.len(), 1); - assert_eq!(v2.len(), 2); + fail_unless_eq!(mem::size_of::(), 0); + fail_unless_eq!(v0.len(), 0); + fail_unless_eq!(v1.len(), 1); + fail_unless_eq!(v2.len(), 2); } #[test] fn test_get() { let mut a = ~[11]; - assert_eq!(a.get(1), None); + fail_unless_eq!(a.get(1), None); a = ~[11, 12]; - assert_eq!(a.get(1).unwrap(), &12); + fail_unless_eq!(a.get(1).unwrap(), &12); a = ~[11, 12, 13]; - assert_eq!(a.get(1).unwrap(), &12); + fail_unless_eq!(a.get(1).unwrap(), &12); } #[test] fn test_head() { let mut a = ~[]; - assert_eq!(a.head(), None); + fail_unless_eq!(a.head(), None); a = ~[11]; - assert_eq!(a.head().unwrap(), &11); + fail_unless_eq!(a.head().unwrap(), &11); a = ~[11, 12]; - assert_eq!(a.head().unwrap(), &11); + fail_unless_eq!(a.head().unwrap(), &11); } #[test] fn test_tail() { let mut a = ~[11]; - assert_eq!(a.tail(), &[]); + fail_unless_eq!(a.tail(), &[]); a = ~[11, 12]; - assert_eq!(a.tail(), &[12]); + fail_unless_eq!(a.tail(), &[12]); } #[test] @@ -3081,9 +3081,9 @@ mod tests { #[test] fn test_tailn() { let mut a = ~[11, 12, 13]; - assert_eq!(a.tailn(0), &[11, 12, 13]); + fail_unless_eq!(a.tailn(0), &[11, 12, 13]); a = ~[11, 12, 13]; - assert_eq!(a.tailn(2), &[13]); + fail_unless_eq!(a.tailn(2), &[13]); } #[test] @@ -3096,9 +3096,9 @@ mod tests { #[test] fn test_init() { let mut a = ~[11]; - assert_eq!(a.init(), &[]); + fail_unless_eq!(a.init(), &[]); a = ~[11, 12]; - assert_eq!(a.init(), &[11]); + fail_unless_eq!(a.init(), &[11]); } #[test] @@ -3111,9 +3111,9 @@ mod tests { #[test] fn test_initn() { let mut a = ~[11, 12, 13]; - assert_eq!(a.initn(0), &[11, 12, 13]); + fail_unless_eq!(a.initn(0), &[11, 12, 13]); a = ~[11, 12, 13]; - assert_eq!(a.initn(2), &[11]); + fail_unless_eq!(a.initn(2), &[11]); } #[test] @@ -3126,11 +3126,11 @@ mod tests { #[test] fn test_last() { let mut a = ~[]; - assert_eq!(a.last(), None); + fail_unless_eq!(a.last(), None); a = ~[11]; - assert_eq!(a.last().unwrap(), &11); + fail_unless_eq!(a.last().unwrap(), &11); a = ~[11, 12]; - assert_eq!(a.last().unwrap(), &12); + fail_unless_eq!(a.last().unwrap(), &12); } #[test] @@ -3138,43 +3138,43 @@ mod tests { // Test fixed length vector. let vec_fixed = [1, 2, 3, 4]; let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_owned(); - assert_eq!(v_a.len(), 3u); - assert_eq!(v_a[0], 2); - assert_eq!(v_a[1], 3); - assert_eq!(v_a[2], 4); + fail_unless_eq!(v_a.len(), 3u); + fail_unless_eq!(v_a[0], 2); + fail_unless_eq!(v_a[1], 3); + fail_unless_eq!(v_a[2], 4); // Test on stack. let vec_stack = &[1, 2, 3]; let v_b = vec_stack.slice(1u, 3u).to_owned(); - assert_eq!(v_b.len(), 2u); - assert_eq!(v_b[0], 2); - assert_eq!(v_b[1], 3); + fail_unless_eq!(v_b.len(), 2u); + fail_unless_eq!(v_b[0], 2); + fail_unless_eq!(v_b[1], 3); // Test on exchange heap. let vec_unique = ~[1, 2, 3, 4, 5, 6]; let v_d = vec_unique.slice(1u, 6u).to_owned(); - assert_eq!(v_d.len(), 5u); - assert_eq!(v_d[0], 2); - assert_eq!(v_d[1], 3); - assert_eq!(v_d[2], 4); - assert_eq!(v_d[3], 5); - assert_eq!(v_d[4], 6); + fail_unless_eq!(v_d.len(), 5u); + fail_unless_eq!(v_d[0], 2); + fail_unless_eq!(v_d[1], 3); + fail_unless_eq!(v_d[2], 4); + fail_unless_eq!(v_d[3], 5); + fail_unless_eq!(v_d[4], 6); } #[test] fn test_slice_from() { let vec = &[1, 2, 3, 4]; - assert_eq!(vec.slice_from(0), vec); - assert_eq!(vec.slice_from(2), &[3, 4]); - assert_eq!(vec.slice_from(4), &[]); + fail_unless_eq!(vec.slice_from(0), vec); + fail_unless_eq!(vec.slice_from(2), &[3, 4]); + fail_unless_eq!(vec.slice_from(4), &[]); } #[test] fn test_slice_to() { let vec = &[1, 2, 3, 4]; - assert_eq!(vec.slice_to(4), vec); - assert_eq!(vec.slice_to(2), &[1, 2]); - assert_eq!(vec.slice_to(0), &[]); + fail_unless_eq!(vec.slice_to(4), vec); + fail_unless_eq!(vec.slice_to(2), &[1, 2]); + fail_unless_eq!(vec.slice_to(0), &[]); } @@ -3182,27 +3182,27 @@ mod tests { fn test_pop() { let mut v = ~[5]; let e = v.pop(); - assert_eq!(v.len(), 0); - assert_eq!(e, Some(5)); + fail_unless_eq!(v.len(), 0); + fail_unless_eq!(e, Some(5)); let f = v.pop(); - assert_eq!(f, None); + fail_unless_eq!(f, None); let g = v.pop(); - assert_eq!(g, None); + fail_unless_eq!(g, None); } #[test] fn test_swap_remove() { let mut v = ~[1, 2, 3, 4, 5]; let mut e = v.swap_remove(0); - assert_eq!(v.len(), 4); - assert_eq!(e, 1); - assert_eq!(v[0], 5); + fail_unless_eq!(v.len(), 4); + fail_unless_eq!(e, 1); + fail_unless_eq!(v[0], 5); e = v.swap_remove(3); - assert_eq!(v.len(), 3); - assert_eq!(e, 4); - assert_eq!(v[0], 5); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); + fail_unless_eq!(v.len(), 3); + fail_unless_eq!(e, 4); + fail_unless_eq!(v[0], 5); + fail_unless_eq!(v[1], 2); + fail_unless_eq!(v[2], 3); } #[test] @@ -3212,11 +3212,11 @@ mod tests { ::unstable::sync::Exclusive::new(()), ::unstable::sync::Exclusive::new(())]; let mut _e = v.swap_remove(0); - assert_eq!(v.len(), 2); + fail_unless_eq!(v.len(), 2); _e = v.swap_remove(1); - assert_eq!(v.len(), 1); + fail_unless_eq!(v.len(), 1); _e = v.swap_remove(0); - assert_eq!(v.len(), 0); + fail_unless_eq!(v.len(), 0); } #[test] @@ -3224,14 +3224,14 @@ mod tests { // Test on-stack push(). let mut v = ~[]; v.push(1); - assert_eq!(v.len(), 1u); - assert_eq!(v[0], 1); + fail_unless_eq!(v.len(), 1u); + fail_unless_eq!(v[0], 1); // Test on-heap push(). v.push(2); - assert_eq!(v.len(), 2u); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); + fail_unless_eq!(v.len(), 2u); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[1], 2); } #[test] @@ -3239,48 +3239,48 @@ mod tests { // Test on-stack grow(). let mut v = ~[]; v.grow(2u, &1); - assert_eq!(v.len(), 2u); - assert_eq!(v[0], 1); - assert_eq!(v[1], 1); + fail_unless_eq!(v.len(), 2u); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[1], 1); // Test on-heap grow(). v.grow(3u, &2); - assert_eq!(v.len(), 5u); - assert_eq!(v[0], 1); - assert_eq!(v[1], 1); - assert_eq!(v[2], 2); - assert_eq!(v[3], 2); - assert_eq!(v[4], 2); + fail_unless_eq!(v.len(), 5u); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[1], 1); + fail_unless_eq!(v[2], 2); + fail_unless_eq!(v[3], 2); + fail_unless_eq!(v[4], 2); } #[test] fn test_grow_fn() { let mut v = ~[]; v.grow_fn(3u, square); - assert_eq!(v.len(), 3u); - assert_eq!(v[0], 0u); - assert_eq!(v[1], 1u); - assert_eq!(v[2], 4u); + fail_unless_eq!(v.len(), 3u); + fail_unless_eq!(v[0], 0u); + fail_unless_eq!(v[1], 1u); + fail_unless_eq!(v[2], 4u); } #[test] fn test_grow_set() { let mut v = ~[1, 2, 3]; v.grow_set(4u, &4, 5); - assert_eq!(v.len(), 5u); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - assert_eq!(v[3], 4); - assert_eq!(v[4], 5); + fail_unless_eq!(v.len(), 5u); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[1], 2); + fail_unless_eq!(v[2], 3); + fail_unless_eq!(v[3], 4); + fail_unless_eq!(v[4], 5); } #[test] fn test_truncate() { let mut v = ~[~6,~5,~4]; v.truncate(1); - assert_eq!(v.len(), 1); - assert_eq!(*(v[0]), 6); + fail_unless_eq!(v.len(), 1); + fail_unless_eq!(*(v[0]), 6); // If the unsafe block didn't drop things properly, we blow up here. } @@ -3288,7 +3288,7 @@ mod tests { fn test_clear() { let mut v = ~[~6,~5,~4]; v.clear(); - assert_eq!(v.len(), 0); + fail_unless_eq!(v.len(), 0); // If the unsafe block didn't drop things properly, we blow up here. } @@ -3297,7 +3297,7 @@ mod tests { fn case(a: ~[uint], b: ~[uint]) { let mut v = a; v.dedup(); - assert_eq!(v, b); + fail_unless_eq!(v, b); } case(~[], ~[]); case(~[1], ~[1]); @@ -3342,27 +3342,27 @@ mod tests { // Test on-stack map. let v = &[1u, 2u, 3u]; let mut w = v.map(square_ref); - assert_eq!(w.len(), 3u); - assert_eq!(w[0], 1u); - assert_eq!(w[1], 4u); - assert_eq!(w[2], 9u); + fail_unless_eq!(w.len(), 3u); + fail_unless_eq!(w[0], 1u); + fail_unless_eq!(w[1], 4u); + fail_unless_eq!(w[2], 9u); // Test on-heap map. let v = ~[1u, 2u, 3u, 4u, 5u]; w = v.map(square_ref); - assert_eq!(w.len(), 5u); - assert_eq!(w[0], 1u); - assert_eq!(w[1], 4u); - assert_eq!(w[2], 9u); - assert_eq!(w[3], 16u); - assert_eq!(w[4], 25u); + fail_unless_eq!(w.len(), 5u); + fail_unless_eq!(w[0], 1u); + fail_unless_eq!(w[1], 4u); + fail_unless_eq!(w[2], 9u); + fail_unless_eq!(w[3], 16u); + fail_unless_eq!(w[4], 25u); } #[test] fn test_retain() { let mut v = ~[1, 2, 3, 4, 5]; v.retain(is_odd); - assert_eq!(v, ~[1, 3, 5]); + fail_unless_eq!(v, ~[1, 3, 5]); } #[test] @@ -3371,9 +3371,9 @@ mod tests { let (left, right) = unzip(z1.iter().map(|&x| x)); - assert_eq!((1, 4), (left[0], right[0])); - assert_eq!((2, 5), (left[1], right[1])); - assert_eq!((3, 6), (left[2], right[2])); + fail_unless_eq!((1, 4), (left[0], right[0])); + fail_unless_eq!((2, 5), (left[1], right[1])); + fail_unless_eq!((3, 6), (left[2], right[2])); } #[test] @@ -3382,12 +3382,12 @@ mod tests { for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() { v.swap(a, b); match i { - 0 => assert_eq!(v, [1, 3, 2]), - 1 => assert_eq!(v, [3, 1, 2]), - 2 => assert_eq!(v, [3, 2, 1]), - 3 => assert_eq!(v, [2, 3, 1]), - 4 => assert_eq!(v, [2, 1, 3]), - 5 => assert_eq!(v, [1, 2, 3]), + 0 => fail_unless_eq!(v, [1, 3, 2]), + 1 => fail_unless_eq!(v, [3, 1, 2]), + 2 => fail_unless_eq!(v, [3, 2, 1]), + 3 => fail_unless_eq!(v, [2, 3, 1]), + 4 => fail_unless_eq!(v, [2, 1, 3]), + 5 => fail_unless_eq!(v, [1, 2, 3]), _ => fail!(), } } @@ -3399,23 +3399,23 @@ mod tests { { let v: [int, ..0] = []; let mut it = v.permutations(); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), None); } { let v = [~"Hello"]; let mut it = v.permutations(); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), None); } { let v = [1, 2, 3]; let mut it = v.permutations(); - assert_eq!(it.next(), Some(~[1,2,3])); - assert_eq!(it.next(), Some(~[1,3,2])); - assert_eq!(it.next(), Some(~[3,1,2])); - assert_eq!(it.next(), Some(~[3,2,1])); - assert_eq!(it.next(), Some(~[2,3,1])); - assert_eq!(it.next(), Some(~[2,1,3])); - assert_eq!(it.next(), None); + fail_unless_eq!(it.next(), Some(~[1,2,3])); + fail_unless_eq!(it.next(), Some(~[1,3,2])); + fail_unless_eq!(it.next(), Some(~[3,1,2])); + fail_unless_eq!(it.next(), Some(~[3,2,1])); + fail_unless_eq!(it.next(), Some(~[2,3,1])); + fail_unless_eq!(it.next(), Some(~[2,1,3])); + fail_unless_eq!(it.next(), None); } { // check that we have N! unique permutations @@ -3424,7 +3424,7 @@ mod tests { for perm in v.permutations() { set.insert(perm); } - assert_eq!(set.len(), 2 * 3 * 4 * 5 * 6); + fail_unless_eq!(set.len(), 2 * 3 * 4 * 5 * 6); } } @@ -3433,65 +3433,65 @@ mod tests { fail_unless!([].position_elem(&1).is_none()); let v1 = ~[1, 2, 3, 3, 2, 5]; - assert_eq!(v1.position_elem(&1), Some(0u)); - assert_eq!(v1.position_elem(&2), Some(1u)); - assert_eq!(v1.position_elem(&5), Some(5u)); + fail_unless_eq!(v1.position_elem(&1), Some(0u)); + fail_unless_eq!(v1.position_elem(&2), Some(1u)); + fail_unless_eq!(v1.position_elem(&5), Some(5u)); fail_unless!(v1.position_elem(&4).is_none()); } #[test] fn test_bsearch_elem() { - assert_eq!([1,2,3,4,5].bsearch_elem(&5), Some(4)); - assert_eq!([1,2,3,4,5].bsearch_elem(&4), Some(3)); - assert_eq!([1,2,3,4,5].bsearch_elem(&3), Some(2)); - assert_eq!([1,2,3,4,5].bsearch_elem(&2), Some(1)); - assert_eq!([1,2,3,4,5].bsearch_elem(&1), Some(0)); - - assert_eq!([2,4,6,8,10].bsearch_elem(&1), None); - assert_eq!([2,4,6,8,10].bsearch_elem(&5), None); - assert_eq!([2,4,6,8,10].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6,8,10].bsearch_elem(&10), Some(4)); - - assert_eq!([2,4,6,8].bsearch_elem(&1), None); - assert_eq!([2,4,6,8].bsearch_elem(&5), None); - assert_eq!([2,4,6,8].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6,8].bsearch_elem(&8), Some(3)); - - assert_eq!([2,4,6].bsearch_elem(&1), None); - assert_eq!([2,4,6].bsearch_elem(&5), None); - assert_eq!([2,4,6].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6].bsearch_elem(&6), Some(2)); - - assert_eq!([2,4].bsearch_elem(&1), None); - assert_eq!([2,4].bsearch_elem(&5), None); - assert_eq!([2,4].bsearch_elem(&2), Some(0)); - assert_eq!([2,4].bsearch_elem(&4), Some(1)); - - assert_eq!([2].bsearch_elem(&1), None); - assert_eq!([2].bsearch_elem(&5), None); - assert_eq!([2].bsearch_elem(&2), Some(0)); - - assert_eq!([].bsearch_elem(&1), None); - assert_eq!([].bsearch_elem(&5), None); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&5), Some(4)); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&4), Some(3)); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&3), Some(2)); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&2), Some(1)); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&1), Some(0)); + + fail_unless_eq!([2,4,6,8,10].bsearch_elem(&1), None); + fail_unless_eq!([2,4,6,8,10].bsearch_elem(&5), None); + fail_unless_eq!([2,4,6,8,10].bsearch_elem(&4), Some(1)); + fail_unless_eq!([2,4,6,8,10].bsearch_elem(&10), Some(4)); + + fail_unless_eq!([2,4,6,8].bsearch_elem(&1), None); + fail_unless_eq!([2,4,6,8].bsearch_elem(&5), None); + fail_unless_eq!([2,4,6,8].bsearch_elem(&4), Some(1)); + fail_unless_eq!([2,4,6,8].bsearch_elem(&8), Some(3)); + + fail_unless_eq!([2,4,6].bsearch_elem(&1), None); + fail_unless_eq!([2,4,6].bsearch_elem(&5), None); + fail_unless_eq!([2,4,6].bsearch_elem(&4), Some(1)); + fail_unless_eq!([2,4,6].bsearch_elem(&6), Some(2)); + + fail_unless_eq!([2,4].bsearch_elem(&1), None); + fail_unless_eq!([2,4].bsearch_elem(&5), None); + fail_unless_eq!([2,4].bsearch_elem(&2), Some(0)); + fail_unless_eq!([2,4].bsearch_elem(&4), Some(1)); + + fail_unless_eq!([2].bsearch_elem(&1), None); + fail_unless_eq!([2].bsearch_elem(&5), None); + fail_unless_eq!([2].bsearch_elem(&2), Some(0)); + + fail_unless_eq!([].bsearch_elem(&1), None); + fail_unless_eq!([].bsearch_elem(&5), None); fail_unless!([1,1,1,1,1].bsearch_elem(&1) != None); fail_unless!([1,1,1,1,2].bsearch_elem(&1) != None); fail_unless!([1,1,1,2,2].bsearch_elem(&1) != None); fail_unless!([1,1,2,2,2].bsearch_elem(&1) != None); - assert_eq!([1,2,2,2,2].bsearch_elem(&1), Some(0)); + fail_unless_eq!([1,2,2,2,2].bsearch_elem(&1), Some(0)); - assert_eq!([1,2,3,4,5].bsearch_elem(&6), None); - assert_eq!([1,2,3,4,5].bsearch_elem(&0), None); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&6), None); + fail_unless_eq!([1,2,3,4,5].bsearch_elem(&0), None); } #[test] fn test_reverse() { let mut v: ~[int] = ~[10, 20]; - assert_eq!(v[0], 10); - assert_eq!(v[1], 20); + fail_unless_eq!(v[0], 10); + fail_unless_eq!(v[1], 20); v.reverse(); - assert_eq!(v[0], 20); - assert_eq!(v[1], 10); + fail_unless_eq!(v[0], 20); + fail_unless_eq!(v[1], 10); let mut v3: ~[int] = ~[]; v3.reverse(); @@ -3522,7 +3522,7 @@ mod tests { let mut v = [0xDEADBEEF]; v.sort(); - assert_eq!(v, [0xDEADBEEF]); + fail_unless_eq!(v, [0xDEADBEEF]); } #[test] @@ -3558,76 +3558,76 @@ mod tests { #[test] fn test_partition() { - assert_eq!((~[]).partition(|x: &int| *x < 3), (~[], ~[])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 4), (~[1, 2, 3], ~[])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 2), (~[1], ~[2, 3])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 0), (~[], ~[1, 2, 3])); + fail_unless_eq!((~[]).partition(|x: &int| *x < 3), (~[], ~[])); + fail_unless_eq!((~[1, 2, 3]).partition(|x: &int| *x < 4), (~[1, 2, 3], ~[])); + fail_unless_eq!((~[1, 2, 3]).partition(|x: &int| *x < 2), (~[1], ~[2, 3])); + fail_unless_eq!((~[1, 2, 3]).partition(|x: &int| *x < 0), (~[], ~[1, 2, 3])); } #[test] fn test_partitioned() { - assert_eq!(([]).partitioned(|x: &int| *x < 3), (~[], ~[])) - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (~[1, 2, 3], ~[])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (~[1], ~[2, 3])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (~[], ~[1, 2, 3])); + fail_unless_eq!(([]).partitioned(|x: &int| *x < 3), (~[], ~[])) + fail_unless_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (~[1, 2, 3], ~[])); + fail_unless_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (~[1], ~[2, 3])); + fail_unless_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (~[], ~[1, 2, 3])); } #[test] fn test_concat() { let v: [~[int], ..0] = []; - assert_eq!(v.concat_vec(), ~[]); - assert_eq!([~[1], ~[2,3]].concat_vec(), ~[1, 2, 3]); + fail_unless_eq!(v.concat_vec(), ~[]); + fail_unless_eq!([~[1], ~[2,3]].concat_vec(), ~[1, 2, 3]); - assert_eq!([&[1], &[2,3]].concat_vec(), ~[1, 2, 3]); + fail_unless_eq!([&[1], &[2,3]].concat_vec(), ~[1, 2, 3]); } #[test] fn test_connect() { let v: [~[int], ..0] = []; - assert_eq!(v.connect_vec(&0), ~[]); - assert_eq!([~[1], ~[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); - assert_eq!([~[1], ~[2], ~[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); + fail_unless_eq!(v.connect_vec(&0), ~[]); + fail_unless_eq!([~[1], ~[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); + fail_unless_eq!([~[1], ~[2], ~[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); - assert_eq!(v.connect_vec(&0), ~[]); - assert_eq!([&[1], &[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); - assert_eq!([&[1], &[2], &[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); + fail_unless_eq!(v.connect_vec(&0), ~[]); + fail_unless_eq!([&[1], &[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); + fail_unless_eq!([&[1], &[2], &[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); } #[test] fn test_shift() { let mut x = ~[1, 2, 3]; - assert_eq!(x.shift(), Some(1)); - assert_eq!(&x, &~[2, 3]); - assert_eq!(x.shift(), Some(2)); - assert_eq!(x.shift(), Some(3)); - assert_eq!(x.shift(), None); - assert_eq!(x.len(), 0); + fail_unless_eq!(x.shift(), Some(1)); + fail_unless_eq!(&x, &~[2, 3]); + fail_unless_eq!(x.shift(), Some(2)); + fail_unless_eq!(x.shift(), Some(3)); + fail_unless_eq!(x.shift(), None); + fail_unless_eq!(x.len(), 0); } #[test] fn test_unshift() { let mut x = ~[1, 2, 3]; x.unshift(0); - assert_eq!(x, ~[0, 1, 2, 3]); + fail_unless_eq!(x, ~[0, 1, 2, 3]); } #[test] fn test_insert() { let mut a = ~[1, 2, 4]; a.insert(2, 3); - assert_eq!(a, ~[1, 2, 3, 4]); + fail_unless_eq!(a, ~[1, 2, 3, 4]); let mut a = ~[1, 2, 3]; a.insert(0, 0); - assert_eq!(a, ~[0, 1, 2, 3]); + fail_unless_eq!(a, ~[0, 1, 2, 3]); let mut a = ~[1, 2, 3]; a.insert(3, 4); - assert_eq!(a, ~[1, 2, 3, 4]); + fail_unless_eq!(a, ~[1, 2, 3, 4]); let mut a = ~[]; a.insert(0, 1); - assert_eq!(a, ~[1]); + fail_unless_eq!(a, ~[1]); } #[test] @@ -3641,42 +3641,42 @@ mod tests { fn test_remove() { let mut a = ~[1,2,3,4]; - assert_eq!(a.remove(2), Some(3)); - assert_eq!(a, ~[1,2,4]); + fail_unless_eq!(a.remove(2), Some(3)); + fail_unless_eq!(a, ~[1,2,4]); - assert_eq!(a.remove(2), Some(4)); - assert_eq!(a, ~[1,2]); + fail_unless_eq!(a.remove(2), Some(4)); + fail_unless_eq!(a, ~[1,2]); - assert_eq!(a.remove(2), None); - assert_eq!(a, ~[1,2]); + fail_unless_eq!(a.remove(2), None); + fail_unless_eq!(a, ~[1,2]); - assert_eq!(a.remove(0), Some(1)); - assert_eq!(a, ~[2]); + fail_unless_eq!(a.remove(0), Some(1)); + fail_unless_eq!(a, ~[2]); - assert_eq!(a.remove(0), Some(2)); - assert_eq!(a, ~[]); + fail_unless_eq!(a.remove(0), Some(2)); + fail_unless_eq!(a, ~[]); - assert_eq!(a.remove(0), None); - assert_eq!(a.remove(10), None); + fail_unless_eq!(a.remove(0), None); + fail_unless_eq!(a.remove(10), None); } #[test] fn test_capacity() { let mut v = ~[0u64]; v.reserve_exact(10u); - assert_eq!(v.capacity(), 10u); + fail_unless_eq!(v.capacity(), 10u); let mut v = ~[0u32]; v.reserve_exact(10u); - assert_eq!(v.capacity(), 10u); + fail_unless_eq!(v.capacity(), 10u); } #[test] fn test_slice_2() { let v = ~[1, 2, 3, 4, 5]; let v = v.slice(1u, 3u); - assert_eq!(v.len(), 2u); - assert_eq!(v[0], 2); - assert_eq!(v[1], 3); + fail_unless_eq!(v.len(), 2u); + fail_unless_eq!(v[0], 2); + fail_unless_eq!(v[1], 3); } @@ -3807,17 +3807,17 @@ mod tests { use iter::*; let xs = [1, 2, 5, 10, 11]; let mut it = xs.iter(); - assert_eq!(it.size_hint(), (5, Some(5))); - assert_eq!(it.next().unwrap(), &1); - assert_eq!(it.size_hint(), (4, Some(4))); - assert_eq!(it.next().unwrap(), &2); - assert_eq!(it.size_hint(), (3, Some(3))); - assert_eq!(it.next().unwrap(), &5); - assert_eq!(it.size_hint(), (2, Some(2))); - assert_eq!(it.next().unwrap(), &10); - assert_eq!(it.size_hint(), (1, Some(1))); - assert_eq!(it.next().unwrap(), &11); - assert_eq!(it.size_hint(), (0, Some(0))); + fail_unless_eq!(it.size_hint(), (5, Some(5))); + fail_unless_eq!(it.next().unwrap(), &1); + fail_unless_eq!(it.size_hint(), (4, Some(4))); + fail_unless_eq!(it.next().unwrap(), &2); + fail_unless_eq!(it.size_hint(), (3, Some(3))); + fail_unless_eq!(it.next().unwrap(), &5); + fail_unless_eq!(it.size_hint(), (2, Some(2))); + fail_unless_eq!(it.next().unwrap(), &10); + fail_unless_eq!(it.size_hint(), (1, Some(1))); + fail_unless_eq!(it.next().unwrap(), &11); + fail_unless_eq!(it.size_hint(), (0, Some(0))); fail_unless!(it.next().is_none()); } @@ -3827,34 +3827,34 @@ mod tests { let xs = [1, 2, 5, 10, 11]; let mut it = xs.iter(); - assert_eq!(it.indexable(), 5); - assert_eq!(it.idx(0).unwrap(), &1); - assert_eq!(it.idx(2).unwrap(), &5); - assert_eq!(it.idx(4).unwrap(), &11); + fail_unless_eq!(it.indexable(), 5); + fail_unless_eq!(it.idx(0).unwrap(), &1); + fail_unless_eq!(it.idx(2).unwrap(), &5); + fail_unless_eq!(it.idx(4).unwrap(), &11); fail_unless!(it.idx(5).is_none()); - assert_eq!(it.next().unwrap(), &1); - assert_eq!(it.indexable(), 4); - assert_eq!(it.idx(0).unwrap(), &2); - assert_eq!(it.idx(3).unwrap(), &11); + fail_unless_eq!(it.next().unwrap(), &1); + fail_unless_eq!(it.indexable(), 4); + fail_unless_eq!(it.idx(0).unwrap(), &2); + fail_unless_eq!(it.idx(3).unwrap(), &11); fail_unless!(it.idx(4).is_none()); - assert_eq!(it.next().unwrap(), &2); - assert_eq!(it.indexable(), 3); - assert_eq!(it.idx(1).unwrap(), &10); + fail_unless_eq!(it.next().unwrap(), &2); + fail_unless_eq!(it.indexable(), 3); + fail_unless_eq!(it.idx(1).unwrap(), &10); fail_unless!(it.idx(3).is_none()); - assert_eq!(it.next().unwrap(), &5); - assert_eq!(it.indexable(), 2); - assert_eq!(it.idx(1).unwrap(), &11); + fail_unless_eq!(it.next().unwrap(), &5); + fail_unless_eq!(it.indexable(), 2); + fail_unless_eq!(it.idx(1).unwrap(), &11); - assert_eq!(it.next().unwrap(), &10); - assert_eq!(it.indexable(), 1); - assert_eq!(it.idx(0).unwrap(), &11); + fail_unless_eq!(it.next().unwrap(), &10); + fail_unless_eq!(it.indexable(), 1); + fail_unless_eq!(it.idx(0).unwrap(), &11); fail_unless!(it.idx(1).is_none()); - assert_eq!(it.next().unwrap(), &11); - assert_eq!(it.indexable(), 0); + fail_unless_eq!(it.next().unwrap(), &11); + fail_unless_eq!(it.indexable(), 0); fail_unless!(it.idx(0).is_none()); fail_unless!(it.next().is_none()); @@ -3864,10 +3864,10 @@ mod tests { fn test_iter_size_hints() { use iter::*; let mut xs = [1, 2, 5, 10, 11]; - assert_eq!(xs.iter().size_hint(), (5, Some(5))); - assert_eq!(xs.rev_iter().size_hint(), (5, Some(5))); - assert_eq!(xs.mut_iter().size_hint(), (5, Some(5))); - assert_eq!(xs.mut_rev_iter().size_hint(), (5, Some(5))); + fail_unless_eq!(xs.iter().size_hint(), (5, Some(5))); + fail_unless_eq!(xs.rev_iter().size_hint(), (5, Some(5))); + fail_unless_eq!(xs.mut_iter().size_hint(), (5, Some(5))); + fail_unless_eq!(xs.mut_rev_iter().size_hint(), (5, Some(5))); } #[test] @@ -3876,9 +3876,9 @@ mod tests { let mut it = xs.iter(); it.next(); let mut jt = it.clone(); - assert_eq!(it.next(), jt.next()); - assert_eq!(it.next(), jt.next()); - assert_eq!(it.next(), jt.next()); + fail_unless_eq!(it.next(), jt.next()); + fail_unless_eq!(it.next(), jt.next()); + fail_unless_eq!(it.next(), jt.next()); } #[test] @@ -3888,7 +3888,7 @@ mod tests { for x in xs.mut_iter() { *x += 1; } - assert_eq!(xs, [2, 3, 4, 5, 6]) + fail_unless_eq!(xs, [2, 3, 4, 5, 6]) } #[test] @@ -3899,10 +3899,10 @@ mod tests { let ys = [11, 10, 5, 2, 1]; let mut i = 0; for &x in xs.rev_iter() { - assert_eq!(x, ys[i]); + fail_unless_eq!(x, ys[i]); i += 1; } - assert_eq!(i, 5); + fail_unless_eq!(i, 5); } #[test] @@ -3912,95 +3912,95 @@ mod tests { for (i,x) in xs.mut_rev_iter().enumerate() { *x += i; } - assert_eq!(xs, [5, 5, 5, 5, 5]) + fail_unless_eq!(xs, [5, 5, 5, 5, 5]) } #[test] fn test_move_iterator() { use iter::*; let xs = ~[1u,2,3,4,5]; - assert_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); + fail_unless_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); } #[test] fn test_move_rev_iterator() { use iter::*; let xs = ~[1u,2,3,4,5]; - assert_eq!(xs.move_rev_iter().fold(0, |a: uint, b: uint| 10*a + b), 54321); + fail_unless_eq!(xs.move_rev_iter().fold(0, |a: uint, b: uint| 10*a + b), 54321); } #[test] fn test_splitator() { let xs = &[1i,2,3,4,5]; - assert_eq!(xs.split(|x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.split(|x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[1], &[3], &[5]]); - assert_eq!(xs.split(|x| *x == 1).collect::<~[&[int]]>(), + fail_unless_eq!(xs.split(|x| *x == 1).collect::<~[&[int]]>(), ~[&[], &[2,3,4,5]]); - assert_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), + fail_unless_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), ~[&[1,2,3,4], &[]]); - assert_eq!(xs.split(|x| *x == 10).collect::<~[&[int]]>(), + fail_unless_eq!(xs.split(|x| *x == 10).collect::<~[&[int]]>(), ~[&[1,2,3,4,5]]); - assert_eq!(xs.split(|_| true).collect::<~[&[int]]>(), + fail_unless_eq!(xs.split(|_| true).collect::<~[&[int]]>(), ~[&[], &[], &[], &[], &[], &[]]); let xs: &[int] = &[]; - assert_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + fail_unless_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); } #[test] fn test_splitnator() { let xs = &[1i,2,3,4,5]; - assert_eq!(xs.splitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.splitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[1,2,3,4,5]]); - assert_eq!(xs.splitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.splitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[1], &[3,4,5]]); - assert_eq!(xs.splitn(3, |_| true).collect::<~[&[int]]>(), + fail_unless_eq!(xs.splitn(3, |_| true).collect::<~[&[int]]>(), ~[&[], &[], &[], &[4,5]]); let xs: &[int] = &[]; - assert_eq!(xs.splitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + fail_unless_eq!(xs.splitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); } #[test] fn test_rsplitator() { let xs = &[1i,2,3,4,5]; - assert_eq!(xs.rsplit(|x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplit(|x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[5], &[3], &[1]]); - assert_eq!(xs.rsplit(|x| *x == 1).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplit(|x| *x == 1).collect::<~[&[int]]>(), ~[&[2,3,4,5], &[]]); - assert_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(), ~[&[], &[1,2,3,4]]); - assert_eq!(xs.rsplit(|x| *x == 10).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplit(|x| *x == 10).collect::<~[&[int]]>(), ~[&[1,2,3,4,5]]); let xs: &[int] = &[]; - assert_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + fail_unless_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); } #[test] fn test_rsplitnator() { let xs = &[1,2,3,4,5]; - assert_eq!(xs.rsplitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[1,2,3,4,5]]); - assert_eq!(xs.rsplitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), ~[&[5], &[1,2,3]]); - assert_eq!(xs.rsplitn(3, |_| true).collect::<~[&[int]]>(), + fail_unless_eq!(xs.rsplitn(3, |_| true).collect::<~[&[int]]>(), ~[&[], &[], &[], &[1,2]]); let xs: &[int] = &[]; - assert_eq!(xs.rsplitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + fail_unless_eq!(xs.rsplitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); } #[test] fn test_windowsator() { let v = &[1i,2,3,4]; - assert_eq!(v.windows(2).collect::<~[&[int]]>(), ~[&[1,2], &[2,3], &[3,4]]); - assert_eq!(v.windows(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[2,3,4]]); + fail_unless_eq!(v.windows(2).collect::<~[&[int]]>(), ~[&[1,2], &[2,3], &[3,4]]); + fail_unless_eq!(v.windows(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[2,3,4]]); fail_unless!(v.windows(6).next().is_none()); } @@ -4015,17 +4015,17 @@ mod tests { fn test_chunksator() { let v = &[1i,2,3,4,5]; - assert_eq!(v.chunks(2).collect::<~[&[int]]>(), ~[&[1i,2], &[3,4], &[5]]); - assert_eq!(v.chunks(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[4,5]]); - assert_eq!(v.chunks(6).collect::<~[&[int]]>(), ~[&[1i,2,3,4,5]]); + fail_unless_eq!(v.chunks(2).collect::<~[&[int]]>(), ~[&[1i,2], &[3,4], &[5]]); + fail_unless_eq!(v.chunks(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[4,5]]); + fail_unless_eq!(v.chunks(6).collect::<~[&[int]]>(), ~[&[1i,2,3,4,5]]); - assert_eq!(v.chunks(2).rev().collect::<~[&[int]]>(), ~[&[5i], &[3,4], &[1,2]]); + fail_unless_eq!(v.chunks(2).rev().collect::<~[&[int]]>(), ~[&[5i], &[3,4], &[1,2]]); let it = v.chunks(2); - assert_eq!(it.indexable(), 3); - assert_eq!(it.idx(0).unwrap(), &[1,2]); - assert_eq!(it.idx(1).unwrap(), &[3,4]); - assert_eq!(it.idx(2).unwrap(), &[5]); - assert_eq!(it.idx(3), None); + fail_unless_eq!(it.indexable(), 3); + fail_unless_eq!(it.idx(0).unwrap(), &[1,2]); + fail_unless_eq!(it.idx(1).unwrap(), &[3,4]); + fail_unless_eq!(it.idx(2).unwrap(), &[5]); + fail_unless_eq!(it.idx(3), None); } #[test] @@ -4039,39 +4039,39 @@ mod tests { fn test_move_from() { let mut a = [1,2,3,4,5]; let b = ~[6,7,8]; - assert_eq!(a.move_from(b, 0, 3), 3); - assert_eq!(a, [6,7,8,4,5]); + fail_unless_eq!(a.move_from(b, 0, 3), 3); + fail_unless_eq!(a, [6,7,8,4,5]); let mut a = [7,2,8,1]; let b = ~[3,1,4,1,5,9]; - assert_eq!(a.move_from(b, 0, 6), 4); - assert_eq!(a, [3,1,4,1]); + fail_unless_eq!(a.move_from(b, 0, 6), 4); + fail_unless_eq!(a, [3,1,4,1]); let mut a = [1,2,3,4]; let b = ~[5,6,7,8,9,0]; - assert_eq!(a.move_from(b, 2, 3), 1); - assert_eq!(a, [7,2,3,4]); + fail_unless_eq!(a.move_from(b, 2, 3), 1); + fail_unless_eq!(a, [7,2,3,4]); let mut a = [1,2,3,4,5]; let b = ~[5,6,7,8,9,0]; - assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); - assert_eq!(a, [1,2,6,7,5]); + fail_unless_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); + fail_unless_eq!(a, [1,2,6,7,5]); } #[test] fn test_copy_from() { let mut a = [1,2,3,4,5]; let b = [6,7,8]; - assert_eq!(a.copy_from(b), 3); - assert_eq!(a, [6,7,8,4,5]); + fail_unless_eq!(a.copy_from(b), 3); + fail_unless_eq!(a, [6,7,8,4,5]); let mut c = [7,2,8,1]; let d = [3,1,4,1,5,9]; - assert_eq!(c.copy_from(d), 4); - assert_eq!(c, [3,1,4,1]); + fail_unless_eq!(c.copy_from(d), 4); + fail_unless_eq!(c, [3,1,4,1]); } #[test] fn test_reverse_part() { let mut values = [1,2,3,4,5]; values.mut_slice(1, 4).reverse(); - assert_eq!(values, [1,4,3,2,5]); + fail_unless_eq!(values, [1,4,3,2,5]); } #[test] @@ -4079,8 +4079,8 @@ mod tests { macro_rules! test_show_vec( ($x:expr, $x_str:expr) => ({ let (x, x_str) = ($x, $x_str); - assert_eq!(format!("{}", x), x_str); - assert_eq!(format!("{}", x.as_slice()), x_str); + fail_unless_eq!(format!("{}", x), x_str); + fail_unless_eq!(format!("{}", x.as_slice()), x_str); }) ) let empty: ~[int] = ~[]; @@ -4109,9 +4109,9 @@ mod tests { use vec::bytes::MutableByteVector; let mut values = [1u8,2,3,4,5]; values.mut_slice(0,5).set_memory(0xAB); - assert_eq!(values, [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); + fail_unless_eq!(values, [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); values.mut_slice(2,4).set_memory(0xFF); - assert_eq!(values, [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); + fail_unless_eq!(values, [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); } #[test] @@ -4137,18 +4137,18 @@ mod tests { let mut values = [1u8,2,3,4,5]; { let (left, right) = values.mut_split_at(2); - assert_eq!(left.slice(0, left.len()), [1, 2]); + fail_unless_eq!(left.slice(0, left.len()), [1, 2]); for p in left.mut_iter() { *p += 1; } - assert_eq!(right.slice(0, right.len()), [3, 4, 5]); + fail_unless_eq!(right.slice(0, right.len()), [3, 4, 5]); for p in right.mut_iter() { *p += 2; } } - assert_eq!(values, [2, 3, 5, 6, 7]); + fail_unless_eq!(values, [2, 3, 5, 6, 7]); } #[deriving(Clone, Eq)] @@ -4157,39 +4157,39 @@ mod tests { #[test] fn test_iter_zero_sized() { let mut v = ~[Foo, Foo, Foo]; - assert_eq!(v.len(), 3); + fail_unless_eq!(v.len(), 3); let mut cnt = 0; for f in v.iter() { fail_unless!(*f == Foo); cnt += 1; } - assert_eq!(cnt, 3); + fail_unless_eq!(cnt, 3); for f in v.slice(1, 3).iter() { fail_unless!(*f == Foo); cnt += 1; } - assert_eq!(cnt, 5); + fail_unless_eq!(cnt, 5); for f in v.mut_iter() { fail_unless!(*f == Foo); cnt += 1; } - assert_eq!(cnt, 8); + fail_unless_eq!(cnt, 8); for f in v.move_iter() { fail_unless!(f == Foo); cnt += 1; } - assert_eq!(cnt, 11); + fail_unless_eq!(cnt, 11); let xs = ~[Foo, Foo, Foo]; - assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), + fail_unless_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), ~"~[vec::tests::Foo, vec::tests::Foo]"); let xs: [Foo, ..3] = [Foo, Foo, Foo]; - assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), + fail_unless_eq!(format!("{:?}", xs.slice(0, 2).to_owned()), ~"~[vec::tests::Foo, vec::tests::Foo]"); cnt = 0; for f in xs.iter() { @@ -4205,10 +4205,10 @@ mod tests { for i in range(4, 100) { xs.push(i) } - assert_eq!(xs.capacity(), 128); + fail_unless_eq!(xs.capacity(), 128); xs.shrink_to_fit(); - assert_eq!(xs.capacity(), 100); - assert_eq!(xs, range(0, 100).to_owned_vec()); + fail_unless_eq!(xs.capacity(), 100); + fail_unless_eq!(xs, range(0, 100).to_owned_vec()); } #[test] @@ -4243,23 +4243,23 @@ mod tests { fn test_shift_ref() { let mut x: &[int] = [1, 2, 3, 4, 5]; let h = x.shift_ref(); - assert_eq!(*h.unwrap(), 1); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 2); - assert_eq!(x[3], 5); + fail_unless_eq!(*h.unwrap(), 1); + fail_unless_eq!(x.len(), 4); + fail_unless_eq!(x[0], 2); + fail_unless_eq!(x[3], 5); let mut y: &[int] = []; - assert_eq!(y.shift_ref(), None); + fail_unless_eq!(y.shift_ref(), None); } #[test] fn test_pop_ref() { let mut x: &[int] = [1, 2, 3, 4, 5]; let h = x.pop_ref(); - assert_eq!(*h.unwrap(), 5); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 1); - assert_eq!(x[3], 4); + fail_unless_eq!(*h.unwrap(), 5); + fail_unless_eq!(x.len(), 4); + fail_unless_eq!(x[0], 1); + fail_unless_eq!(x[3], 4); let mut y: &[int] = []; fail_unless!(y.pop_ref().is_none()); @@ -4268,17 +4268,17 @@ mod tests { #[test] fn test_mut_splitator() { let mut xs = [0,1,0,2,3,0,0,4,5,0]; - assert_eq!(xs.mut_split(|x| *x == 0).len(), 6); + fail_unless_eq!(xs.mut_split(|x| *x == 0).len(), 6); for slice in xs.mut_split(|x| *x == 0) { slice.reverse(); } - assert_eq!(xs, [0,1,0,3,2,0,0,5,4,0]); + fail_unless_eq!(xs, [0,1,0,3,2,0,0,5,4,0]); let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7]; for slice in xs.mut_split(|x| *x == 0).take(5) { slice.reverse(); } - assert_eq!(xs, [0,1,0,3,2,0,0,5,4,0,6,7]); + fail_unless_eq!(xs, [0,1,0,3,2,0,0,5,4,0,6,7]); } #[test] @@ -4287,7 +4287,7 @@ mod tests { for slice in xs.mut_split(|x| *x == 0).rev().take(4) { slice.reverse(); } - assert_eq!(xs, [1,2,0,4,3,0,0,6,5,0]); + fail_unless_eq!(xs, [1,2,0,4,3,0,0,6,5,0]); } #[test] @@ -4299,7 +4299,7 @@ mod tests { } } let result = [0u8, 0, 0, 1, 1, 1, 2]; - assert_eq!(v, result); + fail_unless_eq!(v, result); } #[test] @@ -4311,7 +4311,7 @@ mod tests { } } let result = [2u8, 2, 2, 1, 1, 1, 0]; - assert_eq!(v, result); + fail_unless_eq!(v, result); } #[test] @@ -4325,10 +4325,10 @@ mod tests { fn test_mut_shift_ref() { let mut x: &mut [int] = [1, 2, 3, 4, 5]; let h = x.mut_shift_ref(); - assert_eq!(*h.unwrap(), 1); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 2); - assert_eq!(x[3], 5); + fail_unless_eq!(*h.unwrap(), 1); + fail_unless_eq!(x.len(), 4); + fail_unless_eq!(x[0], 2); + fail_unless_eq!(x[3], 5); let mut y: &mut [int] = []; fail_unless!(y.mut_shift_ref().is_none()); @@ -4338,10 +4338,10 @@ mod tests { fn test_mut_pop_ref() { let mut x: &mut [int] = [1, 2, 3, 4, 5]; let h = x.mut_pop_ref(); - assert_eq!(*h.unwrap(), 5); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 1); - assert_eq!(x[3], 4); + fail_unless_eq!(*h.unwrap(), 5); + fail_unless_eq!(x.len(), 4); + fail_unless_eq!(x[0], 1); + fail_unless_eq!(x[3], 4); let mut y: &mut [int] = []; fail_unless!(y.mut_pop_ref().is_none()); @@ -4351,7 +4351,7 @@ mod tests { fn test_mut_last() { let mut x = [1, 2, 3, 4, 5]; let h = x.mut_last(); - assert_eq!(*h.unwrap(), 5); + fail_unless_eq!(*h.unwrap(), 5); let y: &mut [int] = []; fail_unless!(y.mut_last().is_none()); diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index 2bf1f584c4baf..a79b62e20f07d 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -583,13 +583,13 @@ mod tests { let arc_v: Arc<~[int]> = p.recv(); let v = arc_v.get().clone(); - assert_eq!(v[3], 4); + fail_unless_eq!(v[3], 4); }); c.send(arc_v.clone()); - assert_eq!(arc_v.get()[2], 3); - assert_eq!(arc_v.get()[4], 5); + fail_unless_eq!(arc_v.get()[2], 3); + fail_unless_eq!(arc_v.get()[4], 5); info!("{:?}", arc_v); } @@ -628,7 +628,7 @@ mod tests { arc2.access_cond(|one, cond| { cond.signal(); // Parent should fail when it wakes up. - assert_eq!(*one, 0); + fail_unless_eq!(*one, 0); }) }); @@ -646,11 +646,11 @@ mod tests { let arc2 = ~arc.clone(); let _ = task::try(proc() { arc2.access(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }); arc.access(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } @@ -685,7 +685,7 @@ mod tests { let _u = Unwinder { i: arc2 }; fail!(); }); - assert_eq!(2, arc.access(|n| *n)); + fail_unless_eq!(2, arc.access(|n| *n)); } #[test] #[should_fail] @@ -694,11 +694,11 @@ mod tests { let arc2 = arc.clone(); let _ = task::try(proc() { arc2.write(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }); arc.read(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } @@ -708,11 +708,11 @@ mod tests { let arc2 = arc.clone(); let _ = task::try(proc() { arc2.write(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }); arc.write(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } #[test] #[should_fail] @@ -722,12 +722,12 @@ mod tests { let _ = task::try(proc() { arc2.write_downgrade(|mut write_mode| { write_mode.write(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }) }); arc.write(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } #[test] @@ -736,11 +736,11 @@ mod tests { let arc2 = arc.clone(); let _ = task::try(proc() { arc2.read(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }); arc.read(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } #[test] @@ -749,11 +749,11 @@ mod tests { let arc2 = arc.clone(); let _ = task::try(proc() { arc2.read(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }); arc.write(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } #[test] @@ -764,12 +764,12 @@ mod tests { arc2.write_downgrade(|write_mode| { let read_mode = arc2.downgrade(write_mode); read_mode.read(|one| { - assert_eq!(*one, 2); + fail_unless_eq!(*one, 2); }) }) }); arc.write(|one| { - assert_eq!(*one, 1); + fail_unless_eq!(*one, 1); }) } #[test] @@ -811,7 +811,7 @@ mod tests { // Wait for writer to finish p.recv(); arc.read(|num| { - assert_eq!(*num, 10); + fail_unless_eq!(*num, 10); }) } @@ -831,7 +831,7 @@ mod tests { let _u = Unwinder { i: arc2 }; fail!(); }); - assert_eq!(2, arc.read(|n| *n)); + fail_unless_eq!(2, arc.read(|n| *n)); } #[test] @@ -853,7 +853,7 @@ mod tests { task::spawn(proc() { rp1.recv(); // wait for downgrader to give go-ahead arcn.read(|state| { - assert_eq!(*state, 31337); + fail_unless_eq!(*state, 31337); rc2.send(()); }) }); @@ -865,7 +865,7 @@ mod tests { task::spawn(proc() { wp1.recv(); arc2.write_cond(|state, cond| { - assert_eq!(*state, 0); + fail_unless_eq!(*state, 0); *state = 42; cond.signal(); }); @@ -873,7 +873,7 @@ mod tests { arc2.write(|state| { // This shouldn't happen until after the downgrade read // section, and all other readers, finish. - assert_eq!(*state, 31337); + fail_unless_eq!(*state, 31337); *state = 42; }); wc2.send(()); @@ -886,7 +886,7 @@ mod tests { while *state == 0 { cond.wait(); } - assert_eq!(*state, 42); + fail_unless_eq!(*state, 42); *state = 31337; // send to other readers for &(ref mut rc, _) in reader_convos.mut_iter() { @@ -900,7 +900,7 @@ mod tests { rp.recv() } wc1.send(()); // tell writer to try again - assert_eq!(*state, 31337); + fail_unless_eq!(*state, 31337); }); }); diff --git a/src/libsync/future.rs b/src/libsync/future.rs index 9984d2dd0adb2..e5e5ed6d94aeb 100644 --- a/src/libsync/future.rs +++ b/src/libsync/future.rs @@ -144,7 +144,7 @@ mod test { #[test] fn test_from_value() { let mut f = Future::from_value(~"snail"); - assert_eq!(f.get(), ~"snail"); + fail_unless_eq!(f.get(), ~"snail"); } #[test] @@ -152,37 +152,37 @@ mod test { let (po, ch) = Chan::new(); ch.send(~"whale"); let mut f = Future::from_port(po); - assert_eq!(f.get(), ~"whale"); + fail_unless_eq!(f.get(), ~"whale"); } #[test] fn test_from_fn() { let mut f = Future::from_fn(proc() ~"brail"); - assert_eq!(f.get(), ~"brail"); + fail_unless_eq!(f.get(), ~"brail"); } #[test] fn test_interface_get() { let mut f = Future::from_value(~"fail"); - assert_eq!(f.get(), ~"fail"); + fail_unless_eq!(f.get(), ~"fail"); } #[test] fn test_interface_unwrap() { let f = Future::from_value(~"fail"); - assert_eq!(f.unwrap(), ~"fail"); + fail_unless_eq!(f.unwrap(), ~"fail"); } #[test] fn test_get_ref_method() { let mut f = Future::from_value(22); - assert_eq!(*f.get_ref(), 22); + fail_unless_eq!(*f.get_ref(), 22); } #[test] fn test_spawn() { let mut f = Future::spawn(proc() ~"bale"); - assert_eq!(f.get(), ~"bale"); + fail_unless_eq!(f.get(), ~"bale"); } #[test] @@ -199,7 +199,7 @@ mod test { task::spawn(proc() { let mut f = f; let actual = f.get(); - assert_eq!(actual, expected); + fail_unless_eq!(actual, expected); }); } } diff --git a/src/libsync/sync/mod.rs b/src/libsync/sync/mod.rs index 336ede7072f43..ac665b9a88581 100644 --- a/src/libsync/sync/mod.rs +++ b/src/libsync/sync/mod.rs @@ -883,7 +883,7 @@ mod tests { access_shared(sharedstate, &m, 10); let _ = p.recv(); - assert_eq!(*sharedstate, 20); + fail_unless_eq!(*sharedstate, 20); } fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) { @@ -950,7 +950,7 @@ mod tests { for port in ports.mut_iter() { let _ = port.recv(); } m.lock_cond(|cond| { let num_woken = cond.broadcast(); - assert_eq!(num_woken, num_waiters); + fail_unless_eq!(num_woken, num_waiters); }); // wait until all children wake up for port in ports.mut_iter() { let _ = port.recv(); } @@ -1058,7 +1058,7 @@ mod tests { for p in r.mut_iter() { p.recv(); } // wait on all its siblings m.lock_cond(|cond| { let woken = cond.broadcast(); - assert_eq!(woken, 0); + fail_unless_eq!(woken, 0); }) } #[test] @@ -1158,7 +1158,7 @@ mod tests { access_shared(sharedstate, x, mode2, 10); let _ = p.recv(); - assert_eq!(*sharedstate, 20); + fail_unless_eq!(*sharedstate, 20); } fn access_shared(sharedstate: &mut int, x: &RWLock, mode: RWLockMode, @@ -1311,7 +1311,7 @@ mod tests { for port in ports.mut_iter() { let _ = port.recv(); } lock_cond(&x, dg2, |cond| { let num_woken = cond.broadcast(); - assert_eq!(num_woken, num_waiters); + fail_unless_eq!(num_woken, num_waiters); }); // wait until all children wake up for port in ports.mut_iter() { let _ = port.recv(); } diff --git a/src/libsync/sync/mutex.rs b/src/libsync/sync/mutex.rs index a9de7b667aa76..f281b65dc9974 100644 --- a/src/libsync/sync/mutex.rs +++ b/src/libsync/sync/mutex.rs @@ -238,15 +238,15 @@ impl StaticMutex { t.deschedule(1, |task| { let task = unsafe { task.cast_to_uint() }; if can_block { - assert_eq!(self.native_blocker, 0); + fail_unless_eq!(self.native_blocker, 0); self.native_blocker = task; } else { - assert_eq!(self.green_blocker, 0); + fail_unless_eq!(self.green_blocker, 0); self.green_blocker = task; } loop { - assert_eq!(old & native_bit, 0); + fail_unless_eq!(old & native_bit, 0); // If the old state was locked, then we need to flag ourselves // as blocking in the state. If the old state was unlocked, then // we attempt to acquire the mutex. Everything here is a CAS @@ -259,12 +259,12 @@ impl StaticMutex { n => n }; } else { - assert_eq!(old, 0); + fail_unless_eq!(old, 0); old = match self.state.compare_and_swap(old, old | LOCKED, atomics::SeqCst) { n if n == old => { - assert_eq!(self.flavor, Unlocked); + fail_unless_eq!(self.flavor, Unlocked); if can_block { self.native_blocker = 0; self.flavor = NativeAcquisition; @@ -376,7 +376,7 @@ impl StaticMutex { self.flavor = NativeAcquisition; break; } else { - assert_eq!(state, LOCKED); + fail_unless_eq!(state, LOCKED); if !unlocked { match flavor { GreenAcquisition => { self.green_unlock(); } @@ -544,7 +544,7 @@ mod test { for _ in range(0, 2 * N) { p.recv(); } - assert_eq!(unsafe {CNT}, M * N * 2); + fail_unless_eq!(unsafe {CNT}, M * N * 2); unsafe { m.destroy(); } diff --git a/src/libsync/sync/one.rs b/src/libsync/sync/one.rs index 50c04a21c874c..0ec00271c9e78 100644 --- a/src/libsync/sync/one.rs +++ b/src/libsync/sync/one.rs @@ -127,9 +127,9 @@ mod test { static mut o: Once = ONCE_INIT; let mut a = 0; unsafe { o.doit(|| a += 1); } - assert_eq!(a, 1); + fail_unless_eq!(a, 1); unsafe { o.doit(|| a += 1); } - assert_eq!(a, 1); + fail_unless_eq!(a, 1); } #[test] diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 2dc6b0048e2d2..85237ab84f9cd 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -404,15 +404,15 @@ fn abi_to_str_rust() { #[test] fn indices_are_correct() { for (i, abi_data) in AbiDatas.iter().enumerate() { - assert_eq!(i, abi_data.abi.index()); + fail_unless_eq!(i, abi_data.abi.index()); } let bits = 1 << (X86 as u32); let bits = bits | 1 << (X86_64 as u32); - assert_eq!(IntelBits, bits); + fail_unless_eq!(IntelBits, bits); let bits = 1 << (Arm as u32); - assert_eq!(ArmBits, bits); + fail_unless_eq!(ArmBits, bits); } #[cfg(test)] @@ -426,19 +426,19 @@ fn get_arch(abis: &[Abi], os: Os, arch: Architecture) -> Option { #[test] fn pick_multiplatform() { - assert_eq!(get_arch([C, Cdecl], OsLinux, X86), Some(Cdecl)); - assert_eq!(get_arch([C, Cdecl], OsLinux, X86_64), Some(Cdecl)); - assert_eq!(get_arch([C, Cdecl], OsLinux, Arm), Some(C)); + fail_unless_eq!(get_arch([C, Cdecl], OsLinux, X86), Some(Cdecl)); + fail_unless_eq!(get_arch([C, Cdecl], OsLinux, X86_64), Some(Cdecl)); + fail_unless_eq!(get_arch([C, Cdecl], OsLinux, Arm), Some(C)); } #[test] fn pick_uniplatform() { - assert_eq!(get_arch([Stdcall], OsLinux, X86), Some(Stdcall)); - assert_eq!(get_arch([Stdcall], OsLinux, Arm), None); - assert_eq!(get_arch([System], OsLinux, X86), Some(C)); - assert_eq!(get_arch([System], OsWin32, X86), Some(Stdcall)); - assert_eq!(get_arch([System], OsWin32, X86_64), Some(C)); - assert_eq!(get_arch([System], OsWin32, Arm), Some(C)); - assert_eq!(get_arch([Stdcall], OsWin32, X86), Some(Stdcall)); - assert_eq!(get_arch([Stdcall], OsWin32, X86_64), Some(Stdcall)); + fail_unless_eq!(get_arch([Stdcall], OsLinux, X86), Some(Stdcall)); + fail_unless_eq!(get_arch([Stdcall], OsLinux, Arm), None); + fail_unless_eq!(get_arch([System], OsLinux, X86), Some(C)); + fail_unless_eq!(get_arch([System], OsWin32, X86), Some(Stdcall)); + fail_unless_eq!(get_arch([System], OsWin32, X86_64), Some(C)); + fail_unless_eq!(get_arch([System], OsWin32, Arm), Some(C)); + fail_unless_eq!(get_arch([Stdcall], OsWin32, X86), Some(Stdcall)); + fail_unless_eq!(get_arch([Stdcall], OsWin32, X86_64), Some(Stdcall)); } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 26c4b07fc9644..fb3bb50a3a311 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -418,7 +418,7 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> { self.parent = DUMMY_NODE_ID; let i = fold::noop_fold_item(i, self).expect_one("expected one item"); - assert_eq!(self.parent, i.id); + fail_unless_eq!(self.parent, i.id); match i.node { ItemImpl(_, _, _, ref ms) => { @@ -509,7 +509,7 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> { let parent = self.parent; self.parent = DUMMY_NODE_ID; let m = fold::noop_fold_method(m, self); - assert_eq!(self.parent, m.id); + fail_unless_eq!(self.parent, m.id); self.parent = parent; m } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 1e186eea78ce0..cf5bef1b2eb01 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -986,19 +986,19 @@ mod test { #[test] fn xorpush_test () { let mut s = ~[]; xorPush(&mut s, 14); - assert_eq!(s.clone(), ~[14]); + fail_unless_eq!(s.clone(), ~[14]); xorPush(&mut s, 14); - assert_eq!(s.clone(), ~[]); + fail_unless_eq!(s.clone(), ~[]); xorPush(&mut s, 14); - assert_eq!(s.clone(), ~[14]); + fail_unless_eq!(s.clone(), ~[14]); xorPush(&mut s, 15); - assert_eq!(s.clone(), ~[14, 15]); + fail_unless_eq!(s.clone(), ~[14, 15]); xorPush(&mut s, 16); - assert_eq!(s.clone(), ~[14, 15, 16]); + fail_unless_eq!(s.clone(), ~[14, 15, 16]); xorPush(&mut s, 16); - assert_eq!(s.clone(), ~[14, 15]); + fail_unless_eq!(s.clone(), ~[14, 15]); xorPush(&mut s, 15); - assert_eq!(s.clone(), ~[14]); + fail_unless_eq!(s.clone(), ~[14]); } fn id(n: Name, s: SyntaxContext) -> Ident { @@ -1049,14 +1049,14 @@ mod test { let mut t = new_sctable_internal(); let test_sc = ~[M(3),R(id(101,0),14),M(9)]; - assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); + fail_unless_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); { let table = t.table.borrow(); - assert_eq!(table.get()[2],Mark(9,0)); - assert_eq!(table.get()[3],Rename(id(101,0),14,2)); - assert_eq!(table.get()[4],Mark(3,3)); + fail_unless_eq!(table.get()[2],Mark(9,0)); + fail_unless_eq!(table.get()[3],Rename(id(101,0),14,2)); + fail_unless_eq!(table.get()[4],Mark(3,3)); } - assert_eq!(refold_test_sc(4,&t),test_sc); + fail_unless_eq!(refold_test_sc(4,&t),test_sc); } // extend a syntax context with a sequence of marks given @@ -1070,11 +1070,11 @@ mod test { #[test] fn unfold_marks_test() { let mut t = new_sctable_internal(); - assert_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3); + fail_unless_eq!(unfold_marks(~[3,7],EMPTY_CTXT,&mut t),3); { let table = t.table.borrow(); - assert_eq!(table.get()[2],Mark(7,0)); - assert_eq!(table.get()[3],Mark(3,2)); + fail_unless_eq!(table.get()[2],Mark(7,0)); + fail_unless_eq!(table.get()[3],Mark(3,2)); } } @@ -1082,16 +1082,16 @@ mod test { let stopname = 242; let name1 = 243; let mut t = new_sctable_internal(); - assert_eq!(marksof (EMPTY_CTXT,stopname,&t),~[]); + fail_unless_eq!(marksof (EMPTY_CTXT,stopname,&t),~[]); // FIXME #5074: ANF'd to dodge nested calls { let ans = unfold_marks(~[4,98],EMPTY_CTXT,&mut t); - assert_eq! (marksof (ans,stopname,&t),~[4,98]);} + fail_unless_eq! (marksof (ans,stopname,&t),~[4,98]);} // does xoring work? { let ans = unfold_marks(~[5,5,16],EMPTY_CTXT,&mut t); - assert_eq! (marksof (ans,stopname,&t), ~[16]);} + fail_unless_eq! (marksof (ans,stopname,&t), ~[16]);} // does nested xoring work? { let ans = unfold_marks(~[5,10,10,5,16],EMPTY_CTXT,&mut t); - assert_eq! (marksof (ans, stopname,&t), ~[16]);} + fail_unless_eq! (marksof (ans, stopname,&t), ~[16]);} // rename where stop doesn't match: { let chain = ~[M(9), R(id(name1, @@ -1099,7 +1099,7 @@ mod test { 100101102), M(14)]; let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t); - assert_eq! (marksof (ans, stopname, &t), ~[9,14]);} + fail_unless_eq! (marksof (ans, stopname, &t), ~[9,14]);} // rename where stop does match { let name1sc = new_mark_internal(4, EMPTY_CTXT, &mut t); let chain = ~[M(9), @@ -1107,7 +1107,7 @@ mod test { stopname), M(14)]; let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t); - assert_eq! (marksof (ans, stopname, &t), ~[9]); } + fail_unless_eq! (marksof (ans, stopname, &t), ~[9]); } } @@ -1116,28 +1116,28 @@ mod test { let mut t = new_sctable_internal(); let mut rt = HashMap::new(); // - ctxt is MT - assert_eq!(resolve_internal(id(a,EMPTY_CTXT),&mut t, &mut rt),a); + fail_unless_eq!(resolve_internal(id(a,EMPTY_CTXT),&mut t, &mut rt),a); // - simple ignored marks { let sc = unfold_marks(~[1,2,3],EMPTY_CTXT,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),a);} + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),a);} // - orthogonal rename where names don't match { let sc = unfold_test_sc(~[R(id(50,EMPTY_CTXT),51),M(12)],EMPTY_CTXT,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),a);} + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),a);} // - rename where names do match, but marks don't { let sc1 = new_mark_internal(1,EMPTY_CTXT,&mut t); let sc = unfold_test_sc(~[R(id(a,sc1),50), M(1), M(2)], EMPTY_CTXT,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), a);} + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), a);} // - rename where names and marks match { let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t); let sc = unfold_test_sc(~[R(id(a,sc1),50),M(1),M(2)],EMPTY_CTXT,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 50); } + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 50); } // - rename where names and marks match by literal sharing { let sc1 = unfold_test_sc(~[M(1),M(2)],EMPTY_CTXT,&mut t); let sc = unfold_test_sc(~[R(id(a,sc1),50)],sc1,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 50); } + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 50); } // - two renames of the same var.. can only happen if you use // local-expand to prevent the inner binding from being renamed // during the rename-pass caused by the first: @@ -1145,47 +1145,47 @@ mod test { { let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50), R(id(a,EMPTY_CTXT),51)], EMPTY_CTXT,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 51); } + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt), 51); } // the simplest double-rename: { let a_to_a50 = new_rename_internal(id(a,EMPTY_CTXT),50,EMPTY_CTXT,&mut t); let a50_to_a51 = new_rename_internal(id(a,a_to_a50),51,a_to_a50,&mut t); - assert_eq!(resolve_internal(id(a,a50_to_a51),&mut t, &mut rt),51); + fail_unless_eq!(resolve_internal(id(a,a50_to_a51),&mut t, &mut rt),51); // mark on the outside doesn't stop rename: let sc = new_mark_internal(9,a50_to_a51,&mut t); - assert_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),51); + fail_unless_eq!(resolve_internal(id(a,sc),&mut t, &mut rt),51); // but mark on the inside does: let a50_to_a51_b = unfold_test_sc(~[R(id(a,a_to_a50),51), M(9)], a_to_a50, &mut t); - assert_eq!(resolve_internal(id(a,a50_to_a51_b),&mut t, &mut rt),50);} + fail_unless_eq!(resolve_internal(id(a,a50_to_a51_b),&mut t, &mut rt),50);} } #[test] fn mtwt_resolve_test(){ let a = 40; - assert_eq!(mtwt_resolve(id(a,EMPTY_CTXT)),a); + fail_unless_eq!(mtwt_resolve(id(a,EMPTY_CTXT)),a); } #[test] fn hashing_tests () { let mut t = new_sctable_internal(); - assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); - assert_eq!(new_mark_internal(13,EMPTY_CTXT,&mut t),3); + fail_unless_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); + fail_unless_eq!(new_mark_internal(13,EMPTY_CTXT,&mut t),3); // using the same one again should result in the same index: - assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); + fail_unless_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2); // I'm assuming that the rename table will behave the same.... } #[test] fn resolve_table_hashing_tests() { let mut t = new_sctable_internal(); let mut rt = HashMap::new(); - assert_eq!(rt.len(),0); + fail_unless_eq!(rt.len(),0); resolve_internal(id(30,EMPTY_CTXT),&mut t, &mut rt); - assert_eq!(rt.len(),1); + fail_unless_eq!(rt.len(),1); resolve_internal(id(39,EMPTY_CTXT),&mut t, &mut rt); - assert_eq!(rt.len(),2); + fail_unless_eq!(rt.len(),2); resolve_internal(id(30,EMPTY_CTXT),&mut t, &mut rt); - assert_eq!(rt.len(),2); + fail_unless_eq!(rt.len(),2); } } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index b0c82965060ff..1f42db4e927d7 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -483,10 +483,10 @@ mod test { let cm = CodeMap::new(); let fm = cm.new_filemap(~"blork.rs",~"first line.\nsecond line"); fm.next_line(BytePos(0)); - assert_eq!(&fm.get_line(0),&~"first line."); + fail_unless_eq!(&fm.get_line(0),&~"first line."); // TESTING BROKEN BEHAVIOR: fm.next_line(BytePos(10)); - assert_eq!(&fm.get_line(1),&~"."); + fail_unless_eq!(&fm.get_line(1),&~"."); } #[test] @@ -521,12 +521,12 @@ mod test { let cm = init_code_map(); let fmabp1 = cm.lookup_byte_offset(BytePos(22)); - assert_eq!(fmabp1.fm.name, ~"blork.rs"); - assert_eq!(fmabp1.pos, BytePos(22)); + fail_unless_eq!(fmabp1.fm.name, ~"blork.rs"); + fail_unless_eq!(fmabp1.pos, BytePos(22)); let fmabp2 = cm.lookup_byte_offset(BytePos(23)); - assert_eq!(fmabp2.fm.name, ~"blork2.rs"); - assert_eq!(fmabp2.pos, BytePos(0)); + fail_unless_eq!(fmabp2.fm.name, ~"blork2.rs"); + fail_unless_eq!(fmabp2.pos, BytePos(0)); } #[test] @@ -535,10 +535,10 @@ mod test { let cm = init_code_map(); let cp1 = cm.bytepos_to_charpos(BytePos(22)); - assert_eq!(cp1, CharPos(22)); + fail_unless_eq!(cp1, CharPos(22)); let cp2 = cm.bytepos_to_charpos(BytePos(23)); - assert_eq!(cp2, CharPos(23)); + fail_unless_eq!(cp2, CharPos(23)); } #[test] @@ -547,13 +547,13 @@ mod test { let cm = init_code_map(); let loc1 = cm.lookup_char_pos(BytePos(22)); - assert_eq!(loc1.file.name, ~"blork.rs"); - assert_eq!(loc1.line, 2); - assert_eq!(loc1.col, CharPos(10)); + fail_unless_eq!(loc1.file.name, ~"blork.rs"); + fail_unless_eq!(loc1.line, 2); + fail_unless_eq!(loc1.col, CharPos(10)); let loc2 = cm.lookup_char_pos(BytePos(23)); - assert_eq!(loc2.file.name, ~"blork2.rs"); - assert_eq!(loc2.line, 1); - assert_eq!(loc2.col, CharPos(0)); + fail_unless_eq!(loc2.file.name, ~"blork2.rs"); + fail_unless_eq!(loc2.line, 1); + fail_unless_eq!(loc2.col, CharPos(0)); } } diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs index a6fc365757cd4..c8621281d936e 100644 --- a/src/libsyntax/crateid.rs +++ b/src/libsyntax/crateid.rs @@ -106,17 +106,17 @@ impl CrateId { #[test] fn bare_name() { let crateid: CrateId = from_str("foo").expect("valid crateid"); - assert_eq!(crateid.name, ~"foo"); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, ~"foo"); + fail_unless_eq!(crateid.name, ~"foo"); + fail_unless_eq!(crateid.version, None); + fail_unless_eq!(crateid.path, ~"foo"); } #[test] fn bare_name_single_char() { let crateid: CrateId = from_str("f").expect("valid crateid"); - assert_eq!(crateid.name, ~"f"); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, ~"f"); + fail_unless_eq!(crateid.name, ~"f"); + fail_unless_eq!(crateid.version, None); + fail_unless_eq!(crateid.path, ~"f"); } #[test] @@ -128,17 +128,17 @@ fn empty_crateid() { #[test] fn simple_path() { let crateid: CrateId = from_str("example.com/foo/bar").expect("valid crateid"); - assert_eq!(crateid.name, ~"bar"); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, ~"example.com/foo/bar"); + fail_unless_eq!(crateid.name, ~"bar"); + fail_unless_eq!(crateid.version, None); + fail_unless_eq!(crateid.path, ~"example.com/foo/bar"); } #[test] fn simple_version() { let crateid: CrateId = from_str("foo#1.0").expect("valid crateid"); - assert_eq!(crateid.name, ~"foo"); - assert_eq!(crateid.version, Some(~"1.0")); - assert_eq!(crateid.path, ~"foo"); + fail_unless_eq!(crateid.name, ~"foo"); + fail_unless_eq!(crateid.version, Some(~"1.0")); + fail_unless_eq!(crateid.path, ~"foo"); } #[test] @@ -156,39 +156,39 @@ fn path_ends_with_slash() { #[test] fn path_and_version() { let crateid: CrateId = from_str("example.com/foo/bar#1.0").expect("valid crateid"); - assert_eq!(crateid.name, ~"bar"); - assert_eq!(crateid.version, Some(~"1.0")); - assert_eq!(crateid.path, ~"example.com/foo/bar"); + fail_unless_eq!(crateid.name, ~"bar"); + fail_unless_eq!(crateid.version, Some(~"1.0")); + fail_unless_eq!(crateid.path, ~"example.com/foo/bar"); } #[test] fn single_chars() { let crateid: CrateId = from_str("a/b#1").expect("valid crateid"); - assert_eq!(crateid.name, ~"b"); - assert_eq!(crateid.version, Some(~"1")); - assert_eq!(crateid.path, ~"a/b"); + fail_unless_eq!(crateid.name, ~"b"); + fail_unless_eq!(crateid.version, Some(~"1")); + fail_unless_eq!(crateid.path, ~"a/b"); } #[test] fn missing_version() { let crateid: CrateId = from_str("foo#").expect("valid crateid"); - assert_eq!(crateid.name, ~"foo"); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, ~"foo"); + fail_unless_eq!(crateid.name, ~"foo"); + fail_unless_eq!(crateid.version, None); + fail_unless_eq!(crateid.path, ~"foo"); } #[test] fn path_and_name() { let crateid: CrateId = from_str("foo/rust-bar#bar:1.0").expect("valid crateid"); - assert_eq!(crateid.name, ~"bar"); - assert_eq!(crateid.version, Some(~"1.0")); - assert_eq!(crateid.path, ~"foo/rust-bar"); + fail_unless_eq!(crateid.name, ~"bar"); + fail_unless_eq!(crateid.version, Some(~"1.0")); + fail_unless_eq!(crateid.path, ~"foo/rust-bar"); } #[test] fn empty_name() { let crateid: CrateId = from_str("foo/bar#:1.0").expect("valid crateid"); - assert_eq!(crateid.name, ~"bar"); - assert_eq!(crateid.version, Some(~"1.0")); - assert_eq!(crateid.path, ~"foo/bar"); + fail_unless_eq!(crateid.name, ~"bar"); + fail_unless_eq!(crateid.version, Some(~"1.0")); + fail_unless_eq!(crateid.path, ~"foo/bar"); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b37699b80ba02..36c8e1e53e9a8 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -988,9 +988,9 @@ mod test { let attr2 = make_dummy_attr ("bar"); let escape_attr = make_dummy_attr ("macro_escape"); let attrs1 = ~[attr1, escape_attr, attr2]; - assert_eq!(contains_macro_escape (attrs1),true); + fail_unless_eq!(contains_macro_escape (attrs1),true); let attrs2 = ~[attr1,attr2]; - assert_eq!(contains_macro_escape (attrs2),false); + fail_unless_eq!(contains_macro_escape (attrs2),false); } // make a MetaWord outer attribute with the given name @@ -1120,7 +1120,7 @@ mod test { let varrefs = path_finder.path_accumulator; // must be one check clause for each binding: - assert_eq!(bindings.len(),bound_connections.len()); + fail_unless_eq!(bindings.len(),bound_connections.len()); for (binding_idx,shouldmatch) in bound_connections.iter().enumerate() { let binding_name = mtwt_resolve(bindings[binding_idx]); let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,invalid_name); @@ -1131,7 +1131,7 @@ mod test { if shouldmatch.contains(&idx) { // it should be a path of length 1, and it should // be free-identifier=? or bound-identifier=? to the given binding - assert_eq!(varref.segments.len(),1); + fail_unless_eq!(varref.segments.len(),1); let varref_name = mtwt_resolve(varref.segments[0].identifier); let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt, invalid_name); @@ -1141,11 +1141,11 @@ mod test { println!("binding: {:?}", bindings[binding_idx]); ast_util::display_sctable(get_sctable()); } - assert_eq!(varref_name,binding_name); + fail_unless_eq!(varref_name,binding_name); if bound_ident_check { // we're checking bound-identifier=?, and the marks // should be the same, too: - assert_eq!(varref_marks,binding_marks.clone()); + fail_unless_eq!(varref_marks,binding_marks.clone()); } } else { let fail = (varref.segments.len() == 1) @@ -1222,7 +1222,7 @@ foo_module!() } } } - assert_eq!(mtwt_resolve(v.segments[0].identifier),resolved_binding); + fail_unless_eq!(mtwt_resolve(v.segments[0].identifier),resolved_binding); }; } @@ -1231,7 +1231,7 @@ foo_module!() let pat = string_to_pat(~"(a,Foo{x:c @ (b,9),y:Bar(4,d)})"); let mut pat_idents = new_name_finder(~[]); pat_idents.visit_pat(pat, ()); - assert_eq!(pat_idents.ident_accumulator, + fail_unless_eq!(pat_idents.ident_accumulator, strs_to_idents(~["a","c","b","d"])); } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index df14daccc1094..81d9c4dff794f 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -399,41 +399,41 @@ mod test { #[test] fn test_block_doc_comment_1() { let comment = "/**\n * Test \n ** Test\n * Test\n*/"; let stripped = strip_doc_comment_decoration(comment); - assert_eq!(stripped, ~" Test \n* Test\n Test"); + fail_unless_eq!(stripped, ~" Test \n* Test\n Test"); } #[test] fn test_block_doc_comment_2() { let comment = "/**\n * Test\n * Test\n*/"; let stripped = strip_doc_comment_decoration(comment); - assert_eq!(stripped, ~" Test\n Test"); + fail_unless_eq!(stripped, ~" Test\n Test"); } #[test] fn test_block_doc_comment_3() { let comment = "/**\n let a: *int;\n *a = 5;\n*/"; let stripped = strip_doc_comment_decoration(comment); - assert_eq!(stripped, ~" let a: *int;\n *a = 5;"); + fail_unless_eq!(stripped, ~" let a: *int;\n *a = 5;"); } #[test] fn test_block_doc_comment_4() { let comment = "/*******************\n test\n *********************/"; let stripped = strip_doc_comment_decoration(comment); - assert_eq!(stripped, ~" test"); + fail_unless_eq!(stripped, ~" test"); } #[test] fn test_line_doc_comment() { let stripped = strip_doc_comment_decoration("/// test"); - assert_eq!(stripped, ~" test"); + fail_unless_eq!(stripped, ~" test"); let stripped = strip_doc_comment_decoration("///! test"); - assert_eq!(stripped, ~" test"); + fail_unless_eq!(stripped, ~" test"); let stripped = strip_doc_comment_decoration("// test"); - assert_eq!(stripped, ~" test"); + fail_unless_eq!(stripped, ~" test"); let stripped = strip_doc_comment_decoration("// test"); - assert_eq!(stripped, ~" test"); + fail_unless_eq!(stripped, ~" test"); let stripped = strip_doc_comment_decoration("///test"); - assert_eq!(stripped, ~"test"); + fail_unless_eq!(stripped, ~"test"); let stripped = strip_doc_comment_decoration("///!test"); - assert_eq!(stripped, ~"test"); + fail_unless_eq!(stripped, ~"test"); let stripped = strip_doc_comment_decoration("//test"); - assert_eq!(stripped, ~"test"); + fail_unless_eq!(stripped, ~"test"); } } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 1c0d863420706..550b2cd942776 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -1030,17 +1030,17 @@ mod test { let tok2 = TokenAndSpan{ tok:token::IDENT(id, false), sp:Span {lo:BytePos(21),hi:BytePos(23),expn_info: None}}; - assert_eq!(tok1,tok2); + fail_unless_eq!(tok1,tok2); // the 'main' id is already read: - assert_eq!(string_reader.last_pos.get().clone(), BytePos(28)); + fail_unless_eq!(string_reader.last_pos.get().clone(), BytePos(28)); // read another token: let tok3 = string_reader.next_token(); let tok4 = TokenAndSpan{ tok:token::IDENT(str_to_ident("main"), false), sp:Span {lo:BytePos(24),hi:BytePos(28),expn_info: None}}; - assert_eq!(tok3,tok4); + fail_unless_eq!(tok3,tok4); // the lparen is already read: - assert_eq!(string_reader.last_pos.get().clone(), BytePos(29)) + fail_unless_eq!(string_reader.last_pos.get().clone(), BytePos(29)) } // check that the given reader produces the desired stream @@ -1049,7 +1049,7 @@ mod test { for expected_tok in expected.iter() { let TokenAndSpan {tok:actual_tok, sp: _} = env.string_reader.next_token(); - assert_eq!(&actual_tok,expected_tok); + fail_unless_eq!(&actual_tok,expected_tok); } } @@ -1093,21 +1093,21 @@ mod test { let env = setup(~"'a'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert_eq!(tok,token::LIT_CHAR('a' as u32)); + fail_unless_eq!(tok,token::LIT_CHAR('a' as u32)); } #[test] fn character_space() { let env = setup(~"' '"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert_eq!(tok, token::LIT_CHAR(' ' as u32)); + fail_unless_eq!(tok, token::LIT_CHAR(' ' as u32)); } #[test] fn character_escaped() { let env = setup(~"'\\n'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert_eq!(tok, token::LIT_CHAR('\n' as u32)); + fail_unless_eq!(tok, token::LIT_CHAR('\n' as u32)); } #[test] fn lifetime_name() { @@ -1115,7 +1115,7 @@ mod test { let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); let id = token::str_to_ident("abc"); - assert_eq!(tok, token::LIFETIME(id)); + fail_unless_eq!(tok, token::LIFETIME(id)); } #[test] fn raw_string() { @@ -1123,7 +1123,7 @@ mod test { let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); let id = token::str_to_ident("\"#a\\b\x00c\""); - assert_eq!(tok, token::LIT_STR_RAW(id, 3)); + fail_unless_eq!(tok, token::LIT_STR_RAW(id, 3)); } #[test] fn line_doc_comments() { @@ -1136,7 +1136,7 @@ mod test { let env = setup(~"/* /* */ */'a'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert_eq!(tok,token::LIT_CHAR('a' as u32)); + fail_unless_eq!(tok,token::LIT_CHAR('a' as u32)); } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 08aec07577098..16ee2b2d67334 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -314,7 +314,7 @@ mod test { } #[test] fn path_exprs_1() { - assert_eq!(string_to_expr(~"a"), + fail_unless_eq!(string_to_expr(~"a"), @ast::Expr{ id: ast::DUMMY_NODE_ID, node: ast::ExprPath(ast::Path { @@ -333,7 +333,7 @@ mod test { } #[test] fn path_exprs_2 () { - assert_eq!(string_to_expr(~"::a::b"), + fail_unless_eq!(string_to_expr(~"::a::b"), @ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprPath(ast::Path { @@ -390,33 +390,33 @@ mod test { ast::TTTok(_,token::DOLLAR), ast::TTTok(_,_), ast::TTTok(_,token::RPAREN)] => { - assert_eq!("correct","correct") + fail_unless_eq!("correct","correct") } - _ => assert_eq!("wrong 4","correct") + _ => fail_unless_eq!("wrong 4","correct") } }, _ => { error!("failing value 3: {:?}",first_set); - assert_eq!("wrong 3","correct") + fail_unless_eq!("wrong 3","correct") } } }, _ => { error!("failing value 2: {:?}",delim_elts); - assert_eq!("wrong","correct"); + fail_unless_eq!("wrong","correct"); } } }, _ => { error!("failing value: {:?}",tts); - assert_eq!("wrong 1","correct"); + fail_unless_eq!("wrong 1","correct"); } } } #[test] fn string_to_tts_1 () { let tts = string_to_tts(~"fn a (b : int) { b; }"); - assert_eq!(to_json_str(&tts), + fail_unless_eq!(to_json_str(&tts), ~"[\ {\ \"variant\":\"TTTok\",\ @@ -544,7 +544,7 @@ mod test { } #[test] fn ret_expr() { - assert_eq!(string_to_expr(~"return d"), + fail_unless_eq!(string_to_expr(~"return d"), @ast::Expr{ id: ast::DUMMY_NODE_ID, node:ast::ExprRet(Some(@ast::Expr{ @@ -567,7 +567,7 @@ mod test { } #[test] fn parse_stmt_1 () { - assert_eq!(string_to_stmt(~"b;"), + fail_unless_eq!(string_to_stmt(~"b;"), @Spanned{ node: ast::StmtExpr(@ast::Expr { id: ast::DUMMY_NODE_ID, @@ -589,12 +589,12 @@ mod test { } fn parser_done(p: Parser){ - assert_eq!(p.token.clone(), token::EOF); + fail_unless_eq!(p.token.clone(), token::EOF); } #[test] fn parse_ident_pat () { let mut parser = string_to_parser(~"b"); - assert_eq!(parser.parse_pat(), + fail_unless_eq!(parser.parse_pat(), @ast::Pat{id: ast::DUMMY_NODE_ID, node: ast::PatIdent( ast::BindByValue(ast::MutImmutable), @@ -617,7 +617,7 @@ mod test { // check the contents of the tt manually: #[test] fn parse_fundecl () { // this test depends on the intern order of "fn" and "int" - assert_eq!(string_to_item(~"fn a (b : int) { b; }"), + fail_unless_eq!(string_to_item(~"fn a (b : int) { b; }"), Some( @ast::Item{ident:str_to_ident("a"), attrs:~[], diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 302881472263f..6483ead086013 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -122,7 +122,7 @@ pub fn tok_str(t: Token) -> ~str { pub fn buf_str(toks: ~[Token], szs: ~[int], left: uint, right: uint, lim: uint) -> ~str { let n = toks.len(); - assert_eq!(n, szs.len()); + fail_unless_eq!(n, szs.len()); let mut i = left; let mut L = lim; let mut s = ~"["; @@ -428,7 +428,7 @@ impl Printer { match x { Break(b) => self.left_total += b.blank_space, String(_, len) => { - assert_eq!(len, L); self.left_total += len; + fail_unless_eq!(len, L); self.left_total += len; } _ => () } @@ -564,7 +564,7 @@ impl Printer { } String(s, len) => { debug!("print String({})", s); - assert_eq!(L, len); + fail_unless_eq!(L, len); // fail_unless!(L <= space); self.space -= len; self.print_str(s) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ffe73852597ef..3ea64f6955bed 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2333,7 +2333,7 @@ pub fn print_comment(s: &mut State, cmnt: &comments::Comment) -> io::IoResult<()> { match cmnt.style { comments::Mixed => { - assert_eq!(cmnt.lines.len(), 1u); + fail_unless_eq!(cmnt.lines.len(), 1u); try!(zerobreak(&mut s.s)); try!(word(&mut s.s, cmnt.lines[0])); try!(zerobreak(&mut s.s)); @@ -2548,7 +2548,7 @@ mod test { variadic: false }; let generics = ast_util::empty_generics(); - assert_eq!(&fun_to_str(&decl, ast::ImpureFn, abba_ident, + fail_unless_eq!(&fun_to_str(&decl, ast::ImpureFn, abba_ident, None, &generics), &~"fn abba()"); } @@ -2568,6 +2568,6 @@ mod test { }); let varstr = variant_to_str(&var); - assert_eq!(&varstr,&~"pub principal_skinner"); + fail_unless_eq!(&varstr,&~"pub principal_skinner"); } } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index aedff2d785492..f4b39eae04749 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -230,25 +230,25 @@ mod tests { fn interner_tests () { let i : Interner = Interner::new(); // first one is zero: - assert_eq!(i.intern(RcStr::new("dog")), 0); + fail_unless_eq!(i.intern(RcStr::new("dog")), 0); // re-use gets the same entry: - assert_eq!(i.intern(RcStr::new("dog")), 0); + fail_unless_eq!(i.intern(RcStr::new("dog")), 0); // different string gets a different #: - assert_eq!(i.intern(RcStr::new("cat")), 1); - assert_eq!(i.intern(RcStr::new("cat")), 1); + fail_unless_eq!(i.intern(RcStr::new("cat")), 1); + fail_unless_eq!(i.intern(RcStr::new("cat")), 1); // dog is still at zero - assert_eq!(i.intern(RcStr::new("dog")), 0); + fail_unless_eq!(i.intern(RcStr::new("dog")), 0); // gensym gets 3 - assert_eq!(i.gensym(RcStr::new("zebra") ), 2); + fail_unless_eq!(i.gensym(RcStr::new("zebra") ), 2); // gensym of same string gets new number : - assert_eq!(i.gensym (RcStr::new("zebra") ), 3); + fail_unless_eq!(i.gensym (RcStr::new("zebra") ), 3); // gensym of *existing* string gets new number: - assert_eq!(i.gensym(RcStr::new("dog")), 4); - assert_eq!(i.get(0), RcStr::new("dog")); - assert_eq!(i.get(1), RcStr::new("cat")); - assert_eq!(i.get(2), RcStr::new("zebra")); - assert_eq!(i.get(3), RcStr::new("zebra")); - assert_eq!(i.get(4), RcStr::new("dog")); + fail_unless_eq!(i.gensym(RcStr::new("dog")), 4); + fail_unless_eq!(i.get(0), RcStr::new("dog")); + fail_unless_eq!(i.get(1), RcStr::new("cat")); + fail_unless_eq!(i.get(2), RcStr::new("zebra")); + fail_unless_eq!(i.get(3), RcStr::new("zebra")); + fail_unless_eq!(i.get(4), RcStr::new("dog")); } #[test] @@ -258,39 +258,39 @@ mod tests { RcStr::new("Bob"), RcStr::new("Carol") ]); - assert_eq!(i.get(0), RcStr::new("Alan")); - assert_eq!(i.get(1), RcStr::new("Bob")); - assert_eq!(i.get(2), RcStr::new("Carol")); - assert_eq!(i.intern(RcStr::new("Bob")), 1); + fail_unless_eq!(i.get(0), RcStr::new("Alan")); + fail_unless_eq!(i.get(1), RcStr::new("Bob")); + fail_unless_eq!(i.get(2), RcStr::new("Carol")); + fail_unless_eq!(i.intern(RcStr::new("Bob")), 1); } #[test] fn string_interner_tests() { let i : StrInterner = StrInterner::new(); // first one is zero: - assert_eq!(i.intern("dog"), 0); + fail_unless_eq!(i.intern("dog"), 0); // re-use gets the same entry: - assert_eq!(i.intern ("dog"), 0); + fail_unless_eq!(i.intern ("dog"), 0); // different string gets a different #: - assert_eq!(i.intern("cat"), 1); - assert_eq!(i.intern("cat"), 1); + fail_unless_eq!(i.intern("cat"), 1); + fail_unless_eq!(i.intern("cat"), 1); // dog is still at zero - assert_eq!(i.intern("dog"), 0); + fail_unless_eq!(i.intern("dog"), 0); // gensym gets 3 - assert_eq!(i.gensym("zebra"), 2); + fail_unless_eq!(i.gensym("zebra"), 2); // gensym of same string gets new number : - assert_eq!(i.gensym("zebra"), 3); + fail_unless_eq!(i.gensym("zebra"), 3); // gensym of *existing* string gets new number: - assert_eq!(i.gensym("dog"), 4); + fail_unless_eq!(i.gensym("dog"), 4); // gensym tests again with gensym_copy: - assert_eq!(i.gensym_copy(2), 5); - assert_eq!(i.get(5), RcStr::new("zebra")); - assert_eq!(i.gensym_copy(2), 6); - assert_eq!(i.get(6), RcStr::new("zebra")); - assert_eq!(i.get(0), RcStr::new("dog")); - assert_eq!(i.get(1), RcStr::new("cat")); - assert_eq!(i.get(2), RcStr::new("zebra")); - assert_eq!(i.get(3), RcStr::new("zebra")); - assert_eq!(i.get(4), RcStr::new("dog")); + fail_unless_eq!(i.gensym_copy(2), 5); + fail_unless_eq!(i.get(5), RcStr::new("zebra")); + fail_unless_eq!(i.gensym_copy(2), 6); + fail_unless_eq!(i.get(6), RcStr::new("zebra")); + fail_unless_eq!(i.get(0), RcStr::new("dog")); + fail_unless_eq!(i.get(1), RcStr::new("cat")); + fail_unless_eq!(i.get(2), RcStr::new("zebra")); + fail_unless_eq!(i.get(3), RcStr::new("zebra")); + fail_unless_eq!(i.get(4), RcStr::new("dog")); } } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 8c7ad028a8ee0..87087f1f182ca 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -156,15 +156,15 @@ mod test { use super::*; #[test] fn eqmodws() { - assert_eq!(matches_codepattern("",""),true); - assert_eq!(matches_codepattern("","a"),false); - assert_eq!(matches_codepattern("a",""),false); - assert_eq!(matches_codepattern("a","a"),true); - assert_eq!(matches_codepattern("a b","a \n\t\r b"),true); - assert_eq!(matches_codepattern("a b ","a \n\t\r b"),true); - assert_eq!(matches_codepattern("a b","a \n\t\r b "),false); - assert_eq!(matches_codepattern("a b","a b"),true); - assert_eq!(matches_codepattern("ab","a b"),false); - assert_eq!(matches_codepattern("a b","ab"),true); + fail_unless_eq!(matches_codepattern("",""),true); + fail_unless_eq!(matches_codepattern("","a"),false); + fail_unless_eq!(matches_codepattern("a",""),false); + fail_unless_eq!(matches_codepattern("a","a"),true); + fail_unless_eq!(matches_codepattern("a b","a \n\t\r b"),true); + fail_unless_eq!(matches_codepattern("a b ","a \n\t\r b"),true); + fail_unless_eq!(matches_codepattern("a b","a \n\t\r b "),false); + fail_unless_eq!(matches_codepattern("a b","a b"),true); + fail_unless_eq!(matches_codepattern("ab","a b"),false); + fail_unless_eq!(matches_codepattern("a b","ab"),true); } } diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index d6cc35a6f9d3e..455b1461cbdab 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -139,46 +139,46 @@ mod test { #[test] fn test_len() { let v: SmallVector = SmallVector::zero(); - assert_eq!(0, v.len()); + fail_unless_eq!(0, v.len()); - assert_eq!(1, SmallVector::one(1).len()); - assert_eq!(5, SmallVector::many(~[1, 2, 3, 4, 5]).len()); + fail_unless_eq!(1, SmallVector::one(1).len()); + fail_unless_eq!(5, SmallVector::many(~[1, 2, 3, 4, 5]).len()); } #[test] fn test_push_get() { let mut v = SmallVector::zero(); v.push(1); - assert_eq!(1, v.len()); - assert_eq!(&1, v.get(0)); + fail_unless_eq!(1, v.len()); + fail_unless_eq!(&1, v.get(0)); v.push(2); - assert_eq!(2, v.len()); - assert_eq!(&2, v.get(1)); + fail_unless_eq!(2, v.len()); + fail_unless_eq!(&2, v.get(1)); v.push(3); - assert_eq!(3, v.len()); - assert_eq!(&3, v.get(2)); + fail_unless_eq!(3, v.len()); + fail_unless_eq!(&3, v.get(2)); } #[test] fn test_from_iterator() { let v: SmallVector = (~[1, 2, 3]).move_iter().collect(); - assert_eq!(3, v.len()); - assert_eq!(&1, v.get(0)); - assert_eq!(&2, v.get(1)); - assert_eq!(&3, v.get(2)); + fail_unless_eq!(3, v.len()); + fail_unless_eq!(&1, v.get(0)); + fail_unless_eq!(&2, v.get(1)); + fail_unless_eq!(&3, v.get(2)); } #[test] fn test_move_iter() { let v = SmallVector::zero(); let v: ~[int] = v.move_iter().collect(); - assert_eq!(~[], v); + fail_unless_eq!(~[], v); let v = SmallVector::one(1); - assert_eq!(~[1], v.move_iter().collect()); + fail_unless_eq!(~[1], v.move_iter().collect()); let v = SmallVector::many(~[1, 2, 3]); - assert_eq!(~[1, 2, 3], v.move_iter().collect()); + fail_unless_eq!(~[1, 2, 3], v.move_iter().collect()); } #[test] @@ -195,7 +195,7 @@ mod test { #[test] fn test_expect_one_one() { - assert_eq!(1, SmallVector::one(1).expect_one("")); - assert_eq!(1, SmallVector::many(~[1]).expect_one("")); + fail_unless_eq!(1, SmallVector::one(1).expect_one("")); + fail_unless_eq!(1, SmallVector::many(~[1]).expect_one("")); } } diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index a9a7f6909b3d1..0d412d99546bd 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -560,23 +560,23 @@ mod test { #[test] fn test_basic_setabf() { let s = bytes!("\\E[48;5;%p1%dm"); - assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(), + fail_unless_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(), bytes!("\\E[48;5;1m").to_owned()); } #[test] fn test_multiple_int_constants() { - assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(), + fail_unless_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(), bytes!("21").to_owned()); } #[test] fn test_op_i() { let mut vars = Variables::new(); - assert_eq!(expand(bytes!("%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d"), + fail_unless_eq!(expand(bytes!("%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d"), [Number(1),Number(2),Number(3)], &mut vars), Ok(bytes!("123233").to_owned())); - assert_eq!(expand(bytes!("%p1%d%p2%d%i%p1%d%p2%d"), [], &mut vars), + fail_unless_eq!(expand(bytes!("%p1%d%p2%d%i%p1%d%p2%d"), [], &mut vars), Ok(bytes!("0011").to_owned())); } @@ -620,15 +620,15 @@ mod test { let s = format!("%\\{1\\}%\\{2\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), ~['0' as u8 + bs[0]]); + fail_unless_eq!(res.unwrap(), ~['0' as u8 + bs[0]]); let s = format!("%\\{1\\}%\\{1\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), ~['0' as u8 + bs[1]]); + fail_unless_eq!(res.unwrap(), ~['0' as u8 + bs[1]]); let s = format!("%\\{2\\}%\\{1\\}%{}%d", op); let res = expand(s.as_bytes(), [], &mut Variables::new()); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), ~['0' as u8 + bs[2]]); + fail_unless_eq!(res.unwrap(), ~['0' as u8 + bs[2]]); } } @@ -638,28 +638,28 @@ mod test { let s = bytes!("\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"); let res = expand(s, [Number(1)], &mut vars); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), bytes!("\\E[31m").to_owned()); + fail_unless_eq!(res.unwrap(), bytes!("\\E[31m").to_owned()); let res = expand(s, [Number(8)], &mut vars); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), bytes!("\\E[90m").to_owned()); + fail_unless_eq!(res.unwrap(), bytes!("\\E[90m").to_owned()); let res = expand(s, [Number(42)], &mut vars); fail_unless!(res.is_ok(), res.unwrap_err()); - assert_eq!(res.unwrap(), bytes!("\\E[38;5;42m").to_owned()); + fail_unless_eq!(res.unwrap(), bytes!("\\E[38;5;42m").to_owned()); } #[test] fn test_format() { let mut varstruct = Variables::new(); let vars = &mut varstruct; - assert_eq!(expand(bytes!("%p1%s%p2%2s%p3%2s%p4%.2s"), + fail_unless_eq!(expand(bytes!("%p1%s%p2%2s%p3%2s%p4%.2s"), [String(~"foo"), String(~"foo"), String(~"f"), String(~"foo")], vars), Ok(bytes!("foofoo ffo").to_owned())); - assert_eq!(expand(bytes!("%p1%:-4.2s"), [String(~"foo")], vars), + fail_unless_eq!(expand(bytes!("%p1%:-4.2s"), [String(~"foo")], vars), Ok(bytes!("fo ").to_owned())); - assert_eq!(expand(bytes!("%p1%d%p1%.3d%p1%5d%p1%:+d"), [Number(1)], vars), + fail_unless_eq!(expand(bytes!("%p1%d%p1%.3d%p1%5d%p1%:+d"), [Number(1)], vars), Ok(bytes!("1001 1+1").to_owned())); - assert_eq!(expand(bytes!("%p1%o%p1%#o%p2%6.4x%p2%#6.4X"), [Number(15), Number(27)], vars), + fail_unless_eq!(expand(bytes!("%p1%o%p1%#o%p2%6.4x%p2%#6.4X"), [Number(15), Number(27)], vars), Ok(bytes!("17017 001b0X001B").to_owned())); } } diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index 684bb6409d00e..3c61cbe98132b 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -345,9 +345,9 @@ mod test { #[test] fn test_veclens() { - assert_eq!(boolfnames.len(), boolnames.len()); - assert_eq!(numfnames.len(), numnames.len()); - assert_eq!(stringfnames.len(), stringnames.len()); + fail_unless_eq!(boolfnames.len(), boolnames.len()); + fail_unless_eq!(numfnames.len(), numnames.len()); + fail_unless_eq!(stringfnames.len(), stringnames.len()); } #[test] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 2074302ea71da..304dc1bf0ce33 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1327,7 +1327,7 @@ mod tests { let (p, ch) = Chan::new(); run_test(false, desc, ch); let (_, res, _) = p.recv(); - assert_eq!(res, TrIgnored); + fail_unless_eq!(res, TrIgnored); } #[test] @@ -1344,7 +1344,7 @@ mod tests { let (p, ch) = Chan::new(); run_test(false, desc, ch); let (_, res, _) = p.recv(); - assert_eq!(res, TrOk); + fail_unless_eq!(res, TrOk); } #[test] @@ -1361,7 +1361,7 @@ mod tests { let (p, ch) = Chan::new(); run_test(false, desc, ch); let (_, res, _) = p.recv(); - assert_eq!(res, TrFailed); + fail_unless_eq!(res, TrFailed); } #[test] @@ -1421,8 +1421,8 @@ mod tests { ]; let filtered = filter_tests(&opts, tests); - assert_eq!(filtered.len(), 1); - assert_eq!(filtered[0].desc.name.to_str(), ~"1"); + fail_unless_eq!(filtered.len(), 1); + fail_unless_eq!(filtered[0].desc.name.to_str(), ~"1"); fail_unless!(filtered[0].desc.ignore == false); } @@ -1504,29 +1504,29 @@ mod tests { let diff1 = m2.compare_to_old(&m1, None); - assert_eq!(*(diff1.find(&~"in-both-noise").unwrap()), LikelyNoise); - assert_eq!(*(diff1.find(&~"in-first-noise").unwrap()), MetricRemoved); - assert_eq!(*(diff1.find(&~"in-second-noise").unwrap()), MetricAdded); - assert_eq!(*(diff1.find(&~"in-both-want-downwards-but-regressed").unwrap()), + fail_unless_eq!(*(diff1.find(&~"in-both-noise").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff1.find(&~"in-first-noise").unwrap()), MetricRemoved); + fail_unless_eq!(*(diff1.find(&~"in-second-noise").unwrap()), MetricAdded); + fail_unless_eq!(*(diff1.find(&~"in-both-want-downwards-but-regressed").unwrap()), Regression(100.0)); - assert_eq!(*(diff1.find(&~"in-both-want-downwards-and-improved").unwrap()), + fail_unless_eq!(*(diff1.find(&~"in-both-want-downwards-and-improved").unwrap()), Improvement(50.0)); - assert_eq!(*(diff1.find(&~"in-both-want-upwards-but-regressed").unwrap()), + fail_unless_eq!(*(diff1.find(&~"in-both-want-upwards-but-regressed").unwrap()), Regression(50.0)); - assert_eq!(*(diff1.find(&~"in-both-want-upwards-and-improved").unwrap()), + fail_unless_eq!(*(diff1.find(&~"in-both-want-upwards-and-improved").unwrap()), Improvement(100.0)); - assert_eq!(diff1.len(), 7); + fail_unless_eq!(diff1.len(), 7); let diff2 = m2.compare_to_old(&m1, Some(200.0)); - assert_eq!(*(diff2.find(&~"in-both-noise").unwrap()), LikelyNoise); - assert_eq!(*(diff2.find(&~"in-first-noise").unwrap()), MetricRemoved); - assert_eq!(*(diff2.find(&~"in-second-noise").unwrap()), MetricAdded); - assert_eq!(*(diff2.find(&~"in-both-want-downwards-but-regressed").unwrap()), LikelyNoise); - assert_eq!(*(diff2.find(&~"in-both-want-downwards-and-improved").unwrap()), LikelyNoise); - assert_eq!(*(diff2.find(&~"in-both-want-upwards-but-regressed").unwrap()), LikelyNoise); - assert_eq!(*(diff2.find(&~"in-both-want-upwards-and-improved").unwrap()), LikelyNoise); - assert_eq!(diff2.len(), 7); + fail_unless_eq!(*(diff2.find(&~"in-both-noise").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff2.find(&~"in-first-noise").unwrap()), MetricRemoved); + fail_unless_eq!(*(diff2.find(&~"in-second-noise").unwrap()), MetricAdded); + fail_unless_eq!(*(diff2.find(&~"in-both-want-downwards-but-regressed").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff2.find(&~"in-both-want-downwards-and-improved").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff2.find(&~"in-both-want-upwards-but-regressed").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff2.find(&~"in-both-want-upwards-and-improved").unwrap()), LikelyNoise); + fail_unless_eq!(diff2.len(), 7); } #[test] @@ -1547,32 +1547,32 @@ mod tests { // Ask for a ratchet that should fail to advance. let (diff1, ok1) = m2.ratchet(&pth, None); - assert_eq!(ok1, false); - assert_eq!(diff1.len(), 2); - assert_eq!(*(diff1.find(&~"runtime").unwrap()), Regression(10.0)); - assert_eq!(*(diff1.find(&~"throughput").unwrap()), LikelyNoise); + fail_unless_eq!(ok1, false); + fail_unless_eq!(diff1.len(), 2); + fail_unless_eq!(*(diff1.find(&~"runtime").unwrap()), Regression(10.0)); + fail_unless_eq!(*(diff1.find(&~"throughput").unwrap()), LikelyNoise); // Check that it was not rewritten. let m3 = MetricMap::load(&pth); let MetricMap(m3) = m3; - assert_eq!(m3.len(), 2); - assert_eq!(*(m3.find(&~"runtime").unwrap()), Metric::new(1000.0, 2.0)); - assert_eq!(*(m3.find(&~"throughput").unwrap()), Metric::new(50.0, 2.0)); + fail_unless_eq!(m3.len(), 2); + fail_unless_eq!(*(m3.find(&~"runtime").unwrap()), Metric::new(1000.0, 2.0)); + fail_unless_eq!(*(m3.find(&~"throughput").unwrap()), Metric::new(50.0, 2.0)); // Ask for a ratchet with an explicit noise-percentage override, // that should advance. let (diff2, ok2) = m2.ratchet(&pth, Some(10.0)); - assert_eq!(ok2, true); - assert_eq!(diff2.len(), 2); - assert_eq!(*(diff2.find(&~"runtime").unwrap()), LikelyNoise); - assert_eq!(*(diff2.find(&~"throughput").unwrap()), LikelyNoise); + fail_unless_eq!(ok2, true); + fail_unless_eq!(diff2.len(), 2); + fail_unless_eq!(*(diff2.find(&~"runtime").unwrap()), LikelyNoise); + fail_unless_eq!(*(diff2.find(&~"throughput").unwrap()), LikelyNoise); // Check that it was rewritten. let m4 = MetricMap::load(&pth); let MetricMap(m4) = m4; - assert_eq!(m4.len(), 2); - assert_eq!(*(m4.find(&~"runtime").unwrap()), Metric::new(1100.0, 2.0)); - assert_eq!(*(m4.find(&~"throughput").unwrap()), Metric::new(50.0, 2.0)); + fail_unless_eq!(m4.len(), 2); + fail_unless_eq!(*(m4.find(&~"runtime").unwrap()), Metric::new(1100.0, 2.0)); + fail_unless_eq!(*(m4.find(&~"throughput").unwrap()), Metric::new(50.0, 2.0)); } } diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 0898db9a4b498..5ccd431420224 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -146,12 +146,12 @@ pub fn precise_time_ns() -> u64 { #[cfg(windows)] fn os_precise_time_ns() -> u64 { let mut ticks_per_s = 0; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { libc::QueryPerformanceFrequency(&mut ticks_per_s) }, 1); let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s}; let mut ticks = 0; - assert_eq!(unsafe { + fail_unless_eq!(unsafe { libc::QueryPerformanceCounter(&mut ticks) }, 1); @@ -1118,18 +1118,18 @@ mod tests { let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); - assert_eq!(utc.tm_sec, 30_i32); - assert_eq!(utc.tm_min, 31_i32); - assert_eq!(utc.tm_hour, 23_i32); - assert_eq!(utc.tm_mday, 13_i32); - assert_eq!(utc.tm_mon, 1_i32); - assert_eq!(utc.tm_year, 109_i32); - assert_eq!(utc.tm_wday, 5_i32); - assert_eq!(utc.tm_yday, 43_i32); - assert_eq!(utc.tm_isdst, 0_i32); - assert_eq!(utc.tm_gmtoff, 0_i32); - assert_eq!(utc.tm_zone, ~"UTC"); - assert_eq!(utc.tm_nsec, 54321_i32); + fail_unless_eq!(utc.tm_sec, 30_i32); + fail_unless_eq!(utc.tm_min, 31_i32); + fail_unless_eq!(utc.tm_hour, 23_i32); + fail_unless_eq!(utc.tm_mday, 13_i32); + fail_unless_eq!(utc.tm_mon, 1_i32); + fail_unless_eq!(utc.tm_year, 109_i32); + fail_unless_eq!(utc.tm_wday, 5_i32); + fail_unless_eq!(utc.tm_yday, 43_i32); + fail_unless_eq!(utc.tm_isdst, 0_i32); + fail_unless_eq!(utc.tm_gmtoff, 0_i32); + fail_unless_eq!(utc.tm_zone, ~"UTC"); + fail_unless_eq!(utc.tm_nsec, 54321_i32); } fn test_at() { @@ -1140,23 +1140,23 @@ mod tests { error!("time_at: {:?}", local); - assert_eq!(local.tm_sec, 30_i32); - assert_eq!(local.tm_min, 31_i32); - assert_eq!(local.tm_hour, 15_i32); - assert_eq!(local.tm_mday, 13_i32); - assert_eq!(local.tm_mon, 1_i32); - assert_eq!(local.tm_year, 109_i32); - assert_eq!(local.tm_wday, 5_i32); - assert_eq!(local.tm_yday, 43_i32); - assert_eq!(local.tm_isdst, 0_i32); - assert_eq!(local.tm_gmtoff, -28800_i32); + fail_unless_eq!(local.tm_sec, 30_i32); + fail_unless_eq!(local.tm_min, 31_i32); + fail_unless_eq!(local.tm_hour, 15_i32); + fail_unless_eq!(local.tm_mday, 13_i32); + fail_unless_eq!(local.tm_mon, 1_i32); + fail_unless_eq!(local.tm_year, 109_i32); + fail_unless_eq!(local.tm_wday, 5_i32); + fail_unless_eq!(local.tm_yday, 43_i32); + fail_unless_eq!(local.tm_isdst, 0_i32); + fail_unless_eq!(local.tm_gmtoff, -28800_i32); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = &local.tm_zone; fail_unless!(*zone == ~"PST" || *zone == ~"Pacific Standard Time"); - assert_eq!(local.tm_nsec, 54321_i32); + fail_unless_eq!(local.tm_nsec, 54321_i32); } fn test_to_timespec() { @@ -1165,8 +1165,8 @@ mod tests { let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); - assert_eq!(utc.to_timespec(), time); - assert_eq!(utc.to_local().to_timespec(), time); + fail_unless_eq!(utc.to_timespec(), time); + fail_unless_eq!(utc.to_local().to_timespec(), time); } fn test_conversions() { @@ -1205,7 +1205,7 @@ mod tests { } let format = "%a %b %e %T.%f %Y"; - assert_eq!(strptime("", format), Err(~"Invalid time")); + fail_unless_eq!(strptime("", format), Err(~"Invalid time")); fail_unless!(strptime("Fri Feb 13 15:31:30", format) == Err(~"Invalid time")); @@ -1345,7 +1345,7 @@ mod tests { fail_unless!(test("%", "%%")); // Test for #7256 - assert_eq!(strptime("360", "%Y-%m-%d"), Err(~"Invalid year")) + fail_unless_eq!(strptime("360", "%Y-%m-%d"), Err(~"Invalid year")) } fn test_ctime() { @@ -1357,8 +1357,8 @@ mod tests { error!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime()); - assert_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009"); - assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); + fail_unless_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009"); + fail_unless_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); } fn test_strftime() { @@ -1368,55 +1368,55 @@ mod tests { let utc = at_utc(time); let local = at(time); - assert_eq!(local.strftime(""), ~""); - assert_eq!(local.strftime("%A"), ~"Friday"); - assert_eq!(local.strftime("%a"), ~"Fri"); - assert_eq!(local.strftime("%B"), ~"February"); - assert_eq!(local.strftime("%b"), ~"Feb"); - assert_eq!(local.strftime("%C"), ~"20"); - assert_eq!(local.strftime("%c"), ~"Fri Feb 13 15:31:30 2009"); - assert_eq!(local.strftime("%D"), ~"02/13/09"); - assert_eq!(local.strftime("%d"), ~"13"); - assert_eq!(local.strftime("%e"), ~"13"); - assert_eq!(local.strftime("%f"), ~"000054321"); - assert_eq!(local.strftime("%F"), ~"2009-02-13"); - assert_eq!(local.strftime("%G"), ~"2009"); - assert_eq!(local.strftime("%g"), ~"09"); - assert_eq!(local.strftime("%H"), ~"15"); - assert_eq!(local.strftime("%I"), ~"03"); - assert_eq!(local.strftime("%j"), ~"044"); - assert_eq!(local.strftime("%k"), ~"15"); - assert_eq!(local.strftime("%l"), ~" 3"); - assert_eq!(local.strftime("%M"), ~"31"); - assert_eq!(local.strftime("%m"), ~"02"); - assert_eq!(local.strftime("%n"), ~"\n"); - assert_eq!(local.strftime("%P"), ~"pm"); - assert_eq!(local.strftime("%p"), ~"PM"); - assert_eq!(local.strftime("%R"), ~"15:31"); - assert_eq!(local.strftime("%r"), ~"03:31:30 PM"); - assert_eq!(local.strftime("%S"), ~"30"); - assert_eq!(local.strftime("%s"), ~"1234567890"); - assert_eq!(local.strftime("%T"), ~"15:31:30"); - assert_eq!(local.strftime("%t"), ~"\t"); - assert_eq!(local.strftime("%U"), ~"06"); - assert_eq!(local.strftime("%u"), ~"5"); - assert_eq!(local.strftime("%V"), ~"07"); - assert_eq!(local.strftime("%v"), ~"13-Feb-2009"); - assert_eq!(local.strftime("%W"), ~"06"); - assert_eq!(local.strftime("%w"), ~"5"); - assert_eq!(local.strftime("%X"), ~"15:31:30"); // FIXME (#2350): support locale - assert_eq!(local.strftime("%x"), ~"02/13/09"); // FIXME (#2350): support locale - assert_eq!(local.strftime("%Y"), ~"2009"); - assert_eq!(local.strftime("%y"), ~"09"); - assert_eq!(local.strftime("%+"), ~"2009-02-13T15:31:30-08:00"); + fail_unless_eq!(local.strftime(""), ~""); + fail_unless_eq!(local.strftime("%A"), ~"Friday"); + fail_unless_eq!(local.strftime("%a"), ~"Fri"); + fail_unless_eq!(local.strftime("%B"), ~"February"); + fail_unless_eq!(local.strftime("%b"), ~"Feb"); + fail_unless_eq!(local.strftime("%C"), ~"20"); + fail_unless_eq!(local.strftime("%c"), ~"Fri Feb 13 15:31:30 2009"); + fail_unless_eq!(local.strftime("%D"), ~"02/13/09"); + fail_unless_eq!(local.strftime("%d"), ~"13"); + fail_unless_eq!(local.strftime("%e"), ~"13"); + fail_unless_eq!(local.strftime("%f"), ~"000054321"); + fail_unless_eq!(local.strftime("%F"), ~"2009-02-13"); + fail_unless_eq!(local.strftime("%G"), ~"2009"); + fail_unless_eq!(local.strftime("%g"), ~"09"); + fail_unless_eq!(local.strftime("%H"), ~"15"); + fail_unless_eq!(local.strftime("%I"), ~"03"); + fail_unless_eq!(local.strftime("%j"), ~"044"); + fail_unless_eq!(local.strftime("%k"), ~"15"); + fail_unless_eq!(local.strftime("%l"), ~" 3"); + fail_unless_eq!(local.strftime("%M"), ~"31"); + fail_unless_eq!(local.strftime("%m"), ~"02"); + fail_unless_eq!(local.strftime("%n"), ~"\n"); + fail_unless_eq!(local.strftime("%P"), ~"pm"); + fail_unless_eq!(local.strftime("%p"), ~"PM"); + fail_unless_eq!(local.strftime("%R"), ~"15:31"); + fail_unless_eq!(local.strftime("%r"), ~"03:31:30 PM"); + fail_unless_eq!(local.strftime("%S"), ~"30"); + fail_unless_eq!(local.strftime("%s"), ~"1234567890"); + fail_unless_eq!(local.strftime("%T"), ~"15:31:30"); + fail_unless_eq!(local.strftime("%t"), ~"\t"); + fail_unless_eq!(local.strftime("%U"), ~"06"); + fail_unless_eq!(local.strftime("%u"), ~"5"); + fail_unless_eq!(local.strftime("%V"), ~"07"); + fail_unless_eq!(local.strftime("%v"), ~"13-Feb-2009"); + fail_unless_eq!(local.strftime("%W"), ~"06"); + fail_unless_eq!(local.strftime("%w"), ~"5"); + fail_unless_eq!(local.strftime("%X"), ~"15:31:30"); // FIXME (#2350): support locale + fail_unless_eq!(local.strftime("%x"), ~"02/13/09"); // FIXME (#2350): support locale + fail_unless_eq!(local.strftime("%Y"), ~"2009"); + fail_unless_eq!(local.strftime("%y"), ~"09"); + fail_unless_eq!(local.strftime("%+"), ~"2009-02-13T15:31:30-08:00"); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. let zone = local.strftime("%Z"); fail_unless!(zone == ~"PST" || zone == ~"Pacific Standard Time"); - assert_eq!(local.strftime("%z"), ~"-0800"); - assert_eq!(local.strftime("%%"), ~"%"); + fail_unless_eq!(local.strftime("%z"), ~"-0800"); + fail_unless_eq!(local.strftime("%%"), ~"%"); // FIXME (#2350): We should probably standardize on the timezone // abbreviation. @@ -1424,14 +1424,14 @@ mod tests { let prefix = ~"Fri, 13 Feb 2009 15:31:30 "; fail_unless!(rfc822 == prefix + "PST" || rfc822 == prefix + "Pacific Standard Time"); - assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); - assert_eq!(local.rfc822z(), ~"Fri, 13 Feb 2009 15:31:30 -0800"); - assert_eq!(local.rfc3339(), ~"2009-02-13T15:31:30-08:00"); + fail_unless_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009"); + fail_unless_eq!(local.rfc822z(), ~"Fri, 13 Feb 2009 15:31:30 -0800"); + fail_unless_eq!(local.rfc3339(), ~"2009-02-13T15:31:30-08:00"); - assert_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009"); - assert_eq!(utc.rfc822(), ~"Fri, 13 Feb 2009 23:31:30 GMT"); - assert_eq!(utc.rfc822z(), ~"Fri, 13 Feb 2009 23:31:30 -0000"); - assert_eq!(utc.rfc3339(), ~"2009-02-13T23:31:30Z"); + fail_unless_eq!(utc.ctime(), ~"Fri Feb 13 23:31:30 2009"); + fail_unless_eq!(utc.rfc822(), ~"Fri, 13 Feb 2009 23:31:30 GMT"); + fail_unless_eq!(utc.rfc822z(), ~"Fri, 13 Feb 2009 23:31:30 -0000"); + fail_unless_eq!(utc.rfc3339(), ~"2009-02-13T23:31:30Z"); } fn test_timespec_eq_ord() { diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index c3e1fbae23f07..bfb927fb12a17 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -795,7 +795,7 @@ mod test { u.encode(&mut ebml::writer::Encoder(&mut wr)); let doc = ebml::reader::Doc(wr.get_ref()); let u2 = Decodable::decode(&mut ebml::reader::Decoder(doc)); - assert_eq!(u, u2); + fail_unless_eq!(u, u2); } #[test] diff --git a/src/test/auxiliary/xcrate_static_addresses.rs b/src/test/auxiliary/xcrate_static_addresses.rs index b6cbae2d2afed..7dd31945c5a3f 100644 --- a/src/test/auxiliary/xcrate_static_addresses.rs +++ b/src/test/auxiliary/xcrate_static_addresses.rs @@ -16,11 +16,11 @@ pub static global2: &'static int = &global0; pub fn verify_same(a: &'static int) { let a = a as *int as uint; let b = &global as *int as uint; - assert_eq!(a, b); + fail_unless_eq!(a, b); } pub fn verify_same2(a: &'static int) { let a = a as *int as uint; let b = global2 as *int as uint; - assert_eq!(a, b); + fail_unless_eq!(a, b); } diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 66639e11d906e..ef42cdb769b94 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -37,7 +37,7 @@ fn ascending>(map: &mut M, n_keys: uint) { timed("search", || { for i in range(0u, n_keys) { - assert_eq!(map.find(&i).unwrap(), &(i + 1)); + fail_unless_eq!(map.find(&i).unwrap(), &(i + 1)); } }); @@ -59,7 +59,7 @@ fn descending>(map: &mut M, n_keys: uint) { timed("search", || { for i in range(0, n_keys).rev() { - assert_eq!(map.find(&i).unwrap(), &(i + 1)); + fail_unless_eq!(map.find(&i).unwrap(), &(i + 1)); } }); @@ -79,7 +79,7 @@ fn vector>(map: &mut M, n_keys: uint, dist: &[uint]) { timed("search", || { for i in range(0u, n_keys) { - assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1)); + fail_unless_eq!(map.find(&dist[i]).unwrap(), &(i + 1)); } }); diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 68f5bba159fc8..e24aaa60c2dba 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -90,7 +90,7 @@ fn run(args: &[~str]) { print!("Test took {:?} seconds\n", elapsed); let thruput = ((size / workers * workers) as f64) / (elapsed as f64); print!("Throughput={} per sec\n", thruput); - assert_eq!(result, num_bytes * size); + fail_unless_eq!(result, num_bytes * size); } fn main() { diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 9da4a70656249..6d8b25c5b19d0 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -100,7 +100,7 @@ fn run(args: &[~str]) { print!("Test took {:?} seconds\n", elapsed); let thruput = ((size / workers * workers) as f64) / (elapsed as f64); print!("Throughput={} per sec\n", thruput); - assert_eq!(result, num_bytes * size); + fail_unless_eq!(result, num_bytes * size); } fn main() { diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 11a843d6cb573..9265c1324574d 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -68,7 +68,7 @@ fn stress_task(id: int) { let mut i = 0; loop { let n = 15; - assert_eq!(fib(n), fib(n)); + fail_unless_eq!(fib(n), fib(n)); i += 1; error!("{}: Completed {} iterations", id, i); } diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 98deeec7e1818..ca5fe3c911244 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -25,7 +25,7 @@ fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap) { fn check_sequential(min: uint, max: uint, map: &SmallIntMap) { for i in range(min, max) { - assert_eq!(*map.get(&i), i + 22u); + fail_unless_eq!(*map.get(&i), i + 22u); } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 625eb8c8b1846..579563023dea5 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -221,30 +221,30 @@ static DEFAULT_SOLUTION: [[u8, ..9], ..9] = [ #[test] fn colors_new_works() { - assert_eq!(*Colors::new(1), 1022u16); - assert_eq!(*Colors::new(2), 1020u16); - assert_eq!(*Colors::new(3), 1016u16); - assert_eq!(*Colors::new(4), 1008u16); - assert_eq!(*Colors::new(5), 992u16); - assert_eq!(*Colors::new(6), 960u16); - assert_eq!(*Colors::new(7), 896u16); - assert_eq!(*Colors::new(8), 768u16); - assert_eq!(*Colors::new(9), 512u16); + fail_unless_eq!(*Colors::new(1), 1022u16); + fail_unless_eq!(*Colors::new(2), 1020u16); + fail_unless_eq!(*Colors::new(3), 1016u16); + fail_unless_eq!(*Colors::new(4), 1008u16); + fail_unless_eq!(*Colors::new(5), 992u16); + fail_unless_eq!(*Colors::new(6), 960u16); + fail_unless_eq!(*Colors::new(7), 896u16); + fail_unless_eq!(*Colors::new(8), 768u16); + fail_unless_eq!(*Colors::new(9), 512u16); } #[test] fn colors_next_works() { - assert_eq!(Colors(0).next(), 0u8); - assert_eq!(Colors(2).next(), 1u8); - assert_eq!(Colors(4).next(), 2u8); - assert_eq!(Colors(8).next(), 3u8); - assert_eq!(Colors(16).next(), 4u8); - assert_eq!(Colors(32).next(), 5u8); - assert_eq!(Colors(64).next(), 6u8); - assert_eq!(Colors(128).next(), 7u8); - assert_eq!(Colors(256).next(), 8u8); - assert_eq!(Colors(512).next(), 9u8); - assert_eq!(Colors(1024).next(), 0u8); + fail_unless_eq!(Colors(0).next(), 0u8); + fail_unless_eq!(Colors(2).next(), 1u8); + fail_unless_eq!(Colors(4).next(), 2u8); + fail_unless_eq!(Colors(8).next(), 3u8); + fail_unless_eq!(Colors(16).next(), 4u8); + fail_unless_eq!(Colors(32).next(), 5u8); + fail_unless_eq!(Colors(64).next(), 6u8); + fail_unless_eq!(Colors(128).next(), 7u8); + fail_unless_eq!(Colors(256).next(), 8u8); + fail_unless_eq!(Colors(512).next(), 9u8); + fail_unless_eq!(Colors(1024).next(), 0u8); } #[test] @@ -256,7 +256,7 @@ fn colors_remove_works() { colors.remove(1); // THEN - assert_eq!(colors.next(), 2u8); + fail_unless_eq!(colors.next(), 2u8); } #[test] diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 1741210f9ed50..827cfe2254501 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -24,11 +24,11 @@ fn main() { let b: clam = clam{x: @10, y: @20}; let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `@int` info!("{:?}", z); - assert_eq!(z, 21); + fail_unless_eq!(z, 21); let forty: fish = fish{a: @40}; let two: fish = fish{a: @2}; let answer: int = forty.a + two.a; //~^ ERROR binary operation `+` cannot be applied to type `@int` info!("{:?}", answer); - assert_eq!(answer, 42); + fail_unless_eq!(answer, 42); } diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index 6a0d3ef82fb21..b2b28468bdb2a 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -17,8 +17,8 @@ fn box_imm() { borrow(v, |w| { //~ ERROR cannot borrow `v` as mutable v = ~4; - assert_eq!(*v, 3); - assert_eq!(*w, 4); + fail_unless_eq!(*v, 3); + fail_unless_eq!(*w, 4); }) } diff --git a/src/test/compile-fail/borrowck-ref-mut-of-imm.rs b/src/test/compile-fail/borrowck-ref-mut-of-imm.rs index 4a34b85c3edfa..9999c75c73e90 100644 --- a/src/test/compile-fail/borrowck-ref-mut-of-imm.rs +++ b/src/test/compile-fail/borrowck-ref-mut-of-imm.rs @@ -16,5 +16,5 @@ fn destructure(x: Option) -> int { } fn main() { - assert_eq!(destructure(Some(22)), 22); + fail_unless_eq!(destructure(Some(22)), 22); } diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 19bd9b2476b04..66d3d0f798275 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -40,8 +40,8 @@ fn main() { let mut v = ~[]; v = ~[(res)] + v; //~ failed to find an implementation of trait - assert_eq!(v.len(), 2); + fail_unless_eq!(v.len(), 2); } - assert_eq!(x.get(), 1); + fail_unless_eq!(x.get(), 1); } diff --git a/src/test/compile-fail/issue-2969.rs b/src/test/compile-fail/issue-2969.rs index 414273b1bf3ed..704d002c5ce79 100644 --- a/src/test/compile-fail/issue-2969.rs +++ b/src/test/compile-fail/issue-2969.rs @@ -16,5 +16,5 @@ fn main() let mut x = [1, 2, 4]; let v : &int = &x[2]; x[2] = 6; - assert_eq!(*v, 6); + fail_unless_eq!(*v, 6); } diff --git a/src/test/compile-fail/issue-5927.rs b/src/test/compile-fail/issue-5927.rs index a1b4ee7aa3445..f79266f9f9d93 100644 --- a/src/test/compile-fail/issue-5927.rs +++ b/src/test/compile-fail/issue-5927.rs @@ -16,5 +16,5 @@ fn main() { let z = match 3 { x() => x }; - assert_eq!(z,3); + fail_unless_eq!(z,3); } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 2e131485301c6..3d338d1c43179 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -40,7 +40,7 @@ fn to_foo(t: T) { let v = &3; struct F { f: T } let x = @F {f:t} as @foo; - assert_eq!(x.foo(v), 3); + fail_unless_eq!(x.foo(v), 3); } fn to_foo_2(t: T) -> @foo { diff --git a/src/test/compile-fail/macro-crate-unexported-macro.rs b/src/test/compile-fail/macro-crate-unexported-macro.rs index aaf89807ced31..75b14b8d8994a 100644 --- a/src/test/compile-fail/macro-crate-unexported-macro.rs +++ b/src/test/compile-fail/macro-crate-unexported-macro.rs @@ -18,5 +18,5 @@ extern crate macro_crate_test; fn main() { - assert_eq!(3, unexported_macro!()); //~ ERROR macro undefined: 'unexported_macro' + fail_unless_eq!(3, unexported_macro!()); //~ ERROR macro undefined: 'unexported_macro' } diff --git a/src/test/compile-fail/mod_file_disambig.rs b/src/test/compile-fail/mod_file_disambig.rs index 48bd00a3ee06c..d6e0b974567a5 100644 --- a/src/test/compile-fail/mod_file_disambig.rs +++ b/src/test/compile-fail/mod_file_disambig.rs @@ -11,5 +11,5 @@ mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both fn main() { - assert_eq!(mod_file_aux::bar(), 10); + fail_unless_eq!(mod_file_aux::bar(), 10); } diff --git a/src/test/compile-fail/mod_file_not_exist.rs b/src/test/compile-fail/mod_file_not_exist.rs index 8391ff6fa395e..00406d70763d5 100644 --- a/src/test/compile-fail/mod_file_not_exist.rs +++ b/src/test/compile-fail/mod_file_not_exist.rs @@ -11,5 +11,5 @@ mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` fn main() { - assert_eq!(mod_file_aux::bar(), 10); + fail_unless_eq!(mod_file_aux::bar(), 10); } diff --git a/src/test/compile-fail/mod_file_with_path_attr.rs b/src/test/compile-fail/mod_file_with_path_attr.rs index ff330047c4e96..99060d2fb176c 100644 --- a/src/test/compile-fail/mod_file_with_path_attr.rs +++ b/src/test/compile-fail/mod_file_with_path_attr.rs @@ -12,5 +12,5 @@ mod m; //~ ERROR not_a_real_file.rs fn main() { - assert_eq!(m::foo(), 10); + fail_unless_eq!(m::foo(), 10); } diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index 8df156d8332fe..35e160d3b0802 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -21,10 +21,10 @@ fn main() { task::spawn(proc() { let v = arc_v.get(); - assert_eq!(v[3], 4); + fail_unless_eq!(v[3], 4); }); - assert_eq!((arc_v.get())[2], 3); + fail_unless_eq!((arc_v.get())[2], 3); info!("{:?}", arc_v); } diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index b387d3a1719e9..d0e6539943e92 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -19,10 +19,10 @@ fn main() { task::spawn(proc() { let v = arc_v.get(); - assert_eq!(v[3], 4); + fail_unless_eq!(v[3], 4); }); - assert_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v` + fail_unless_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v` info!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v` } diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index 8453ace2b51d9..a28bb69bcab5f 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -37,5 +37,5 @@ mod argparse { fn main () { let f : argparse::Flag = argparse::flag(~"flag", ~"My flag"); let updated_flag = f.set_desc(~"My new flag"); - assert_eq!(updated_flag.desc, "My new flag"); + fail_unless_eq!(updated_flag.desc, "My new flag"); } diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index b17ec8782f10c..663c78fd9fe75 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -21,7 +21,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int { fn foo(p: @point) -> &int { let xc = x_coord(p); //~ ERROR cannot root - assert_eq!(*xc, 3); + fail_unless_eq!(*xc, 3); return xc; } diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index 54d437b9dbb48..661c1a9c66ada 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -21,7 +21,7 @@ fn foo(cond: || -> bool, make_box: || -> @int) { // of this borrow is the fn body as a whole. y = borrow(x); //~ ERROR cannot root - assert_eq!(*x, *y); + fail_unless_eq!(*x, *y); if cond() { break; } } fail_unless!(*y != 0); diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 7aa545ab1b940..c1d3855aac7c0 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -34,5 +34,5 @@ fn get_v(gc: ~get_ctxt) -> uint { fn main() { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; - assert_eq!(get_v(~hc as ~get_ctxt), 22u); + fail_unless_eq!(get_v(~hc as ~get_ctxt), 22u); } diff --git a/src/test/compile-fail/regions-var-type-out-of-scope.rs b/src/test/compile-fail/regions-var-type-out-of-scope.rs index 8955a26de0b93..7eeb7593804c9 100644 --- a/src/test/compile-fail/regions-var-type-out-of-scope.rs +++ b/src/test/compile-fail/regions-var-type-out-of-scope.rs @@ -15,7 +15,7 @@ fn foo(cond: bool) { if cond { x = &3; //~ ERROR borrowed value does not live long enough - assert_eq!(*x, 3); + fail_unless_eq!(*x, 3); } } diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index 5d0991024c4f6..4a36017c29f96 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -29,5 +29,5 @@ fn call_it(b: B) -> int { fn main() { let x = 3i; - assert_eq!(call_it(x), 22); + fail_unless_eq!(call_it(x), 22); } diff --git a/src/test/pretty/record-trailing-comma.rs b/src/test/pretty/record-trailing-comma.rs index 1cdf2e6de4607..e9108f82a4a8f 100644 --- a/src/test/pretty/record-trailing-comma.rs +++ b/src/test/pretty/record-trailing-comma.rs @@ -18,5 +18,5 @@ struct Thing { fn main() { let sth = Thing{x: 0, y: 1,}; let sth2 = Thing{y: 9 , ..sth}; - assert_eq!(sth.x + sth2.y, 9); + fail_unless_eq!(sth.x + sth2.y, 9); } diff --git a/src/test/run-fail/assert-eq-macro-fail.rs b/src/test/run-fail/assert-eq-macro-fail.rs index 7cebfc723de5f..8776611cf85ad 100644 --- a/src/test/run-fail/assert-eq-macro-fail.rs +++ b/src/test/run-fail/assert-eq-macro-fail.rs @@ -14,5 +14,5 @@ struct Point { x : int } fn main() { - assert_eq!(14,15); + fail_unless_eq!(14,15); } diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs index 5e158fe74189e..e8a4c7ae88fc2 100644 --- a/src/test/run-fail/str-overrun.rs +++ b/src/test/run-fail/str-overrun.rs @@ -14,5 +14,5 @@ fn main() { let s: ~str = ~"hello"; // Bounds-check failure. - assert_eq!(s[5], 0x0 as u8); + fail_unless_eq!(s[5], 0x0 as u8); } diff --git a/src/test/run-fail/unwind-match.rs b/src/test/run-fail/unwind-match.rs index 44cc3145c4407..d64bf91812176 100644 --- a/src/test/run-fail/unwind-match.rs +++ b/src/test/run-fail/unwind-match.rs @@ -18,7 +18,7 @@ fn test_box() { fn test_str() { let res = match false { true => { ~"happy" }, _ => fail!("non-exhaustive match failure") }; - assert_eq!(res, ~"happy"); + fail_unless_eq!(res, ~"happy"); } fn main() { test_box(); diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index e7421fe241d7c..c1c1e91ffb818 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -13,8 +13,8 @@ fn main() { let v: ~[int] = ~[10]; let x: int = 0; - assert_eq!(v[x], 10); + fail_unless_eq!(v[x], 10); // Bounds-check failure. - assert_eq!(v[x + 2], 20); + fail_unless_eq!(v[x + 2], 20); } diff --git a/src/test/run-make/mixing-deps/prog.rs b/src/test/run-make/mixing-deps/prog.rs index ed8675eb7064f..82d332164cd19 100644 --- a/src/test/run-make/mixing-deps/prog.rs +++ b/src/test/run-make/mixing-deps/prog.rs @@ -14,6 +14,6 @@ extern crate both; use std::cast; fn main() { - assert_eq!(unsafe { cast::transmute::<&int, uint>(&both::foo) }, + fail_unless_eq!(unsafe { cast::transmute::<&int, uint>(&both::foo) }, dylib::addr()); } diff --git a/src/test/run-make/volatile-intrinsics/main.rs b/src/test/run-make/volatile-intrinsics/main.rs index 5011a7540a726..bd4e8bc430990 100644 --- a/src/test/run-make/volatile-intrinsics/main.rs +++ b/src/test/run-make/volatile-intrinsics/main.rs @@ -14,6 +14,6 @@ pub fn main() { unsafe { let mut i : int = 1; volatile_store(&mut i, 2); - assert_eq!(volatile_load(&i), 2); + fail_unless_eq!(volatile_load(&i), 2); } } diff --git a/src/test/run-pass-fulldeps/macro-crate.rs b/src/test/run-pass-fulldeps/macro-crate.rs index 6738bd245e341..e35a284686535 100644 --- a/src/test/run-pass-fulldeps/macro-crate.rs +++ b/src/test/run-pass-fulldeps/macro-crate.rs @@ -19,6 +19,6 @@ extern crate macro_crate_test; pub fn main() { - assert_eq!(1, make_a_1!()); - assert_eq!(2, exported_macro!()); + fail_unless_eq!(1, make_a_1!()); + fail_unless_eq!(2, exported_macro!()); } diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 0e31cbd2e955c..c013eed8a28e3 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -85,6 +85,6 @@ fn check_pp(cx: fake_ext_ctxt, stdout().write_line(s); if expect != ~"" { error!("expect: '%s', got: '%s'", expect, s); - assert_eq!(s, expect); + fail_unless_eq!(s, expect); } } diff --git a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs index a6f118d77faab..1d54c197c8b88 100644 --- a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs +++ b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs @@ -25,21 +25,21 @@ static static_val_target: u32 = fourcc!("foo ", target); fn main() { let val = fourcc!("foo ", big); - assert_eq!(val, 0x666f6f20u32); - assert_eq!(val, fourcc!("foo ")); + fail_unless_eq!(val, 0x666f6f20u32); + fail_unless_eq!(val, fourcc!("foo ")); let val = fourcc!("foo ", little); - assert_eq!(val, 0x206f6f66u32); + fail_unless_eq!(val, 0x206f6f66u32); let val = fourcc!("foo ", target); let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 }; - assert_eq!(val, exp); + fail_unless_eq!(val, exp); - assert_eq!(static_val_be, 0x666f6f20u32); - assert_eq!(static_val, static_val_be); - assert_eq!(static_val_le, 0x206f6f66u32); + fail_unless_eq!(static_val_be, 0x666f6f20u32); + fail_unless_eq!(static_val, static_val_be); + fail_unless_eq!(static_val_le, 0x206f6f66u32); let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 }; - assert_eq!(static_val_target, exp); + fail_unless_eq!(static_val_target, exp); - assert_eq!(fourcc!("\xC0\xFF\xEE!"), 0xC0FFEE21); + fail_unless_eq!(fourcc!("\xC0\xFF\xEE!"), 0xC0FFEE21); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 5683a2b669861..808c2910ec547 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -37,6 +37,6 @@ fn f(a: A, b: u16) -> ~Invokable: { pub fn main() { let (a, b) = f(22_u64, 44u16).f(); info!("a={:?} b={:?}", a, b); - assert_eq!(a, 22u64); - assert_eq!(b, 44u16); + fail_unless_eq!(a, 22u64); + fail_unless_eq!(b, 44u16); } diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index e6f2edd6d59cf..88ecaa27873ea 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -27,9 +27,9 @@ pub fn main() { let mut a = X {x: 1}; let mut b = 2; let c = 3; - assert_eq!(f1(&mut a, &mut b, c), 6); - assert_eq!(a.x, 0); - assert_eq!(b, 10); - assert_eq!(f2(a.x, |_| a.x = 50), 0); - assert_eq!(a.x, 50); + fail_unless_eq!(f1(&mut a, &mut b, c), 6); + fail_unless_eq!(a.x, 0); + fail_unless_eq!(b, 10); + fail_unless_eq!(f2(a.x, |_| a.x = 50), 0); + fail_unless_eq!(a.x, 50); } diff --git a/src/test/run-pass/arith-0.rs b/src/test/run-pass/arith-0.rs index 5cbd0da23cf7f..191d62e531ab0 100644 --- a/src/test/run-pass/arith-0.rs +++ b/src/test/run-pass/arith-0.rs @@ -13,5 +13,5 @@ pub fn main() { let a: int = 10; info!("{}", a); - assert_eq!(a * (a - 1), 90); + fail_unless_eq!(a * (a - 1), 90); } diff --git a/src/test/run-pass/arith-1.rs b/src/test/run-pass/arith-1.rs index 0b3492784c871..b266051cca054 100644 --- a/src/test/run-pass/arith-1.rs +++ b/src/test/run-pass/arith-1.rs @@ -12,22 +12,22 @@ pub fn main() { let i32_a: int = 10; - assert_eq!(i32_a, 10); - assert_eq!(i32_a - 10, 0); - assert_eq!(i32_a / 10, 1); - assert_eq!(i32_a - 20, -10); - assert_eq!(i32_a << 10, 10240); - assert_eq!(i32_a << 16, 655360); - assert_eq!(i32_a * 16, 160); - assert_eq!(i32_a * i32_a * i32_a, 1000); - assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000); - assert_eq!(i32_a * i32_a / i32_a * i32_a, 100); - assert_eq!(i32_a * (i32_a - 1) << 2 + i32_a, 368640); + fail_unless_eq!(i32_a, 10); + fail_unless_eq!(i32_a - 10, 0); + fail_unless_eq!(i32_a / 10, 1); + fail_unless_eq!(i32_a - 20, -10); + fail_unless_eq!(i32_a << 10, 10240); + fail_unless_eq!(i32_a << 16, 655360); + fail_unless_eq!(i32_a * 16, 160); + fail_unless_eq!(i32_a * i32_a * i32_a, 1000); + fail_unless_eq!(i32_a * i32_a * i32_a * i32_a, 10000); + fail_unless_eq!(i32_a * i32_a / i32_a * i32_a, 100); + fail_unless_eq!(i32_a * (i32_a - 1) << 2 + i32_a, 368640); let i32_b: int = 0x10101010; - assert_eq!(i32_b + 1 - 1, i32_b); - assert_eq!(i32_b << 1, i32_b << 1); - assert_eq!(i32_b >> 1, i32_b >> 1); - assert_eq!(i32_b & i32_b << 1, 0); + fail_unless_eq!(i32_b + 1 - 1, i32_b); + fail_unless_eq!(i32_b << 1, i32_b << 1); + fail_unless_eq!(i32_b >> 1, i32_b >> 1); + fail_unless_eq!(i32_b & i32_b << 1, 0); info!("{}", i32_b | i32_b << 1); - assert_eq!(i32_b | i32_b << 1, 0x30303030); + fail_unless_eq!(i32_b | i32_b << 1, 0x30303030); } diff --git a/src/test/run-pass/arith-unsigned.rs b/src/test/run-pass/arith-unsigned.rs index 43ad8a31926ec..78ed4f6e85f8e 100644 --- a/src/test/run-pass/arith-unsigned.rs +++ b/src/test/run-pass/arith-unsigned.rs @@ -16,20 +16,20 @@ pub fn main() { fail_unless!((0u8 <= 255u8)); fail_unless!((255u8 > 0u8)); fail_unless!((255u8 >= 0u8)); - assert_eq!(250u8 / 10u8, 25u8); - assert_eq!(255u8 % 10u8, 5u8); + fail_unless_eq!(250u8 / 10u8, 25u8); + fail_unless_eq!(255u8 % 10u8, 5u8); fail_unless!((0u16 < 60000u16)); fail_unless!((0u16 <= 60000u16)); fail_unless!((60000u16 > 0u16)); fail_unless!((60000u16 >= 0u16)); - assert_eq!(60000u16 / 10u16, 6000u16); - assert_eq!(60005u16 % 10u16, 5u16); + fail_unless_eq!(60000u16 / 10u16, 6000u16); + fail_unless_eq!(60005u16 % 10u16, 5u16); fail_unless!((0u32 < 4000000000u32)); fail_unless!((0u32 <= 4000000000u32)); fail_unless!((4000000000u32 > 0u32)); fail_unless!((4000000000u32 >= 0u32)); - assert_eq!(4000000000u32 / 10u32, 400000000u32); - assert_eq!(4000000005u32 % 10u32, 5u32); + fail_unless_eq!(4000000000u32 / 10u32, 400000000u32); + fail_unless_eq!(4000000005u32 % 10u32, 5u32); // 64-bit numbers have some flakiness yet. Not tested } diff --git a/src/test/run-pass/asm-out-assign.rs b/src/test/run-pass/asm-out-assign.rs index 823da4faaf639..ee2ef345dff5e 100644 --- a/src/test/run-pass/asm-out-assign.rs +++ b/src/test/run-pass/asm-out-assign.rs @@ -19,16 +19,16 @@ pub fn main() { // Treat the output as initialization. asm!("mov $1, $0" : "=r"(x) : "r"(5u)); } - assert_eq!(x, 5); + fail_unless_eq!(x, 5); let mut x = x + 1; - assert_eq!(x, 6); + fail_unless_eq!(x, 6); unsafe { // Assignment to mutable. asm!("mov $1, $0" : "=r"(x) : "r"(x + 7)); } - assert_eq!(x, 13); + fail_unless_eq!(x, 13); } #[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))] diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index 047c339fafb3c..e6e376a3d6fa9 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -12,9 +12,9 @@ struct Point { x : int } pub fn main() { - assert_eq!(14,14); - assert_eq!(~"abc",~"abc"); - assert_eq!(~Point{x:34},~Point{x:34}); - assert_eq!(&Point{x:34},&Point{x:34}); - assert_eq!(@Point{x:34},@Point{x:34}); + fail_unless_eq!(14,14); + fail_unless_eq!(~"abc",~"abc"); + fail_unless_eq!(~Point{x:34},~Point{x:34}); + fail_unless_eq!(&Point{x:34},&Point{x:34}); + fail_unless_eq!(@Point{x:34},@Point{x:34}); } diff --git a/src/test/run-pass/assign-assign.rs b/src/test/run-pass/assign-assign.rs index 0f5d27015fb74..0b6e384f6b0af 100644 --- a/src/test/run-pass/assign-assign.rs +++ b/src/test/run-pass/assign-assign.rs @@ -12,27 +12,27 @@ fn test_assign() { let mut x: int; let y: () = x = 10; - assert_eq!(x, 10); - assert_eq!(y, ()); + fail_unless_eq!(x, 10); + fail_unless_eq!(y, ()); let mut z = x = 11; - assert_eq!(x, 11); - assert_eq!(z, ()); + fail_unless_eq!(x, 11); + fail_unless_eq!(z, ()); z = x = 12; - assert_eq!(x, 12); - assert_eq!(z, ()); + fail_unless_eq!(x, 12); + fail_unless_eq!(z, ()); } fn test_assign_op() { let mut x: int = 0; let y: () = x += 10; - assert_eq!(x, 10); - assert_eq!(y, ()); + fail_unless_eq!(x, 10); + fail_unless_eq!(y, ()); let mut z = x += 11; - assert_eq!(x, 21); - assert_eq!(z, ()); + fail_unless_eq!(x, 21); + fail_unless_eq!(z, ()); z = x += 12; - assert_eq!(x, 33); - assert_eq!(z, ()); + fail_unless_eq!(x, 33); + fail_unless_eq!(z, ()); } pub fn main() { test_assign(); test_assign_op(); } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 40f6aa3e1145f..1e03ca5786ad1 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -42,15 +42,15 @@ pub fn main() { // Call a method x.iterate(|y| { fail_unless!(x[*y] == *y); true }); // Call a parameterized function - assert_eq!(length(x.clone()), x.len()); + fail_unless_eq!(length(x.clone()), x.len()); // Call a parameterized function, with type arguments that require // a borrow - assert_eq!(length::(x), x.len()); + fail_unless_eq!(length::(x), x.len()); // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; // Call a method z.iterate(|y| { fail_unless!(z[*y] == *y); true }); // Call a parameterized function - assert_eq!(length::(z), z.len()); + fail_unless_eq!(length::(z), z.len()); } diff --git a/src/test/run-pass/attr-no-drop-flag-size.rs b/src/test/run-pass/attr-no-drop-flag-size.rs index 48768a1c6fd27..ded04f861b696 100644 --- a/src/test/run-pass/attr-no-drop-flag-size.rs +++ b/src/test/run-pass/attr-no-drop-flag-size.rs @@ -21,5 +21,5 @@ impl Drop for Test { } pub fn main() { - assert_eq!(size_of::(), size_of::>()); + fail_unless_eq!(size_of::(), size_of::>()); } diff --git a/src/test/run-pass/auto-loop.rs b/src/test/run-pass/auto-loop.rs index 33aee55b8c738..ef51972252964 100644 --- a/src/test/run-pass/auto-loop.rs +++ b/src/test/run-pass/auto-loop.rs @@ -14,5 +14,5 @@ pub fn main() { for x in xs.iter() { sum += *x; } - assert_eq!(sum, 15); + fail_unless_eq!(sum, 15); } diff --git a/src/test/run-pass/auto-ref-slice-plus-ref.rs b/src/test/run-pass/auto-ref-slice-plus-ref.rs index c22e25e5d95be..66c8609eaf6e1 100644 --- a/src/test/run-pass/auto-ref-slice-plus-ref.rs +++ b/src/test/run-pass/auto-ref-slice-plus-ref.rs @@ -18,11 +18,11 @@ trait MyIter { } impl<'a> MyIter for &'a [int] { - fn test_imm(&self) { assert_eq!(self[0], 1) } + fn test_imm(&self) { fail_unless_eq!(self[0], 1) } } impl<'a> MyIter for &'a str { - fn test_imm(&self) { assert_eq!(*self, "test") } + fn test_imm(&self) { fail_unless_eq!(*self, "test") } } pub fn main() { diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index 8e2b3b56736e2..7d945a4427121 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -22,5 +22,5 @@ pub fn main() { let mut v = ~[1]; v.push_val(2); v.push_val(3); - assert_eq!(v, ~[1, 2, 3]); + fail_unless_eq!(v, ~[1, 2, 3]); } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index c0ceb50a2c4be..51bcab84a23e4 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -13,7 +13,7 @@ fn f(x: ~[T]) -> T { return x[0]; } fn g(act: |~[int]| -> int) -> int { return act(~[1, 2, 3]); } pub fn main() { - assert_eq!(g(f), 1); + fail_unless_eq!(g(f), 1); let f1: |~[~str]| -> ~str = f; - assert_eq!(f1(~[~"x", ~"y", ~"z"]), ~"x"); + fail_unless_eq!(f1(~[~"x", ~"y", ~"z"]), ~"x"); } diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 6f0bba72025f4..84b8351129e14 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -18,5 +18,5 @@ impl double for uint { pub fn main() { let x = ~(~3u as ~double); - assert_eq!(x.double(), 6u); + fail_unless_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index fa124a70627dd..156d42a1e4340 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -24,5 +24,5 @@ impl double for @uint { pub fn main() { let x = @3u; - assert_eq!(x.double(), 6u); + fail_unless_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index a03ac80a3f16b..30f87dafbbdf6 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -18,5 +18,5 @@ impl double for ~uint { pub fn main() { let x = ~~~~~3u; - assert_eq!(x.double(), 6u); + fail_unless_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 7835eaae510d3..b7d522978f6c3 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -18,5 +18,5 @@ impl double for uint { pub fn main() { let x = ~~3u; - assert_eq!(x.double(), 6u); + fail_unless_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 81469e5454a88..d8dea8390f46e 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -18,5 +18,5 @@ impl double for uint { pub fn main() { let x = ~3u; - assert_eq!(x.double(), 6u); + fail_unless_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index bad594bf4e4c7..f2c1a7423718a 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -28,5 +28,5 @@ impl Foo for uint { pub fn main() { let x = @3u; - assert_eq!(x.foo(), ~"@3"); + fail_unless_eq!(x.foo(), ~"@3"); } diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index 9da3a7079df62..765bdcf567bde 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -11,11 +11,11 @@ // except according to those terms. pub fn main() { - assert_eq!(0xffffffffu32, (-1 as u32)); - assert_eq!(4294967295u32, (-1 as u32)); - assert_eq!(0xffffffffffffffffu64, (-1 as u64)); - assert_eq!(18446744073709551615u64, (-1 as u64)); + fail_unless_eq!(0xffffffffu32, (-1 as u32)); + fail_unless_eq!(4294967295u32, (-1 as u32)); + fail_unless_eq!(0xffffffffffffffffu64, (-1 as u64)); + fail_unless_eq!(18446744073709551615u64, (-1 as u64)); - assert_eq!(-2147483648i32 - 1i32, 2147483647i32); - assert_eq!(-9223372036854775808i64 - 1i64, 9223372036854775807i64); + fail_unless_eq!(-2147483648i32 - 1i32, 2147483647i32); + fail_unless_eq!(-9223372036854775808i64 - 1i64, 9223372036854775807i64); } diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index 78edf3e112e98..19426f2cce628 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -12,5 +12,5 @@ pub fn main() { match -1 { -1 => {}, _ => fail!("wat") } - assert_eq!(1-1, 0); + fail_unless_eq!(1-1, 0); } diff --git a/src/test/run-pass/bind-field-short-with-modifiers.rs b/src/test/run-pass/bind-field-short-with-modifiers.rs index 470577d729730..fda3f54bcb281 100644 --- a/src/test/run-pass/bind-field-short-with-modifiers.rs +++ b/src/test/run-pass/bind-field-short-with-modifiers.rs @@ -16,8 +16,8 @@ pub fn main() { } match f { Foo { ref x, ref y } => { - assert_eq!(f.x, 11); - assert_eq!(f.y, 0); + fail_unless_eq!(f.x, 11); + fail_unless_eq!(f.y, 0); } } match f { @@ -26,6 +26,6 @@ pub fn main() { *y = 1; } } - assert_eq!(f.x, 11); - assert_eq!(f.y, 1); + fail_unless_eq!(f.x, 11); + fail_unless_eq!(f.y, 1); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 5ac1f3310315a..f9f47f79bcc33 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -11,7 +11,7 @@ // Binop corner cases fn test_nil() { - assert_eq!((), ()); + fail_unless_eq!((), ()); fail_unless!((!(() != ()))); fail_unless!((!(() < ()))); fail_unless!((() <= ())); @@ -31,19 +31,19 @@ fn test_bool() { fail_unless!((!(false >= true))); // Bools support bitwise binops - assert_eq!(false & false, false); - assert_eq!(true & false, false); - assert_eq!(true & true, true); - assert_eq!(false | false, false); - assert_eq!(true | false, true); - assert_eq!(true | true, true); - assert_eq!(false ^ false, false); - assert_eq!(true ^ false, true); - assert_eq!(true ^ true, false); + fail_unless_eq!(false & false, false); + fail_unless_eq!(true & false, false); + fail_unless_eq!(true & true, true); + fail_unless_eq!(false | false, false); + fail_unless_eq!(true | false, true); + fail_unless_eq!(true | true, true); + fail_unless_eq!(false ^ false, false); + fail_unless_eq!(true ^ false, true); + fail_unless_eq!(true ^ true, false); } fn test_box() { - assert_eq!(@10, @10); + fail_unless_eq!(@10, @10); } fn test_ptr() { @@ -52,7 +52,7 @@ fn test_ptr() { let p2: *u8 = ::std::cast::transmute(0); let p3: *u8 = ::std::cast::transmute(1); - assert_eq!(p1, p2); + fail_unless_eq!(p1, p2); fail_unless!(p1 != p3); fail_unless!(p1 < p3); fail_unless!(p1 <= p3); @@ -85,10 +85,10 @@ fn test_class() { (::std::cast::transmute::<*p, uint>(&q)), (::std::cast::transmute::<*p, uint>(&r))); } - assert_eq!(q, r); + fail_unless_eq!(q, r); r.y = 17; fail_unless!((r.y != q.y)); - assert_eq!(r.y, 17); + fail_unless_eq!(r.y, 17); fail_unless!((q != r)); } diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index 61e36d2d720e7..b687f511dea96 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -12,12 +12,12 @@ #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] fn target() { - assert_eq!(-1000 as uint >> 3u, 536870787u); + fail_unless_eq!(-1000 as uint >> 3u, 536870787u); } #[cfg(target_arch = "x86_64")] fn target() { - assert_eq!(-1000 as uint >> 3u, 2305843009213693827u); + fail_unless_eq!(-1000 as uint >> 3u, 2305843009213693827u); } fn general() { @@ -28,14 +28,14 @@ fn general() { a = a ^ b; info!("{}", a); info!("{}", b); - assert_eq!(b, 1); - assert_eq!(a, 2); - assert_eq!(!0xf0 & 0xff, 0xf); - assert_eq!(0xf0 | 0xf, 0xff); - assert_eq!(0xf << 4, 0xf0); - assert_eq!(0xf0 >> 4, 0xf); - assert_eq!(-16 >> 2, -4); - assert_eq!(0b1010_1010 | 0b0101_0101, 0xff); + fail_unless_eq!(b, 1); + fail_unless_eq!(a, 2); + fail_unless_eq!(!0xf0 & 0xff, 0xf); + fail_unless_eq!(0xf0 | 0xf, 0xff); + fail_unless_eq!(0xf << 4, 0xf0); + fail_unless_eq!(0xf0 >> 4, 0xf); + fail_unless_eq!(-16 >> 2, -4); + fail_unless_eq!(0b1010_1010 | 0b0101_0101, 0xff); } pub fn main() { diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index c149afb87822c..1ae710927045a 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -20,7 +20,7 @@ fn asBlock(f: || -> uint) -> uint { pub fn main() { let x = asSendfn(proc() 22u); - assert_eq!(x, 22u); + fail_unless_eq!(x, 22u); let x = asBlock(|| 22u); - assert_eq!(x, 22u); + fail_unless_eq!(x, 22u); } diff --git a/src/test/run-pass/block-expr-precedence.rs b/src/test/run-pass/block-expr-precedence.rs index ace372dd2d3d9..53c168f282865 100644 --- a/src/test/run-pass/block-expr-precedence.rs +++ b/src/test/run-pass/block-expr-precedence.rs @@ -58,8 +58,8 @@ pub fn main() { let num = 12; - assert_eq!(if (true) { 12 } else { 12 } - num, 0); - assert_eq!(12 - if (true) { 12 } else { 12 }, 0); + fail_unless_eq!(if (true) { 12 } else { 12 } - num, 0); + fail_unless_eq!(12 - if (true) { 12 } else { 12 }, 0); if (true) { 12; } {-num}; if (true) { 12; }; {-num}; if (true) { 12; };;; -num; diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index bbb30e9578e9e..f858a177b076d 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -11,7 +11,7 @@ fn force(f: || -> int) -> int { return f(); } pub fn main() { fn f() -> int { return 7; } - assert_eq!(force(f), 7); + fail_unless_eq!(force(f), 7); let g = {||force(f)}; - assert_eq!(g(), 7); + fail_unless_eq!(g(), 7); } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 4aebcd6aa24c9..e79b4ed7cc804 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -21,5 +21,5 @@ pub fn main() { } }); error!("{:?}", odds); - assert_eq!(odds, 4); + fail_unless_eq!(odds, 4); } diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 2e149f88478c1..8d576eb8c67c2 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -21,5 +21,5 @@ pub fn main() { }); }); error!("{:?}", sum); - assert_eq!(sum, 225); + fail_unless_eq!(sum, 225); } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index 61f58df618aa7..86e8dcfc8e0f5 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -18,7 +18,7 @@ fn test1(x: @~int) { borrow(&*(*x).clone(), |p| { let x_a = &**x as *int; fail_unless!((x_a as uint) != (p as *int as uint)); - assert_eq!(unsafe{*x_a}, *p); + fail_unless_eq!(unsafe{*x_a}, *p); }) } diff --git a/src/test/run-pass/borrowck-closures-two-imm.rs b/src/test/run-pass/borrowck-closures-two-imm.rs index 3bd12b030411e..d57587c287971 100644 --- a/src/test/run-pass/borrowck-closures-two-imm.rs +++ b/src/test/run-pass/borrowck-closures-two-imm.rs @@ -43,7 +43,7 @@ fn c() -> int { } pub fn main() { - assert_eq!(a(), 1280); - assert_eq!(b(), 1024); - assert_eq!(c(), 1280); + fail_unless_eq!(a(), 1280); + fail_unless_eq!(b(), 1024); + fail_unless_eq!(c(), 1280); } diff --git a/src/test/run-pass/borrowck-fixed-length-vecs.rs b/src/test/run-pass/borrowck-fixed-length-vecs.rs index ee561fdb0be52..e134db5edfe3b 100644 --- a/src/test/run-pass/borrowck-fixed-length-vecs.rs +++ b/src/test/run-pass/borrowck-fixed-length-vecs.rs @@ -11,5 +11,5 @@ pub fn main() { let x = [22]; let y = &x[0]; - assert_eq!(*y, 22); + fail_unless_eq!(*y, 22); } diff --git a/src/test/run-pass/borrowck-freeze-frozen-mut.rs b/src/test/run-pass/borrowck-freeze-frozen-mut.rs index 77e1a258dec84..8e447f65b228c 100644 --- a/src/test/run-pass/borrowck-freeze-frozen-mut.rs +++ b/src/test/run-pass/borrowck-freeze-frozen-mut.rs @@ -26,11 +26,11 @@ pub fn main() { let index0 = get(&slice, 0); let index1 = get(&slice, 1); let index2 = get(&slice, 2); - assert_eq!(*index0, 5); - assert_eq!(*index1, 2); - assert_eq!(*index2, 3); + fail_unless_eq!(*index0, 5); + fail_unless_eq!(*index1, 2); + fail_unless_eq!(*index2, 3); } - assert_eq!(data[0], 5); - assert_eq!(data[1], 2); - assert_eq!(data[2], 3); + fail_unless_eq!(data[0], 5); + fail_unless_eq!(data[1], 2); + fail_unless_eq!(data[2], 3); } diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs index 8ceef83094876..4f393de5fd012 100644 --- a/src/test/run-pass/borrowck-move-by-capture-ok.rs +++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs @@ -11,5 +11,5 @@ pub fn main() { let bar = ~3; let h: proc() -> int = proc() *bar; - assert_eq!(h(), 3); + fail_unless_eq!(h(), 3); } diff --git a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs index 1ca94d6a2219e..3050f4c61fbb5 100644 --- a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs +++ b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs @@ -19,5 +19,5 @@ fn has_mut_vec(v: ~[int]) -> int { } pub fn main() { - assert_eq!(has_mut_vec(~[1, 2, 3]), 6); + fail_unless_eq!(has_mut_vec(~[1, 2, 3]), 6); } diff --git a/src/test/run-pass/borrowck-nested-calls.rs b/src/test/run-pass/borrowck-nested-calls.rs index 993b8d506d25e..3b05962fcf525 100644 --- a/src/test/run-pass/borrowck-nested-calls.rs +++ b/src/test/run-pass/borrowck-nested-calls.rs @@ -27,6 +27,6 @@ impl Foo { pub fn main() { let mut f = Foo {a: 22, b: 23}; f.inc_a(f.next_b()); - assert_eq!(f.a, 22+23); - assert_eq!(f.b, 24); + fail_unless_eq!(f.a, 22+23); + fail_unless_eq!(f.b, 24); } diff --git a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs index 4ccbf6b5b0fed..247f370592b78 100644 --- a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs +++ b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs @@ -18,5 +18,5 @@ pub fn main() { } Some(_) => { } } - assert_eq!(x, Some(0)); + fail_unless_eq!(x, Some(0)); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index 815ffffabf24e..7e38432028b30 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -18,7 +18,7 @@ fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; - assert_eq!(before, after); + fail_unless_eq!(before, after); } struct F { f: ~int } @@ -26,12 +26,12 @@ struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow(x.f, |b_x| { - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *int, &(*b_x) as *int); + fail_unless_eq!(*b_x, 3); + fail_unless_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; info!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); + fail_unless_eq!(*b_x, 3); fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs index 0650b03b4853f..d162b3c8c89ba 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs @@ -32,5 +32,5 @@ fn lend(x: @Foo) -> int { } pub fn main() { - assert_eq!(lend(@Foo {f: @Bar {g: 22}}), 22); + fail_unless_eq!(lend(@Foo {f: @Bar {g: 22}}), 22); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 4bbc9d02e40c0..f42e7ef51decc 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -18,7 +18,7 @@ fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; - assert_eq!(before, after); + fail_unless_eq!(before, after); } struct F { f: ~int } @@ -26,12 +26,12 @@ struct F { f: ~int } pub fn main() { let mut x = ~@F{f: ~3}; borrow(x.f, |b_x| { - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *int, &(*b_x) as *int); + fail_unless_eq!(*b_x, 3); + fail_unless_eq!(&(*x.f) as *int, &(*b_x) as *int); *x = @F{f: ~4}; info!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); + fail_unless_eq!(*b_x, 3); fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index 0c6606ea2d647..bd1b5bc171d7b 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -18,18 +18,18 @@ fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; - assert_eq!(before, after); + fail_unless_eq!(before, after); } pub fn main() { let mut x = @3; borrow(x, |b_x| { - assert_eq!(*b_x, 3); - assert_eq!(&(*x) as *int, &(*b_x) as *int); + fail_unless_eq!(*b_x, 3); + fail_unless_eq!(&(*x) as *int, &(*b_x) as *int); x = @22; info!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); + fail_unless_eq!(*b_x, 3); fail_unless!(&(*x) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-cond-box.rs b/src/test/run-pass/borrowck-preserve-cond-box.rs index 57365e98f97e9..3ec53384883de 100644 --- a/src/test/run-pass/borrowck-preserve-cond-box.rs +++ b/src/test/run-pass/borrowck-preserve-cond-box.rs @@ -28,15 +28,15 @@ fn testfn(cond: bool) { } info!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); + fail_unless_eq!(*r, exp); x = @5; y = @6; info!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); - assert_eq!(x, @5); - assert_eq!(y, @6); + fail_unless_eq!(*r, exp); + fail_unless_eq!(x, @5); + fail_unless_eq!(y, @6); } pub fn main() { diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index 6c6a4ebf81478..3a11c794d6e97 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -18,7 +18,7 @@ fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); let after = *x; - assert_eq!(before, after); + fail_unless_eq!(before, after); } struct F { f: ~int } @@ -26,12 +26,12 @@ struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; borrow((*x).f, |b_x| { - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *int, &(*b_x) as *int); + fail_unless_eq!(*b_x, 3); + fail_unless_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; info!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); + fail_unless_eq!(*b_x, 3); fail_unless!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-rvalues-mutable.rs b/src/test/run-pass/borrowck-rvalues-mutable.rs index d4de4ef34d397..73a2b763b3593 100644 --- a/src/test/run-pass/borrowck-rvalues-mutable.rs +++ b/src/test/run-pass/borrowck-rvalues-mutable.rs @@ -35,8 +35,8 @@ impl Counter { pub fn main() { let v = Counter::new(22).get_and_inc(); - assert_eq!(v, 22); + fail_unless_eq!(v, 22); let v = Counter::new(22).inc().inc().get(); - assert_eq!(v, 24);; + fail_unless_eq!(v, 24);; } diff --git a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs index 420ee843766bb..f572cf5f3722f 100644 --- a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs +++ b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs @@ -33,7 +33,7 @@ fn fun1() { a_box.set(22); v = *a_box.get(); a_box.set(v+1); - assert_eq!(23, *a_box.get()); + fail_unless_eq!(23, *a_box.get()); } fn fun2() { @@ -41,7 +41,7 @@ fn fun2() { a_box.set(22); let v = *a_box.get(); a_box.set(v+1); - assert_eq!(23, *a_box.get()); + fail_unless_eq!(23, *a_box.get()); } pub fn main() { diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 97d92f421c148..226be16487907 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -29,5 +29,5 @@ pub fn main() { x.get() * b } }; - assert_eq!(z, 18); + fail_unless_eq!(z, 18); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs index 07a13e5395fc3..60d673882b2bf 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs @@ -12,6 +12,6 @@ pub fn main() { let (&x, &y) = (&3, &'a'); - assert_eq!(x, 3); - assert_eq!(y, 'a'); + fail_unless_eq!(x, 3); + fail_unless_eq!(y, 'a'); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-option.rs b/src/test/run-pass/borrowed-ptr-pattern-option.rs index 9f17b9d7f95b5..c9653163f78a3 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-option.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-option.rs @@ -19,5 +19,5 @@ fn select<'r>(x: &'r Option, y: &'r Option) -> &'r Option { pub fn main() { let x = None; let y = Some(3); - assert_eq!(select(&x, &y).unwrap(), 3); + fail_unless_eq!(select(&x, &y).unwrap(), 3); } diff --git a/src/test/run-pass/borrowed-ptr-pattern.rs b/src/test/run-pass/borrowed-ptr-pattern.rs index 7ccb40c8e7b37..3f5fb441e8de8 100644 --- a/src/test/run-pass/borrowed-ptr-pattern.rs +++ b/src/test/run-pass/borrowed-ptr-pattern.rs @@ -15,6 +15,6 @@ fn foo(x: &T) -> T{ } pub fn main() { - assert_eq!(foo(&3), 3); - assert_eq!(foo(&'a'), 'a'); + fail_unless_eq!(foo(&3), 3); + fail_unless_eq!(foo(&'a'), 'a'); } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index a5ba89271c4eb..1e9da9cded308 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -18,5 +18,5 @@ pub fn main() { let foo: int = 17; let bfoo: Box = Box {c: @foo}; info!("see what's in our box"); - assert_eq!(unbox::(bfoo), foo); + fail_unless_eq!(unbox::(bfoo), foo); } diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index ce4fc64059d52..979b85d3917a2 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -11,9 +11,9 @@ pub fn main() { let mut i = 0; while i < 20 { i += 1; if i == 10 { break; } } - assert_eq!(i, 10); + fail_unless_eq!(i, 10); loop { i += 1; if i == 20 { break; } } - assert_eq!(i, 20); + fail_unless_eq!(i, 20); let xs = [1, 2, 3, 4, 5, 6]; for x in xs.iter() { if *x == 3 { break; } fail_unless!((*x <= 3)); diff --git a/src/test/run-pass/bug-7183-generics.rs b/src/test/run-pass/bug-7183-generics.rs index 3e89ac8bd3864..3238c1ca09a97 100644 --- a/src/test/run-pass/bug-7183-generics.rs +++ b/src/test/run-pass/bug-7183-generics.rs @@ -34,10 +34,10 @@ impl Speak for Option { pub fn main() { - assert_eq!(3.hi(), ~"hello: 3"); - assert_eq!(Some(Some(3)).hi(), ~"something!something!hello: 3"); - assert_eq!(None::.hi(), ~"hello - none"); + fail_unless_eq!(3.hi(), ~"hello: 3"); + fail_unless_eq!(Some(Some(3)).hi(), ~"something!something!hello: 3"); + fail_unless_eq!(None::.hi(), ~"hello - none"); - assert_eq!(Some(None::).hi(), ~"something!hello - none"); - assert_eq!(Some(3).hi(), ~"something!hello: 3"); + fail_unless_eq!(Some(None::).hi(), ~"something!hello - none"); + fail_unless_eq!(Some(3).hi(), ~"something!hello: 3"); } diff --git a/src/test/run-pass/by-value-self-in-mut-slot.rs b/src/test/run-pass/by-value-self-in-mut-slot.rs index aa88004cd1199..e35d02d1a5e15 100644 --- a/src/test/run-pass/by-value-self-in-mut-slot.rs +++ b/src/test/run-pass/by-value-self-in-mut-slot.rs @@ -26,5 +26,5 @@ impl Changer for X { pub fn main() { let x = X { a: 32 }; let new_x = x.change(); - assert_eq!(new_x.a, 55); + fail_unless_eq!(new_x.a, 55); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 390c534eb28c1..c9bdfba615811 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -27,6 +27,6 @@ fn atoll(s: ~str) -> i64 { } pub fn main() { - assert_eq!(atol(~"1024") * 10, atol(~"10240")); + fail_unless_eq!(atol(~"1024") * 10, atol(~"10240")); fail_unless!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); } diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index 16728dffd19b1..ee4a131bd0a0d 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -13,5 +13,5 @@ fn foo() -> int { 22 } pub fn main() { let mut x: ~[extern "Rust" fn() -> int] = ~[]; x.push(foo); - assert_eq!((x[0])(), 22); + fail_unless_eq!((x[0])(), 22); } diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index 2473911483ce8..938546b25a894 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -43,5 +43,5 @@ fn main() { debug!("debug"); info!("info"); }); - assert_eq!(r.read_to_str().unwrap(), ~"info\n"); + fail_unless_eq!(r.read_to_str().unwrap(), ~"info\n"); } diff --git a/src/test/run-pass/cast.rs b/src/test/run-pass/cast.rs index f8a680b2a97ac..cb7b2f17f7a1f 100644 --- a/src/test/run-pass/cast.rs +++ b/src/test/run-pass/cast.rs @@ -10,12 +10,12 @@ pub fn main() { let i: int = 'Q' as int; - assert_eq!(i, 0x51); + fail_unless_eq!(i, 0x51); let u: u32 = i as u32; - assert_eq!(u, 0x51 as u32); - assert_eq!(u, 'Q' as u32); - assert_eq!(i as u8, 'Q' as u8); - assert_eq!(i as u8 as i8, 'Q' as u8 as i8); - assert_eq!(0x51u8 as char, 'Q'); - assert_eq!(0 as u32, false as u32); + fail_unless_eq!(u, 0x51 as u32); + fail_unless_eq!(u, 'Q' as u32); + fail_unless_eq!(i as u8, 'Q' as u8); + fail_unless_eq!(i as u8 as i8, 'Q' as u8 as i8); + fail_unless_eq!(0x51u8 as char, 'Q'); + fail_unless_eq!(0 as u32, false as u32); } diff --git a/src/test/run-pass/cci_borrow.rs b/src/test/run-pass/cci_borrow.rs index cb77c63d4511a..64dedc40b8aa7 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -20,5 +20,5 @@ pub fn main() { let p = @22u; let r = foo(p); info!("r={}", r); - assert_eq!(r, 22u); + fail_unless_eq!(r, 22u); } diff --git a/src/test/run-pass/cci_nested_exe.rs b/src/test/run-pass/cci_nested_exe.rs index 3810f7919ac26..939baef9f9576 100644 --- a/src/test/run-pass/cci_nested_exe.rs +++ b/src/test/run-pass/cci_nested_exe.rs @@ -20,12 +20,12 @@ pub fn main() { let lst = new_int_alist(); alist_add(&lst, 22, ~"hi"); alist_add(&lst, 44, ~"ho"); - assert_eq!(alist_get(&lst, 22), ~"hi"); - assert_eq!(alist_get(&lst, 44), ~"ho"); + fail_unless_eq!(alist_get(&lst, 22), ~"hi"); + fail_unless_eq!(alist_get(&lst, 44), ~"ho"); let lst = new_int_alist_2(); alist_add(&lst, 22, ~"hi"); alist_add(&lst, 44, ~"ho"); - assert_eq!(alist_get(&lst, 22), ~"hi"); - assert_eq!(alist_get(&lst, 44), ~"ho"); + fail_unless_eq!(alist_get(&lst, 22), ~"hi"); + fail_unless_eq!(alist_get(&lst, 44), ~"ho"); } diff --git a/src/test/run-pass/cfgs-on-items.rs b/src/test/run-pass/cfgs-on-items.rs index 72d12b56c5c98..92adbd6d8ccb5 100644 --- a/src/test/run-pass/cfgs-on-items.rs +++ b/src/test/run-pass/cfgs-on-items.rs @@ -26,6 +26,6 @@ fn foo2() -> int { 3 } pub fn main() { - assert_eq!(1, foo1()); - assert_eq!(3, foo2()); + fail_unless_eq!(1, foo1()); + fail_unless_eq!(3, foo2()); } diff --git a/src/test/run-pass/char.rs b/src/test/run-pass/char.rs index f982d3723b4c2..465c89549ae77 100644 --- a/src/test/run-pass/char.rs +++ b/src/test/run-pass/char.rs @@ -13,11 +13,11 @@ pub fn main() { let c: char = 'x'; let d: char = 'x'; - assert_eq!(c, 'x'); - assert_eq!('x', c); - assert_eq!(c, c); - assert_eq!(c, d); - assert_eq!(d, c); - assert_eq!(d, 'x'); - assert_eq!('x', d); + fail_unless_eq!(c, 'x'); + fail_unless_eq!('x', c); + fail_unless_eq!(c, c); + fail_unless_eq!(c, d); + fail_unless_eq!(d, c); + fail_unless_eq!(d, 'x'); + fail_unless_eq!('x', d); } diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 746342ae97345..54877441c3022 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -17,7 +17,7 @@ use cci_class_cast::kitty::cat; fn print_out(thing: ~ToStr, expected: ~str) { let actual = thing.to_str(); info!("{}", actual); - assert_eq!(actual, expected); + fail_unless_eq!(actual, expected); } pub fn main() { diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index 10b0ac375a95d..6cdca3ce3c167 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -97,6 +97,6 @@ pub fn main() { let mut whitefang: dog = dog(); annoy_neighbors(&mut nyan); annoy_neighbors(&mut whitefang); - assert_eq!(nyan.meow_count(), 10u); - assert_eq!(whitefang.volume, 1); + fail_unless_eq!(nyan.meow_count(), 10u); + fail_unless_eq!(whitefang.volume, 1); } diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 016b38826e532..b0a23a888fb74 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -34,5 +34,5 @@ mod kitty { } pub fn main() { - assert_eq!(cat(~"Spreckles").get_name(), ~"Spreckles"); + fail_unless_eq!(cat(~"Spreckles").get_name(), ~"Spreckles"); } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index eef8720ed0291..3e4ec1f258adc 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -117,10 +117,10 @@ pub fn main() { let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan"); for _ in range(1u, 5) { nyan.speak(); } fail_unless!(*nyan.find(&1).unwrap() == ~"nyan"); - assert_eq!(nyan.find(&10), None); + fail_unless_eq!(nyan.find(&10), None); let mut spotty: cat = cat::new(2, 57, tuxedo); for _ in range(0u, 6) { spotty.speak(); } - assert_eq!(spotty.len(), 8); + fail_unless_eq!(spotty.len(), 8); fail_unless!((spotty.contains_key(&2))); - assert_eq!(spotty.get(&3), &tuxedo); + fail_unless_eq!(spotty.get(&3), &tuxedo); } diff --git a/src/test/run-pass/class-method-cross-crate.rs b/src/test/run-pass/class-method-cross-crate.rs index 8ee367d281f2c..76590e5ebd351 100644 --- a/src/test/run-pass/class-method-cross-crate.rs +++ b/src/test/run-pass/class-method-cross-crate.rs @@ -16,7 +16,7 @@ use cci_class_2::kitties::cat; pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(); } diff --git a/src/test/run-pass/class-methods-cross-crate.rs b/src/test/run-pass/class-methods-cross-crate.rs index ca3b491844f12..5fd9bfec596c9 100644 --- a/src/test/run-pass/class-methods-cross-crate.rs +++ b/src/test/run-pass/class-methods-cross-crate.rs @@ -16,8 +16,8 @@ use cci_class_3::kitties::cat; pub fn main() { let mut nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(); - assert_eq!(nyan.meow_count(), 53u); + fail_unless_eq!(nyan.meow_count(), 53u); } diff --git a/src/test/run-pass/class-methods.rs b/src/test/run-pass/class-methods.rs index 25a2009bb9a6c..578e96db35b47 100644 --- a/src/test/run-pass/class-methods.rs +++ b/src/test/run-pass/class-methods.rs @@ -29,8 +29,8 @@ fn cat(in_x: uint, in_y: int) -> cat { pub fn main() { let mut nyan: cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(); - assert_eq!(nyan.meow_count(), 53u); + fail_unless_eq!(nyan.meow_count(), 53u); } diff --git a/src/test/run-pass/class-poly-methods-cross-crate.rs b/src/test/run-pass/class-poly-methods-cross-crate.rs index 671d7a403531b..cef5df25d131a 100644 --- a/src/test/run-pass/class-poly-methods-cross-crate.rs +++ b/src/test/run-pass/class-poly-methods-cross-crate.rs @@ -16,10 +16,10 @@ use cci_class_6::kitties::cat; pub fn main() { let mut nyan : cat = cat::(52u, 99, ~['p']); let mut kitty = cat(1000u, 2, ~[~"tabby"]); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(~[1u,2u,3u]); - assert_eq!(nyan.meow_count(), 55u); + fail_unless_eq!(nyan.meow_count(), 55u); kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); - assert_eq!(kitty.meow_count(), 1004u); + fail_unless_eq!(kitty.meow_count(), 1004u); } diff --git a/src/test/run-pass/class-poly-methods.rs b/src/test/run-pass/class-poly-methods.rs index f4d3a115ef136..d328ff70a86c9 100644 --- a/src/test/run-pass/class-poly-methods.rs +++ b/src/test/run-pass/class-poly-methods.rs @@ -33,10 +33,10 @@ fn cat(in_x : uint, in_y : int, in_info: ~[U]) -> cat { pub fn main() { let mut nyan : cat = cat::(52u, 99, ~[9]); let mut kitty = cat(1000u, 2, ~[~"tabby"]); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(~[1,2,3]); - assert_eq!(nyan.meow_count(), 55u); + fail_unless_eq!(nyan.meow_count(), 55u); kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); - assert_eq!(kitty.meow_count(), 1004u); + fail_unless_eq!(kitty.meow_count(), 1004u); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index e813210f4f4e3..0edc9173c3671 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -59,7 +59,7 @@ impl ToStr for cat { fn print_out(thing: ~ToStr, expected: ~str) { let actual = thing.to_str(); info!("{}", actual); - assert_eq!(actual, expected); + fail_unless_eq!(actual, expected); } pub fn main() { diff --git a/src/test/run-pass/classes-simple-cross-crate.rs b/src/test/run-pass/classes-simple-cross-crate.rs index 6d816e725b9b9..f88ccb26a609a 100644 --- a/src/test/run-pass/classes-simple-cross-crate.rs +++ b/src/test/run-pass/classes-simple-cross-crate.rs @@ -16,6 +16,6 @@ use cci_class::kitties::cat; pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); } diff --git a/src/test/run-pass/classes-simple-method.rs b/src/test/run-pass/classes-simple-method.rs index 6f21afff12000..0864420c8a4d6 100644 --- a/src/test/run-pass/classes-simple-method.rs +++ b/src/test/run-pass/classes-simple-method.rs @@ -28,7 +28,7 @@ fn cat(in_x : uint, in_y : int) -> cat { pub fn main() { let mut nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); nyan.speak(); } diff --git a/src/test/run-pass/classes-simple.rs b/src/test/run-pass/classes-simple.rs index 496efc2172e48..11a5b5b708e7a 100644 --- a/src/test/run-pass/classes-simple.rs +++ b/src/test/run-pass/classes-simple.rs @@ -24,6 +24,6 @@ fn cat(in_x : uint, in_y : int) -> cat { pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); + fail_unless_eq!(nyan.how_hungry, 99); + fail_unless_eq!(kitty.how_hungry, 2); } diff --git a/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs b/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs index 1ae907065bfac..b804fa87c9a52 100644 --- a/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs +++ b/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs @@ -37,7 +37,7 @@ pub fn main() { // `drop` 6 times. while borrow().do_stuff() { i += 1; - unsafe { assert_eq!(DROPPED, i) } + unsafe { fail_unless_eq!(DROPPED, i) } if i > 5 { break; } @@ -46,6 +46,6 @@ pub fn main() { // This if condition should // call it 1 time if borrow().do_stuff() { - unsafe { assert_eq!(DROPPED, i + 1) } + unsafe { fail_unless_eq!(DROPPED, i + 1) } } } diff --git a/src/test/run-pass/cleanup-rvalue-for-scope.rs b/src/test/run-pass/cleanup-rvalue-for-scope.rs index 68441a2d89462..054a51b081703 100644 --- a/src/test/run-pass/cleanup-rvalue-for-scope.rs +++ b/src/test/run-pass/cleanup-rvalue-for-scope.rs @@ -37,7 +37,7 @@ fn check_flags(exp: u64) { let x = FLAGS; FLAGS = 0; println!("flags {}, expected {}", x, exp); - assert_eq!(x, exp); + fail_unless_eq!(x, exp); } } diff --git a/src/test/run-pass/cleanup-rvalue-scopes.rs b/src/test/run-pass/cleanup-rvalue-scopes.rs index 7ed59ec74b4d9..a311d507f12e0 100644 --- a/src/test/run-pass/cleanup-rvalue-scopes.rs +++ b/src/test/run-pass/cleanup-rvalue-scopes.rs @@ -38,7 +38,7 @@ fn check_flags(exp: u64) { let x = FLAGS; FLAGS = 0; println!("flags {}, expected {}", x, exp); - assert_eq!(x, exp); + fail_unless_eq!(x, exp); } } diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 091cebcc0633b..5d6da19ca9d28 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -20,8 +20,8 @@ pub fn main() { let z = ~Pair { a : 10, b : 12}; let f: proc() = proc() { - assert_eq!(z.a, 10); - assert_eq!(z.b, 12); + fail_unless_eq!(z.a, 10); + fail_unless_eq!(z.b, 12); }; spawn(f); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 6ba665e4005f5..a3d3b979cd82f 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -41,6 +41,6 @@ fn f(a: A, b: u16) -> ~Invokable: { pub fn main() { let (a, b) = f(22_u64, 44u16).f(); info!("a={:?} b={:?}", a, b); - assert_eq!(a, 22u64); - assert_eq!(b, 44u16); + fail_unless_eq!(a, 22u64); + fail_unless_eq!(b, 44u16); } diff --git a/src/test/run-pass/closure-inference.rs b/src/test/run-pass/closure-inference.rs index 4b74ed3d4a72d..f95059b422ce6 100644 --- a/src/test/run-pass/closure-inference.rs +++ b/src/test/run-pass/closure-inference.rs @@ -16,5 +16,5 @@ fn apply(f: |A| -> A, v: A) -> A { f(v) } pub fn main() { let f = {|i| foo(i)}; - assert_eq!(apply(f, 2), 3); + fail_unless_eq!(apply(f, 2), 3); } diff --git a/src/test/run-pass/closure-inference2.rs b/src/test/run-pass/closure-inference2.rs index fa16ea001452c..22cece30c8734 100644 --- a/src/test/run-pass/closure-inference2.rs +++ b/src/test/run-pass/closure-inference2.rs @@ -12,6 +12,6 @@ pub fn main() { let f = {|i| i}; - assert_eq!(f(2), 2); - assert_eq!(f(5), 5); + fail_unless_eq!(f(2), 2); + fail_unless_eq!(f(5), 5); } diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs index 419df84bdf55b..b8f84b536f755 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs @@ -22,5 +22,5 @@ fn foo(speaker: &SpeechMaker) -> uint { pub fn main() { let lincoln = SpeechMaker {speeches: 22}; - assert_eq!(foo(&lincoln), 55); + fail_unless_eq!(foo(&lincoln), 55); } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index dee2b6f2568d7..8ee71a474f6c0 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -18,6 +18,6 @@ fn bip(v: &[uint]) -> ~[uint] { pub fn main() { let mut the_vec = ~[1u, 2, 3, 100]; - assert_eq!(the_vec.clone(), bar(the_vec)); - assert_eq!(the_vec.clone(), bip(the_vec)); + fail_unless_eq!(the_vec.clone(), bar(the_vec)); + fail_unless_eq!(the_vec.clone(), bip(the_vec)); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs index 0e205617173cb..c88d31fa3af4e 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -21,5 +21,5 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; bar(the_vec); - assert_eq!(the_vec, ~[100, 3, 2, 1]); + fail_unless_eq!(the_vec, ~[100, 3, 2, 1]); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs index 3deb31efd311d..cd33ac65851da 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs @@ -17,5 +17,5 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; bar(the_vec); - assert_eq!(the_vec, ~[100, 3, 2, 1]); + fail_unless_eq!(the_vec, ~[100, 3, 2, 1]); } diff --git a/src/test/run-pass/coerce-to-closure-and-proc.rs b/src/test/run-pass/coerce-to-closure-and-proc.rs index 6f643ca0f4101..99d2348a45666 100644 --- a/src/test/run-pass/coerce-to-closure-and-proc.rs +++ b/src/test/run-pass/coerce-to-closure-and-proc.rs @@ -22,26 +22,26 @@ enum Bar { pub fn main() { let f: |int| -> int = id; - assert_eq!(f(5), 5); + fail_unless_eq!(f(5), 5); let f: proc(int) -> int = id; - assert_eq!(f(5), 5); + fail_unless_eq!(f(5), 5); let f: |int| -> Foo = Foo; - assert_eq!(f(5), Foo(5)); + fail_unless_eq!(f(5), Foo(5)); let f: proc(int) -> Foo = Foo; - assert_eq!(f(5), Foo(5)); + fail_unless_eq!(f(5), Foo(5)); let f: |int| -> Bar = Bar; - assert_eq!(f(5), Bar(5)); + fail_unless_eq!(f(5), Bar(5)); let f: proc(int) -> Bar = Bar; - assert_eq!(f(5), Bar(5)); + fail_unless_eq!(f(5), Bar(5)); let f: |int| -> Option = Some; - assert_eq!(f(5), Some(5)); + fail_unless_eq!(f(5), Some(5)); let f: proc(int) -> Option = Some; - assert_eq!(f(5), Some(5)); + fail_unless_eq!(f(5), Some(5)); } diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 25e31f0b548b5..ee840add565eb 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -16,7 +16,7 @@ pub fn main() { let y = p.recv(); error!("received"); error!("{:?}", y); - assert_eq!(y, 10); + fail_unless_eq!(y, 10); } fn child(c: &Chan) { diff --git a/src/test/run-pass/concat.rs b/src/test/run-pass/concat.rs index bcf1c4c63f593..f1b41797dca55 100644 --- a/src/test/run-pass/concat.rs +++ b/src/test/run-pass/concat.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - assert_eq!(format!(concat!("foo", "bar", "{}"), "baz"), ~"foobarbaz"); - assert_eq!(format!(concat!()), ~""); + fail_unless_eq!(format!(concat!("foo", "bar", "{}"), "baz"), ~"foobarbaz"); + fail_unless_eq!(format!(concat!()), ~""); - assert_eq!( + fail_unless_eq!( concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()), "12344.0atrue" ); diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index c424127536a8e..8a8148eb0bd87 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -102,7 +102,7 @@ fn test_in_fn_ctxt() { #[cfg(bogus)] static i: int = 0; static i: int = 1; - assert_eq!(i, 1); + fail_unless_eq!(i, 1); } mod test_foreign_items { diff --git a/src/test/run-pass/const-autoderef.rs b/src/test/run-pass/const-autoderef.rs index e80ed7c984b4a..aea5bfae52c84 100644 --- a/src/test/run-pass/const-autoderef.rs +++ b/src/test/run-pass/const-autoderef.rs @@ -14,6 +14,6 @@ static C: &'static &'static &'static &'static [u8, ..1] = & & & &A; static D: u8 = (&C)[0]; pub fn main() { - assert_eq!(B, A[0]); - assert_eq!(D, A[0]); + fail_unless_eq!(B, A[0]); + fail_unless_eq!(D, A[0]); } diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index b533da032d38e..2d55c227b8ccd 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -27,8 +27,8 @@ pub fn main() { } match Z { Quux(d,h) => { - assert_eq!(d, 0x123456789abcdef0); - assert_eq!(h, 0x1234); + fail_unless_eq!(d, 0x123456789abcdef0); + fail_unless_eq!(h, 0x1234); } _ => fail!() } diff --git a/src/test/run-pass/const-binops.rs b/src/test/run-pass/const-binops.rs index 010a9a0d83473..81646869c27b4 100644 --- a/src/test/run-pass/const-binops.rs +++ b/src/test/run-pass/const-binops.rs @@ -77,60 +77,60 @@ static AN: bool = 2 > -2; static AO: bool = 1.0 > -2.0; pub fn main() { - assert_eq!(A, -1); - assert_eq!(A2, 6); + fail_unless_eq!(A, -1); + fail_unless_eq!(A2, 6); assert_approx_eq!(B, 5.7); - assert_eq!(C, -1); - assert_eq!(D, 0); + fail_unless_eq!(C, -1); + fail_unless_eq!(D, 0); assert_approx_eq!(E, 0.3); - assert_eq!(E2, -9); - assert_eq!(F, 9); + fail_unless_eq!(E2, -9); + fail_unless_eq!(F, 9); assert_approx_eq!(G, 10.89); - assert_eq!(H, -3); - assert_eq!(I, 1); + fail_unless_eq!(H, -3); + fail_unless_eq!(I, 1); assert_approx_eq!(J, 1.0); - assert_eq!(N, false); + fail_unless_eq!(N, false); - assert_eq!(O, true); + fail_unless_eq!(O, true); - assert_eq!(P, 1); - assert_eq!(Q, 1); + fail_unless_eq!(P, 1); + fail_unless_eq!(Q, 1); - assert_eq!(R, 3); - assert_eq!(S, 3); + fail_unless_eq!(R, 3); + fail_unless_eq!(S, 3); - assert_eq!(T, 2); - assert_eq!(U, 2); + fail_unless_eq!(T, 2); + fail_unless_eq!(U, 2); - assert_eq!(V, 8); + fail_unless_eq!(V, 8); - assert_eq!(W, 64); - assert_eq!(X, 64); + fail_unless_eq!(W, 64); + fail_unless_eq!(X, 64); - assert_eq!(Y, true); - assert_eq!(Z, true); + fail_unless_eq!(Y, true); + fail_unless_eq!(Z, true); - assert_eq!(AA, true); - assert_eq!(AB, true); - assert_eq!(AC, true); + fail_unless_eq!(AA, true); + fail_unless_eq!(AB, true); + fail_unless_eq!(AC, true); - assert_eq!(AD, true); - assert_eq!(AE, true); - assert_eq!(AF, true); + fail_unless_eq!(AD, true); + fail_unless_eq!(AE, true); + fail_unless_eq!(AF, true); - assert_eq!(AG, true); - assert_eq!(AH, true); - assert_eq!(AI, true); + fail_unless_eq!(AG, true); + fail_unless_eq!(AH, true); + fail_unless_eq!(AI, true); - assert_eq!(AJ, true); - assert_eq!(AK, true); - assert_eq!(AL, true); + fail_unless_eq!(AJ, true); + fail_unless_eq!(AK, true); + fail_unless_eq!(AL, true); - assert_eq!(AM, true); - assert_eq!(AN, true); - assert_eq!(AO, true); + fail_unless_eq!(AM, true); + fail_unless_eq!(AN, true); + fail_unless_eq!(AO, true); } diff --git a/src/test/run-pass/const-cast-ptr-int.rs b/src/test/run-pass/const-cast-ptr-int.rs index 88ab70f596adf..0c77a0291d90a 100644 --- a/src/test/run-pass/const-cast-ptr-int.rs +++ b/src/test/run-pass/const-cast-ptr-int.rs @@ -13,5 +13,5 @@ use std::ptr; static a: *u8 = 0 as *u8; pub fn main() { - assert_eq!(a, ptr::null()); + fail_unless_eq!(a, ptr::null()); } diff --git a/src/test/run-pass/const-cast.rs b/src/test/run-pass/const-cast.rs index d511930c70fa7..4e44a3adfff0f 100644 --- a/src/test/run-pass/const-cast.rs +++ b/src/test/run-pass/const-cast.rs @@ -18,6 +18,6 @@ static a: &'static int = &10; static b: *int = a as *int; pub fn main() { - assert_eq!(x as *libc::c_void, y); - assert_eq!(a as *int, b); + fail_unless_eq!(x as *libc::c_void, y); + fail_unless_eq!(a as *int, b); } diff --git a/src/test/run-pass/const-const.rs b/src/test/run-pass/const-const.rs index bdb2b3d211043..9a96fb533f0a6 100644 --- a/src/test/run-pass/const-const.rs +++ b/src/test/run-pass/const-const.rs @@ -12,5 +12,5 @@ static a: int = 1; static b: int = a + 2; pub fn main() { - assert_eq!(b, 3); + fail_unless_eq!(b, 3); } diff --git a/src/test/run-pass/const-contents.rs b/src/test/run-pass/const-contents.rs index 616826f9f9502..d8ce6f80c9959 100644 --- a/src/test/run-pass/const-contents.rs +++ b/src/test/run-pass/const-contents.rs @@ -18,10 +18,10 @@ static notb : bool = !true; static neg : int = -(1); pub fn main() { - assert_eq!(lsl, 4); - assert_eq!(add, 3); - assert_eq!(addf, 3.0); - assert_eq!(not, -1); - assert_eq!(notb, false); - assert_eq!(neg, -1); + fail_unless_eq!(lsl, 4); + fail_unless_eq!(add, 3); + fail_unless_eq!(addf, 3.0); + fail_unless_eq!(not, -1); + fail_unless_eq!(notb, false); + fail_unless_eq!(neg, -1); } diff --git a/src/test/run-pass/const-cross-crate-const.rs b/src/test/run-pass/const-cross-crate-const.rs index c8dc98baac6be..7a340a47debdf 100644 --- a/src/test/run-pass/const-cross-crate-const.rs +++ b/src/test/run-pass/const-cross-crate-const.rs @@ -17,9 +17,9 @@ static a: uint = cci_const::uint_val; static b: uint = cci_const::uint_expr + 5; pub fn main() { - assert_eq!(a, 12); + fail_unless_eq!(a, 12); let foo2 = a; - assert_eq!(foo2, cci_const::uint_val); - assert_eq!(b, cci_const::uint_expr + 5); - assert_eq!(foo, cci_const::foopy); + fail_unless_eq!(foo2, cci_const::uint_val); + fail_unless_eq!(b, cci_const::uint_expr + 5); + fail_unless_eq!(foo, cci_const::foopy); } diff --git a/src/test/run-pass/const-cross-crate-extern.rs b/src/test/run-pass/const-cross-crate-extern.rs index 75a0bac0293ca..2c3b4b6d5b582 100644 --- a/src/test/run-pass/const-cross-crate-extern.rs +++ b/src/test/run-pass/const-cross-crate-extern.rs @@ -16,5 +16,5 @@ use cci_const::bar; static foo: extern "C" fn() = bar; pub fn main() { - assert_eq!(foo, bar); + fail_unless_eq!(foo, bar); } diff --git a/src/test/run-pass/const-deref.rs b/src/test/run-pass/const-deref.rs index 7c2771c3544f7..af983ace2c338 100644 --- a/src/test/run-pass/const-deref.rs +++ b/src/test/run-pass/const-deref.rs @@ -12,5 +12,5 @@ static C: &'static int = &1000; static D: int = *C; pub fn main() { - assert_eq!(D, 1000); + fail_unless_eq!(D, 1000); } diff --git a/src/test/run-pass/const-enum-cast.rs b/src/test/run-pass/const-enum-cast.rs index 75e942cb767c8..d1c49b14861fd 100644 --- a/src/test/run-pass/const-enum-cast.rs +++ b/src/test/run-pass/const-enum-cast.rs @@ -20,12 +20,12 @@ pub fn main () { let a2 = B2 as int; let a3 = A2 as f64; let a4 = B2 as f64; - assert_eq!(c1, 1); - assert_eq!(c2, 2); - assert_eq!(c3, 1.0); - assert_eq!(c4, 2.0); - assert_eq!(a1, 1); - assert_eq!(a2, 2); - assert_eq!(a3, 1.0); - assert_eq!(a4, 2.0); + fail_unless_eq!(c1, 1); + fail_unless_eq!(c2, 2); + fail_unless_eq!(c3, 1.0); + fail_unless_eq!(c4, 2.0); + fail_unless_eq!(a1, 1); + fail_unless_eq!(a2, 2); + fail_unless_eq!(a3, 1.0); + fail_unless_eq!(a4, 2.0); } diff --git a/src/test/run-pass/const-enum-struct.rs b/src/test/run-pass/const-enum-struct.rs index 2f430a03fabd5..831dca25657d3 100644 --- a/src/test/run-pass/const-enum-struct.rs +++ b/src/test/run-pass/const-enum-struct.rs @@ -15,5 +15,5 @@ static C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-struct2.rs b/src/test/run-pass/const-enum-struct2.rs index 36572a7f50735..ec6e7e265e93a 100644 --- a/src/test/run-pass/const-enum-struct2.rs +++ b/src/test/run-pass/const-enum-struct2.rs @@ -15,5 +15,5 @@ static C: S = S { a: V0, b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuple.rs b/src/test/run-pass/const-enum-tuple.rs index 5ef8691cad16c..02cad661de5b4 100644 --- a/src/test/run-pass/const-enum-tuple.rs +++ b/src/test/run-pass/const-enum-tuple.rs @@ -14,5 +14,5 @@ static C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuple2.rs b/src/test/run-pass/const-enum-tuple2.rs index 6fb713daf9a2d..3d6c3fff7d451 100644 --- a/src/test/run-pass/const-enum-tuple2.rs +++ b/src/test/run-pass/const-enum-tuple2.rs @@ -14,5 +14,5 @@ static C: (E, u16, u16) = (V0, 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct.rs b/src/test/run-pass/const-enum-tuplestruct.rs index a168c4a7caf2d..7b97f9c4f6132 100644 --- a/src/test/run-pass/const-enum-tuplestruct.rs +++ b/src/test/run-pass/const-enum-tuplestruct.rs @@ -15,5 +15,5 @@ static C: S = S(V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct2.rs b/src/test/run-pass/const-enum-tuplestruct2.rs index 7ad5feb269bac..248f7ba0c69ff 100644 --- a/src/test/run-pass/const-enum-tuplestruct2.rs +++ b/src/test/run-pass/const-enum-tuplestruct2.rs @@ -15,5 +15,5 @@ static C: S = S(V0, 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; fail_unless!(n != 0xBAD); - assert_eq!(n, 0x600D); + fail_unless_eq!(n, 0x600D); } diff --git a/src/test/run-pass/const-extern-function.rs b/src/test/run-pass/const-extern-function.rs index 501a87955da57..b0d04bf8a17f9 100644 --- a/src/test/run-pass/const-extern-function.rs +++ b/src/test/run-pass/const-extern-function.rs @@ -18,6 +18,6 @@ struct S { } pub fn main() { - assert_eq!(foopy, f); - assert_eq!(f, s.f); + fail_unless_eq!(foopy, f); + fail_unless_eq!(f, s.f); } diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index e99b0ed185b39..2486f8385af15 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -28,7 +28,7 @@ pub fn main() { println!("{:?}", p); println!("{:?}", q); println!("{:?}", t); - assert_eq!(p, 3); - assert_eq!(q, 3); - assert_eq!(t, 20); + fail_unless_eq!(p, 3); + fail_unless_eq!(q, 3); + fail_unless_eq!(t, 20); } diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index 0ad8dfc277cbb..68c5768dca5c1 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -17,5 +17,5 @@ struct Bar<'a> { f: 'a || -> int } static b : Bar<'static> = Bar { f: foo }; pub fn main() { - assert_eq!((b.f)(), 0xca7f000d); + fail_unless_eq!((b.f)(), 0xca7f000d); } diff --git a/src/test/run-pass/const-negative.rs b/src/test/run-pass/const-negative.rs index 4e2be013c11e4..c52011c1e8d0c 100644 --- a/src/test/run-pass/const-negative.rs +++ b/src/test/run-pass/const-negative.rs @@ -13,5 +13,5 @@ static toplevel_mod: int = -1; pub fn main() { - assert_eq!(toplevel_mod, -1); + fail_unless_eq!(toplevel_mod, -1); } diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index 30fbe38aed033..f2fd779ade6fc 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -15,8 +15,8 @@ enum Foo { static X: Foo = Bar; pub fn main() { - assert_eq!((X as uint), 0xDEADBEE); - assert_eq!((Y as uint), 0xDEADBEE); + fail_unless_eq!((X as uint), 0xDEADBEE); + fail_unless_eq!((Y as uint), 0xDEADBEE); } static Y: Foo = Bar; diff --git a/src/test/run-pass/const-rec-and-tup.rs b/src/test/run-pass/const-rec-and-tup.rs index e6680fe3e8fdb..5ee91b27f80a3 100644 --- a/src/test/run-pass/const-rec-and-tup.rs +++ b/src/test/run-pass/const-rec-and-tup.rs @@ -20,6 +20,6 @@ static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, pub fn main() { let (p, _) = y.x; - assert_eq!(p, - 1085102592571150096); + fail_unless_eq!(p, - 1085102592571150096); println!("{:#x}", p); } diff --git a/src/test/run-pass/const-region-ptrs-noncopy.rs b/src/test/run-pass/const-region-ptrs-noncopy.rs index 87363c0e55e86..ad2613fb6493d 100644 --- a/src/test/run-pass/const-region-ptrs-noncopy.rs +++ b/src/test/run-pass/const-region-ptrs-noncopy.rs @@ -14,5 +14,5 @@ static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { - assert_eq!(x as *Big, y.b as *Big); + fail_unless_eq!(x as *Big, y.b as *Big); } diff --git a/src/test/run-pass/const-region-ptrs.rs b/src/test/run-pass/const-region-ptrs.rs index 1d7ba0ed6c71e..618e6ddf3fb7a 100644 --- a/src/test/run-pass/const-region-ptrs.rs +++ b/src/test/run-pass/const-region-ptrs.rs @@ -17,6 +17,6 @@ static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { println!("x = {}", *x); println!("y = \\{a: {}, b: {}\\}", y.a, *(y.b)); - assert_eq!(*x, 10); - assert_eq!(*(y.b), 10); + fail_unless_eq!(*x, 10); + fail_unless_eq!(*(y.b), 10); } diff --git a/src/test/run-pass/const-str-ptr.rs b/src/test/run-pass/const-str-ptr.rs index 025cc28bb686a..57e7fb75ab6ac 100644 --- a/src/test/run-pass/const-str-ptr.rs +++ b/src/test/run-pass/const-str-ptr.rs @@ -17,13 +17,13 @@ static C: *u8 = B as *u8; pub fn main() { unsafe { let foo = &A as *u8; - assert_eq!(str::raw::from_utf8(A), "hi"); - assert_eq!(str::raw::from_buf_len(foo, A.len()), ~"hi"); - assert_eq!(str::raw::from_buf_len(C, B.len()), ~"hi"); + fail_unless_eq!(str::raw::from_utf8(A), "hi"); + fail_unless_eq!(str::raw::from_buf_len(foo, A.len()), ~"hi"); + fail_unless_eq!(str::raw::from_buf_len(C, B.len()), ~"hi"); fail_unless!(*C == A[0]); fail_unless!(*(&B[0] as *u8) == A[0]); let bar = str::raw::from_utf8(A).to_c_str(); - assert_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), ~"hi"); + fail_unless_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), ~"hi"); } } diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index af6dd4029f500..b24159a030785 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -27,11 +27,11 @@ static z : &'static foo = &foo { a: 10, b: 22, c: 12 }; static w : foo = foo { a:5, ..x }; pub fn main() { - assert_eq!(x.b, 2); - assert_eq!(x, y); - assert_eq!(z.b, 22); - assert_eq!(w.a, 5); - assert_eq!(w.c, 3); + fail_unless_eq!(x.b, 2); + fail_unless_eq!(x, y); + fail_unless_eq!(z.b, 22); + fail_unless_eq!(w.a, 5); + fail_unless_eq!(w.c, 3); println!("{:#x}", x.b); println!("{:#x}", z.c); } diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index 54116dd4082ed..4fd108fba11ef 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -15,8 +15,8 @@ static X: Bar = Bar(1, 2); pub fn main() { match X { Bar(x, y) => { - assert_eq!(x, 1); - assert_eq!(y, 2); + fail_unless_eq!(x, 1); + fail_unless_eq!(y, 2); } } } diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 3935bb241c751..ac61522ffbe6f 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -14,7 +14,7 @@ static y : &'static [int] = &[1,2,3,4]; pub fn main() { println!("{:?}", x[1]); println!("{:?}", y[1]); - assert_eq!(x[1], 2); - assert_eq!(x[3], 4); - assert_eq!(x[3], y[3]); + fail_unless_eq!(x[1], 2); + fail_unless_eq!(x[3], 4); + fail_unless_eq!(x[3], y[3]); } diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index 788c30562c182..5f6771314f327 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -18,5 +18,5 @@ pub fn main() { BAR => 2, _ => 3 }; - assert_eq!(y, 2); + fail_unless_eq!(y, 2); } diff --git a/src/test/run-pass/crateresolve1.rs b/src/test/run-pass/crateresolve1.rs index bf13e66690cd1..f9f047d5bd928 100644 --- a/src/test/run-pass/crateresolve1.rs +++ b/src/test/run-pass/crateresolve1.rs @@ -16,5 +16,5 @@ extern crate crateresolve1 = "crateresolve1#0.2"; pub fn main() { - assert_eq!(crateresolve1::f(), 20); + fail_unless_eq!(crateresolve1::f(), 20); } diff --git a/src/test/run-pass/crateresolve8.rs b/src/test/run-pass/crateresolve8.rs index 46ccb01f66048..8f8f202830223 100644 --- a/src/test/run-pass/crateresolve8.rs +++ b/src/test/run-pass/crateresolve8.rs @@ -17,5 +17,5 @@ extern crate crateresolve8 = "crateresolve8#0.1"; //extern crate crateresolve8(vers = "0.1"); pub fn main() { - assert_eq!(crateresolve8::f(), 20); + fail_unless_eq!(crateresolve8::f(), 20); } diff --git a/src/test/run-pass/cross-crate-newtype-struct-pat.rs b/src/test/run-pass/cross-crate-newtype-struct-pat.rs index 8988ee52b1649..df3145ea320dd 100644 --- a/src/test/run-pass/cross-crate-newtype-struct-pat.rs +++ b/src/test/run-pass/cross-crate-newtype-struct-pat.rs @@ -16,6 +16,6 @@ extern crate newtype_struct_xc; pub fn main() { let x = newtype_struct_xc::Au(21); match x { - newtype_struct_xc::Au(n) => assert_eq!(n, 21) + newtype_struct_xc::Au(n) => fail_unless_eq!(n, 21) } } diff --git a/src/test/run-pass/default-method-supertrait-vtable.rs b/src/test/run-pass/default-method-supertrait-vtable.rs index 2bcf264bb1f14..50d192ab97c25 100644 --- a/src/test/run-pass/default-method-supertrait-vtable.rs +++ b/src/test/run-pass/default-method-supertrait-vtable.rs @@ -32,5 +32,5 @@ impl Y for int { impl Z for int {} pub fn main() { - assert_eq!(12.x(), 12); + fail_unless_eq!(12.x(), 12); } diff --git a/src/test/run-pass/deriving-cmp-generic-enum.rs b/src/test/run-pass/deriving-cmp-generic-enum.rs index 094d17c100ebd..3c85d837322e1 100644 --- a/src/test/run-pass/deriving-cmp-generic-enum.rs +++ b/src/test/run-pass/deriving-cmp-generic-enum.rs @@ -36,21 +36,21 @@ pub fn main() { let ge = i >= j; // Eq - assert_eq!(*e1 == *e2, eq); - assert_eq!(*e1 != *e2, !eq); + fail_unless_eq!(*e1 == *e2, eq); + fail_unless_eq!(*e1 != *e2, !eq); // TotalEq - assert_eq!(e1.equals(e2), eq); + fail_unless_eq!(e1.equals(e2), eq); // Ord - assert_eq!(*e1 < *e2, lt); - assert_eq!(*e1 > *e2, gt); + fail_unless_eq!(*e1 < *e2, lt); + fail_unless_eq!(*e1 > *e2, gt); - assert_eq!(*e1 <= *e2, le); - assert_eq!(*e1 >= *e2, ge); + fail_unless_eq!(*e1 <= *e2, le); + fail_unless_eq!(*e1 >= *e2, ge); // TotalOrd - assert_eq!(e1.cmp(e2), ord); + fail_unless_eq!(e1.cmp(e2), ord); } } } diff --git a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs index aedf4732afdbb..c2c84a67ef227 100644 --- a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs +++ b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs @@ -32,21 +32,21 @@ pub fn main() { let (gt, ge) = (i > j, i >= j); // Eq - assert_eq!(*es1 == *es2, eq); - assert_eq!(*es1 != *es2, !eq); + fail_unless_eq!(*es1 == *es2, eq); + fail_unless_eq!(*es1 != *es2, !eq); // TotalEq - assert_eq!(es1.equals(es2), eq); + fail_unless_eq!(es1.equals(es2), eq); // Ord - assert_eq!(*es1 < *es2, lt); - assert_eq!(*es1 > *es2, gt); + fail_unless_eq!(*es1 < *es2, lt); + fail_unless_eq!(*es1 > *es2, gt); - assert_eq!(*es1 <= *es2, le); - assert_eq!(*es1 >= *es2, ge); + fail_unless_eq!(*es1 <= *es2, le); + fail_unless_eq!(*es1 >= *es2, ge); // TotalOrd - assert_eq!(es1.cmp(es2), ord); + fail_unless_eq!(es1.cmp(es2), ord); } } } diff --git a/src/test/run-pass/deriving-cmp-generic-struct.rs b/src/test/run-pass/deriving-cmp-generic-struct.rs index d04bdee34e611..fdcf005777011 100644 --- a/src/test/run-pass/deriving-cmp-generic-struct.rs +++ b/src/test/run-pass/deriving-cmp-generic-struct.rs @@ -32,21 +32,21 @@ pub fn main() { let ge = i >= j; // Eq - assert_eq!(*s1 == *s2, eq); - assert_eq!(*s1 != *s2, !eq); + fail_unless_eq!(*s1 == *s2, eq); + fail_unless_eq!(*s1 != *s2, !eq); // TotalEq - assert_eq!(s1.equals(s2), eq); + fail_unless_eq!(s1.equals(s2), eq); // Ord - assert_eq!(*s1 < *s2, lt); - assert_eq!(*s1 > *s2, gt); + fail_unless_eq!(*s1 < *s2, lt); + fail_unless_eq!(*s1 > *s2, gt); - assert_eq!(*s1 <= *s2, le); - assert_eq!(*s1 >= *s2, ge); + fail_unless_eq!(*s1 <= *s2, le); + fail_unless_eq!(*s1 >= *s2, ge); // TotalOrd - assert_eq!(s1.cmp(s2), ord); + fail_unless_eq!(s1.cmp(s2), ord); } } } diff --git a/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs b/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs index 5d4cf7c745769..25bfbe7006b75 100644 --- a/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs +++ b/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs @@ -30,21 +30,21 @@ pub fn main() { let ge = i >= j; // Eq - assert_eq!(*ts1 == *ts2, eq); - assert_eq!(*ts1 != *ts2, !eq); + fail_unless_eq!(*ts1 == *ts2, eq); + fail_unless_eq!(*ts1 != *ts2, !eq); // TotalEq - assert_eq!(ts1.equals(ts2), eq); + fail_unless_eq!(ts1.equals(ts2), eq); // Ord - assert_eq!(*ts1 < *ts2, lt); - assert_eq!(*ts1 > *ts2, gt); + fail_unless_eq!(*ts1 < *ts2, lt); + fail_unless_eq!(*ts1 > *ts2, gt); - assert_eq!(*ts1 <= *ts2, le); - assert_eq!(*ts1 >= *ts2, ge); + fail_unless_eq!(*ts1 <= *ts2, le); + fail_unless_eq!(*ts1 >= *ts2, ge); // TotalOrd - assert_eq!(ts1.cmp(ts2), ord); + fail_unless_eq!(ts1.cmp(ts2), ord); } } } diff --git a/src/test/run-pass/deriving-cmp-shortcircuit.rs b/src/test/run-pass/deriving-cmp-shortcircuit.rs index 6c3b2faf97557..73ab1631d727e 100644 --- a/src/test/run-pass/deriving-cmp-shortcircuit.rs +++ b/src/test/run-pass/deriving-cmp-shortcircuit.rs @@ -42,5 +42,5 @@ pub fn main() { fail_unless!(a != b); fail_unless!(a < b); fail_unless!(!a.equals(&b)); - assert_eq!(a.cmp(&b), ::std::cmp::Less); + fail_unless_eq!(a.cmp(&b), ::std::cmp::Less); } diff --git a/src/test/run-pass/deriving-primitive.rs b/src/test/run-pass/deriving-primitive.rs index bf63290a011f9..6ff20e1ed562c 100644 --- a/src/test/run-pass/deriving-primitive.rs +++ b/src/test/run-pass/deriving-primitive.rs @@ -21,17 +21,17 @@ enum A { pub fn main() { let x: Option = FromPrimitive::from_int(int::MAX); - assert_eq!(x, Some(Foo)); + fail_unless_eq!(x, Some(Foo)); let x: Option = FromPrimitive::from_int(1); - assert_eq!(x, Some(Bar)); + fail_unless_eq!(x, Some(Bar)); let x: Option = FromPrimitive::from_int(3); - assert_eq!(x, Some(Baz)); + fail_unless_eq!(x, Some(Baz)); let x: Option = FromPrimitive::from_int(4); - assert_eq!(x, Some(Qux)); + fail_unless_eq!(x, Some(Qux)); let x: Option = FromPrimitive::from_int(5); - assert_eq!(x, None); + fail_unless_eq!(x, None); } diff --git a/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs b/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs index acd12d6d38fe4..05b60352cf498 100644 --- a/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs +++ b/src/test/run-pass/deriving-self-lifetime-totalord-totaleq.rs @@ -23,9 +23,9 @@ pub fn main() { fail_unless!(b.equals(&b)); - assert_eq!(a.cmp(&a), Equal); - assert_eq!(b.cmp(&b), Equal); + fail_unless_eq!(a.cmp(&a), Equal); + fail_unless_eq!(b.cmp(&b), Equal); - assert_eq!(a.cmp(&b), Less); - assert_eq!(b.cmp(&a), Greater); + fail_unless_eq!(a.cmp(&b), Less); + fail_unless_eq!(b.cmp(&a), Greater); } diff --git a/src/test/run-pass/deriving-self-lifetime.rs b/src/test/run-pass/deriving-self-lifetime.rs index 818d2d831d89a..d142bb36054b8 100644 --- a/src/test/run-pass/deriving-self-lifetime.rs +++ b/src/test/run-pass/deriving-self-lifetime.rs @@ -19,8 +19,8 @@ pub fn main() { let a = A { x: &1 }; let b = A { x: &2 }; - assert_eq!(a, a); - assert_eq!(b, b); + fail_unless_eq!(a, a); + fail_unless_eq!(b, b); fail_unless!(a < b); diff --git a/src/test/run-pass/deriving-show.rs b/src/test/run-pass/deriving-show.rs index 40965615506c7..d1d9497b6bfee 100644 --- a/src/test/run-pass/deriving-show.rs +++ b/src/test/run-pass/deriving-show.rs @@ -28,7 +28,7 @@ enum Enum { macro_rules! t { ($x:expr, $expected:expr) => { - assert_eq!(format!("{}", $x), $expected.to_owned()) + fail_unless_eq!(format!("{}", $x), $expected.to_owned()) } } diff --git a/src/test/run-pass/deriving-to-str.rs b/src/test/run-pass/deriving-to-str.rs index d9f69bd4a4936..63768578ffa98 100644 --- a/src/test/run-pass/deriving-to-str.rs +++ b/src/test/run-pass/deriving-to-str.rs @@ -37,15 +37,15 @@ impl ToStr for Custom { } pub fn main() { - assert_eq!(B1.to_str(), ~"B1"); - assert_eq!(B2.to_str(), ~"B2"); - assert_eq!(C1(3).to_str(), ~"C1(3)"); - assert_eq!(C2(B2).to_str(), ~"C2(B2)"); - assert_eq!(D1{ a: 2 }.to_str(), ~"D1{a: 2}"); - assert_eq!(E.to_str(), ~"E"); - assert_eq!(F(3).to_str(), ~"F(3)"); - assert_eq!(G(3, 4).to_str(), ~"G(3, 4)"); - assert_eq!(G(3, 4).to_str(), ~"G(3, 4)"); - assert_eq!(I{ a: 2, b: 4 }.to_str(), ~"I{a: 2, b: 4}"); - assert_eq!(J(Custom).to_str(), ~"J(yay)"); + fail_unless_eq!(B1.to_str(), ~"B1"); + fail_unless_eq!(B2.to_str(), ~"B2"); + fail_unless_eq!(C1(3).to_str(), ~"C1(3)"); + fail_unless_eq!(C2(B2).to_str(), ~"C2(B2)"); + fail_unless_eq!(D1{ a: 2 }.to_str(), ~"D1{a: 2}"); + fail_unless_eq!(E.to_str(), ~"E"); + fail_unless_eq!(F(3).to_str(), ~"F(3)"); + fail_unless_eq!(G(3, 4).to_str(), ~"G(3, 4)"); + fail_unless_eq!(G(3, 4).to_str(), ~"G(3, 4)"); + fail_unless_eq!(I{ a: 2, b: 4 }.to_str(), ~"I{a: 2, b: 4}"); + fail_unless_eq!(J(Custom).to_str(), ~"J(yay)"); } diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 894a849347352..da9ae5e482279 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -18,7 +18,7 @@ enum Foo { pub fn main() { let a = Bar; let b = Bar; - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!(!(a != b)); fail_unless!(a.eq(&b)); fail_unless!(!a.ne(&b)); diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs index 398dd3e274b8d..64e8e010d8e5a 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -17,7 +17,7 @@ enum Foo { pub fn main() { let a = Bar(1, 2); let b = Bar(1, 2); - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!(!(a != b)); fail_unless!(a.eq(&b)); fail_unless!(!a.ne(&b)); diff --git a/src/test/run-pass/deriving-via-extension-struct-empty.rs b/src/test/run-pass/deriving-via-extension-struct-empty.rs index 49c738b34a08a..16761bdcfe57f 100644 --- a/src/test/run-pass/deriving-via-extension-struct-empty.rs +++ b/src/test/run-pass/deriving-via-extension-struct-empty.rs @@ -12,6 +12,6 @@ struct Foo; pub fn main() { - assert_eq!(Foo, Foo); + fail_unless_eq!(Foo, Foo); fail_unless!(!(Foo != Foo)); } diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index e47429442ee13..f24167cf981d5 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -18,6 +18,6 @@ enum S { pub fn main() { let x = X { x: 1, y: 2 }; - assert_eq!(x, x); + fail_unless_eq!(x, x); fail_unless!(!(x != x)); } diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index 9d90e2e21658c..2ba3a4d59259b 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -18,7 +18,7 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 }; - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!(!(a != b)); fail_unless!(a.eq(&b)); fail_unless!(!a.ne(&b)); diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index 3fc47f758e012..48e90042732d7 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -21,7 +21,7 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2.0, z: 3 }; let b = Foo { x: 1, y: 2.0, z: 3 }; - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!(!(a != b)); fail_unless!(a.eq(&b)); fail_unless!(!a.ne(&b)); diff --git a/src/test/run-pass/div-mod.rs b/src/test/run-pass/div-mod.rs index 331cd36a69402..ce8f1a6509030 100644 --- a/src/test/run-pass/div-mod.rs +++ b/src/test/run-pass/div-mod.rs @@ -14,14 +14,14 @@ pub fn main() { let x: int = 15; let y: int = 5; - assert_eq!(x / 5, 3); - assert_eq!(x / 4, 3); - assert_eq!(x / 3, 5); - assert_eq!(x / y, 3); - assert_eq!(15 / y, 3); - assert_eq!(x % 5, 0); - assert_eq!(x % 4, 3); - assert_eq!(x % 3, 0); - assert_eq!(x % y, 0); - assert_eq!(15 % y, 0); + fail_unless_eq!(x / 5, 3); + fail_unless_eq!(x / 4, 3); + fail_unless_eq!(x / 3, 5); + fail_unless_eq!(x / y, 3); + fail_unless_eq!(15 / y, 3); + fail_unless_eq!(x % 5, 0); + fail_unless_eq!(x % 4, 3); + fail_unless_eq!(x % 3, 0); + fail_unless_eq!(x % y, 0); + fail_unless_eq!(15 % y, 0); } diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index 7b9046318ab43..eb7d12205d743 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -18,7 +18,7 @@ impl Eq for chan { } fn wrapper3(i: chan) { - assert_eq!(i, chan_t); + fail_unless_eq!(i, chan_t); } pub fn main() { diff --git a/src/test/run-pass/enum-clike-ffi-as-int.rs b/src/test/run-pass/enum-clike-ffi-as-int.rs index 0c897b959a5a3..e0ed85f62b947 100644 --- a/src/test/run-pass/enum-clike-ffi-as-int.rs +++ b/src/test/run-pass/enum-clike-ffi-as-int.rs @@ -34,6 +34,6 @@ extern "C" fn foo(_x: uint) -> Foo { B } pub fn main() { unsafe { let f: extern "C" fn(uint) -> u32 = ::std::cast::transmute(foo); - assert_eq!(f(0xDEADBEEF), B as u32); + fail_unless_eq!(f(0xDEADBEEF), B as u32); } } diff --git a/src/test/run-pass/enum-discrim-autosizing.rs b/src/test/run-pass/enum-discrim-autosizing.rs index ef34115739dd4..f247266573d17 100644 --- a/src/test/run-pass/enum-discrim-autosizing.rs +++ b/src/test/run-pass/enum-discrim-autosizing.rs @@ -51,12 +51,12 @@ enum Eu64 { } pub fn main() { - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::(), 8); + fail_unless_eq!(size_of::(), 1); + fail_unless_eq!(size_of::(), 1); + fail_unless_eq!(size_of::(), 2); + fail_unless_eq!(size_of::(), 2); + fail_unless_eq!(size_of::(), 4); + fail_unless_eq!(size_of::(), 4); + fail_unless_eq!(size_of::(), 8); + fail_unless_eq!(size_of::(), 8); } diff --git a/src/test/run-pass/enum-discrim-manual-sizing.rs b/src/test/run-pass/enum-discrim-manual-sizing.rs index 16eaac082abac..37837dc5b1f65 100644 --- a/src/test/run-pass/enum-discrim-manual-sizing.rs +++ b/src/test/run-pass/enum-discrim-manual-sizing.rs @@ -71,14 +71,14 @@ enum Euint { } pub fn main() { - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), 1); + fail_unless_eq!(size_of::(), 1); + fail_unless_eq!(size_of::(), 2); + fail_unless_eq!(size_of::(), 2); + fail_unless_eq!(size_of::(), 4); + fail_unless_eq!(size_of::(), 4); + fail_unless_eq!(size_of::(), 8); + fail_unless_eq!(size_of::(), 8); + fail_unless_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), size_of::()); } diff --git a/src/test/run-pass/enum-discrim-width-stuff.rs b/src/test/run-pass/enum-discrim-width-stuff.rs index 6a0110436b3c8..7053ae0f407f8 100644 --- a/src/test/run-pass/enum-discrim-width-stuff.rs +++ b/src/test/run-pass/enum-discrim-width-stuff.rs @@ -20,11 +20,11 @@ macro_rules! check { } static C: E = V; pub fn check() { - assert_eq!(size_of::(), size_of::<$t>()); - assert_eq!(V as $t, $v); - assert_eq!(C as $t, $v); - assert_eq!(format!("{:?}", V), ~"V"); - assert_eq!(format!("{:?}", C), ~"V"); + fail_unless_eq!(size_of::(), size_of::<$t>()); + fail_unless_eq!(V as $t, $v); + fail_unless_eq!(C as $t, $v); + fail_unless_eq!(format!("{:?}", V), ~"V"); + fail_unless_eq!(format!("{:?}", C), ~"V"); } } $m::check(); @@ -51,5 +51,5 @@ pub fn main() { check!(s, i64, -0x1727374757677787); enum Simple { A, B } - assert_eq!(::std::mem::size_of::(), 1); + fail_unless_eq!(::std::mem::size_of::(), 1); } diff --git a/src/test/run-pass/estr-slice.rs b/src/test/run-pass/estr-slice.rs index 17ea00ad576b5..8538a4996e0d2 100644 --- a/src/test/run-pass/estr-slice.rs +++ b/src/test/run-pass/estr-slice.rs @@ -17,11 +17,11 @@ pub fn main() { info!("{}", x); info!("{}", y); - assert_eq!(x[0], 'h' as u8); - assert_eq!(x[4], 'o' as u8); + fail_unless_eq!(x[0], 'h' as u8); + fail_unless_eq!(x[4], 'o' as u8); let z : &str = &"thing"; - assert_eq!(v, x); + fail_unless_eq!(v, x); fail_unless!(x != z); let a = &"aaaa"; diff --git a/src/test/run-pass/estr-uniq.rs b/src/test/run-pass/estr-uniq.rs index 7935886d39b3b..30001a4f7c639 100644 --- a/src/test/run-pass/estr-uniq.rs +++ b/src/test/run-pass/estr-uniq.rs @@ -15,6 +15,6 @@ pub fn main() { let _y : ~str = ~"there"; let mut z = ~"thing"; z = x; - assert_eq!(z[0], ('h' as u8)); - assert_eq!(z[4], ('o' as u8)); + fail_unless_eq!(z[0], ('h' as u8)); + fail_unless_eq!(z[4], ('o' as u8)); } diff --git a/src/test/run-pass/evec-internal-boxes.rs b/src/test/run-pass/evec-internal-boxes.rs index 7ba8a3de24412..dd11e227d5003 100644 --- a/src/test/run-pass/evec-internal-boxes.rs +++ b/src/test/run-pass/evec-internal-boxes.rs @@ -16,6 +16,6 @@ pub fn main() { let _y : [@int, ..5] = [@1,@2,@3,@4,@5]; let mut z = [@1,@2,@3,@4,@5]; z = x; - assert_eq!(*z[0], 1); - assert_eq!(*z[4], 5); + fail_unless_eq!(*z[0], 1); + fail_unless_eq!(*z[4], 5); } diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index 02bd10b24f630..d78e65463d73c 100644 --- a/src/test/run-pass/evec-internal.rs +++ b/src/test/run-pass/evec-internal.rs @@ -18,8 +18,8 @@ pub fn main() { let _y : [int, ..5] = [1,2,3,4,5]; let mut z = [1,2,3,4,5]; z = x; - assert_eq!(z[0], 1); - assert_eq!(z[4], 5); + fail_unless_eq!(z[0], 1); + fail_unless_eq!(z[4], 5); let a : [int, ..5] = [1,1,1,1,1]; let b : [int, ..5] = [2,2,2,2,2]; diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index 52f64e1c66f46..d6721b63ced9c 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -14,8 +14,8 @@ pub fn main() { let x : &[int] = &[1,2,3,4,5]; let mut z = &[1,2,3,4,5]; z = x; - assert_eq!(z[0], 1); - assert_eq!(z[4], 5); + fail_unless_eq!(z[0], 1); + fail_unless_eq!(z[4], 5); let a : &[int] = &[1,1,1,1,1]; let b : &[int] = &[2,2,2,2,2]; diff --git a/src/test/run-pass/exec-env.rs b/src/test/run-pass/exec-env.rs index 9b251d4be77e1..fc6aa54158480 100644 --- a/src/test/run-pass/exec-env.rs +++ b/src/test/run-pass/exec-env.rs @@ -14,5 +14,5 @@ use std::os; pub fn main() { - assert_eq!(os::getenv("TEST_EXEC_ENV"), Some(~"22")); + fail_unless_eq!(os::getenv("TEST_EXEC_ENV"), Some(~"22")); } diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index a3c5256c2d365..9a9cc0cf51252 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -40,5 +40,5 @@ impl HashMap { pub fn main() { let mut m = ~linear_map::<(),()>(); - assert_eq!(m.len(), 0); + fail_unless_eq!(m.len(), 0); } diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index 69ca98eb018ed..f3b1c44fc3487 100644 --- a/src/test/run-pass/explicit-self-objects-uniq.rs +++ b/src/test/run-pass/explicit-self-objects-uniq.rs @@ -18,7 +18,7 @@ struct S { impl Foo for S { fn f(~self) { - assert_eq!(self.x, 3); + fail_unless_eq!(self.x, 3); } } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 1076fc1662fa2..813f3b7b80db4 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -68,9 +68,9 @@ impl Nus for thing { fn f(&self) {} } pub fn main() { let y = ~thing(A {a: 10}); - assert_eq!(y.clone().bar(), 10); - assert_eq!(y.quux(), 10); + fail_unless_eq!(y.clone().bar(), 10); + fail_unless_eq!(y.quux(), 10); let z = thing(A {a: 11}); - assert_eq!(z.spam(), 11); + fail_unless_eq!(z.spam(), 11); } diff --git a/src/test/run-pass/exponential-notation.rs b/src/test/run-pass/exponential-notation.rs index 254c093e703a3..28775d28e06c8 100644 --- a/src/test/run-pass/exponential-notation.rs +++ b/src/test/run-pass/exponential-notation.rs @@ -13,7 +13,7 @@ use s = std::num::strconv; use to_str = std::num::strconv::float_to_str_common; -macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_owned()) } }) +macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; fail_unless_eq!(r, $b.to_owned()) } }) pub fn main() { // Basic usage diff --git a/src/test/run-pass/expr-block-slot.rs b/src/test/run-pass/expr-block-slot.rs index cfb764e85f8d3..fa194c3d385e1 100644 --- a/src/test/run-pass/expr-block-slot.rs +++ b/src/test/run-pass/expr-block-slot.rs @@ -15,7 +15,7 @@ struct V { v: int } pub fn main() { let a = { let b = A {a: 3}; b }; - assert_eq!(a.a, 3); + fail_unless_eq!(a.a, 3); let c = { let d = V {v: 3}; d }; - assert_eq!(c.v, 3); + fail_unless_eq!(c.v, 3); } diff --git a/src/test/run-pass/expr-block.rs b/src/test/run-pass/expr-block.rs index 404aee69457a6..da413debd99e0 100644 --- a/src/test/run-pass/expr-block.rs +++ b/src/test/run-pass/expr-block.rs @@ -21,7 +21,7 @@ fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; fail_unless!((rs.v2 == 20)); } fn test_filled_with_stuff() { let rs = { let mut a = 0; while a < 10 { a += 1; } a }; - assert_eq!(rs, 10); + fail_unless_eq!(rs, 10); } pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); } diff --git a/src/test/run-pass/expr-copy.rs b/src/test/run-pass/expr-copy.rs index d47ef3c7f90e9..664d93dbc6692 100644 --- a/src/test/run-pass/expr-copy.rs +++ b/src/test/run-pass/expr-copy.rs @@ -19,9 +19,9 @@ struct A { a: int } pub fn main() { let mut x = A {a: 10}; f(&mut x); - assert_eq!(x.a, 100); + fail_unless_eq!(x.a, 100); x.a = 20; let mut y = x; f(&mut y); - assert_eq!(x.a, 20); + fail_unless_eq!(x.a, 20); } diff --git a/src/test/run-pass/expr-elseif-ref.rs b/src/test/run-pass/expr-elseif-ref.rs index 105c2cc08052b..6ce9e27e0757a 100644 --- a/src/test/run-pass/expr-elseif-ref.rs +++ b/src/test/run-pass/expr-elseif-ref.rs @@ -15,5 +15,5 @@ pub fn main() { let y: @uint = @10u; let _x = if false { y } else if true { y } else { y }; - assert_eq!(*y, 10u); + fail_unless_eq!(*y, 10u); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index cba1bab300468..3751f6af068df 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -10,32 +10,32 @@ fn test_int() { fn f() -> int { 10 } - assert_eq!(f(), 10); + fail_unless_eq!(f(), 10); } fn test_vec() { fn f() -> ~[int] { ~[10, 11] } - assert_eq!(f()[1], 11); + fail_unless_eq!(f()[1], 11); } fn test_generic() { fn f(t: T) -> T { t } - assert_eq!(f(10), 10); + fail_unless_eq!(f(10), 10); } fn test_alt() { fn f() -> int { match true { false => { 10 } true => { 20 } } } - assert_eq!(f(), 20); + fail_unless_eq!(f(), 20); } fn test_if() { fn f() -> int { if true { 10 } else { 20 } } - assert_eq!(f(), 10); + fail_unless_eq!(f(), 10); } fn test_block() { fn f() -> int { { 10 } } - assert_eq!(f(), 10); + fail_unless_eq!(f(), 10); } fn test_ret() { @@ -43,14 +43,14 @@ fn test_ret() { return 10 // no semi } - assert_eq!(f(), 10); + fail_unless_eq!(f(), 10); } // From issue #372 fn test_372() { fn f() -> int { let x = { 3 }; x } - assert_eq!(f(), 3); + fail_unless_eq!(f(), 3); } fn test_nil() { () } diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs index b83c7b8852c9f..2325fa1891fa7 100644 --- a/src/test/run-pass/expr-if-box.rs +++ b/src/test/run-pass/expr-if-box.rs @@ -13,12 +13,12 @@ // Tests for if as expressions returning boxed types fn test_box() { let rs = if true { @100 } else { @101 }; - assert_eq!(*rs, 100); + fail_unless_eq!(*rs, 100); } fn test_str() { let rs = if true { ~"happy" } else { ~"sad" }; - assert_eq!(rs, ~"happy"); + fail_unless_eq!(rs, ~"happy"); } pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index 1333bb30aba81..6d63a73b558ab 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -12,12 +12,12 @@ fn test_if_fail() { let x = if false { fail!() } else { 10 }; fail_unless!((x == fn test_else_fail() { let x = if true { 10 } else { fail!() }; - assert_eq!(x, 10); + fail_unless_eq!(x, 10); } fn test_elseif_fail() { let x = if false { 0 } else if false { fail!() } else { 10 }; - assert_eq!(x, 10); + fail_unless_eq!(x, 10); } pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index c40f2aa01c101..3089abcebe29d 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -18,7 +18,7 @@ struct I { i: int } fn test_rec() { let rs = if true { I {i: 100} } else { I {i: 101} }; - assert_eq!(rs.i, 100); + fail_unless_eq!(rs.i, 100); } enum mood { happy, sad, } @@ -32,7 +32,7 @@ impl Eq for mood { fn test_tag() { let rs = if true { happy } else { sad }; - assert_eq!(rs, happy); + fail_unless_eq!(rs, happy); } pub fn main() { test_rec(); test_tag(); } diff --git a/src/test/run-pass/expr-if-unique.rs b/src/test/run-pass/expr-if-unique.rs index b40dc03ccfb9b..39041b38e03d2 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -15,7 +15,7 @@ // Tests for if as expressions returning boxed types fn test_box() { let rs = if true { ~100 } else { ~101 }; - assert_eq!(*rs, 100); + fail_unless_eq!(*rs, 100); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-match-box.rs b/src/test/run-pass/expr-match-box.rs index 8557f409b75c2..bf773bef58006 100644 --- a/src/test/run-pass/expr-match-box.rs +++ b/src/test/run-pass/expr-match-box.rs @@ -13,13 +13,13 @@ // Tests for match as expressions resulting in boxed types fn test_box() { let res = match true { true => { @100 } _ => fail!("wat") }; - assert_eq!(*res, 100); + fail_unless_eq!(*res, 100); } fn test_str() { let res = match true { true => { ~"happy" }, _ => fail!("not happy at all") }; - assert_eq!(res, ~"happy"); + fail_unless_eq!(res, ~"happy"); } pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-match-fail.rs b/src/test/run-pass/expr-match-fail.rs index 3e1b96763e196..12fa56afe341d 100644 --- a/src/test/run-pass/expr-match-fail.rs +++ b/src/test/run-pass/expr-match-fail.rs @@ -10,12 +10,12 @@ fn test_simple() { let r = match true { true => { true } false => { fail!() } }; - assert_eq!(r, true); + fail_unless_eq!(r, true); } fn test_box() { let r = match true { true => { ~[10] } false => { fail!() } }; - assert_eq!(r[0], 10); + fail_unless_eq!(r[0], 10); } pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/expr-match-struct.rs b/src/test/run-pass/expr-match-struct.rs index 66ab591bb5242..19e1e44b30808 100644 --- a/src/test/run-pass/expr-match-struct.rs +++ b/src/test/run-pass/expr-match-struct.rs @@ -17,7 +17,7 @@ struct R { i: int } fn test_rec() { let rs = match true { true => R {i: 100}, _ => fail!() }; - assert_eq!(rs.i, 100); + fail_unless_eq!(rs.i, 100); } enum mood { happy, sad, } @@ -31,7 +31,7 @@ impl Eq for mood { fn test_tag() { let rs = match true { true => { happy } false => { sad } }; - assert_eq!(rs, happy); + fail_unless_eq!(rs, happy); } pub fn main() { test_rec(); test_tag(); } diff --git a/src/test/run-pass/expr-match-unique.rs b/src/test/run-pass/expr-match-unique.rs index 85c6652c5aab3..1821b2ab333d4 100644 --- a/src/test/run-pass/expr-match-unique.rs +++ b/src/test/run-pass/expr-match-unique.rs @@ -15,7 +15,7 @@ // Tests for match as expressions resulting in boxed types fn test_box() { let res = match true { true => { ~100 }, _ => fail!() }; - assert_eq!(*res, 100); + fail_unless_eq!(*res, 100); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index 5cf4984bb114a..de170e8ff3955 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -23,8 +23,8 @@ fn f(p: @Cell) { pub fn main() { let a: Point = Point {x: 10, y: 11, z: 12}; let b: @Cell = @Cell::new(a); - assert_eq!(b.get().z, 12); + fail_unless_eq!(b.get().z, 12); f(b); - assert_eq!(a.z, 12); - assert_eq!(b.get().z, 13); + fail_unless_eq!(a.z, 12); + fail_unless_eq!(b.get().z, 13); } diff --git a/src/test/run-pass/extern-call-deep.rs b/src/test/run-pass/extern-call-deep.rs index e3b727fafd3c8..2c27221b216c8 100644 --- a/src/test/run-pass/extern-call-deep.rs +++ b/src/test/run-pass/extern-call-deep.rs @@ -39,5 +39,5 @@ fn count(n: uint) -> uint { pub fn main() { let result = count(1000u); info!("result = {}", result); - assert_eq!(result, 1000u); + fail_unless_eq!(result, 1000u); } diff --git a/src/test/run-pass/extern-call-deep2.rs b/src/test/run-pass/extern-call-deep2.rs index 500ae8951ec4a..b390d85f0c2d8 100644 --- a/src/test/run-pass/extern-call-deep2.rs +++ b/src/test/run-pass/extern-call-deep2.rs @@ -43,6 +43,6 @@ pub fn main() { task::spawn(proc() { let result = count(1000u); info!("result = {}", result); - assert_eq!(result, 1000u); + fail_unless_eq!(result, 1000u); }); } diff --git a/src/test/run-pass/extern-call-direct.rs b/src/test/run-pass/extern-call-direct.rs index 34d2b577f202c..427b48e931ff9 100644 --- a/src/test/run-pass/extern-call-direct.rs +++ b/src/test/run-pass/extern-call-direct.rs @@ -14,5 +14,5 @@ extern fn f(x: uint) -> uint { x * 2 } pub fn main() { let x = f(22); - assert_eq!(x, 44); + fail_unless_eq!(x, 44); } diff --git a/src/test/run-pass/extern-call-indirect.rs b/src/test/run-pass/extern-call-indirect.rs index c49d589572cbe..9c7014f1f27c4 100644 --- a/src/test/run-pass/extern-call-indirect.rs +++ b/src/test/run-pass/extern-call-indirect.rs @@ -39,5 +39,5 @@ fn fact(n: uint) -> uint { pub fn main() { let result = fact(10u); info!("result = {}", result); - assert_eq!(result, 3628800u); + fail_unless_eq!(result, 3628800u); } diff --git a/src/test/run-pass/extern-call-scrub.rs b/src/test/run-pass/extern-call-scrub.rs index c35e84154d80b..0235fccb955e6 100644 --- a/src/test/run-pass/extern-call-scrub.rs +++ b/src/test/run-pass/extern-call-scrub.rs @@ -47,6 +47,6 @@ pub fn main() { task::spawn(proc() { let result = count(12u); info!("result = {}", result); - assert_eq!(result, 2048u); + fail_unless_eq!(result, 2048u); }); } diff --git a/src/test/run-pass/extern-compare-with-return-type.rs b/src/test/run-pass/extern-compare-with-return-type.rs index 8463ae072c8b3..ced575105a67c 100644 --- a/src/test/run-pass/extern-compare-with-return-type.rs +++ b/src/test/run-pass/extern-compare-with-return-type.rs @@ -20,13 +20,13 @@ extern fn uintvoidret(_x: uint) {} extern fn uintuintuintuintret(x: uint, y: uint, z: uint) -> uint { x+y+z } pub fn main() { - assert_eq!(voidret1, voidret1); + fail_unless_eq!(voidret1, voidret1); fail_unless!(voidret1 != voidret2); - assert_eq!(uintret, uintret); + fail_unless_eq!(uintret, uintret); - assert_eq!(uintvoidret, uintvoidret); + fail_unless_eq!(uintvoidret, uintvoidret); - assert_eq!(uintuintuintuintret, uintuintuintuintret); + fail_unless_eq!(uintuintuintuintret, uintuintuintuintret); } diff --git a/src/test/run-pass/extern-crosscrate.rs b/src/test/run-pass/extern-crosscrate.rs index ccd79600a15a7..9a71527ddc1e8 100644 --- a/src/test/run-pass/extern-crosscrate.rs +++ b/src/test/run-pass/extern-crosscrate.rs @@ -23,5 +23,5 @@ fn fact(n: uint) -> uint { pub fn main() { let result = fact(10u); info!("result = {}", result); - assert_eq!(result, 3628800u); + fail_unless_eq!(result, 3628800u); } diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs index 2cbf9a37ca18a..de41ef800f52a 100644 --- a/src/test/run-pass/extern-pass-TwoU16s.rs +++ b/src/test/run-pass/extern-pass-TwoU16s.rs @@ -27,6 +27,6 @@ pub fn main() { unsafe { let x = TwoU16s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU16s(x); - assert_eq!(x, y); + fail_unless_eq!(x, y); } } diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs index 592d42c65d188..425c30824e68f 100644 --- a/src/test/run-pass/extern-pass-TwoU32s.rs +++ b/src/test/run-pass/extern-pass-TwoU32s.rs @@ -25,6 +25,6 @@ pub fn main() { unsafe { let x = TwoU32s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU32s(x); - assert_eq!(x, y); + fail_unless_eq!(x, y); } } diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs index 8bca7a946e56e..1f702d928721d 100644 --- a/src/test/run-pass/extern-pass-TwoU64s.rs +++ b/src/test/run-pass/extern-pass-TwoU64s.rs @@ -27,6 +27,6 @@ pub fn main() { unsafe { let x = TwoU64s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU64s(x); - assert_eq!(x, y); + fail_unless_eq!(x, y); } } diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs index 7ca351994bfca..a0c829daef071 100644 --- a/src/test/run-pass/extern-pass-TwoU8s.rs +++ b/src/test/run-pass/extern-pass-TwoU8s.rs @@ -27,6 +27,6 @@ pub fn main() { unsafe { let x = TwoU8s {one: 22, two: 23}; let y = rust_dbg_extern_identity_TwoU8s(x); - assert_eq!(x, y); + fail_unless_eq!(x, y); } } diff --git a/src/test/run-pass/extern-pass-char.rs b/src/test/run-pass/extern-pass-char.rs index 85d0463fe7252..e7f2cebd005f6 100644 --- a/src/test/run-pass/extern-pass-char.rs +++ b/src/test/run-pass/extern-pass-char.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u8, rust_dbg_extern_identity_u8(22_u8)); + fail_unless_eq!(22_u8, rust_dbg_extern_identity_u8(22_u8)); } } diff --git a/src/test/run-pass/extern-pass-double.rs b/src/test/run-pass/extern-pass-double.rs index 2d35fe6043e8f..96067da43507c 100644 --- a/src/test/run-pass/extern-pass-double.rs +++ b/src/test/run-pass/extern-pass-double.rs @@ -15,6 +15,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22.0_f64, rust_dbg_extern_identity_double(22.0_f64)); + fail_unless_eq!(22.0_f64, rust_dbg_extern_identity_double(22.0_f64)); } } diff --git a/src/test/run-pass/extern-pass-u32.rs b/src/test/run-pass/extern-pass-u32.rs index 5ff3353a8c085..7d410182a0f18 100644 --- a/src/test/run-pass/extern-pass-u32.rs +++ b/src/test/run-pass/extern-pass-u32.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u32, rust_dbg_extern_identity_u32(22_u32)); + fail_unless_eq!(22_u32, rust_dbg_extern_identity_u32(22_u32)); } } diff --git a/src/test/run-pass/extern-pass-u64.rs b/src/test/run-pass/extern-pass-u64.rs index b94c57a7a663d..f7b3d6a0ced5b 100644 --- a/src/test/run-pass/extern-pass-u64.rs +++ b/src/test/run-pass/extern-pass-u64.rs @@ -17,6 +17,6 @@ extern { pub fn main() { unsafe { - assert_eq!(22_u64, rust_dbg_extern_identity_u64(22_u64)); + fail_unless_eq!(22_u64, rust_dbg_extern_identity_u64(22_u64)); } } diff --git a/src/test/run-pass/extern-return-TwoU16s.rs b/src/test/run-pass/extern-return-TwoU16s.rs index 45efbbb278540..3843e91f49cf9 100644 --- a/src/test/run-pass/extern-return-TwoU16s.rs +++ b/src/test/run-pass/extern-return-TwoU16s.rs @@ -20,7 +20,7 @@ extern { pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU16s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); + fail_unless_eq!(y.one, 10); + fail_unless_eq!(y.two, 20); } } diff --git a/src/test/run-pass/extern-return-TwoU32s.rs b/src/test/run-pass/extern-return-TwoU32s.rs index 8258ee623ab22..b40e0365efd33 100644 --- a/src/test/run-pass/extern-return-TwoU32s.rs +++ b/src/test/run-pass/extern-return-TwoU32s.rs @@ -20,7 +20,7 @@ extern { pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU32s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); + fail_unless_eq!(y.one, 10); + fail_unless_eq!(y.two, 20); } } diff --git a/src/test/run-pass/extern-return-TwoU64s.rs b/src/test/run-pass/extern-return-TwoU64s.rs index 0db47a8338e88..5b478e72acccb 100644 --- a/src/test/run-pass/extern-return-TwoU64s.rs +++ b/src/test/run-pass/extern-return-TwoU64s.rs @@ -22,7 +22,7 @@ extern { pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU64s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); + fail_unless_eq!(y.one, 10); + fail_unless_eq!(y.two, 20); } } diff --git a/src/test/run-pass/extern-return-TwoU8s.rs b/src/test/run-pass/extern-return-TwoU8s.rs index 99dbd93fb7d3e..f1ce68de55b58 100644 --- a/src/test/run-pass/extern-return-TwoU8s.rs +++ b/src/test/run-pass/extern-return-TwoU8s.rs @@ -20,7 +20,7 @@ extern { pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU8s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); + fail_unless_eq!(y.one, 10); + fail_unless_eq!(y.two, 20); } } diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index ef1b26fc1af05..9bfa918f77184 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -43,7 +43,7 @@ fn count(n: uint) -> uint { pub fn main() { for _ in range(0, 100u) { task::spawn(proc() { - assert_eq!(count(5u), 16u); + fail_unless_eq!(count(5u), 16u); }); } } diff --git a/src/test/run-pass/extern-take-value.rs b/src/test/run-pass/extern-take-value.rs index 571875c93f08f..556138b259a79 100644 --- a/src/test/run-pass/extern-take-value.rs +++ b/src/test/run-pass/extern-take-value.rs @@ -19,6 +19,6 @@ pub fn main() { let b: extern "C" fn() = f; let c: extern "C" fn() = g; - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!(a != c); } diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index d7b8ed583a518..d561aedc94338 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -42,7 +42,7 @@ pub fn main() { task::spawn(proc() { let result = count(5u); info!("result = {}", result); - assert_eq!(result, 16u); + fail_unless_eq!(result, 16u); }); } } diff --git a/src/test/run-pass/fact.rs b/src/test/run-pass/fact.rs index 2f79784ce5409..5288991abc268 100644 --- a/src/test/run-pass/fact.rs +++ b/src/test/run-pass/fact.rs @@ -31,7 +31,7 @@ fn f(x: int) -> int { } pub fn main() { - assert_eq!(f(5), 120); + fail_unless_eq!(f(5), 120); // info!("all done"); } diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index bbd7b9130e7b9..d85b9af86126b 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -11,6 +11,6 @@ pub fn main() { let arr = [1,2,3]; let arr2 = arr; - assert_eq!(arr[1], 2); - assert_eq!(arr2[2], 3); + fail_unless_eq!(arr[1], 2); + fail_unless_eq!(arr2[2], 3); } diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs index 1e3754c61cf2e..f913f8040d4ee 100644 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ b/src/test/run-pass/fixed_length_vec_glue.rs @@ -18,5 +18,5 @@ pub fn main() { let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = repr::repr_to_str(&struc); - assert_eq!(s, ~"Struc{a: 13u8, b: [1, 2, 3], c: 42}"); + fail_unless_eq!(s, ~"Struc{a: 13u8, b: [1, 2, 3], c: 42}"); } diff --git a/src/test/run-pass/float-nan.rs b/src/test/run-pass/float-nan.rs index ceeccb98cdd84..3b1b737031d67 100644 --- a/src/test/run-pass/float-nan.rs +++ b/src/test/run-pass/float-nan.rs @@ -18,7 +18,7 @@ pub fn main() { let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); - assert_eq!(-inf, neg_inf); + fail_unless_eq!(-inf, neg_inf); fail_unless!( nan != nan); fail_unless!( nan != -nan); diff --git a/src/test/run-pass/float2.rs b/src/test/run-pass/float2.rs index 6df04e06107e4..cbd09183a9e00 100644 --- a/src/test/run-pass/float2.rs +++ b/src/test/run-pass/float2.rs @@ -22,13 +22,13 @@ pub fn main() { let i = 1.0E7f64; let j = 3.1e+9; let k = 3.2e-10; - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!((c < b)); - assert_eq!(c, d); + fail_unless_eq!(c, d); fail_unless!((e < g)); fail_unless!((f < h)); - assert_eq!(g, 1000000.0f32); - assert_eq!(h, i); + fail_unless_eq!(g, 1000000.0f32); + fail_unless_eq!(h, i); fail_unless!((j > k)); fail_unless!((k < a)); } diff --git a/src/test/run-pass/fn-bare-assign.rs b/src/test/run-pass/fn-bare-assign.rs index 7c8fbd2989f76..0593f55d81671 100644 --- a/src/test/run-pass/fn-bare-assign.rs +++ b/src/test/run-pass/fn-bare-assign.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f(i: int, called: &mut bool) { - assert_eq!(i, 10); + fail_unless_eq!(i, 10); *called = true; } @@ -21,5 +21,5 @@ pub fn main() { let mut called = false; let h = f; g(h, &mut called); - assert_eq!(called, true); + fail_unless_eq!(called, true); } diff --git a/src/test/run-pass/fn-bare-size.rs b/src/test/run-pass/fn-bare-size.rs index cdde98331e2d0..0c0c230281636 100644 --- a/src/test/run-pass/fn-bare-size.rs +++ b/src/test/run-pass/fn-bare-size.rs @@ -12,5 +12,5 @@ use std::mem; pub fn main() { // Bare functions should just be a pointer - assert_eq!(mem::size_of::(), mem::size_of::()); + fail_unless_eq!(mem::size_of::(), mem::size_of::()); } diff --git a/src/test/run-pass/fn-bare-spawn.rs b/src/test/run-pass/fn-bare-spawn.rs index e9954be93575c..fe394af37a4c0 100644 --- a/src/test/run-pass/fn-bare-spawn.rs +++ b/src/test/run-pass/fn-bare-spawn.rs @@ -15,7 +15,7 @@ fn spawn(val: T, f: extern fn(T)) { } fn f(i: int) { - assert_eq!(i, 100); + fail_unless_eq!(i, 100); } pub fn main() { diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index fb75abc6ea093..9aa5be3538695 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -10,8 +10,8 @@ pub fn main() { let f: |(int,int)| = |(x, y)| { - assert_eq!(x, 1); - assert_eq!(y, 2); + fail_unless_eq!(x, 1); + fail_unless_eq!(y, 2); }; f((1, 2)); } diff --git a/src/test/run-pass/for-destruct.rs b/src/test/run-pass/for-destruct.rs index d090f9a243c4a..ab7e6fc0c4cee 100644 --- a/src/test/run-pass/for-destruct.rs +++ b/src/test/run-pass/for-destruct.rs @@ -15,6 +15,6 @@ use std::vec; struct Pair { x: int, y: int } pub fn main() { for vec::each(~[Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) |elt| { - assert_eq!(elt.x + elt.y, 30); + fail_unless_eq!(elt.x + elt.y, 30); } } diff --git a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs index 34ce8c4711329..2b1e38fffb6e6 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs @@ -36,6 +36,6 @@ pub fn main() { y += v; } - assert_eq!(x, 6); - assert_eq!(y, 60); + fail_unless_eq!(x, 6); + fail_unless_eq!(y, 60); } diff --git a/src/test/run-pass/foreach-external-iterators-hashmap.rs b/src/test/run-pass/foreach-external-iterators-hashmap.rs index 365cde34dce82..6ca6e1395d35c 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap.rs @@ -22,6 +22,6 @@ pub fn main() { x += k; y += v; } - assert_eq!(x, 6); - assert_eq!(y, 60); + fail_unless_eq!(x, 6); + fail_unless_eq!(y, 60); } diff --git a/src/test/run-pass/foreach-external-iterators-loop.rs b/src/test/run-pass/foreach-external-iterators-loop.rs index 3757687431219..d788a68eec4ad 100644 --- a/src/test/run-pass/foreach-external-iterators-loop.rs +++ b/src/test/run-pass/foreach-external-iterators-loop.rs @@ -17,5 +17,5 @@ pub fn main() { } y += *i; } - assert_eq!(y, 90); + fail_unless_eq!(y, 90); } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 9646c6b6eb79d..cd29f59422775 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -19,8 +19,8 @@ pub fn main() { two(|i| { two(|j| { a[p] = 10 * i + j; p += 1; }) }); - assert_eq!(a[0], 0); - assert_eq!(a[1], 1); - assert_eq!(a[2], 10); - assert_eq!(a[3], 11); + fail_unless_eq!(a[0], 0); + fail_unless_eq!(a[1], 1); + fail_unless_eq!(a[2], 10); + fail_unless_eq!(a[3], 11); } diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 7011088fa5d44..0065b2834956e 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -23,9 +23,9 @@ pub fn main() { let (_0, _1) = p; info!("{}", _0); info!("{}", _1); - assert_eq!(_0 + 10, i); + fail_unless_eq!(_0 + 10, i); i += 1; j = _1; }); - assert_eq!(j, 45); + fail_unless_eq!(j, 45); } diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index 81e9ac1b80876..3f47756bbccb1 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -16,7 +16,7 @@ pub fn main() { first_ten(|i| { info!("main"); info!("{}", i); sum = sum + i; }); info!("sum"); info!("{}", sum); - assert_eq!(sum, 45); + fail_unless_eq!(sum, 45); } fn first_ten(it: |int|) { diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index 130f04b3fb2ad..85bdebf69de03 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -30,6 +30,6 @@ pub fn main() { extern fn callback(data: libc::uintptr_t) { unsafe { let data: *int = cast::transmute(data); - assert_eq!(*data, 100); + fail_unless_eq!(*data, 100); } } diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index b9d8d622731d3..f37495f6fd2c9 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -31,5 +31,5 @@ fn strlen(str: ~str) -> uint { pub fn main() { let len = strlen(~"Rust"); - assert_eq!(len, 4u); + fail_unless_eq!(len, 4u); } diff --git a/src/test/run-pass/foreign-lib-path.rs b/src/test/run-pass/foreign-lib-path.rs index 3ee43d00dee7c..20d6ddd779b23 100644 --- a/src/test/run-pass/foreign-lib-path.rs +++ b/src/test/run-pass/foreign-lib-path.rs @@ -22,5 +22,5 @@ mod WHATGOESHERE { } pub fn main() { - assert_eq!(IDONTKNOW(), 0x_BAD_DOOD_u32); + fail_unless_eq!(IDONTKNOW(), 0x_BAD_DOOD_u32); } diff --git a/src/test/run-pass/format-ref-cell.rs b/src/test/run-pass/format-ref-cell.rs index 6428d496382b1..dc7f5f02bc511 100644 --- a/src/test/run-pass/format-ref-cell.rs +++ b/src/test/run-pass/format-ref-cell.rs @@ -14,5 +14,5 @@ pub fn main() { let name = RefCell::new("rust"); let what = RefCell::new("rocks"); let msg = format!("{name:?} {:?}", what.borrow().get(), name=name.borrow().get()); - assert_eq!(msg, ~"&\"rust\" &\"rocks\""); + fail_unless_eq!(msg, ~"&\"rust\" &\"rocks\""); } diff --git a/src/test/run-pass/fsu-moves-and-copies.rs b/src/test/run-pass/fsu-moves-and-copies.rs index 878ea298db395..95fd56bdd5556 100644 --- a/src/test/run-pass/fsu-moves-and-copies.rs +++ b/src/test/run-pass/fsu-moves-and-copies.rs @@ -48,27 +48,27 @@ fn test0() { let f = DropNoFoo::new(1, 2); let b = DropNoFoo { inner: NoFoo { nopod: ncint(3), ..f.inner }}; let c = DropNoFoo { inner: NoFoo { nopod: ncint(4), ..f.inner }}; - assert_eq!(f.inner.copied, 1); - assert_eq!(f.inner.nopod.v, 2); + fail_unless_eq!(f.inner.copied, 1); + fail_unless_eq!(f.inner.nopod.v, 2); - assert_eq!(b.inner.copied, 1); - assert_eq!(b.inner.nopod.v, 3); + fail_unless_eq!(b.inner.copied, 1); + fail_unless_eq!(b.inner.nopod.v, 3); - assert_eq!(c.inner.copied, 1); - assert_eq!(c.inner.nopod.v, 4); + fail_unless_eq!(c.inner.copied, 1); + fail_unless_eq!(c.inner.nopod.v, 4); // Case 2: Owned let f = DropMoveFoo::new(5, 6); let b = DropMoveFoo { inner: MoveFoo { moved: ~7, ..f.inner }}; let c = DropMoveFoo { inner: MoveFoo { moved: ~8, ..f.inner }}; - assert_eq!(f.inner.copied, 5); - assert_eq!(*f.inner.moved, 6); + fail_unless_eq!(f.inner.copied, 5); + fail_unless_eq!(*f.inner.moved, 6); - assert_eq!(b.inner.copied, 5); - assert_eq!(*b.inner.moved, 7); + fail_unless_eq!(b.inner.copied, 5); + fail_unless_eq!(*b.inner.moved, 7); - assert_eq!(c.inner.copied, 5); - assert_eq!(*c.inner.moved, 8); + fail_unless_eq!(c.inner.copied, 5); + fail_unless_eq!(*c.inner.moved, 8); } fn test1() { @@ -77,10 +77,10 @@ fn test1() { let b = MoveFoo {moved: ~13, ..f}; let c = MoveFoo {copied: 14, ..f}; - assert_eq!(b.copied, 11); - assert_eq!(*b.moved, 13); - assert_eq!(c.copied, 14); - assert_eq!(*c.moved, 12); + fail_unless_eq!(b.copied, 11); + fail_unless_eq!(*b.moved, 13); + fail_unless_eq!(c.copied, 14); + fail_unless_eq!(*c.moved, 12); } fn test2() { @@ -88,10 +88,10 @@ fn test2() { let f = NoFoo::new(21, 22); let b = NoFoo {nopod: ncint(23), ..f}; let c = NoFoo {copied: 24, ..f}; - assert_eq!(b.copied, 21); - assert_eq!(b.nopod.v, 23); - assert_eq!(c.copied, 24); - assert_eq!(c.nopod.v, 22); + fail_unless_eq!(b.copied, 21); + fail_unless_eq!(b.nopod.v, 23); + fail_unless_eq!(c.copied, 24); + fail_unless_eq!(c.nopod.v, 22); } pub fn main() { diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 479f4f8387fb4..a7f0930599405 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -16,5 +16,5 @@ pub fn main() { let a: int = direct(3); // direct let b: int = ho(direct); // indirect unbound - assert_eq!(a, b); + fail_unless_eq!(a, b); } diff --git a/src/test/run-pass/fun-indirect-call.rs b/src/test/run-pass/fun-indirect-call.rs index 72383104b3c41..6284f2bcb449d 100644 --- a/src/test/run-pass/fun-indirect-call.rs +++ b/src/test/run-pass/fun-indirect-call.rs @@ -16,5 +16,5 @@ fn f() -> int { return 42; } pub fn main() { let g: extern fn() -> int = f; let i: int = g(); - assert_eq!(i, 42); + fail_unless_eq!(i, 42); } diff --git a/src/test/run-pass/func-arg-incomplete-pattern.rs b/src/test/run-pass/func-arg-incomplete-pattern.rs index 6dc9ef2fa4bbf..01a9289379df4 100644 --- a/src/test/run-pass/func-arg-incomplete-pattern.rs +++ b/src/test/run-pass/func-arg-incomplete-pattern.rs @@ -26,5 +26,5 @@ pub fn main() { let objptr: *uint = &*obj; let f = Foo {x: obj, y: ~2}; let xptr = foo(f); - assert_eq!(objptr, xptr); + fail_unless_eq!(objptr, xptr); } diff --git a/src/test/run-pass/func-arg-ref-pattern.rs b/src/test/run-pass/func-arg-ref-pattern.rs index 11df22d7433d6..d336ce2d57211 100644 --- a/src/test/run-pass/func-arg-ref-pattern.rs +++ b/src/test/run-pass/func-arg-ref-pattern.rs @@ -27,8 +27,8 @@ pub fn main() { let obj = ~1; let objptr: *uint = &*obj; let xptr = getaddr(obj); - assert_eq!(objptr, xptr); + fail_unless_eq!(objptr, xptr); let obj = ~22; - assert_eq!(checkval(obj), 22); + fail_unless_eq!(checkval(obj), 22); } diff --git a/src/test/run-pass/func-arg-wild-pattern.rs b/src/test/run-pass/func-arg-wild-pattern.rs index 97ba561baea39..9882dbf910425 100644 --- a/src/test/run-pass/func-arg-wild-pattern.rs +++ b/src/test/run-pass/func-arg-wild-pattern.rs @@ -16,5 +16,5 @@ fn foo((x, _): (int, int)) -> int { } pub fn main() { - assert_eq!(foo((22, 23)), 22); + fail_unless_eq!(foo((22, 23)), 22); } diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index 72427b6c53906..5b81ee5101fcd 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -16,5 +16,5 @@ pub fn main() { let expected = @100; let actual = id::<@int>(expected); info!("{:?}", *actual); - assert_eq!(*expected, *actual); + fail_unless_eq!(*expected, *actual); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index a54c68a907b9b..f3df08a3f50df 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -16,5 +16,5 @@ pub fn main() { let expected = ~100; let actual = id::<~int>(expected.clone()); info!("{:?}", *actual); - assert_eq!(*expected, *actual); + fail_unless_eq!(*expected, *actual); } diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index a5f5d56fe06cd..6882c0c41c72d 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -16,5 +16,5 @@ struct Box {x: T, y: T, z: T} pub fn main() { let x: @Box = box_it::(Box{x: 1, y: 2, z: 3}); - assert_eq!(x.y, 2); + fail_unless_eq!(x.y, 2); } diff --git a/src/test/run-pass/generic-default-type-params.rs b/src/test/run-pass/generic-default-type-params.rs index b2d20b859df2a..9dee6f11f0aae 100644 --- a/src/test/run-pass/generic-default-type-params.rs +++ b/src/test/run-pass/generic-default-type-params.rs @@ -32,8 +32,8 @@ impl Foo { impl Foo { fn bar(&self) { let (i, c): (int, char) = self.a; - assert_eq!(Foo { a: i }.bar_int(), i); - assert_eq!(Foo { a: c }.bar_char(), c); + fail_unless_eq!(Foo { a: i }.bar_int(), i); + fail_unless_eq!(Foo { a: c }.bar_char(), c); } } @@ -45,11 +45,11 @@ impl Foo { fn default_foo(x: Foo) { let (i, c): (int, char) = x.a; - assert_eq!(i, 1); - assert_eq!(c, 'a'); + fail_unless_eq!(i, 1); + fail_unless_eq!(c, 'a'); x.bar(); - assert_eq!(x.baz(), (1, 'a')); + fail_unless_eq!(x.baz(), (1, 'a')); } #[deriving(Eq)] @@ -63,5 +63,5 @@ fn main() { default_foo(Foo { a: (1, 'a') }); let x: Baz = Baz(true, BazHelper(false), Some(BazHelper(true))); - assert_eq!(x, Baz(true, BazHelper(false), Some(BazHelper(true)))); + fail_unless_eq!(x, Baz(true, BazHelper(false), Some(BazHelper(true)))); } diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 396ac88bd06de..a1dc5810bbd6a 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -27,6 +27,6 @@ pub fn main() { let b = f::(10); info!("{:?}" ,b.a); info!("{:?}", b.b); - assert_eq!(b.a, 10); - assert_eq!(b.b, 10); + fail_unless_eq!(b.a, 10); + fail_unless_eq!(b.b, 10); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index 1382c01918964..99050b88cc309 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -17,5 +17,5 @@ fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } pub fn main() { let foo: int = 17; let rbfoo: Recbox = reclift::(foo); - assert_eq!(*rbfoo.x, foo); + fail_unless_eq!(*rbfoo.x, foo); } diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 0820923efcfec..6e16fad352671 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -15,5 +15,5 @@ fn reclift(t: T) -> Recbox { return Recbox {x: ~t}; } pub fn main() { let foo: int = 17; let rbfoo: Recbox = reclift::(foo); - assert_eq!(*rbfoo.x, foo); + fail_unless_eq!(*rbfoo.x, foo); } diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index 27dc4ad8069b1..b26ecc9027003 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -23,13 +23,13 @@ pub fn main() { let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::(x); info!("{}", y); - assert_eq!(x, y); + fail_unless_eq!(x, y); b = id::(a); info!("{}", b); - assert_eq!(a, b); + fail_unless_eq!(a, b); q = id::(p); x = p.z; y = q.z; info!("{}", y); - assert_eq!(x, y); + fail_unless_eq!(x, y); } diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index 76db4a01829ab..08b8631c76b67 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -25,5 +25,5 @@ impl Foo for S { pub fn main() { let x = ~S { x: 1 }; let y = x as ~Foo; - assert_eq!(y.get(), 1); + fail_unless_eq!(y.get(), 1); } diff --git a/src/test/run-pass/generic-static-methods.rs b/src/test/run-pass/generic-static-methods.rs index 5832c565d7f4c..2ed32f32c8afd 100644 --- a/src/test/run-pass/generic-static-methods.rs +++ b/src/test/run-pass/generic-static-methods.rs @@ -23,5 +23,5 @@ impl vec_utils for ~[T] { } pub fn main() { - assert_eq!(vec_utils::map_(&~[1,2,3], |&x| x+1), ~[2,3,4]); + fail_unless_eq!(vec_utils::map_(&~[1,2,3], |&x| x+1), ~[2,3,4]); } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index 0f5cc364d482d..3bf9bab9a3deb 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -23,8 +23,8 @@ pub fn main() { some(t) => { info!("{:?}", t.x); info!("{:?}", t.y); - assert_eq!(t.x, 17); - assert_eq!(t.y, 42); + fail_unless_eq!(t.x, 17); + fail_unless_eq!(t.y, 42); } } } diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index 9626884be9dd9..51e993fe9caa8 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -12,6 +12,6 @@ fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } pub fn main() { info!("{:?}", get_third((1, 2, 3))); - assert_eq!(get_third((1, 2, 3)), 3); - assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8); + fail_unless_eq!(get_third((1, 2, 3)), 3); + fail_unless_eq!(get_third((5u8, 6u8, 7u8)), 7u8); } diff --git a/src/test/run-pass/generic-type.rs b/src/test/run-pass/generic-type.rs index 0ff7cedc6c5f1..d1111fc2f4f32 100644 --- a/src/test/run-pass/generic-type.rs +++ b/src/test/run-pass/generic-type.rs @@ -14,6 +14,6 @@ struct Pair {x: T, y: T} pub fn main() { let x: Pair = Pair {x: 10, y: 12}; - assert_eq!(x.x, 10); - assert_eq!(x.y, 12); + fail_unless_eq!(x.x, 10); + fail_unless_eq!(x.y, 12); } diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 3b817b314cf14..0b5eb159030a2 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -14,5 +14,5 @@ fn box_it(x: Triple) -> ~Triple { return ~x; } pub fn main() { let x: ~Triple = box_it::(Triple{x: 1, y: 2, z: 3}); - assert_eq!(x.y, 2); + fail_unless_eq!(x.y, 2); } diff --git a/src/test/run-pass/glob-std.rs b/src/test/run-pass/glob-std.rs index 960cb50ecace2..601607bee8d5d 100644 --- a/src/test/run-pass/glob-std.rs +++ b/src/test/run-pass/glob-std.rs @@ -65,129 +65,129 @@ pub fn main() { mk_file("xyz/y", false); mk_file("xyz/z", false); - assert_eq!(glob_vec(""), ~[]); - assert_eq!(glob_vec("."), ~[]); - assert_eq!(glob_vec(".."), ~[]); + fail_unless_eq!(glob_vec(""), ~[]); + fail_unless_eq!(glob_vec("."), ~[]); + fail_unless_eq!(glob_vec(".."), ~[]); - assert_eq!(glob_vec("aaa"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aaa/"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("a"), ~[]); - assert_eq!(glob_vec("aa"), ~[]); - assert_eq!(glob_vec("aaaa"), ~[]); + fail_unless_eq!(glob_vec("aaa"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aaa/"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("a"), ~[]); + fail_unless_eq!(glob_vec("aa"), ~[]); + fail_unless_eq!(glob_vec("aaaa"), ~[]); - assert_eq!(glob_vec("aaa/apple"), ~[abs_path("aaa/apple")]); - assert_eq!(glob_vec("aaa/apple/nope"), ~[]); + fail_unless_eq!(glob_vec("aaa/apple"), ~[abs_path("aaa/apple")]); + fail_unless_eq!(glob_vec("aaa/apple/nope"), ~[]); // windows should support both / and \ as directory separators if os::consts::FAMILY == os::consts::windows::FAMILY { - assert_eq!(glob_vec("aaa\\apple"), ~[abs_path("aaa/apple")]); + fail_unless_eq!(glob_vec("aaa\\apple"), ~[abs_path("aaa/apple")]); } - assert_eq!(glob_vec("???/"), ~[ + fail_unless_eq!(glob_vec("???/"), ~[ abs_path("aaa"), abs_path("bbb"), abs_path("ccc"), abs_path("xyz")]); - assert_eq!(glob_vec("aaa/tomato/tom?to.txt"), ~[ + fail_unless_eq!(glob_vec("aaa/tomato/tom?to.txt"), ~[ abs_path("aaa/tomato/tomato.txt"), abs_path("aaa/tomato/tomoto.txt")]); - assert_eq!(glob_vec("xyz/?"), ~[ + fail_unless_eq!(glob_vec("xyz/?"), ~[ abs_path("xyz/x"), abs_path("xyz/y"), abs_path("xyz/z")]); - assert_eq!(glob_vec("a*"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("*a*"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("a*a"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aaa*"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("*aaa"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("*aaa*"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("*a*a*a*"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aaa*/"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("a*"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("*a*"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("a*a"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aaa*"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("*aaa"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("*aaa*"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("*a*a*a*"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aaa*/"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aaa/*"), ~[ + fail_unless_eq!(glob_vec("aaa/*"), ~[ abs_path("aaa/apple"), abs_path("aaa/orange"), abs_path("aaa/tomato")]); - assert_eq!(glob_vec("aaa/*a*"), ~[ + fail_unless_eq!(glob_vec("aaa/*a*"), ~[ abs_path("aaa/apple"), abs_path("aaa/orange"), abs_path("aaa/tomato")]); - assert_eq!(glob_vec("*/*/*.txt"), ~[ + fail_unless_eq!(glob_vec("*/*/*.txt"), ~[ abs_path("aaa/tomato/tomato.txt"), abs_path("aaa/tomato/tomoto.txt")]); - assert_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), ~[ + fail_unless_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), ~[ abs_path("aaa/tomato/tomato.txt"), abs_path("aaa/tomato/tomoto.txt")]); - assert_eq!(glob_vec("aa[a]"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aa[abc]"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("a[bca]a"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aa[b]"), ~[]); - assert_eq!(glob_vec("aa[xyz]"), ~[]); - assert_eq!(glob_vec("aa[]]"), ~[]); + fail_unless_eq!(glob_vec("aa[a]"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aa[abc]"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("a[bca]a"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aa[b]"), ~[]); + fail_unless_eq!(glob_vec("aa[xyz]"), ~[]); + fail_unless_eq!(glob_vec("aa[]]"), ~[]); - assert_eq!(glob_vec("aa[!b]"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aa[!bcd]"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("a[!bcd]a"), ~[abs_path("aaa")]); - assert_eq!(glob_vec("aa[!a]"), ~[]); - assert_eq!(glob_vec("aa[!abc]"), ~[]); + fail_unless_eq!(glob_vec("aa[!b]"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aa[!bcd]"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("a[!bcd]a"), ~[abs_path("aaa")]); + fail_unless_eq!(glob_vec("aa[!a]"), ~[]); + fail_unless_eq!(glob_vec("aa[!abc]"), ~[]); - assert_eq!(glob_vec("bbb/specials/[[]"), ~[abs_path("bbb/specials/[")]); - assert_eq!(glob_vec("bbb/specials/!"), ~[abs_path("bbb/specials/!")]); - assert_eq!(glob_vec("bbb/specials/[]]"), ~[abs_path("bbb/specials/]")]); + fail_unless_eq!(glob_vec("bbb/specials/[[]"), ~[abs_path("bbb/specials/[")]); + fail_unless_eq!(glob_vec("bbb/specials/!"), ~[abs_path("bbb/specials/!")]); + fail_unless_eq!(glob_vec("bbb/specials/[]]"), ~[abs_path("bbb/specials/]")]); if os::consts::FAMILY != os::consts::windows::FAMILY { - assert_eq!(glob_vec("bbb/specials/[*]"), ~[abs_path("bbb/specials/*")]); - assert_eq!(glob_vec("bbb/specials/[?]"), ~[abs_path("bbb/specials/?")]); + fail_unless_eq!(glob_vec("bbb/specials/[*]"), ~[abs_path("bbb/specials/*")]); + fail_unless_eq!(glob_vec("bbb/specials/[?]"), ~[abs_path("bbb/specials/?")]); } if os::consts::FAMILY == os::consts::windows::FAMILY { - assert_eq!(glob_vec("bbb/specials/[![]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[![]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/]")]); - assert_eq!(glob_vec("bbb/specials/[!]]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!]]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/[")]); - assert_eq!(glob_vec("bbb/specials/[!!]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!!]"), ~[ abs_path("bbb/specials/["), abs_path("bbb/specials/]")]); } else { - assert_eq!(glob_vec("bbb/specials/[![]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[![]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/*"), abs_path("bbb/specials/?"), abs_path("bbb/specials/]")]); - assert_eq!(glob_vec("bbb/specials/[!]]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!]]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/*"), abs_path("bbb/specials/?"), abs_path("bbb/specials/[")]); - assert_eq!(glob_vec("bbb/specials/[!!]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!!]"), ~[ abs_path("bbb/specials/*"), abs_path("bbb/specials/?"), abs_path("bbb/specials/["), abs_path("bbb/specials/]")]); - assert_eq!(glob_vec("bbb/specials/[!*]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!*]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/?"), abs_path("bbb/specials/["), abs_path("bbb/specials/]")]); - assert_eq!(glob_vec("bbb/specials/[!?]"), ~[ + fail_unless_eq!(glob_vec("bbb/specials/[!?]"), ~[ abs_path("bbb/specials/!"), abs_path("bbb/specials/*"), abs_path("bbb/specials/["), diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index 4496769ec5646..a1991a8dff62e 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -19,5 +19,5 @@ fn xyzzy(q: Q) -> uint { pub fn main() { - assert_eq!(xyzzy(R(Some(5))), 0); + fail_unless_eq!(xyzzy(R(Some(5))), 0); } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index bf29fa603c7ec..0aa17946a87a2 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -13,7 +13,7 @@ struct Pair { x: int, y: int } pub fn main() { let a = match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; - assert_eq!(a, 2); + fail_unless_eq!(a, 2); let b = match Pair {x: 10, y: 20} { @@ -21,5 +21,5 @@ pub fn main() { Pair {x: x, y: y} if x == 10 && y == 20 => { 2 } Pair {x: _x, y: _y} => { 3 } }; - assert_eq!(b, 2); + fail_unless_eq!(b, 2); } diff --git a/src/test/run-pass/hygiene-dodging-1.rs b/src/test/run-pass/hygiene-dodging-1.rs index 3969394a26b93..6230143b70eb1 100644 --- a/src/test/run-pass/hygiene-dodging-1.rs +++ b/src/test/run-pass/hygiene-dodging-1.rs @@ -17,5 +17,5 @@ pub fn main(){ let x = 9; // use it to avoid warnings: x+3; - assert_eq!(x::g(),14); + fail_unless_eq!(x::g(),14); } diff --git a/src/test/run-pass/i8-incr.rs b/src/test/run-pass/i8-incr.rs index fbb4e446dd55e..d6c5397d4b681 100644 --- a/src/test/run-pass/i8-incr.rs +++ b/src/test/run-pass/i8-incr.rs @@ -16,5 +16,5 @@ pub fn main() { let y: i8 = -12i8; x = x + 1i8; x = x - 1i8; - assert_eq!(x, y); + fail_unless_eq!(x, y); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index ca798a77a4fd1..1f62bf2d357e7 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -33,7 +33,7 @@ impl fmt::Signed for B { } } -macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a, $b.to_owned()) }) +macro_rules! t(($a:expr, $b:expr) => { fail_unless_eq!($a, $b.to_owned()) }) pub fn main() { // Make sure there's a poly formatter that takes anything diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index f2117efb0bbe6..dac6d6f0b5c24 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -19,5 +19,5 @@ use std::vec::*; pub fn main() { let mut v = from_elem(0u, 0); v = append(v, [4, 2]); - assert_eq!(from_fn(2, |i| 2*(i+1)), ~[2, 4]); + fail_unless_eq!(from_fn(2, |i| 2*(i+1)), ~[2, 4]); } diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs index 447ee2c890c22..b3263b347e429 100644 --- a/src/test/run-pass/inferred-suffix-in-pattern-range.rs +++ b/src/test/run-pass/inferred-suffix-in-pattern-range.rs @@ -14,19 +14,19 @@ pub fn main() { 0 .. 1 => { ~"not many" } _ => { ~"lots" } }; - assert_eq!(x_message, ~"lots"); + fail_unless_eq!(x_message, ~"lots"); let y = 2i; let y_message = match y { 0 .. 1 => { ~"not many" } _ => { ~"lots" } }; - assert_eq!(y_message, ~"lots"); + fail_unless_eq!(y_message, ~"lots"); let z = 1u64; let z_message = match z { 0 .. 1 => { ~"not many" } _ => { ~"lots" } }; - assert_eq!(z_message, ~"not many"); + fail_unless_eq!(z_message, ~"not many"); } diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index ede67275ba9d7..22e3f1281c00a 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -39,7 +39,7 @@ fn test_box() { { let _a = @r(i); } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } fn test_rec() { @@ -47,7 +47,7 @@ fn test_rec() { { let _a = Box {x: r(i)}; } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } fn test_tag() { @@ -59,7 +59,7 @@ fn test_tag() { { let _a = t0(r(i)); } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } fn test_tup() { @@ -67,7 +67,7 @@ fn test_tup() { { let _a = (r(i), 0); } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } fn test_unique() { @@ -75,7 +75,7 @@ fn test_unique() { { let _a = ~r(i); } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } fn test_box_rec() { @@ -85,7 +85,7 @@ fn test_box_rec() { x: r(i) }; } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } pub fn main() { diff --git a/src/test/run-pass/inner-static.rs b/src/test/run-pass/inner-static.rs index 3e04a8a3922e3..6bbb4bf48a02a 100644 --- a/src/test/run-pass/inner-static.rs +++ b/src/test/run-pass/inner-static.rs @@ -17,7 +17,7 @@ pub fn main() { let a = inner_static::A::<()>; let b = inner_static::B::<()>; let c = inner_static::test::A::<()>; - assert_eq!(a.bar(), 2); - assert_eq!(b.bar(), 4); - assert_eq!(c.bar(), 6); + fail_unless_eq!(a.bar(), 2); + fail_unless_eq!(b.bar(), 4); + fail_unless_eq!(c.bar(), 6); } diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs index ad414bec22692..a17d32916e7d9 100644 --- a/src/test/run-pass/int-conversion-coherence.rs +++ b/src/test/run-pass/int-conversion-coherence.rs @@ -21,5 +21,5 @@ impl foo of plus for uint { fn plus() -> int { self as int + 20 } } impl foo of plus for int { fn plus() -> int { self + 10 } } pub fn main() { - assert_eq!(10.plus(), 20); + fail_unless_eq!(10.plus(), 20); } diff --git a/src/test/run-pass/integer-literal-radix.rs b/src/test/run-pass/integer-literal-radix.rs index 0423e7b89f077..3d3044c015605 100644 --- a/src/test/run-pass/integer-literal-radix.rs +++ b/src/test/run-pass/integer-literal-radix.rs @@ -16,12 +16,12 @@ pub fn main() { let e = -0o755; let f = -0b10101; - assert_eq!(a, 48879); - assert_eq!(b, 493); - assert_eq!(c, 21); - assert_eq!(d, -48879); - assert_eq!(e, -493); - assert_eq!(f, -21); + fail_unless_eq!(a, 48879); + fail_unless_eq!(b, 493); + fail_unless_eq!(c, 21); + fail_unless_eq!(d, -48879); + fail_unless_eq!(e, -493); + fail_unless_eq!(f, -21); } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs index edc71b524e337..4f25da00f7899 100644 --- a/src/test/run-pass/integral-indexing.rs +++ b/src/test/run-pass/integral-indexing.rs @@ -15,16 +15,16 @@ pub fn main() { let v: ~[int] = ~[0, 1, 2, 3, 4, 5]; let s: ~str = ~"abcdef"; - assert_eq!(v[3u], 3); - assert_eq!(v[3u8], 3); - assert_eq!(v[3i8], 3); - assert_eq!(v[3u32], 3); - assert_eq!(v[3i32], 3); + fail_unless_eq!(v[3u], 3); + fail_unless_eq!(v[3u8], 3); + fail_unless_eq!(v[3i8], 3); + fail_unless_eq!(v[3u32], 3); + fail_unless_eq!(v[3i32], 3); info!("{}", v[3u8]); - assert_eq!(s[3u], 'd' as u8); - assert_eq!(s[3u8], 'd' as u8); - assert_eq!(s[3i8], 'd' as u8); - assert_eq!(s[3u32], 'd' as u8); - assert_eq!(s[3i32], 'd' as u8); + fail_unless_eq!(s[3u], 'd' as u8); + fail_unless_eq!(s[3u8], 'd' as u8); + fail_unless_eq!(s[3i8], 'd' as u8); + fail_unless_eq!(s[3u32], 'd' as u8); + fail_unless_eq!(s[3i32], 'd' as u8); info!("{}", s[3u8]); } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 010ab8be7478e..bd06dfd8d10c0 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -25,8 +25,8 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::(), 8u); - assert_eq!(::rusti::min_align_of::(), 4u); + fail_unless_eq!(::rusti::pref_align_of::(), 8u); + fail_unless_eq!(::rusti::min_align_of::(), 4u); } } @@ -34,8 +34,8 @@ mod m { #[cfg(target_arch = "x86_64")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::(), 8u); - assert_eq!(::rusti::min_align_of::(), 8u); + fail_unless_eq!(::rusti::pref_align_of::(), 8u); + fail_unless_eq!(::rusti::min_align_of::(), 8u); } } } @@ -46,8 +46,8 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::(), 8u); - assert_eq!(::rusti::min_align_of::(), 8u); + fail_unless_eq!(::rusti::pref_align_of::(), 8u); + fail_unless_eq!(::rusti::min_align_of::(), 8u); } } } @@ -58,8 +58,8 @@ mod m { #[cfg(target_arch = "arm")] pub fn main() { unsafe { - assert_eq!(::rusti::pref_align_of::(), 8u); - assert_eq!(::rusti::min_align_of::(), 8u); + fail_unless_eq!(::rusti::pref_align_of::(), 8u); + fail_unless_eq!(::rusti::min_align_of::(), 8u); } } } diff --git a/src/test/run-pass/intrinsic-atomics-cc.rs b/src/test/run-pass/intrinsic-atomics-cc.rs index 7fda83a14bb61..7973c3e74b23c 100644 --- a/src/test/run-pass/intrinsic-atomics-cc.rs +++ b/src/test/run-pass/intrinsic-atomics-cc.rs @@ -17,5 +17,5 @@ use cci_intrinsic::atomic_xchg; pub fn main() { let mut x = 1; atomic_xchg(&mut x, 5); - assert_eq!(x, 5); + fail_unless_eq!(x, 5); } diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index d6e394a345e22..e3275cbbefa78 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -38,41 +38,41 @@ pub fn main() { unsafe { let mut x = ~1; - assert_eq!(rusti::atomic_load(x), 1); + fail_unless_eq!(rusti::atomic_load(x), 1); *x = 5; - assert_eq!(rusti::atomic_load_acq(x), 5); + fail_unless_eq!(rusti::atomic_load_acq(x), 5); rusti::atomic_store(x,3); - assert_eq!(*x, 3); + fail_unless_eq!(*x, 3); rusti::atomic_store_rel(x,1); - assert_eq!(*x, 1); + fail_unless_eq!(*x, 1); - assert_eq!(rusti::atomic_cxchg(x, 1, 2), 1); - assert_eq!(*x, 2); + fail_unless_eq!(rusti::atomic_cxchg(x, 1, 2), 1); + fail_unless_eq!(*x, 2); - assert_eq!(rusti::atomic_cxchg_acq(x, 1, 3), 2); - assert_eq!(*x, 2); + fail_unless_eq!(rusti::atomic_cxchg_acq(x, 1, 3), 2); + fail_unless_eq!(*x, 2); - assert_eq!(rusti::atomic_cxchg_rel(x, 2, 1), 2); - assert_eq!(*x, 1); + fail_unless_eq!(rusti::atomic_cxchg_rel(x, 2, 1), 2); + fail_unless_eq!(*x, 1); - assert_eq!(rusti::atomic_xchg(x, 0), 1); - assert_eq!(*x, 0); + fail_unless_eq!(rusti::atomic_xchg(x, 0), 1); + fail_unless_eq!(*x, 0); - assert_eq!(rusti::atomic_xchg_acq(x, 1), 0); - assert_eq!(*x, 1); + fail_unless_eq!(rusti::atomic_xchg_acq(x, 1), 0); + fail_unless_eq!(*x, 1); - assert_eq!(rusti::atomic_xchg_rel(x, 0), 1); - assert_eq!(*x, 0); + fail_unless_eq!(rusti::atomic_xchg_rel(x, 0), 1); + fail_unless_eq!(*x, 0); - assert_eq!(rusti::atomic_xadd(x, 1), 0); - assert_eq!(rusti::atomic_xadd_acq(x, 1), 1); - assert_eq!(rusti::atomic_xadd_rel(x, 1), 2); - assert_eq!(*x, 3); + fail_unless_eq!(rusti::atomic_xadd(x, 1), 0); + fail_unless_eq!(rusti::atomic_xadd_acq(x, 1), 1); + fail_unless_eq!(rusti::atomic_xadd_rel(x, 1), 2); + fail_unless_eq!(*x, 3); - assert_eq!(rusti::atomic_xsub(x, 1), 3); - assert_eq!(rusti::atomic_xsub_acq(x, 1), 2); - assert_eq!(rusti::atomic_xsub_rel(x, 1), 1); - assert_eq!(*x, 0); + fail_unless_eq!(rusti::atomic_xsub(x, 1), 3); + fail_unless_eq!(rusti::atomic_xsub_acq(x, 1), 2); + fail_unless_eq!(rusti::atomic_xsub_rel(x, 1), 1); + fail_unless_eq!(*x, 0); } } diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index f42d5ff2e5267..5b5c0d00904c0 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -23,7 +23,7 @@ pub fn main() { let mut y = rusti::init(); let mut z: *uint = transmute(&x); rusti::move_val_init(&mut y, x); - assert_eq!(*y, 1); - assert_eq!(*z, 0); // `x` is nulled out, not directly visible + fail_unless_eq!(*y, 1); + fail_unless_eq!(*z, 0); // `x` is nulled out, not directly visible } } diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index 9c62f5052b2a6..66b92e470bfcc 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -41,83 +41,83 @@ pub fn main() { unsafe { use rusti::*; - assert_eq!(ctpop8(0i8), 0i8); - assert_eq!(ctpop16(0i16), 0i16); - assert_eq!(ctpop32(0i32), 0i32); - assert_eq!(ctpop64(0i64), 0i64); - - assert_eq!(ctpop8(1i8), 1i8); - assert_eq!(ctpop16(1i16), 1i16); - assert_eq!(ctpop32(1i32), 1i32); - assert_eq!(ctpop64(1i64), 1i64); - - assert_eq!(ctpop8(10i8), 2i8); - assert_eq!(ctpop16(10i16), 2i16); - assert_eq!(ctpop32(10i32), 2i32); - assert_eq!(ctpop64(10i64), 2i64); - - assert_eq!(ctpop8(100i8), 3i8); - assert_eq!(ctpop16(100i16), 3i16); - assert_eq!(ctpop32(100i32), 3i32); - assert_eq!(ctpop64(100i64), 3i64); - - assert_eq!(ctpop8(-1i8), 8i8); - assert_eq!(ctpop16(-1i16), 16i16); - assert_eq!(ctpop32(-1i32), 32i32); - assert_eq!(ctpop64(-1i64), 64i64); - - assert_eq!(ctlz8(0i8), 8i8); - assert_eq!(ctlz16(0i16), 16i16); - assert_eq!(ctlz32(0i32), 32i32); - assert_eq!(ctlz64(0i64), 64i64); - - assert_eq!(ctlz8(1i8), 7i8); - assert_eq!(ctlz16(1i16), 15i16); - assert_eq!(ctlz32(1i32), 31i32); - assert_eq!(ctlz64(1i64), 63i64); - - assert_eq!(ctlz8(10i8), 4i8); - assert_eq!(ctlz16(10i16), 12i16); - assert_eq!(ctlz32(10i32), 28i32); - assert_eq!(ctlz64(10i64), 60i64); - - assert_eq!(ctlz8(100i8), 1i8); - assert_eq!(ctlz16(100i16), 9i16); - assert_eq!(ctlz32(100i32), 25i32); - assert_eq!(ctlz64(100i64), 57i64); - - assert_eq!(cttz8(-1i8), 0i8); - assert_eq!(cttz16(-1i16), 0i16); - assert_eq!(cttz32(-1i32), 0i32); - assert_eq!(cttz64(-1i64), 0i64); - - assert_eq!(cttz8(0i8), 8i8); - assert_eq!(cttz16(0i16), 16i16); - assert_eq!(cttz32(0i32), 32i32); - assert_eq!(cttz64(0i64), 64i64); - - assert_eq!(cttz8(1i8), 0i8); - assert_eq!(cttz16(1i16), 0i16); - assert_eq!(cttz32(1i32), 0i32); - assert_eq!(cttz64(1i64), 0i64); - - assert_eq!(cttz8(10i8), 1i8); - assert_eq!(cttz16(10i16), 1i16); - assert_eq!(cttz32(10i32), 1i32); - assert_eq!(cttz64(10i64), 1i64); - - assert_eq!(cttz8(100i8), 2i8); - assert_eq!(cttz16(100i16), 2i16); - assert_eq!(cttz32(100i32), 2i32); - assert_eq!(cttz64(100i64), 2i64); - - assert_eq!(cttz8(-1i8), 0i8); - assert_eq!(cttz16(-1i16), 0i16); - assert_eq!(cttz32(-1i32), 0i32); - assert_eq!(cttz64(-1i64), 0i64); - - assert_eq!(bswap16(0x0A0Bi16), 0x0B0Ai16); - assert_eq!(bswap32(0x0ABBCC0Di32), 0x0DCCBB0Ai32); - assert_eq!(bswap64(0x0122334455667708i64), 0x0877665544332201i64); + fail_unless_eq!(ctpop8(0i8), 0i8); + fail_unless_eq!(ctpop16(0i16), 0i16); + fail_unless_eq!(ctpop32(0i32), 0i32); + fail_unless_eq!(ctpop64(0i64), 0i64); + + fail_unless_eq!(ctpop8(1i8), 1i8); + fail_unless_eq!(ctpop16(1i16), 1i16); + fail_unless_eq!(ctpop32(1i32), 1i32); + fail_unless_eq!(ctpop64(1i64), 1i64); + + fail_unless_eq!(ctpop8(10i8), 2i8); + fail_unless_eq!(ctpop16(10i16), 2i16); + fail_unless_eq!(ctpop32(10i32), 2i32); + fail_unless_eq!(ctpop64(10i64), 2i64); + + fail_unless_eq!(ctpop8(100i8), 3i8); + fail_unless_eq!(ctpop16(100i16), 3i16); + fail_unless_eq!(ctpop32(100i32), 3i32); + fail_unless_eq!(ctpop64(100i64), 3i64); + + fail_unless_eq!(ctpop8(-1i8), 8i8); + fail_unless_eq!(ctpop16(-1i16), 16i16); + fail_unless_eq!(ctpop32(-1i32), 32i32); + fail_unless_eq!(ctpop64(-1i64), 64i64); + + fail_unless_eq!(ctlz8(0i8), 8i8); + fail_unless_eq!(ctlz16(0i16), 16i16); + fail_unless_eq!(ctlz32(0i32), 32i32); + fail_unless_eq!(ctlz64(0i64), 64i64); + + fail_unless_eq!(ctlz8(1i8), 7i8); + fail_unless_eq!(ctlz16(1i16), 15i16); + fail_unless_eq!(ctlz32(1i32), 31i32); + fail_unless_eq!(ctlz64(1i64), 63i64); + + fail_unless_eq!(ctlz8(10i8), 4i8); + fail_unless_eq!(ctlz16(10i16), 12i16); + fail_unless_eq!(ctlz32(10i32), 28i32); + fail_unless_eq!(ctlz64(10i64), 60i64); + + fail_unless_eq!(ctlz8(100i8), 1i8); + fail_unless_eq!(ctlz16(100i16), 9i16); + fail_unless_eq!(ctlz32(100i32), 25i32); + fail_unless_eq!(ctlz64(100i64), 57i64); + + fail_unless_eq!(cttz8(-1i8), 0i8); + fail_unless_eq!(cttz16(-1i16), 0i16); + fail_unless_eq!(cttz32(-1i32), 0i32); + fail_unless_eq!(cttz64(-1i64), 0i64); + + fail_unless_eq!(cttz8(0i8), 8i8); + fail_unless_eq!(cttz16(0i16), 16i16); + fail_unless_eq!(cttz32(0i32), 32i32); + fail_unless_eq!(cttz64(0i64), 64i64); + + fail_unless_eq!(cttz8(1i8), 0i8); + fail_unless_eq!(cttz16(1i16), 0i16); + fail_unless_eq!(cttz32(1i32), 0i32); + fail_unless_eq!(cttz64(1i64), 0i64); + + fail_unless_eq!(cttz8(10i8), 1i8); + fail_unless_eq!(cttz16(10i16), 1i16); + fail_unless_eq!(cttz32(10i32), 1i32); + fail_unless_eq!(cttz64(10i64), 1i64); + + fail_unless_eq!(cttz8(100i8), 2i8); + fail_unless_eq!(cttz16(100i16), 2i16); + fail_unless_eq!(cttz32(100i32), 2i32); + fail_unless_eq!(cttz64(100i64), 2i64); + + fail_unless_eq!(cttz8(-1i8), 0i8); + fail_unless_eq!(cttz16(-1i16), 0i16); + fail_unless_eq!(cttz32(-1i32), 0i32); + fail_unless_eq!(cttz64(-1i64), 0i64); + + fail_unless_eq!(bswap16(0x0A0Bi16), 0x0B0Ai16); + fail_unless_eq!(bswap32(0x0ABBCC0Di32), 0x0DCCBB0Ai32); + fail_unless_eq!(bswap64(0x0122334455667708i64), 0x0877665544332201i64); } } diff --git a/src/test/run-pass/issue-1112.rs b/src/test/run-pass/issue-1112.rs index 22c88c874f096..3c484fe883b34 100644 --- a/src/test/run-pass/issue-1112.rs +++ b/src/test/run-pass/issue-1112.rs @@ -35,10 +35,10 @@ pub fn main() { } fn bar(x: X) { - assert_eq!(x.b, 9u8); - assert_eq!(x.c, true); - assert_eq!(x.d, 10u8); - assert_eq!(x.e, 11u16); - assert_eq!(x.f, 12u8); - assert_eq!(x.g, 13u8); + fail_unless_eq!(x.b, 9u8); + fail_unless_eq!(x.c, true); + fail_unless_eq!(x.d, 10u8); + fail_unless_eq!(x.e, 11u16); + fail_unless_eq!(x.f, 12u8); + fail_unless_eq!(x.g, 13u8); } diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index d8e4d04dded54..c5aa928415892 100644 --- a/src/test/run-pass/issue-1701.rs +++ b/src/test/run-pass/issue-1701.rs @@ -24,8 +24,8 @@ fn noise(a: animal) -> Option<~str> { } pub fn main() { - assert_eq!(noise(cat(tabby)), Some(~"meow")); - assert_eq!(noise(dog(pug)), Some(~"woof")); - assert_eq!(noise(rabbit(~"Hilbert", upright)), None); - assert_eq!(noise(tiger), Some(~"roar")); + fail_unless_eq!(noise(cat(tabby)), Some(~"meow")); + fail_unless_eq!(noise(dog(pug)), Some(~"woof")); + fail_unless_eq!(noise(rabbit(~"Hilbert", upright)), None); + fail_unless_eq!(noise(tiger), Some(~"roar")); } diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index f482790ef4c45..6944f8bd8d2d6 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -42,5 +42,5 @@ mod m { pub fn main() { let mut y: int = 5; let x: &mut int = &mut y; - assert_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double); + fail_unless_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double); } diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index 4a1bb2ea8776c..14ba164446cb2 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -28,5 +28,5 @@ pub fn main() { } error!("{:?}", x); - assert_eq!(x, 42); + fail_unless_eq!(x, 42); } diff --git a/src/test/run-pass/issue-2428.rs b/src/test/run-pass/issue-2428.rs index 4e73be8d84e3a..c57fb7d564ead 100644 --- a/src/test/run-pass/issue-2428.rs +++ b/src/test/run-pass/issue-2428.rs @@ -16,5 +16,5 @@ pub fn main() { Bar = quux } - assert_eq!(Bar as int, quux); + fail_unless_eq!(Bar as int, quux); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 2d1bbe1dfb070..bcfcf8e8882c4 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -115,7 +115,7 @@ pub mod pipes { return Some(payload.unwrap()) } terminated => { - assert_eq!(old_state, terminated); + fail_unless_eq!(old_state, terminated); return None; } } diff --git a/src/test/run-pass/issue-2748-b.rs b/src/test/run-pass/issue-2748-b.rs index 3ca8d49eb864d..dde801ced5f36 100644 --- a/src/test/run-pass/issue-2748-b.rs +++ b/src/test/run-pass/issue-2748-b.rs @@ -14,6 +14,6 @@ pub fn main() { let x = &[1,2,3]; let y = x; let z = thing(x); - assert_eq!(z[2], x[2]); - assert_eq!(z[1], y[1]); + fail_unless_eq!(z[2], x[2]); + fail_unless_eq!(z[1], y[1]); } diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index 1e1db39378014..0e6392fdd49cb 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -24,13 +24,13 @@ impl Drop for Kitty { #[cfg(target_arch = "x86_64")] pub fn main() { - assert_eq!(mem::size_of::(), 8 as uint); - assert_eq!(mem::size_of::(), 16 as uint); + fail_unless_eq!(mem::size_of::(), 8 as uint); + fail_unless_eq!(mem::size_of::(), 16 as uint); } #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] pub fn main() { - assert_eq!(mem::size_of::(), 4 as uint); - assert_eq!(mem::size_of::(), 8 as uint); + fail_unless_eq!(mem::size_of::(), 4 as uint); + fail_unless_eq!(mem::size_of::(), 8 as uint); } diff --git a/src/test/run-pass/issue-2936.rs b/src/test/run-pass/issue-2936.rs index 183eb6e079f05..edba4cd1bad61 100644 --- a/src/test/run-pass/issue-2936.rs +++ b/src/test/run-pass/issue-2936.rs @@ -34,5 +34,5 @@ fn cbar(x: int) -> cbar { pub fn main() { let x: int = foo::(cbar(5)); - assert_eq!(x, 5); + fail_unless_eq!(x, 5); } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 94e7297f17993..3d9bf53273124 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -43,5 +43,5 @@ pub fn main() { println!("{} => {} vs {}", i, bools[i], bools2[i]); } - assert_eq!(bools, bools2); + fail_unless_eq!(bools, bools2); } diff --git a/src/test/run-pass/issue-3091.rs b/src/test/run-pass/issue-3091.rs index c4c2c2b7da878..50f8c0e3eb538 100644 --- a/src/test/run-pass/issue-3091.rs +++ b/src/test/run-pass/issue-3091.rs @@ -11,5 +11,5 @@ pub fn main() { let x = 1; let y = 1; - assert_eq!(&x, &y); + fail_unless_eq!(&x, &y); } diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index 6921ba649e6c4..a124de579c1e6 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -11,6 +11,6 @@ pub fn main() { let mut x = 0; for _ in range(0, 4096) { x += 1; } - assert_eq!(x, 4096); + fail_unless_eq!(x, 4096); println!("x = {}", x); } diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index 8cc91134c5869..e710f815e4bf9 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -12,5 +12,5 @@ pub fn main() { let mut x = ~3; x = x; - assert_eq!(*x, 3); + fail_unless_eq!(*x, 3); } diff --git a/src/test/run-pass/issue-3683.rs b/src/test/run-pass/issue-3683.rs index aa7fa0cb5f047..4082bdf6e75d5 100644 --- a/src/test/run-pass/issue-3683.rs +++ b/src/test/run-pass/issue-3683.rs @@ -23,5 +23,5 @@ impl Foo for int { } pub fn main() { - assert_eq!(3.b(), 5); + fail_unless_eq!(3.b(), 5); } diff --git a/src/test/run-pass/issue-3796.rs b/src/test/run-pass/issue-3796.rs index 37cccf717d5d5..ae3cdc69b3928 100644 --- a/src/test/run-pass/issue-3796.rs +++ b/src/test/run-pass/issue-3796.rs @@ -14,7 +14,7 @@ pub fn main() { let mut x = 1; let f: || -> int = || { x + 20 }; - assert_eq!(f(), 21); + fail_unless_eq!(f(), 21); x += 1; - assert_eq!(f(), 22); + fail_unless_eq!(f(), 22); } diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index 86cdd6135ecf2..8356e44ac70df 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -36,5 +36,5 @@ impl Movable for Point {} pub fn main() { let mut p = Point{ x: 1, y: 2}; p.translate(3); - assert_eq!(p.X(), 4); + fail_unless_eq!(p.X(), 4); } diff --git a/src/test/run-pass/issue-3979-xcrate.rs b/src/test/run-pass/issue-3979-xcrate.rs index a50287de97eab..e9f381d97f1e7 100644 --- a/src/test/run-pass/issue-3979-xcrate.rs +++ b/src/test/run-pass/issue-3979-xcrate.rs @@ -29,5 +29,5 @@ impl Movable for Point {} pub fn main() { let mut p = Point{ x: 1, y: 2}; p.translate(3); - assert_eq!(p.X(), 4); + fail_unless_eq!(p.X(), 4); } diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index 4f69342830b93..68dea8f380855 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -37,5 +37,5 @@ impl Movable for Point {} pub fn main() { let mut p = Point{ x: 1, y: 2}; p.translate(3); - assert_eq!(p.X(), 4); + fail_unless_eq!(p.X(), 4); } diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index f6c29658e6a31..7b10e2a1b7a2f 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -33,13 +33,13 @@ priv fn parse_data(len: uint, io: @io::Reader) -> Result { let res = if (len > 0) { let bytes = io.read_bytes(len as uint); - assert_eq!(bytes.len(), len); + fail_unless_eq!(bytes.len(), len); Data(bytes) } else { Data(~[]) }; - assert_eq!(io.read_char(), '\r'); - assert_eq!(io.read_char(), '\n'); + fail_unless_eq!(io.read_char(), '\r'); + fail_unless_eq!(io.read_char(), '\n'); return res; } diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index 35675225aae0c..23b471647b175 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -11,6 +11,6 @@ pub fn main() { let mut count = 0; for _ in range(0, 999_999) { count += 1; } - assert_eq!(count, 999_999); + fail_unless_eq!(count, 999_999); println!("{}", count); } diff --git a/src/test/run-pass/issue-4448.rs b/src/test/run-pass/issue-4448.rs index 8fbc35c72005a..6d90d3f564251 100644 --- a/src/test/run-pass/issue-4448.rs +++ b/src/test/run-pass/issue-4448.rs @@ -14,7 +14,7 @@ pub fn main() { let (port, chan) = Chan::<&'static str>::new(); task::spawn(proc() { - assert_eq!(port.recv(), "hello, world"); + fail_unless_eq!(port.recv(), "hello, world"); }); chan.send("hello, world"); diff --git a/src/test/run-pass/issue-5530.rs b/src/test/run-pass/issue-5530.rs index 68287a3a97ef7..b09db124b0b7f 100644 --- a/src/test/run-pass/issue-5530.rs +++ b/src/test/run-pass/issue-5530.rs @@ -37,13 +37,13 @@ pub fn main() { let foo = Foo { foo: 1 }; let bar = Bar { bar: 1 }; - assert_eq!(fun1(&foo, &foo), 0); - assert_eq!(fun1(&foo, &bar), 1); - assert_eq!(fun1(&bar, &bar), 2); - assert_eq!(fun1(&bar, &foo), 3); + fail_unless_eq!(fun1(&foo, &foo), 0); + fail_unless_eq!(fun1(&foo, &bar), 1); + fail_unless_eq!(fun1(&bar, &bar), 2); + fail_unless_eq!(fun1(&bar, &foo), 3); - assert_eq!(fun2(&foo, &foo), 0); - assert_eq!(fun2(&foo, &bar), 1); // fun2 returns 0 - assert_eq!(fun2(&bar, &bar), 2); - assert_eq!(fun2(&bar, &foo), 3); // fun2 returns 2 + fail_unless_eq!(fun2(&foo, &foo), 0); + fail_unless_eq!(fun2(&foo, &bar), 1); // fun2 returns 0 + fail_unless_eq!(fun2(&bar, &bar), 2); + fail_unless_eq!(fun2(&bar, &foo), 3); // fun2 returns 2 } diff --git a/src/test/run-pass/issue-5917.rs b/src/test/run-pass/issue-5917.rs index 543f4bf027bfd..a77c8e4f395d3 100644 --- a/src/test/run-pass/issue-5917.rs +++ b/src/test/run-pass/issue-5917.rs @@ -12,5 +12,5 @@ struct T (&'static [int]); static t : T = T (&'static [5, 4, 3]); pub fn main () { let T(ref v) = t; - assert_eq!(v[0], 5); + fail_unless_eq!(v[0], 5); } diff --git a/src/test/run-pass/issue-6153.rs b/src/test/run-pass/issue-6153.rs index 989a8e5f9c2c4..7e834a09530d5 100644 --- a/src/test/run-pass/issue-6153.rs +++ b/src/test/run-pass/issue-6153.rs @@ -16,5 +16,5 @@ fn swap(f: |~[int]| -> ~[int]) -> ~[int] { pub fn main() { let v = swap(|mut x| { x.push(4); x }); let w = swap(|mut x| { x.push(4); x }); - assert_eq!(v, w); + fail_unless_eq!(v, w); } diff --git a/src/test/run-pass/issue-6334.rs b/src/test/run-pass/issue-6334.rs index 98a0fa27930ad..736f88dfb31c9 100644 --- a/src/test/run-pass/issue-6334.rs +++ b/src/test/run-pass/issue-6334.rs @@ -52,5 +52,5 @@ pub fn main() { let foo = Foo; let bar = Bar; let r = use_c(&bar, &foo); - assert_eq!(r, 102); + fail_unless_eq!(r, 102); } diff --git a/src/test/run-pass/issue-8860.rs b/src/test/run-pass/issue-8860.rs index d22de5ce4c80a..e7ea4c510dda0 100644 --- a/src/test/run-pass/issue-8860.rs +++ b/src/test/run-pass/issue-8860.rs @@ -20,9 +20,9 @@ static mut DROP_T: int = 0i; fn start(argc: int, argv: **u8) -> int { let ret = green::start(argc, argv, main); unsafe { - assert_eq!(2, DROP); - assert_eq!(1, DROP_S); - assert_eq!(1, DROP_T); + fail_unless_eq!(2, DROP); + fail_unless_eq!(1, DROP_S); + fail_unless_eq!(1, DROP_T); } ret } @@ -53,10 +53,10 @@ fn main() { let s = S; f(s); unsafe { - assert_eq!(1, DROP); - assert_eq!(1, DROP_S); + fail_unless_eq!(1, DROP); + fail_unless_eq!(1, DROP_S); } let t = T { i: 1 }; g(t); - unsafe { assert_eq!(1, DROP_T); } + unsafe { fail_unless_eq!(1, DROP_T); } } diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index ecb8e3ca0ed5d..cd19bcf511b44 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -12,7 +12,7 @@ fn assert_repr_eq(obj : T, expected : ~str) { - assert_eq!(expected, format!("{:?}", obj)); + fail_unless_eq!(expected, format!("{:?}", obj)); } pub fn main() { diff --git a/src/test/run-pass/issue-9188.rs b/src/test/run-pass/issue-9188.rs index 8cded636338c9..760aa4fb1a6c1 100644 --- a/src/test/run-pass/issue-9188.rs +++ b/src/test/run-pass/issue-9188.rs @@ -16,6 +16,6 @@ extern crate issue_9188; pub fn main() { let a = issue_9188::bar(); let b = issue_9188::foo::(); - assert_eq!(*a, *b); + fail_unless_eq!(*a, *b); } diff --git a/src/test/run-pass/issue-9259.rs b/src/test/run-pass/issue-9259.rs index b8519fdd23dd0..6ed734958d357 100644 --- a/src/test/run-pass/issue-9259.rs +++ b/src/test/run-pass/issue-9259.rs @@ -19,5 +19,5 @@ pub fn main() { a: &[~"test"], b: Some(b), }; - assert_eq!(a.b.get_ref()[0].as_slice(), "foo"); + fail_unless_eq!(a.b.get_ref()[0].as_slice(), "foo"); } diff --git a/src/test/run-pass/issue-9394-inherited-trait-calls.rs b/src/test/run-pass/issue-9394-inherited-trait-calls.rs index f2ee9206957ed..0c59f4f9e98c6 100644 --- a/src/test/run-pass/issue-9394-inherited-trait-calls.rs +++ b/src/test/run-pass/issue-9394-inherited-trait-calls.rs @@ -61,10 +61,10 @@ impl Super for X { pub fn main() { let n = X; let s = &n as &Super; - assert_eq!(s.bar(),~"super bar"); - assert_eq!(s.foo(),~"base foo"); - assert_eq!(s.foo1(),~"base foo1"); - assert_eq!(s.foo2(),~"base foo2"); - assert_eq!(s.baz(),~"base2 baz"); - assert_eq!(s.root(),~"base3 root"); + fail_unless_eq!(s.bar(),~"super bar"); + fail_unless_eq!(s.foo(),~"base foo"); + fail_unless_eq!(s.foo1(),~"base foo1"); + fail_unless_eq!(s.foo2(),~"base foo2"); + fail_unless_eq!(s.baz(),~"base2 baz"); + fail_unless_eq!(s.root(),~"base3 root"); } diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index ca83e783268e8..915c67d6bc8d5 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -35,5 +35,5 @@ pub fn main() { let _p = Some(r(b)); } - assert_eq!(b.get(), 1); + fail_unless_eq!(b.get(), 1); } diff --git a/src/test/run-pass/issue-9918.rs b/src/test/run-pass/issue-9918.rs index 240a134221d34..210ad94995c11 100644 --- a/src/test/run-pass/issue-9918.rs +++ b/src/test/run-pass/issue-9918.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - assert_eq!((0 + 0u8) as char, '\0'); + fail_unless_eq!((0 + 0u8) as char, '\0'); } diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs index 17733361de421..425ee21c706f7 100644 --- a/src/test/run-pass/issue2378c.rs +++ b/src/test/run-pass/issue2378c.rs @@ -20,5 +20,5 @@ use issue2378b::{two_maybes}; pub fn main() { let x = two_maybes{a: just(3), b: just(5)}; - assert_eq!(x[0u], (3, 5)); + fail_unless_eq!(x[0u], (3, 5)); } diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 4c843cd211479..34c34bd17d379 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -30,27 +30,27 @@ fn test_heap_assign() { fn test_heap_log() { let s = ~"a big ol' string"; info!("{}", s); } fn test_stack_add() { - assert_eq!(~"a" + "b", ~"ab"); + fail_unless_eq!(~"a" + "b", ~"ab"); let s: ~str = ~"a"; - assert_eq!(s + s, ~"aa"); - assert_eq!(~"" + "", ~""); + fail_unless_eq!(s + s, ~"aa"); + fail_unless_eq!(~"" + "", ~""); } fn test_stack_heap_add() { fail_unless!((~"a" + "bracadabra" == ~"abracadabra")); } fn test_heap_add() { - assert_eq!(~"this should" + " totally work", ~"this should totally work"); + fail_unless_eq!(~"this should" + " totally work", ~"this should totally work"); } fn test_append() { let mut s = ~""; s.push_str("a"); - assert_eq!(s, ~"a"); + fail_unless_eq!(s, ~"a"); let mut s = ~"a"; s.push_str("b"); info!("{}", s.clone()); - assert_eq!(s, ~"ab"); + fail_unless_eq!(s, ~"ab"); let mut s = ~"c"; s.push_str("offee"); diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index ecf530f07f309..337542844d20d 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -14,10 +14,10 @@ fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } pub fn main() { let mut d = double(1); - assert_eq!(d[0], 1); - assert_eq!(d[1], 1); + fail_unless_eq!(d[0], 1); + fail_unless_eq!(d[1], 1); d = double_int(1); - assert_eq!(d[0], 1); - assert_eq!(d[1], 1); + fail_unless_eq!(d[0], 1); + fail_unless_eq!(d[1], 1); } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 0a7e164ca5b98..c23d0abea03cc 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -24,5 +24,5 @@ fn repeater(v: ~A) -> ~repeat: { pub fn main() { let x = 3; let y = repeater(~x); - assert_eq!(x, y.get()); + fail_unless_eq!(x, y.get()); } diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 59baf63d28400..b6d4d5819637a 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -17,5 +17,5 @@ pub fn main() { let mut e = Refs{refs: ~[], n: 0}; let _f: || = || error!("{}", e.n); let x: &[int] = e.refs; - assert_eq!(x.len(), 0); + fail_unless_eq!(x.len(), 0); } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index b72ef59075ce2..3a32d787722f8 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -20,5 +20,5 @@ fn foo() -> 'static || -> int { } pub fn main() { - assert_eq!(foo()(), 22); + fail_unless_eq!(foo()(), 22); } diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index efa1b37bf5931..15d0fc6b33c33 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -17,6 +17,6 @@ pub fn main() { fail_unless!((x)); let mut y: int = 10; info!("{:?}", x || incr(&mut y)); - assert_eq!(y, 10); + fail_unless_eq!(y, 10); if true && x { fail_unless!((true)); } else { fail_unless!((false)); } } diff --git a/src/test/run-pass/let-destruct-ref.rs b/src/test/run-pass/let-destruct-ref.rs index c58fd89bb41f5..2fcc18d3b55c0 100644 --- a/src/test/run-pass/let-destruct-ref.rs +++ b/src/test/run-pass/let-destruct-ref.rs @@ -11,5 +11,5 @@ pub fn main() { let x = ~"hello"; let ref y = x; - assert_eq!(x.slice(0, x.len()), y.slice(0, y.len())); + fail_unless_eq!(x.slice(0, x.len()), y.slice(0, y.len())); } diff --git a/src/test/run-pass/let-var-hygiene.rs b/src/test/run-pass/let-var-hygiene.rs index ce49492fee947..9992bd656544e 100644 --- a/src/test/run-pass/let-var-hygiene.rs +++ b/src/test/run-pass/let-var-hygiene.rs @@ -14,5 +14,5 @@ macro_rules! bad_macro (($ex:expr) => ({let _x = 9; $ex})) pub fn main() { let _x = 8; - assert_eq!(bad_macro!(_x),8) + fail_unless_eq!(bad_macro!(_x),8) } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index 63419f119c726..25fa45422933d 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -13,7 +13,7 @@ pub fn main() { let mut y = 0; for i in x.iter() { info!("{:?}", *i); y += *i; } info!("{:?}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let s = ~"hello there"; let mut i: int = 0; for c in s.bytes() { @@ -28,5 +28,5 @@ pub fn main() { info!("{:?}", i); info!("{:?}", c); } - assert_eq!(i, 11); + fail_unless_eq!(i, 11); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index cc5383c6bde48..7de38b8687aa6 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -20,7 +20,7 @@ enum foo { } fn check_log(exp: ~str, v: T) { - assert_eq!(exp, format!("{:?}", v)); + fail_unless_eq!(exp, format!("{:?}", v)); } pub fn main() { diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 2e0b857f3cdd8..9b39c2917d3fa 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -19,8 +19,8 @@ enum bar { } pub fn main() { - assert_eq!(~"a(22u)", format!("{:?}", a(22u))); - assert_eq!(~"b(~\"hi\")", format!("{:?}", b(~"hi"))); - assert_eq!(~"c", format!("{:?}", c)); - assert_eq!(~"d", format!("{:?}", d)); + fail_unless_eq!(~"a(22u)", format!("{:?}", a(22u))); + fail_unless_eq!(~"b(~\"hi\")", format!("{:?}", b(~"hi"))); + fail_unless_eq!(~"c", format!("{:?}", c)); + fail_unless_eq!(~"d", format!("{:?}", d)); } diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs index 8859b5336260c..3309f3f4a3114 100644 --- a/src/test/run-pass/log-str.rs +++ b/src/test/run-pass/log-str.rs @@ -12,8 +12,8 @@ use std::repr; pub fn main() { let act = repr::repr_to_str(&~[1, 2, 3]); - assert_eq!(~"~[1, 2, 3]", act); + fail_unless_eq!(~"~[1, 2, 3]", act); let act = format!("{:?}/{:6?}", ~[1, 2, 3], ~"hi"); - assert_eq!(act, ~"~[1, 2, 3]/~\"hi\" "); + fail_unless_eq!(act, ~"~[1, 2, 3]/~\"hi\" "); } diff --git a/src/test/run-pass/loop-break-cont.rs b/src/test/run-pass/loop-break-cont.rs index ee54ab76ccc1d..515bd1ca848d1 100644 --- a/src/test/run-pass/loop-break-cont.rs +++ b/src/test/run-pass/loop-break-cont.rs @@ -17,7 +17,7 @@ pub fn main() { break; } } - assert_eq!(i, 10u); + fail_unless_eq!(i, 10u); let mut is_even = false; loop { if i == 21u { diff --git a/src/test/run-pass/loop-scope.rs b/src/test/run-pass/loop-scope.rs index 436bdf256ca42..729bb18b53439 100644 --- a/src/test/run-pass/loop-scope.rs +++ b/src/test/run-pass/loop-scope.rs @@ -12,5 +12,5 @@ pub fn main() { let x = ~[10, 20, 30]; let mut sum = 0; for x in x.iter() { sum += *x; } - assert_eq!(sum, 60); + fail_unless_eq!(sum, 60); } diff --git a/src/test/run-pass/macro-crate-def-only.rs b/src/test/run-pass/macro-crate-def-only.rs index 2c2ffd50eae9b..94a5dc7564795 100644 --- a/src/test/run-pass/macro-crate-def-only.rs +++ b/src/test/run-pass/macro-crate-def-only.rs @@ -17,5 +17,5 @@ extern crate macro_crate_def_only; pub fn main() { - assert_eq!(5, make_a_5!()); + fail_unless_eq!(5, make_a_5!()); } diff --git a/src/test/run-pass/macro-export-inner-module.rs b/src/test/run-pass/macro-export-inner-module.rs index 14c6423ce40cc..06238f3082d15 100644 --- a/src/test/run-pass/macro-export-inner-module.rs +++ b/src/test/run-pass/macro-export-inner-module.rs @@ -18,5 +18,5 @@ extern crate macro_export_inner_module; pub fn main() { - assert_eq!(1, foo!()); + fail_unless_eq!(1, foo!()); } diff --git a/src/test/run-pass/macro-local-data-key.rs b/src/test/run-pass/macro-local-data-key.rs index 569a030609789..90bbb92ed051b 100644 --- a/src/test/run-pass/macro-local-data-key.rs +++ b/src/test/run-pass/macro-local-data-key.rs @@ -23,6 +23,6 @@ pub fn main() { local_data::set(foo, 3); local_data::set(bar::baz, -10.0); - local_data::get(foo, |x| assert_eq!(*x.unwrap(), 3)); - local_data::get(bar::baz, |y| assert_eq!(*y.unwrap(), -10.0)); + local_data::get(foo, |x| fail_unless_eq!(*x.unwrap(), 3)); + local_data::get(bar::baz, |y| fail_unless_eq!(*y.unwrap(), -10.0)); } diff --git a/src/test/run-pass/macro-path.rs b/src/test/run-pass/macro-path.rs index 9740982e2c9d3..1b107d442ed85 100644 --- a/src/test/run-pass/macro-path.rs +++ b/src/test/run-pass/macro-path.rs @@ -22,5 +22,5 @@ macro_rules! foo { } pub fn main() { - assert_eq!(foo!(m::t), 10); + fail_unless_eq!(foo!(m::t), 10); } diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index 921e235aa9b47..d40c9bdd27cc1 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -29,16 +29,16 @@ pub fn main() { ); mylet!(y, 8*2); - assert_eq!(y, 16); + fail_unless_eq!(y, 16); myfn!(mult, (a,b), { a*b } ); - assert_eq!(mult(2, add(4,4)), 16); + fail_unless_eq!(mult(2, add(4,4)), 16); macro_rules! actually_an_expr_macro ( () => ( 16 ) ) - assert_eq!({ actually_an_expr_macro!() }, 16); + fail_unless_eq!({ actually_an_expr_macro!() }, 16); } diff --git a/src/test/run-pass/macro-with-attrs1.rs b/src/test/run-pass/macro-with-attrs1.rs index 57f63cdd7a582..a6db10a630397 100644 --- a/src/test/run-pass/macro-with-attrs1.rs +++ b/src/test/run-pass/macro-with-attrs1.rs @@ -20,5 +20,5 @@ macro_rules! foo( () => (1) ) macro_rules! foo( () => (2) ) pub fn main() { - assert_eq!(foo!(), 1); + fail_unless_eq!(foo!(), 1); } diff --git a/src/test/run-pass/macro-with-attrs2.rs b/src/test/run-pass/macro-with-attrs2.rs index 742769fa37683..fc51f4c1a7fa7 100644 --- a/src/test/run-pass/macro-with-attrs2.rs +++ b/src/test/run-pass/macro-with-attrs2.rs @@ -17,6 +17,6 @@ macro_rules! foo( () => (1) ) macro_rules! foo( () => (2) ) pub fn main() { - assert_eq!(foo!(), 2); + fail_unless_eq!(foo!(), 2); } diff --git a/src/test/run-pass/match-borrowed_str.rs b/src/test/run-pass/match-borrowed_str.rs index b0f31f70f53c0..d084ca0d98dc2 100644 --- a/src/test/run-pass/match-borrowed_str.rs +++ b/src/test/run-pass/match-borrowed_str.rs @@ -43,16 +43,16 @@ fn g2(ref_1: &str, ref_2: &str) -> ~str { } pub fn main() { - assert_eq!(f1(~"b"), ~"found b"); - assert_eq!(f1(&"c"), ~"not found"); - assert_eq!(f1("d"), ~"not found"); - assert_eq!(f2(~"b"), ~"found b"); - assert_eq!(f2(&"c"), ~"not found (c)"); - assert_eq!(f2("d"), ~"not found (d)"); - assert_eq!(g1(~"b", ~"c"), ~"found b,c"); - assert_eq!(g1(&"c", &"d"), ~"not found"); - assert_eq!(g1("d", "e"), ~"not found"); - assert_eq!(g2(~"b", ~"c"), ~"found b,c"); - assert_eq!(g2(&"c", &"d"), ~"not found (c, d)"); - assert_eq!(g2("d", "e"), ~"not found (d, e)"); + fail_unless_eq!(f1(~"b"), ~"found b"); + fail_unless_eq!(f1(&"c"), ~"not found"); + fail_unless_eq!(f1("d"), ~"not found"); + fail_unless_eq!(f2(~"b"), ~"found b"); + fail_unless_eq!(f2(&"c"), ~"not found (c)"); + fail_unless_eq!(f2("d"), ~"not found (d)"); + fail_unless_eq!(g1(~"b", ~"c"), ~"found b,c"); + fail_unless_eq!(g1(&"c", &"d"), ~"not found"); + fail_unless_eq!(g1("d", "e"), ~"not found"); + fail_unless_eq!(g2(~"b", ~"c"), ~"found b,c"); + fail_unless_eq!(g2(&"c", &"d"), ~"not found (c, d)"); + fail_unless_eq!(g2("d", "e"), ~"not found (d, e)"); } diff --git a/src/test/run-pass/match-in-macro.rs b/src/test/run-pass/match-in-macro.rs index b364c8dc59f0c..85edac0a0930b 100644 --- a/src/test/run-pass/match-in-macro.rs +++ b/src/test/run-pass/match-in-macro.rs @@ -23,5 +23,5 @@ macro_rules! match_inside_expansion( ) pub fn main() { - assert_eq!(match_inside_expansion!(),129); + fail_unless_eq!(match_inside_expansion!(),129); } diff --git a/src/test/run-pass/match-pattern-drop.rs b/src/test/run-pass/match-pattern-drop.rs index e0735e7ad24d7..c4ad0da8f37ea 100644 --- a/src/test/run-pass/match-pattern-drop.rs +++ b/src/test/run-pass/match-pattern-drop.rs @@ -16,7 +16,7 @@ fn foo(s: @int) { info!("{:?}", ::std::managed::refcount(s)); let count = ::std::managed::refcount(s); let x: t = make_t(s); // ref up - assert_eq!(::std::managed::refcount(s), count + 1u); + fail_unless_eq!(::std::managed::refcount(s), count + 1u); info!("{:?}", ::std::managed::refcount(s)); match x { @@ -27,7 +27,7 @@ fn foo(s: @int) { _ => { info!("?"); fail!(); } } info!("{:?}", ::std::managed::refcount(s)); - assert_eq!(::std::managed::refcount(s), count + 1u); + fail_unless_eq!(::std::managed::refcount(s), count + 1u); let _ = ::std::managed::refcount(s); // don't get bitten by last-use. } @@ -40,5 +40,5 @@ pub fn main() { info!("{}", ::std::managed::refcount(s)); let count2 = ::std::managed::refcount(s); - assert_eq!(count, count2); + fail_unless_eq!(count, count2); } diff --git a/src/test/run-pass/match-pipe-binding.rs b/src/test/run-pass/match-pipe-binding.rs index 6df4c8123610f..3e08a51ad3d80 100644 --- a/src/test/run-pass/match-pipe-binding.rs +++ b/src/test/run-pass/match-pipe-binding.rs @@ -12,8 +12,8 @@ fn test1() { // from issue 6338 match ((1, ~"a"), (2, ~"b")) { ((1, a), (2, b)) | ((2, b), (1, a)) => { - assert_eq!(a, ~"a"); - assert_eq!(b, ~"b"); + fail_unless_eq!(a, ~"a"); + fail_unless_eq!(b, ~"b"); }, _ => fail!(), } @@ -22,8 +22,8 @@ fn test1() { fn test2() { match (1, 2, 3) { (1, a, b) | (2, b, a) => { - assert_eq!(a, 2); - assert_eq!(b, 3); + fail_unless_eq!(a, 2); + fail_unless_eq!(b, 3); }, _ => fail!(), } @@ -32,8 +32,8 @@ fn test2() { fn test3() { match (1, 2, 3) { (1, ref a, ref b) | (2, ref b, ref a) => { - assert_eq!(*a, 2); - assert_eq!(*b, 3); + fail_unless_eq!(*a, 2); + fail_unless_eq!(*b, 3); }, _ => fail!(), } @@ -42,8 +42,8 @@ fn test3() { fn test4() { match (1, 2, 3) { (1, a, b) | (2, b, a) if a == 2 => { - assert_eq!(a, 2); - assert_eq!(b, 3); + fail_unless_eq!(a, 2); + fail_unless_eq!(b, 3); }, _ => fail!(), } @@ -52,8 +52,8 @@ fn test4() { fn test5() { match (1, 2, 3) { (1, ref a, ref b) | (2, ref b, ref a) if *a == 2 => { - assert_eq!(*a, 2); - assert_eq!(*b, 3); + fail_unless_eq!(*a, 2); + fail_unless_eq!(*b, 3); }, _ => fail!(), } diff --git a/src/test/run-pass/match-ref-binding-mut-option.rs b/src/test/run-pass/match-ref-binding-mut-option.rs index 8d1e483bcd848..d9d3d5714dccd 100644 --- a/src/test/run-pass/match-ref-binding-mut-option.rs +++ b/src/test/run-pass/match-ref-binding-mut-option.rs @@ -14,5 +14,5 @@ pub fn main() { None => {} Some(ref mut p) => { *p += 1; } } - assert_eq!(v, Some(23)); + fail_unless_eq!(v, Some(23)); } diff --git a/src/test/run-pass/match-ref-binding-mut.rs b/src/test/run-pass/match-ref-binding-mut.rs index 266f7cdde11af..68b902ce8ea13 100644 --- a/src/test/run-pass/match-ref-binding-mut.rs +++ b/src/test/run-pass/match-ref-binding-mut.rs @@ -21,5 +21,5 @@ fn destructure(x: &mut Rec) { pub fn main() { let mut v = Rec {f: 22}; destructure(&mut v); - assert_eq!(v.f, 23); + fail_unless_eq!(v.f, 23); } diff --git a/src/test/run-pass/match-ref-binding.rs b/src/test/run-pass/match-ref-binding.rs index 0b613df18ee83..f3d402b016570 100644 --- a/src/test/run-pass/match-ref-binding.rs +++ b/src/test/run-pass/match-ref-binding.rs @@ -16,5 +16,5 @@ fn destructure(x: Option) -> int { } pub fn main() { - assert_eq!(destructure(Some(22)), 22); + fail_unless_eq!(destructure(Some(22)), 22); } diff --git a/src/test/run-pass/match-str.rs b/src/test/run-pass/match-str.rs index 8bbcc507f184f..d3553c3065cc1 100644 --- a/src/test/run-pass/match-str.rs +++ b/src/test/run-pass/match-str.rs @@ -24,7 +24,7 @@ pub fn main() { } let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() }; - assert_eq!(x, 1); + fail_unless_eq!(x, 1); match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() } diff --git a/src/test/run-pass/match-tag.rs b/src/test/run-pass/match-tag.rs index 25e5a84ffc2fc..be7be300b13c1 100644 --- a/src/test/run-pass/match-tag.rs +++ b/src/test/run-pass/match-tag.rs @@ -31,7 +31,7 @@ pub fn main() { let gray: color = rgb(127, 127, 127); let clear: color = rgba(50, 150, 250, 0); let red: color = hsl(0, 255, 255); - assert_eq!(process(gray), 127); - assert_eq!(process(clear), 0); - assert_eq!(process(red), 255); + fail_unless_eq!(process(gray), 127); + fail_unless_eq!(process(clear), 0); + fail_unless_eq!(process(red), 255); } diff --git a/src/test/run-pass/match-unique-bind.rs b/src/test/run-pass/match-unique-bind.rs index 50aa840e6d748..2ec6a1468f6dd 100644 --- a/src/test/run-pass/match-unique-bind.rs +++ b/src/test/run-pass/match-unique-bind.rs @@ -12,7 +12,7 @@ pub fn main() { match ~100 { ~x => { info!("{:?}", x); - assert_eq!(x, 100); + fail_unless_eq!(x, 100); } } } diff --git a/src/test/run-pass/match-vec-rvalue.rs b/src/test/run-pass/match-vec-rvalue.rs index 20693897236a7..a4da95990130e 100644 --- a/src/test/run-pass/match-vec-rvalue.rs +++ b/src/test/run-pass/match-vec-rvalue.rs @@ -13,10 +13,10 @@ pub fn main() { match ~[1, 2, 3] { x => { - assert_eq!(x.len(), 3); - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); + fail_unless_eq!(x.len(), 3); + fail_unless_eq!(x[0], 1); + fail_unless_eq!(x[1], 2); + fail_unless_eq!(x[2], 3); } } } diff --git a/src/test/run-pass/match-with-ret-arm.rs b/src/test/run-pass/match-with-ret-arm.rs index 4257442ea33c8..68e59cdb41484 100644 --- a/src/test/run-pass/match-with-ret-arm.rs +++ b/src/test/run-pass/match-with-ret-arm.rs @@ -18,6 +18,6 @@ pub fn main() { None => return (), Some(num) => num as u32 }; - assert_eq!(f, 1234u32); + fail_unless_eq!(f, 1234u32); error!("{}", f) } diff --git a/src/test/run-pass/mod-inside-fn.rs b/src/test/run-pass/mod-inside-fn.rs index 388d2e4905fab..3b4f682c00c73 100644 --- a/src/test/run-pass/mod-inside-fn.rs +++ b/src/test/run-pass/mod-inside-fn.rs @@ -17,5 +17,5 @@ fn f() -> int { } pub fn main() { - assert_eq!(f(), 720); + fail_unless_eq!(f(), 720); } diff --git a/src/test/run-pass/mod_dir_implicit.rs b/src/test/run-pass/mod_dir_implicit.rs index 316914462897f..195521853534e 100644 --- a/src/test/run-pass/mod_dir_implicit.rs +++ b/src/test/run-pass/mod_dir_implicit.rs @@ -14,5 +14,5 @@ mod mod_dir_implicit_aux; pub fn main() { - assert_eq!(mod_dir_implicit_aux::foo(), 10); + fail_unless_eq!(mod_dir_implicit_aux::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_path.rs b/src/test/run-pass/mod_dir_path.rs index 612d033761951..7de30e125de0a 100644 --- a/src/test/run-pass/mod_dir_path.rs +++ b/src/test/run-pass/mod_dir_path.rs @@ -17,5 +17,5 @@ mod mod_dir_simple { } pub fn main() { - assert_eq!(mod_dir_simple::syrup::foo(), 10); + fail_unless_eq!(mod_dir_simple::syrup::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_path2.rs b/src/test/run-pass/mod_dir_path2.rs index 54e1716766396..0c45f9048aa31 100644 --- a/src/test/run-pass/mod_dir_path2.rs +++ b/src/test/run-pass/mod_dir_path2.rs @@ -18,5 +18,5 @@ mod pancakes { } pub fn main() { - assert_eq!(pancakes::syrup::foo(), 10); + fail_unless_eq!(pancakes::syrup::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_path3.rs b/src/test/run-pass/mod_dir_path3.rs index 0cbe2eed7c4ca..11455a3b092bf 100644 --- a/src/test/run-pass/mod_dir_path3.rs +++ b/src/test/run-pass/mod_dir_path3.rs @@ -17,5 +17,5 @@ mod pancakes { } pub fn main() { - assert_eq!(pancakes::test::foo(), 10); + fail_unless_eq!(pancakes::test::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_path_multi.rs b/src/test/run-pass/mod_dir_path_multi.rs index 0785e49396c48..248273c5e2284 100644 --- a/src/test/run-pass/mod_dir_path_multi.rs +++ b/src/test/run-pass/mod_dir_path_multi.rs @@ -22,6 +22,6 @@ mod gravy { } pub fn main() { - assert_eq!(biscuits::test::foo(), 10); - assert_eq!(gravy::test::foo(), 10); + fail_unless_eq!(biscuits::test::foo(), 10); + fail_unless_eq!(gravy::test::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_recursive.rs b/src/test/run-pass/mod_dir_recursive.rs index c9561a04c34fc..bee9052c27b01 100644 --- a/src/test/run-pass/mod_dir_recursive.rs +++ b/src/test/run-pass/mod_dir_recursive.rs @@ -20,5 +20,5 @@ mod mod_dir_simple { } pub fn main() { - assert_eq!(mod_dir_simple::load_another_mod::test::foo(), 10); + fail_unless_eq!(mod_dir_simple::load_another_mod::test::foo(), 10); } diff --git a/src/test/run-pass/mod_dir_simple.rs b/src/test/run-pass/mod_dir_simple.rs index f6212fc8c3e3e..714dada10951f 100644 --- a/src/test/run-pass/mod_dir_simple.rs +++ b/src/test/run-pass/mod_dir_simple.rs @@ -16,5 +16,5 @@ mod mod_dir_simple { } pub fn main() { - assert_eq!(mod_dir_simple::test::foo(), 10); + fail_unless_eq!(mod_dir_simple::test::foo(), 10); } diff --git a/src/test/run-pass/mod_file.rs b/src/test/run-pass/mod_file.rs index ddda38bafd369..fc62f8f6fcf7c 100644 --- a/src/test/run-pass/mod_file.rs +++ b/src/test/run-pass/mod_file.rs @@ -15,5 +15,5 @@ mod mod_file_aux; pub fn main() { - assert_eq!(mod_file_aux::foo(), 10); + fail_unless_eq!(mod_file_aux::foo(), 10); } diff --git a/src/test/run-pass/mod_file_with_path_attr.rs b/src/test/run-pass/mod_file_with_path_attr.rs index c6e51daaaf054..8c301f9096b65 100644 --- a/src/test/run-pass/mod_file_with_path_attr.rs +++ b/src/test/run-pass/mod_file_with_path_attr.rs @@ -16,5 +16,5 @@ mod m; pub fn main() { - assert_eq!(m::foo(), 10); + fail_unless_eq!(m::foo(), 10); } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 1bb46a36b07a4..9d88560eb8691 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -42,8 +42,8 @@ fn transform(x: Option) -> Option<~str> { } pub fn main() { - assert_eq!(transform(Some(10)), Some(~"11")); - assert_eq!(transform(None), None); + fail_unless_eq!(transform(Some(10)), Some(~"11")); + fail_unless_eq!(transform(None), None); fail_unless!((~[~"hi"]) .bind(|x| ~[x.clone(), *x + "!"] ) .bind(|x| ~[x.clone(), *x + "?"] ) == diff --git a/src/test/run-pass/monomorphize-abi-alignment.rs b/src/test/run-pass/monomorphize-abi-alignment.rs index 0ca606b2cd337..fc3439e0768fe 100644 --- a/src/test/run-pass/monomorphize-abi-alignment.rs +++ b/src/test/run-pass/monomorphize-abi-alignment.rs @@ -28,6 +28,6 @@ struct B(u64); pub fn main() { static Ca: S = S { i: 0, t: A((13, 104)) }; static Cb: S = S { i: 0, t: B(31337) }; - assert_eq!(Ca.unwrap(), A((13, 104))); - assert_eq!(Cb.unwrap(), B(31337)); + fail_unless_eq!(Ca.unwrap(), A((13, 104))); + fail_unless_eq!(Cb.unwrap(), B(31337)); } diff --git a/src/test/run-pass/morestack3.rs b/src/test/run-pass/morestack3.rs index 02b9fec1c6555..2d5868446fe64 100644 --- a/src/test/run-pass/morestack3.rs +++ b/src/test/run-pass/morestack3.rs @@ -23,15 +23,15 @@ fn getbig(a0: int, a8: int, a9: int) -> int { - assert_eq!(a0 + 1, a1); - assert_eq!(a1 + 1, a2); - assert_eq!(a2 + 1, a3); - assert_eq!(a3 + 1, a4); - assert_eq!(a4 + 1, a5); - assert_eq!(a5 + 1, a6); - assert_eq!(a6 + 1, a7); - assert_eq!(a7 + 1, a8); - assert_eq!(a8 + 1, a9); + fail_unless_eq!(a0 + 1, a1); + fail_unless_eq!(a1 + 1, a2); + fail_unless_eq!(a2 + 1, a3); + fail_unless_eq!(a3 + 1, a4); + fail_unless_eq!(a4 + 1, a5); + fail_unless_eq!(a5 + 1, a6); + fail_unless_eq!(a6 + 1, a7); + fail_unless_eq!(a7 + 1, a8); + fail_unless_eq!(a8 + 1, a9); if a0 != 0 { let j = getbig(a0 - 1, a1 - 1, @@ -43,7 +43,7 @@ fn getbig(a0: int, a7 - 1, a8 - 1, a9 - 1); - assert_eq!(j, a0 - 1); + fail_unless_eq!(j, a0 - 1); } return a0; } diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index ac6dfa00f4841..07344cb7e7302 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -24,8 +24,8 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(false, x), 5); + fail_unless_eq!(test(true, x.clone()), 2); + fail_unless_eq!(test(true, x.clone()), 2); + fail_unless_eq!(test(true, x.clone()), 2); + fail_unless_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs index 983c701d82031..56c51ac2bf2d1 100644 --- a/src/test/run-pass/move-1.rs +++ b/src/test/run-pass/move-1.rs @@ -22,8 +22,8 @@ fn test(x: bool, foo: @Triple) -> int { pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(false, x), 5); + fail_unless_eq!(test(true, x), 2); + fail_unless_eq!(test(true, x), 2); + fail_unless_eq!(test(true, x), 2); + fail_unless_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 2bd1eb7fd4bff..b9259e7bfb132 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -27,7 +27,7 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; for _ in range(0u, 10000u) { - assert_eq!(test(true, x.clone()), 2); + fail_unless_eq!(test(true, x.clone()), 2); } - assert_eq!(test(false, x), 5); + fail_unless_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs index 2819d9bd76e40..df17eaab573e3 100644 --- a/src/test/run-pass/move-3.rs +++ b/src/test/run-pass/move-3.rs @@ -24,7 +24,7 @@ fn test(x: bool, foo: @Triple) -> int { pub fn main() { let x = @Triple{x: 1, y: 2, z: 3}; for _i in range(0u, 10000u) { - assert_eq!(test(true, x), 2); + fail_unless_eq!(test(true, x), 2); } - assert_eq!(test(false, x), 5); + fail_unless_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/move-4.rs b/src/test/run-pass/move-4.rs index 67b071af0a27e..b93ffddb6b108 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -25,5 +25,5 @@ fn test(foo: @Triple) -> @Triple { pub fn main() { let x = @Triple{a: 1, b: 2, c: 3}; let y = test(x); - assert_eq!(y.c, 3); + fail_unless_eq!(y.c, 3); } diff --git a/src/test/run-pass/move-out-of-field.rs b/src/test/run-pass/move-out-of-field.rs index 2041c69ceccbc..bc55aacfcdd53 100644 --- a/src/test/run-pass/move-out-of-field.rs +++ b/src/test/run-pass/move-out-of-field.rs @@ -27,5 +27,5 @@ pub fn main() { sb.append("Hello, "); sb.append("World!"); let str = to_str(sb); - assert_eq!(str, ~"Hello, World!"); + fail_unless_eq!(str, ~"Hello, World!"); } diff --git a/src/test/run-pass/move-scalar.rs b/src/test/run-pass/move-scalar.rs index 845cb8ab6011e..71340573ef439 100644 --- a/src/test/run-pass/move-scalar.rs +++ b/src/test/run-pass/move-scalar.rs @@ -13,5 +13,5 @@ pub fn main() { let y: int = 42; let mut x: int; x = y; - assert_eq!(x, 42); + fail_unless_eq!(x, 42); } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index 932322866fa17..28d26a663cc65 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -10,7 +10,7 @@ fn f(mut y: ~int) { *y = 5; - assert_eq!(*y, 5); + fail_unless_eq!(*y, 5); } fn g() { diff --git a/src/test/run-pass/mut-in-ident-patterns.rs b/src/test/run-pass/mut-in-ident-patterns.rs index 13303e7b10881..b16cbd0b2a419 100644 --- a/src/test/run-pass/mut-in-ident-patterns.rs +++ b/src/test/run-pass/mut-in-ident-patterns.rs @@ -21,13 +21,13 @@ impl Foo for X {} pub fn main() { let (a, mut b) = (23, 4); - assert_eq!(a, 23); - assert_eq!(b, 4); + fail_unless_eq!(a, 23); + fail_unless_eq!(b, 4); b = a + b; - assert_eq!(b, 27); + fail_unless_eq!(b, 27); - assert_eq!(X.foo(2), 76); + fail_unless_eq!(X.foo(2), 76); enum Bar { Foo(int), @@ -38,9 +38,9 @@ pub fn main() { match x { mut z @ 32 => { - assert_eq!(z, 32); + fail_unless_eq!(z, 32); z = 34; - assert_eq!(z, 34); + fail_unless_eq!(z, 34); } _ => {} } @@ -52,11 +52,11 @@ pub fn main() { fn check_bar(y: &Bar) { match y { &Foo(a) => { - assert_eq!(a, 21); + fail_unless_eq!(a, 21); } &Baz(a, b) => { - assert_eq!(a, 10.0); - assert_eq!(b, 3); + fail_unless_eq!(a, 10.0); + fail_unless_eq!(b, 3); } } } @@ -71,9 +71,9 @@ pub fn main() { x: int } let A { x: mut x } = A { x: 10 }; - assert_eq!(x, 10); + fail_unless_eq!(x, 10); x = 30; - assert_eq!(x, 30); + fail_unless_eq!(x, 30); (|A { x: mut t }: A| { t = t+1; t })(A { x: 34 }); diff --git a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs index 153149bb925d7..2c58245bd3f02 100644 --- a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs +++ b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs @@ -11,7 +11,7 @@ fn test1() { let mut ints = [0, ..32]; ints[0] += 1; - assert_eq!(ints[0], 1); + fail_unless_eq!(ints[0], 1); } fn test2() { diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs index f512a4659853a..5cf4a405fac52 100644 --- a/src/test/run-pass/mutable-alias-vec.rs +++ b/src/test/run-pass/mutable-alias-vec.rs @@ -21,5 +21,5 @@ pub fn main() { grow(&mut v); let len = v.len(); info!("{}", len); - assert_eq!(len, 3 as uint); + fail_unless_eq!(len, 3 as uint); } diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index 927f8160f7e4a..d361353ee118a 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -26,6 +26,6 @@ pub fn main() { // fn b(x:int) -> int { fail!(); } let z = b(42); - assert_eq!(z.i, 42); - assert_eq!(z.do_stuff(), 37); + fail_unless_eq!(z.i, 42); + fail_unless_eq!(z.do_stuff(), 37); } diff --git a/src/test/run-pass/nested-function-names-issue-8587.rs b/src/test/run-pass/nested-function-names-issue-8587.rs index f697f0b59d65f..132e0850fdafc 100644 --- a/src/test/run-pass/nested-function-names-issue-8587.rs +++ b/src/test/run-pass/nested-function-names-issue-8587.rs @@ -43,8 +43,8 @@ impl X { pub fn main() { let n = X; - assert_eq!(n.f(), 0); - assert_eq!(n.g(), 1); + fail_unless_eq!(n.f(), 0); + fail_unless_eq!(n.g(), 1); // This test `h` used to fail. - assert_eq!(n.h(), 2); + fail_unless_eq!(n.h(), 2); } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 350f4bd170901..0fa26bfdf7c5b 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -20,8 +20,8 @@ pub fn main() { } let mut x@B {b, ..} = B {a: 10, b: C {c: 20}}; x.b.c = 30; - assert_eq!(b.c, 20); + fail_unless_eq!(b.c, 20); let mut y@D {d, ..} = D {a: 10, d: C {c: 20}}; y.d.c = 30; - assert_eq!(d.c, 20); + fail_unless_eq!(d.c, 20); } diff --git a/src/test/run-pass/nested_item_main.rs b/src/test/run-pass/nested_item_main.rs index 5fe1cd7fa558a..f3ce5ab66e94c 100644 --- a/src/test/run-pass/nested_item_main.rs +++ b/src/test/run-pass/nested_item_main.rs @@ -14,6 +14,6 @@ extern crate nested_item; pub fn main() { - assert_eq!(2, nested_item::foo::<()>()); - assert_eq!(2, nested_item::foo::()); + fail_unless_eq!(2, nested_item::foo::<()>()); + fail_unless_eq!(2, nested_item::foo::()); } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index 043136fdad995..ade327ea0d343 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -15,8 +15,8 @@ fn f(i: int, f: |int| -> int) -> int { f(i) } fn g(_g: ||) { } pub fn main() { - assert_eq!(f(10, |a| a), 10); + fail_unless_eq!(f(10, |a| a), 10); g(||()); - assert_eq!(f(10, |a| a), 10); + fail_unless_eq!(f(10, |a| a), 10); g(||{}); } diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 7bc28e6b00ff5..1e2a199cc4e94 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -23,8 +23,8 @@ fn myvec_elt(mv: myvec) -> X { pub fn main() { let mv = myvec(~[1, 2, 3]); - assert_eq!(myvec_deref(mv.clone())[1], 2); - assert_eq!(myvec_elt(mv.clone()), 1); + fail_unless_eq!(myvec_deref(mv.clone())[1], 2); + fail_unless_eq!(myvec_elt(mv.clone()), 1); let myvec(v) = mv; - assert_eq!(v[2], 3); + fail_unless_eq!(v[2], 3); } diff --git a/src/test/run-pass/newtype-struct-drop-run.rs b/src/test/run-pass/newtype-struct-drop-run.rs index abd9c537fd22d..3476bff6e181d 100644 --- a/src/test/run-pass/newtype-struct-drop-run.rs +++ b/src/test/run-pass/newtype-struct-drop-run.rs @@ -29,5 +29,5 @@ pub fn main() { { let _x = Foo(y); } - assert_eq!(y.get(), 23); + fail_unless_eq!(y.get(), 23); } diff --git a/src/test/run-pass/newtype-temporary.rs b/src/test/run-pass/newtype-temporary.rs index 3db333f36b8c6..aa4a8fcc0aa1c 100644 --- a/src/test/run-pass/newtype-temporary.rs +++ b/src/test/run-pass/newtype-temporary.rs @@ -16,5 +16,5 @@ fn foo() -> Foo { } pub fn main() { - assert_eq!(foo(), Foo(42)); + fail_unless_eq!(foo(), Foo(42)); } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index b0d2da9773c50..9b901fb9fdad7 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -21,5 +21,5 @@ pub fn main() { let myval = mytype(Mytype{compute: compute, val: 30}); println!("{}", compute(myval)); let mytype(m) = myval; - assert_eq!((m.compute)(myval), 50); + fail_unless_eq!((m.compute)(myval), 50); } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index e298549fbfd03..14dff83f8d618 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -32,5 +32,5 @@ fn safe_head(ls: @List) -> T { pub fn main() { let mylist = @Cons(@1u, @Nil); fail_unless!((nonempty_list(mylist))); - assert_eq!(*safe_head(mylist), 1u); + fail_unless_eq!(*safe_head(mylist), 1u); } diff --git a/src/test/run-pass/non-legacy-modes.rs b/src/test/run-pass/non-legacy-modes.rs index 8262432db607f..9ba4976a62e86 100644 --- a/src/test/run-pass/non-legacy-modes.rs +++ b/src/test/run-pass/non-legacy-modes.rs @@ -17,7 +17,7 @@ fn apply(x: T, f: |T|) { } fn check_int(x: int) { - assert_eq!(x, 22); + fail_unless_eq!(x, 22); } fn check_struct(x: X) { diff --git a/src/test/run-pass/nul-characters.rs b/src/test/run-pass/nul-characters.rs index 181afd5c46d36..a46e5f2fb0bcb 100644 --- a/src/test/run-pass/nul-characters.rs +++ b/src/test/run-pass/nul-characters.rs @@ -16,27 +16,27 @@ pub fn main() let all_nuls4 = "\x00\u0000\0\U00000000"; // sizes for two should suffice - assert_eq!(all_nuls1.len(), 4); - assert_eq!(all_nuls2.len(), 4); + fail_unless_eq!(all_nuls1.len(), 4); + fail_unless_eq!(all_nuls2.len(), 4); // string equality should pass between the strings - assert_eq!(all_nuls1, all_nuls2); - assert_eq!(all_nuls2, all_nuls3); - assert_eq!(all_nuls3, all_nuls4); + fail_unless_eq!(all_nuls1, all_nuls2); + fail_unless_eq!(all_nuls2, all_nuls3); + fail_unless_eq!(all_nuls3, all_nuls4); // all extracted characters in all_nuls are equivalent to each other for c1 in all_nuls1.chars() { for c2 in all_nuls1.chars() { - assert_eq!(c1,c2); + fail_unless_eq!(c1,c2); } } // testing equality between explicit character literals - assert_eq!('\0', '\x00'); - assert_eq!('\u0000', '\x00'); - assert_eq!('\u0000', '\U00000000'); + fail_unless_eq!('\0', '\x00'); + fail_unless_eq!('\u0000', '\x00'); + fail_unless_eq!('\u0000', '\U00000000'); // NUL characters should make a difference fail_unless!("Hello World" != "Hello \0World"); diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 84a6baa5de8a9..9ba52981fb529 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -19,13 +19,13 @@ struct S(int, T); macro_rules! check_option { ($T:ty) => { - assert_eq!(mem::size_of::>(), mem::size_of::<$T>()); + fail_unless_eq!(mem::size_of::>(), mem::size_of::<$T>()); } } macro_rules! check_fancy { ($T:ty) => { - assert_eq!(mem::size_of::>(), mem::size_of::>()); + fail_unless_eq!(mem::size_of::>(), mem::size_of::>()); } } diff --git a/src/test/run-pass/nullary-or-pattern.rs b/src/test/run-pass/nullary-or-pattern.rs index 8e932c4b14b80..4969384effd1c 100644 --- a/src/test/run-pass/nullary-or-pattern.rs +++ b/src/test/run-pass/nullary-or-pattern.rs @@ -15,6 +15,6 @@ fn or_alt(q: blah) -> int { } pub fn main() { - assert_eq!(or_alt(a), 42); - assert_eq!(or_alt(b), 42); + fail_unless_eq!(or_alt(a), 42); + fail_unless_eq!(or_alt(b), 42); } diff --git a/src/test/run-pass/numeric-method-autoexport.rs b/src/test/run-pass/numeric-method-autoexport.rs index fbb404b3809d7..d6b187a4277ec 100644 --- a/src/test/run-pass/numeric-method-autoexport.rs +++ b/src/test/run-pass/numeric-method-autoexport.rs @@ -17,22 +17,22 @@ pub fn main() { // ints // num - assert_eq!(15i.add(&6), 21); - assert_eq!(15i8.add(&6i8), 21i8); - assert_eq!(15i16.add(&6i16), 21i16); - assert_eq!(15i32.add(&6i32), 21i32); - assert_eq!(15i64.add(&6i64), 21i64); + fail_unless_eq!(15i.add(&6), 21); + fail_unless_eq!(15i8.add(&6i8), 21i8); + fail_unless_eq!(15i16.add(&6i16), 21i16); + fail_unless_eq!(15i32.add(&6i32), 21i32); + fail_unless_eq!(15i64.add(&6i64), 21i64); // uints // num - assert_eq!(15u.add(&6u), 21u); - assert_eq!(15u8.add(&6u8), 21u8); - assert_eq!(15u16.add(&6u16), 21u16); - assert_eq!(15u32.add(&6u32), 21u32); - assert_eq!(15u64.add(&6u64), 21u64); + fail_unless_eq!(15u.add(&6u), 21u); + fail_unless_eq!(15u8.add(&6u8), 21u8); + fail_unless_eq!(15u16.add(&6u16), 21u16); + fail_unless_eq!(15u32.add(&6u32), 21u32); + fail_unless_eq!(15u64.add(&6u64), 21u64); // floats // num - assert_eq!(10f32.to_int().unwrap(), 10); - assert_eq!(10f64.to_int().unwrap(), 10); + fail_unless_eq!(10f32.to_int().unwrap(), 10); + fail_unless_eq!(10f64.to_int().unwrap(), 10); } diff --git a/src/test/run-pass/objects-coerce-freeze-borrored.rs b/src/test/run-pass/objects-coerce-freeze-borrored.rs index 0bdc36750ae6d..6fa7827f86d9c 100644 --- a/src/test/run-pass/objects-coerce-freeze-borrored.rs +++ b/src/test/run-pass/objects-coerce-freeze-borrored.rs @@ -29,14 +29,14 @@ impl Foo for uint { fn do_it_mut(obj: &mut Foo) { let x = obj.bar(); let y = obj.foo(); - assert_eq!(x, y); + fail_unless_eq!(x, y); do_it_imm(obj, y); } fn do_it_imm(obj: &Foo, v: uint) { let y = obj.foo(); - assert_eq!(v, y); + fail_unless_eq!(v, y); } pub fn main() { diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs index 24c1b9d8fe8e7..4a28bf2442fd8 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs @@ -38,6 +38,6 @@ pub fn main() { ]; for i in range(0u, foos.len()) { - assert_eq!(i, foos[i].foo()); + fail_unless_eq!(i, foos[i].foo()); } } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index 72ae7cf9bb993..f5514c9549a20 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -34,6 +34,6 @@ pub fn main() { ]; for i in range(0u, foos.len()) { - assert_eq!(i, foos[i].foo()); + fail_unless_eq!(i, foos[i].foo()); } } diff --git a/src/test/run-pass/objects-owned-object-owned-method.rs b/src/test/run-pass/objects-owned-object-owned-method.rs index 0d675c16d1aad..29f2abc50ce31 100644 --- a/src/test/run-pass/objects-owned-object-owned-method.rs +++ b/src/test/run-pass/objects-owned-object-owned-method.rs @@ -28,5 +28,5 @@ impl FooTrait for BarStruct { pub fn main() { let foo = ~BarStruct{ x: 22 } as ~FooTrait; - assert_eq!(22, foo.foo()); + fail_unless_eq!(22, foo.foo()); } diff --git a/src/test/run-pass/one-tuple.rs b/src/test/run-pass/one-tuple.rs index 8377a45a1d8a0..bbd6b817e40dc 100644 --- a/src/test/run-pass/one-tuple.rs +++ b/src/test/run-pass/one-tuple.rs @@ -13,11 +13,11 @@ pub fn main() { match ('c',) { (x,) => { - assert_eq!(x, 'c'); + fail_unless_eq!(x, 'c'); } } // test the 1-tuple type too let x: (char,) = ('d',); let (y,) = x; - assert_eq!(y, 'd'); + fail_unless_eq!(y, 'd'); } diff --git a/src/test/run-pass/opeq.rs b/src/test/run-pass/opeq.rs index 1fda2c8060886..2448eea90b7af 100644 --- a/src/test/run-pass/opeq.rs +++ b/src/test/run-pass/opeq.rs @@ -15,14 +15,14 @@ pub fn main() { let mut x: int = 1; x *= 2; info!("{}", x); - assert_eq!(x, 2); + fail_unless_eq!(x, 2); x += 3; info!("{}", x); - assert_eq!(x, 5); + fail_unless_eq!(x, 5); x *= x; info!("{}", x); - assert_eq!(x, 25); + fail_unless_eq!(x, 25); x /= 5; info!("{}", x); - assert_eq!(x, 5); + fail_unless_eq!(x, 5); } diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index 9c4b10da3a16c..e1f8d86996525 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -59,14 +59,14 @@ pub fn main() { let mut p = Point {x: 10, y: 20}; p = p + Point {x: 101, y: 102}; p = p - Point {x: 100, y: 100}; - assert_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27}); - assert_eq!(-p, Point {x: -11, y: -22}); - assert_eq!(p[true], 11); - assert_eq!(p[false], 22); + fail_unless_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27}); + fail_unless_eq!(-p, Point {x: -11, y: -22}); + fail_unless_eq!(p[true], 11); + fail_unless_eq!(p[false], 22); let q = !p; - assert_eq!(q.x, !(p.x)); - assert_eq!(q.y, !(p.y)); + fail_unless_eq!(q.x, !(p.x)); + fail_unless_eq!(q.y, !(p.y)); // Issue #1733 let result: proc(int) = proc(_)(); diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 0806bcd185e4f..96ae232ab08f6 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -39,5 +39,5 @@ pub fn main() { let _c = unwrap(b); } - assert_eq!(x.get(), 0); + fail_unless_eq!(x.get(), 0); } diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index a014257fb1c9d..b70f6430b3266 100644 --- a/src/test/run-pass/or-pattern.rs +++ b/src/test/run-pass/or-pattern.rs @@ -15,7 +15,7 @@ fn or_alt(q: blah) -> int { } pub fn main() { - assert_eq!(or_alt(c), 0); - assert_eq!(or_alt(a(10, 100, 0u)), 110); - assert_eq!(or_alt(b(20, 200)), 220); + fail_unless_eq!(or_alt(c), 0); + fail_unless_eq!(or_alt(a(10, 100, 0u)), 110); + fail_unless_eq!(or_alt(b(20, 200)), 220); } diff --git a/src/test/run-pass/packed-struct-borrow-element.rs b/src/test/run-pass/packed-struct-borrow-element.rs index 1434e1da4c758..22bfc819befd7 100644 --- a/src/test/run-pass/packed-struct-borrow-element.rs +++ b/src/test/run-pass/packed-struct-borrow-element.rs @@ -18,5 +18,5 @@ pub fn main() { let foo = Foo { bar: 1, baz: 2 }; let brw = &foo.baz; - assert_eq!(*brw, 2); + fail_unless_eq!(*brw, 2); } diff --git a/src/test/run-pass/packed-struct-generic-layout.rs b/src/test/run-pass/packed-struct-generic-layout.rs index 91b49944be2ef..323b76b1d0418 100644 --- a/src/test/run-pass/packed-struct-generic-layout.rs +++ b/src/test/run-pass/packed-struct-generic-layout.rs @@ -22,7 +22,7 @@ pub fn main() { let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; let transd : [u8, .. 9] = cast::transmute(s); // Don't worry about endianness, the numbers are palindromic. - assert_eq!(transd, + fail_unless_eq!(transd, [0xff, 0xff, 0xff, 0xff, 1, 0xaa, 0xaa, 0xaa, 0xaa]); @@ -31,7 +31,7 @@ pub fn main() { let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16}; let transd : [u8, .. 4] = cast::transmute(s); // Again, no endianness problems. - assert_eq!(transd, + fail_unless_eq!(transd, [1, 2, 0b10000001, 0b10000001]); } } diff --git a/src/test/run-pass/packed-struct-generic-size.rs b/src/test/run-pass/packed-struct-generic-size.rs index 0b6ab579e6b73..78808996abf1e 100644 --- a/src/test/run-pass/packed-struct-generic-size.rs +++ b/src/test/run-pass/packed-struct-generic-size.rs @@ -18,10 +18,10 @@ struct S { } pub fn main() { - assert_eq!(mem::size_of::>(), 3); + fail_unless_eq!(mem::size_of::>(), 3); - assert_eq!(mem::size_of::>(), 11); + fail_unless_eq!(mem::size_of::>(), 11); - assert_eq!(mem::size_of::>(), + fail_unless_eq!(mem::size_of::>(), 1 + mem::size_of::<~str>() + mem::size_of::<~[int]>()); } diff --git a/src/test/run-pass/packed-struct-layout.rs b/src/test/run-pass/packed-struct-layout.rs index f361db4a4b568..8b0bd6634d92b 100644 --- a/src/test/run-pass/packed-struct-layout.rs +++ b/src/test/run-pass/packed-struct-layout.rs @@ -26,11 +26,11 @@ pub fn main() { unsafe { let s4 = S4 { a: 1, b: [2,3,4] }; let transd : [u8, .. 4] = cast::transmute(s4); - assert_eq!(transd, [1, 2, 3, 4]); + fail_unless_eq!(transd, [1, 2, 3, 4]); let s5 = S5 { a: 1, b: 0xff_00_00_ff }; let transd : [u8, .. 5] = cast::transmute(s5); // Don't worry about endianness, the u32 is palindromic. - assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); + fail_unless_eq!(transd, [1, 0xff, 0, 0, 0xff]); } } diff --git a/src/test/run-pass/packed-struct-match.rs b/src/test/run-pass/packed-struct-match.rs index 27ab2c83e5566..32b07322ad626 100644 --- a/src/test/run-pass/packed-struct-match.rs +++ b/src/test/run-pass/packed-struct-match.rs @@ -18,8 +18,8 @@ pub fn main() { let foo = Foo { bar: 1, baz: 2 }; match foo { Foo {bar, baz} => { - assert_eq!(bar, 1); - assert_eq!(baz, 2); + fail_unless_eq!(bar, 1); + fail_unless_eq!(baz, 2); } } } diff --git a/src/test/run-pass/packed-struct-size-xc.rs b/src/test/run-pass/packed-struct-size-xc.rs index 2ee90eb2c4c6b..8e0fb10ff5bf6 100644 --- a/src/test/run-pass/packed-struct-size-xc.rs +++ b/src/test/run-pass/packed-struct-size-xc.rs @@ -16,5 +16,5 @@ extern crate packed; use std::mem; pub fn main() { - assert_eq!(mem::size_of::(), 5); + fail_unless_eq!(mem::size_of::(), 5); } diff --git a/src/test/run-pass/packed-struct-size.rs b/src/test/run-pass/packed-struct-size.rs index f694cc98ad350..1cd4e2b859671 100644 --- a/src/test/run-pass/packed-struct-size.rs +++ b/src/test/run-pass/packed-struct-size.rs @@ -59,9 +59,9 @@ static TEST_S3_Foo: S3_Foo = S3_Foo { a: 1, b: 2, c: Baz }; pub fn main() { - assert_eq!(mem::size_of::(), 4); - assert_eq!(mem::size_of::(), 5); - assert_eq!(mem::size_of::(), 13 + mem::size_of::<~str>()); - assert_eq!(mem::size_of::(), 3 + mem::size_of::()); - assert_eq!(mem::size_of::(), 7 + mem::size_of::>()); + fail_unless_eq!(mem::size_of::(), 4); + fail_unless_eq!(mem::size_of::(), 5); + fail_unless_eq!(mem::size_of::(), 13 + mem::size_of::<~str>()); + fail_unless_eq!(mem::size_of::(), 3 + mem::size_of::()); + fail_unless_eq!(mem::size_of::(), 7 + mem::size_of::>()); } diff --git a/src/test/run-pass/packed-struct-vec.rs b/src/test/run-pass/packed-struct-vec.rs index f1824423064b9..8ba940999b7c5 100644 --- a/src/test/run-pass/packed-struct-vec.rs +++ b/src/test/run-pass/packed-struct-vec.rs @@ -22,13 +22,13 @@ struct Foo { pub fn main() { let foos = [Foo { bar: 1, baz: 2 }, .. 10]; - assert_eq!(mem::size_of::<[Foo, .. 10]>(), 90); + fail_unless_eq!(mem::size_of::<[Foo, .. 10]>(), 90); for i in range(0u, 10) { - assert_eq!(foos[i], Foo { bar: 1, baz: 2}); + fail_unless_eq!(foos[i], Foo { bar: 1, baz: 2}); } for &foo in foos.iter() { - assert_eq!(foo, Foo { bar: 1, baz: 2 }); + fail_unless_eq!(foo, Foo { bar: 1, baz: 2 }); } } diff --git a/src/test/run-pass/packed-tuple-struct-layout.rs b/src/test/run-pass/packed-tuple-struct-layout.rs index b3261faddfa2a..10c42ca950662 100644 --- a/src/test/run-pass/packed-tuple-struct-layout.rs +++ b/src/test/run-pass/packed-tuple-struct-layout.rs @@ -20,11 +20,11 @@ pub fn main() { unsafe { let s4 = S4(1, [2,3,4]); let transd : [u8, .. 4] = cast::transmute(s4); - assert_eq!(transd, [1, 2, 3, 4]); + fail_unless_eq!(transd, [1, 2, 3, 4]); let s5 = S5(1, 0xff_00_00_ff); let transd : [u8, .. 5] = cast::transmute(s5); // Don't worry about endianness, the u32 is palindromic. - assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); + fail_unless_eq!(transd, [1, 0xff, 0, 0, 0xff]); } } diff --git a/src/test/run-pass/packed-tuple-struct-size.rs b/src/test/run-pass/packed-tuple-struct-size.rs index 7d2be73edc398..97fb35973cd36 100644 --- a/src/test/run-pass/packed-tuple-struct-size.rs +++ b/src/test/run-pass/packed-tuple-struct-size.rs @@ -33,16 +33,16 @@ struct S3_Foo(u8, u16, Foo); struct S7_Option(f32, u8, u16, Option<@f64>); pub fn main() { - assert_eq!(mem::size_of::(), 4); + fail_unless_eq!(mem::size_of::(), 4); - assert_eq!(mem::size_of::(), 5); + fail_unless_eq!(mem::size_of::(), 5); - assert_eq!(mem::size_of::(), + fail_unless_eq!(mem::size_of::(), 13 + mem::size_of::<~str>()); - assert_eq!(mem::size_of::(), + fail_unless_eq!(mem::size_of::(), 3 + mem::size_of::()); - assert_eq!(mem::size_of::(), + fail_unless_eq!(mem::size_of::(), 7 + mem::size_of::>()); } diff --git a/src/test/run-pass/pattern-bound-var-in-for-each.rs b/src/test/run-pass/pattern-bound-var-in-for-each.rs index fde1999e72d6a..9f0f67218f201 100644 --- a/src/test/run-pass/pattern-bound-var-in-for-each.rs +++ b/src/test/run-pass/pattern-bound-var-in-for-each.rs @@ -18,7 +18,7 @@ fn foo(src: uint) { Some(src_id) => { for _i in range(0u, 10u) { let yyy = src_id; - assert_eq!(yyy, 0u); + fail_unless_eq!(yyy, 0u); } } _ => { } diff --git a/src/test/run-pass/phase-syntax-link-does-resolve.rs b/src/test/run-pass/phase-syntax-link-does-resolve.rs index a7b8297487d00..2135c8616b4c6 100644 --- a/src/test/run-pass/phase-syntax-link-does-resolve.rs +++ b/src/test/run-pass/phase-syntax-link-does-resolve.rs @@ -30,6 +30,6 @@ extern crate macro_crate_test; fn main() { - assert_eq!(1, make_a_1!()); + fail_unless_eq!(1, make_a_1!()); macro_crate_test::foo(); } diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 876d9d2a6908d..889407be632b0 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -18,5 +18,5 @@ pub fn main() { let p = &mut arena; let x = p.alloc(|| 4u); println!("{}", *x); - assert_eq!(*x, 4u); + fail_unless_eq!(*x, 4u); } diff --git a/src/test/run-pass/private-class-field.rs b/src/test/run-pass/private-class-field.rs index 93872bebec98b..f1c77e94d00ea 100644 --- a/src/test/run-pass/private-class-field.rs +++ b/src/test/run-pass/private-class-field.rs @@ -27,5 +27,5 @@ fn cat(in_x : uint, in_y : int) -> cat { pub fn main() { let mut nyan : cat = cat(52u, 99); - assert_eq!(nyan.meow_count(), 52u); + fail_unless_eq!(nyan.meow_count(), 52u); } diff --git a/src/test/run-pass/raw-str.rs b/src/test/run-pass/raw-str.rs index 5cdc5aa0320eef32396eccc5ae37789439253ba9..c6ebbdce64d2b92aeeb5829e10d085e2624c5fa4 100644 GIT binary patch delta 207 zcmcc0)y};^iitZdF*7H=G%qK$xOlPxlN1Wyfk`F^Nj^TcP*I~uNm*H0Nk;)pX4B2Dkjfol0mWNAd@l*{}q!ZGJmrsb0H(Lz~luiH7I-~R$~CU$wWT@ delta 157 zcmZqYzRI;hib*Z8xHz?_BtErJQKLvHF)3L|M*&P}T61wJ00BgPvKNyK8 get for &'a int { pub fn main() { let x = @6; let y = x.get(); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let x = @6; let y = x.get(); info!("y={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let x = ~6; let y = x.get(); info!("y={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let x = &6; let y = x.get(); info!("y={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); } diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index 050a51c958d57..e8e08eb2f4074 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -25,15 +25,15 @@ pub fn main() { let x = ~[1, 2, 3]; let y = call_sum(x); info!("y=={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let x = ~[1, 2, 3]; let y = x.sum_(); info!("y=={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); let x = ~[1, 2, 3]; let y = x.sum_(); info!("y=={}", y); - assert_eq!(y, 6); + fail_unless_eq!(y, 6); } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 86745deaad8be..8d0378eeb1f10 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -59,12 +59,12 @@ pub fn main() { info!("y = {}", y); // per clang/gcc the alignment of `inner` is 4 on x86. - assert_eq!(rusti::min_align_of::(), m::align()); + fail_unless_eq!(rusti::min_align_of::(), m::align()); // per clang/gcc the size of `outer` should be 12 // because `inner`s alignment was 4. - assert_eq!(mem::size_of::(), m::size()); + fail_unless_eq!(mem::size_of::(), m::size()); - assert_eq!(y, ~"Outer{c8: 22u8, t: Inner{c64: 44u32}}"); + fail_unless_eq!(y, ~"Outer{c8: 22u8, t: Inner{c64: 44u32}}"); } } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 560425dcb21b8..5b482f81b03ce 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -81,12 +81,12 @@ pub fn main() { info!("y = {}", y); // per clang/gcc the alignment of `Inner` is 4 on x86. - assert_eq!(rusti::min_align_of::(), m::m::align()); + fail_unless_eq!(rusti::min_align_of::(), m::m::align()); // per clang/gcc the size of `Outer` should be 12 // because `Inner`s alignment was 4. - assert_eq!(mem::size_of::(), m::m::size()); + fail_unless_eq!(mem::size_of::(), m::m::size()); - assert_eq!(y, ~"Outer{c8: 22u8, t: Inner{c64: 44u64}}"); + fail_unless_eq!(y, ~"Outer{c8: 22u8, t: Inner{c64: 44u64}}"); } } diff --git a/src/test/run-pass/rec-extend.rs b/src/test/run-pass/rec-extend.rs index de2e937ee84c0..5b9df3b8c0b94 100644 --- a/src/test/run-pass/rec-extend.rs +++ b/src/test/run-pass/rec-extend.rs @@ -17,10 +17,10 @@ pub fn main() { let origin: Point = Point {x: 0, y: 0}; let right: Point = Point {x: origin.x + 10,.. origin}; let up: Point = Point {y: origin.y + 10,.. origin}; - assert_eq!(origin.x, 0); - assert_eq!(origin.y, 0); - assert_eq!(right.x, 10); - assert_eq!(right.y, 0); - assert_eq!(up.x, 0); - assert_eq!(up.y, 10); + fail_unless_eq!(origin.x, 0); + fail_unless_eq!(origin.y, 0); + fail_unless_eq!(right.x, 10); + fail_unless_eq!(right.y, 0); + fail_unless_eq!(up.x, 0); + fail_unless_eq!(up.y, 10); } diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index 0dc547f1a027e..5da2e32883e83 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -16,21 +16,21 @@ fn fst(r: rect) -> Point { let (fst, _) = r; return fst; } fn snd(r: rect) -> Point { let (_, snd) = r; return snd; } fn f(r: rect, x1: int, y1: int, x2: int, y2: int) { - assert_eq!(fst(r).x, x1); - assert_eq!(fst(r).y, y1); - assert_eq!(snd(r).x, x2); - assert_eq!(snd(r).y, y2); + fail_unless_eq!(fst(r).x, x1); + fail_unless_eq!(fst(r).y, y1); + fail_unless_eq!(snd(r).x, x2); + fail_unless_eq!(snd(r).y, y2); } pub fn main() { let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22}); - assert_eq!(fst(r).x, 10); - assert_eq!(fst(r).y, 20); - assert_eq!(snd(r).x, 11); - assert_eq!(snd(r).y, 22); + fail_unless_eq!(fst(r).x, 10); + fail_unless_eq!(fst(r).y, 20); + fail_unless_eq!(snd(r).x, 11); + fail_unless_eq!(snd(r).y, 22); let r2 = r; let x: int = fst(r2).x; - assert_eq!(x, 10); + fail_unless_eq!(x, 10); f(r, 10, 20, 11, 22); f(r2, 10, 20, 11, 22); } diff --git a/src/test/run-pass/rec.rs b/src/test/run-pass/rec.rs index b9b5cfebb0b56..fbe88f0855329 100644 --- a/src/test/run-pass/rec.rs +++ b/src/test/run-pass/rec.rs @@ -14,21 +14,21 @@ struct Rect {x: int, y: int, w: int, h: int} fn f(r: Rect, x: int, y: int, w: int, h: int) { - assert_eq!(r.x, x); - assert_eq!(r.y, y); - assert_eq!(r.w, w); - assert_eq!(r.h, h); + fail_unless_eq!(r.x, x); + fail_unless_eq!(r.y, y); + fail_unless_eq!(r.w, w); + fail_unless_eq!(r.h, h); } pub fn main() { let r: Rect = Rect {x: 10, y: 20, w: 100, h: 200}; - assert_eq!(r.x, 10); - assert_eq!(r.y, 20); - assert_eq!(r.w, 100); - assert_eq!(r.h, 200); + fail_unless_eq!(r.x, 10); + fail_unless_eq!(r.y, 20); + fail_unless_eq!(r.w, 100); + fail_unless_eq!(r.h, 200); let r2: Rect = r; let x: int = r2.x; - assert_eq!(x, 10); + fail_unless_eq!(x, 10); f(r, 10, 20, 100, 200); f(r2, 10, 20, 100, 200); } diff --git a/src/test/run-pass/record-pat.rs b/src/test/run-pass/record-pat.rs index ff87cceba1913..315e1d2447c1a 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -20,6 +20,6 @@ fn m(input: t3) -> int { } pub fn main() { - assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); - assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); + fail_unless_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); + fail_unless_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); } diff --git a/src/test/run-pass/reexported-static-methods-cross-crate.rs b/src/test/run-pass/reexported-static-methods-cross-crate.rs index 7c9635c162c68..e67551dea5d2f 100644 --- a/src/test/run-pass/reexported-static-methods-cross-crate.rs +++ b/src/test/run-pass/reexported-static-methods-cross-crate.rs @@ -18,8 +18,8 @@ use reexported_static_methods::Boz; use reexported_static_methods::Bort; pub fn main() { - assert_eq!(42, Foo::foo()); - assert_eq!(84, Baz::bar()); + fail_unless_eq!(42, Foo::foo()); + fail_unless_eq!(84, Baz::bar()); fail_unless!(Boz::boz(1)); - assert_eq!(~"bort()", Bort::bort()); + fail_unless_eq!(~"bort()", Bort::bort()); } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 56db021e2bc29..8a30ba6bbb972 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -156,5 +156,5 @@ pub fn main() { for s in v.types.iter() { println!("type: {}", (*s).clone()); } - assert_eq!(v.types.clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]); + fail_unless_eq!(v.types.clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]); } diff --git a/src/test/run-pass/regions-appearance-constraint.rs b/src/test/run-pass/regions-appearance-constraint.rs index 3b0a457559ccf..190756634498e 100644 --- a/src/test/run-pass/regions-appearance-constraint.rs +++ b/src/test/run-pass/regions-appearance-constraint.rs @@ -27,9 +27,9 @@ fn testfn(cond: bool) { x = @5; y = @6; - assert_eq!(*a, exp); - assert_eq!(x, @5); - assert_eq!(y, @6); + fail_unless_eq!(*a, exp); + fail_unless_eq!(x, @5); + fail_unless_eq!(y, @6); } pub fn main() { diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index 5b1b1dd8ec3b4..b5f99af76a7f7 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -18,5 +18,5 @@ pub fn main() { let p = @22u; let r = foo(p); info!("r={}", r); - assert_eq!(r, 22u); + fail_unless_eq!(r, 22u); } diff --git a/src/test/run-pass/regions-borrow-estr-uniq.rs b/src/test/run-pass/regions-borrow-estr-uniq.rs index b7d9b9f8fa9d5..b0659d20d7193 100644 --- a/src/test/run-pass/regions-borrow-estr-uniq.rs +++ b/src/test/run-pass/regions-borrow-estr-uniq.rs @@ -15,9 +15,9 @@ fn foo(x: &str) -> u8 { pub fn main() { let p = ~"hello"; let r = foo(p); - assert_eq!(r, 'h' as u8); + fail_unless_eq!(r, 'h' as u8); let p = ~"hello"; let r = foo(p); - assert_eq!(r, 'h' as u8); + fail_unless_eq!(r, 'h' as u8); } diff --git a/src/test/run-pass/regions-borrow-evec-fixed.rs b/src/test/run-pass/regions-borrow-evec-fixed.rs index 9022ff92c8f2e..9bf60b8149871 100644 --- a/src/test/run-pass/regions-borrow-evec-fixed.rs +++ b/src/test/run-pass/regions-borrow-evec-fixed.rs @@ -14,5 +14,5 @@ fn foo(x: &[int]) -> int { pub fn main() { let p = [1,2,3,4,5]; - assert_eq!(foo(p), 1); + fail_unless_eq!(foo(p), 1); } diff --git a/src/test/run-pass/regions-borrow-evec-uniq.rs b/src/test/run-pass/regions-borrow-evec-uniq.rs index 914c51eaa7012..6192b8051e964 100644 --- a/src/test/run-pass/regions-borrow-evec-uniq.rs +++ b/src/test/run-pass/regions-borrow-evec-uniq.rs @@ -15,9 +15,9 @@ fn foo(x: &[int]) -> int { pub fn main() { let p = ~[1,2,3,4,5]; let r = foo(p); - assert_eq!(r, 1); + fail_unless_eq!(r, 1); let p = ~[5,4,3,2,1]; let r = foo(p); - assert_eq!(r, 5); + fail_unless_eq!(r, 5); } diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index 10037d9dfe43b..826c1b9852dff 100644 --- a/src/test/run-pass/regions-borrow-uniq.rs +++ b/src/test/run-pass/regions-borrow-uniq.rs @@ -15,5 +15,5 @@ fn foo(x: &uint) -> uint { pub fn main() { let p = ~3u; let r = foo(p); - assert_eq!(r, 3u); + fail_unless_eq!(r, 3u); } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 55cb5c6268462..e33c255f6dd76 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -18,11 +18,11 @@ fn box_it<'r>(x: 'r ||) -> closure_box<'r> { pub fn main() { let mut i = 3; - assert_eq!(i, 3); + fail_unless_eq!(i, 3); { let cl = || i += 1; let cl_box = box_it(cl); (cl_box.cl)(); } - assert_eq!(i, 4); + fail_unless_eq!(i, 4); } diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index de619685ca426..a24218eab0364 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -90,29 +90,29 @@ pub fn main() { v6: Some(C { f: 31 })}}; let p = get_v1(&a); - assert_eq!(*p, a.value.v1); + fail_unless_eq!(*p, a.value.v1); let p = get_v2(&a, 1); - assert_eq!(*p, a.value.v2[1]); + fail_unless_eq!(*p, a.value.v2[1]); let p = get_v3(&a, 1); - assert_eq!(*p, a.value.v3[1]); + fail_unless_eq!(*p, a.value.v3[1]); let p = get_v4(&a, 1); - assert_eq!(*p, a.value.v4.f); + fail_unless_eq!(*p, a.value.v4.f); let p = get_v5(&a, 1); - assert_eq!(*p, a.value.v5.f); + fail_unless_eq!(*p, a.value.v5.f); let p = get_v6_a(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); + fail_unless_eq!(*p, a.value.v6.unwrap().f); let p = get_v6_b(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); + fail_unless_eq!(*p, a.value.v6.unwrap().f); let p = get_v6_c(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); + fail_unless_eq!(*p, a.value.v6.unwrap().f); let p = get_v5_ref(&a, 1); - assert_eq!(*p, a.value.v5.f); + fail_unless_eq!(*p, a.value.v5.f); } diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 8ccda6824bdfd..dca0ae9065dd8 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -15,5 +15,5 @@ fn bar(x: &uint) -> uint { *x } pub fn main() { let p = @3u; - assert_eq!(bar(foo(p)), 3); + fail_unless_eq!(bar(foo(p)), 3); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 1f21ca9ef1b2d..32bd82b357359 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -16,7 +16,7 @@ pub fn main() { let x = @3; loop { let y = borrow(x); - assert_eq!(*x, *y); + fail_unless_eq!(*x, *y); break; } } diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 7db4ce8caf249..d5aff24ea1c54 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -19,5 +19,5 @@ fn x_coord<'r>(p: &'r Point) -> &'r int { pub fn main() { let p = @Point {x: 3, y: 4}; let xc = x_coord(p); - assert_eq!(*xc, 3); + fail_unless_eq!(*xc, 3); } diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index 3350c3b65d090..b44e221ca3cc5 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -19,5 +19,5 @@ fn has_one<'a>(x: &'a int) -> int { } pub fn main() { - assert_eq!(has_one(&2), 22); + fail_unless_eq!(has_one(&2), 22); } diff --git a/src/test/run-pass/regions-infer-call.rs b/src/test/run-pass/regions-infer-call.rs index fdb7485efc35b..1bdae97dd369b 100644 --- a/src/test/run-pass/regions-infer-call.rs +++ b/src/test/run-pass/regions-infer-call.rs @@ -15,5 +15,5 @@ fn has_two<'a,'b>(x: &'a int, y: &'b int) -> int { } pub fn main() { - assert_eq!(has_two(&20, &2), 22); + fail_unless_eq!(has_two(&20, &2), 22); } diff --git a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs index 7e328f3bb0354..936fd299fa2b1 100644 --- a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs @@ -24,5 +24,5 @@ fn with(bi: &boxed_int) -> int { pub fn main() { let g = 21; let foo = boxed_int { f: &g }; - assert_eq!(with(&foo), 22); + fail_unless_eq!(with(&foo), 22); } diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass/regions-mock-tcx.rs index 738a4899f2730..7eea41dbbd730 100644 --- a/src/test/run-pass/regions-mock-tcx.rs +++ b/src/test/run-pass/regions-mock-tcx.rs @@ -125,5 +125,5 @@ pub fn main() { let mut tcx = TypeContext::new(&ty_arena, &ast_arena); let ast = tcx.ast(ExprInt); let ty = compute_types(&mut tcx, ast); - assert_eq!(*ty, TypeInt); + fail_unless_eq!(*ty, TypeInt); } diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index 9f204182514f2..f4ecc50b556eb 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -23,5 +23,5 @@ fn parameterized(x: &uint) -> uint { pub fn main() { let x = 3u; - assert_eq!(parameterized(&x), 3u); + fail_unless_eq!(parameterized(&x), 3u); } diff --git a/src/test/run-pass/regions-return-interior-of-option.rs b/src/test/run-pass/regions-return-interior-of-option.rs index aa4630717db6c..35d17c9448149 100644 --- a/src/test/run-pass/regions-return-interior-of-option.rs +++ b/src/test/run-pass/regions-return-interior-of-option.rs @@ -20,13 +20,13 @@ pub fn main() { { let y = get(&x); - assert_eq!(*y, 23); + fail_unless_eq!(*y, 23); } x = Some(24); { let y = get(&x); - assert_eq!(*y, 24); + fail_unless_eq!(*y, 24); } } diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index 9cf959b5b8314..8901ccb728284 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -43,9 +43,9 @@ fn rename_directory() { 1u as libc::size_t, (s.len() + 1u) as libc::size_t, ostream); - assert_eq!(write_len, (s.len() + 1) as libc::size_t) + fail_unless_eq!(write_len, (s.len() + 1) as libc::size_t) }); - assert_eq!(libc::fclose(ostream), (0u as libc::c_int)); + fail_unless_eq!(libc::fclose(ostream), (0u as libc::c_int)); let new_path = tmpdir.join_many(["quux", "blat"]); fs::mkdir_recursive(&new_path, io::UserRWX); diff --git a/src/test/run-pass/repeat-expr-in-static.rs b/src/test/run-pass/repeat-expr-in-static.rs index d060db2bb0748..ea82ea6641da1 100644 --- a/src/test/run-pass/repeat-expr-in-static.rs +++ b/src/test/run-pass/repeat-expr-in-static.rs @@ -12,5 +12,5 @@ static FOO: [int, ..4] = [32, ..4]; static BAR: [int, ..4] = [32, 32, 32, 32]; pub fn main() { - assert_eq!(FOO, BAR); + fail_unless_eq!(FOO, BAR); } diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index bec101a6d45a9..56541d074f9ce 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -38,5 +38,5 @@ pub fn main() { let (c, _d) = b; info!("{:?}", c); } - assert_eq!(i.get(), 1); + fail_unless_eq!(i.get(), 1); } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 2fc52fc8058e1..ed5c4d8be9d09 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -37,5 +37,5 @@ pub fn main() { let my_total = @@Cell::new(10); { let pt = shrinky_pointer(my_total); fail_unless!((pt.look_at() == 10)); } error!("my_total = {}", my_total.get()); - assert_eq!(my_total.get(), 9); + fail_unless_eq!(my_total.get(), 9); } diff --git a/src/test/run-pass/return-from-closure.rs b/src/test/run-pass/return-from-closure.rs index 1756d74a81e17..4ad04f5778fd8 100644 --- a/src/test/run-pass/return-from-closure.rs +++ b/src/test/run-pass/return-from-closure.rs @@ -37,5 +37,5 @@ fn surrounding() { pub fn main() { surrounding(); - assert_eq!(unsafe {calls}, 3); + fail_unless_eq!(unsafe {calls}, 3); } diff --git a/src/test/run-pass/self-in-mut-slot-default-method.rs b/src/test/run-pass/self-in-mut-slot-default-method.rs index 08d10fd11703b..b1000a9e388c6 100644 --- a/src/test/run-pass/self-in-mut-slot-default-method.rs +++ b/src/test/run-pass/self-in-mut-slot-default-method.rs @@ -35,9 +35,9 @@ impl Changer for X { pub fn main() { let x = X { a: 32 }; let new_x = x.change(); - assert_eq!(new_x.a, 55); + fail_unless_eq!(new_x.a, 55); let x = ~new_x; let new_x = x.change_again(); - assert_eq!(new_x.a, 45); + fail_unless_eq!(new_x.a, 45); } diff --git a/src/test/run-pass/self-in-mut-slot-immediate-value.rs b/src/test/run-pass/self-in-mut-slot-immediate-value.rs index f2482474073e0..5ebea76c503bb 100644 --- a/src/test/run-pass/self-in-mut-slot-immediate-value.rs +++ b/src/test/run-pass/self-in-mut-slot-immediate-value.rs @@ -25,6 +25,6 @@ impl Value { pub fn main() { let x = Value { n: 3 }; let y = x.squared(); - assert_eq!(x.n, 3); - assert_eq!(y.n, 9); + fail_unless_eq!(x.n, 3); + fail_unless_eq!(y.n, 9); } diff --git a/src/test/run-pass/send_str_hashmap.rs b/src/test/run-pass/send_str_hashmap.rs index 51825e62178e6..3ebecafd842ef 100644 --- a/src/test/run-pass/send_str_hashmap.rs +++ b/src/test/run-pass/send_str_hashmap.rs @@ -32,8 +32,8 @@ pub fn main() { let v = 46; - assert_eq!(map.find(&Owned(~"foo")), Some(&v)); - assert_eq!(map.find(&Slice("foo")), Some(&v)); + fail_unless_eq!(map.find(&Owned(~"foo")), Some(&v)); + fail_unless_eq!(map.find(&Slice("foo")), Some(&v)); let (a, b, c, d) = (50, 51, 52, 53); @@ -52,23 +52,23 @@ pub fn main() { fail_unless!(!map.insert(Owned(~"cde"), c)); fail_unless!(!map.insert(Slice("def"), d)); - assert_eq!(map.find_equiv(&("abc")), Some(&a)); - assert_eq!(map.find_equiv(&("bcd")), Some(&b)); - assert_eq!(map.find_equiv(&("cde")), Some(&c)); - assert_eq!(map.find_equiv(&("def")), Some(&d)); + fail_unless_eq!(map.find_equiv(&("abc")), Some(&a)); + fail_unless_eq!(map.find_equiv(&("bcd")), Some(&b)); + fail_unless_eq!(map.find_equiv(&("cde")), Some(&c)); + fail_unless_eq!(map.find_equiv(&("def")), Some(&d)); - assert_eq!(map.find_equiv(&(~"abc")), Some(&a)); - assert_eq!(map.find_equiv(&(~"bcd")), Some(&b)); - assert_eq!(map.find_equiv(&(~"cde")), Some(&c)); - assert_eq!(map.find_equiv(&(~"def")), Some(&d)); + fail_unless_eq!(map.find_equiv(&(~"abc")), Some(&a)); + fail_unless_eq!(map.find_equiv(&(~"bcd")), Some(&b)); + fail_unless_eq!(map.find_equiv(&(~"cde")), Some(&c)); + fail_unless_eq!(map.find_equiv(&(~"def")), Some(&d)); - assert_eq!(map.find_equiv(&Slice("abc")), Some(&a)); - assert_eq!(map.find_equiv(&Slice("bcd")), Some(&b)); - assert_eq!(map.find_equiv(&Slice("cde")), Some(&c)); - assert_eq!(map.find_equiv(&Slice("def")), Some(&d)); + fail_unless_eq!(map.find_equiv(&Slice("abc")), Some(&a)); + fail_unless_eq!(map.find_equiv(&Slice("bcd")), Some(&b)); + fail_unless_eq!(map.find_equiv(&Slice("cde")), Some(&c)); + fail_unless_eq!(map.find_equiv(&Slice("def")), Some(&d)); - assert_eq!(map.find_equiv(&Owned(~"abc")), Some(&a)); - assert_eq!(map.find_equiv(&Owned(~"bcd")), Some(&b)); - assert_eq!(map.find_equiv(&Owned(~"cde")), Some(&c)); - assert_eq!(map.find_equiv(&Owned(~"def")), Some(&d)); + fail_unless_eq!(map.find_equiv(&Owned(~"abc")), Some(&a)); + fail_unless_eq!(map.find_equiv(&Owned(~"bcd")), Some(&b)); + fail_unless_eq!(map.find_equiv(&Owned(~"cde")), Some(&c)); + fail_unless_eq!(map.find_equiv(&Owned(~"def")), Some(&d)); } diff --git a/src/test/run-pass/send_str_treemap.rs b/src/test/run-pass/send_str_treemap.rs index 46de7849801ea..0fc97fdf74eb4 100644 --- a/src/test/run-pass/send_str_treemap.rs +++ b/src/test/run-pass/send_str_treemap.rs @@ -34,8 +34,8 @@ pub fn main() { let v = 46; - assert_eq!(map.find(&Owned(~"foo")), Some(&v)); - assert_eq!(map.find(&Slice("foo")), Some(&v)); + fail_unless_eq!(map.find(&Owned(~"foo")), Some(&v)); + fail_unless_eq!(map.find(&Slice("foo")), Some(&v)); let (a, b, c, d) = (50, 51, 52, 53); @@ -54,18 +54,18 @@ pub fn main() { fail_unless!(!map.insert(Owned(~"cde"), c)); fail_unless!(!map.insert(Slice("def"), d)); - assert_eq!(map.find(&Slice("abc")), Some(&a)); - assert_eq!(map.find(&Slice("bcd")), Some(&b)); - assert_eq!(map.find(&Slice("cde")), Some(&c)); - assert_eq!(map.find(&Slice("def")), Some(&d)); + fail_unless_eq!(map.find(&Slice("abc")), Some(&a)); + fail_unless_eq!(map.find(&Slice("bcd")), Some(&b)); + fail_unless_eq!(map.find(&Slice("cde")), Some(&c)); + fail_unless_eq!(map.find(&Slice("def")), Some(&d)); - assert_eq!(map.find(&Owned(~"abc")), Some(&a)); - assert_eq!(map.find(&Owned(~"bcd")), Some(&b)); - assert_eq!(map.find(&Owned(~"cde")), Some(&c)); - assert_eq!(map.find(&Owned(~"def")), Some(&d)); + fail_unless_eq!(map.find(&Owned(~"abc")), Some(&a)); + fail_unless_eq!(map.find(&Owned(~"bcd")), Some(&b)); + fail_unless_eq!(map.find(&Owned(~"cde")), Some(&c)); + fail_unless_eq!(map.find(&Owned(~"def")), Some(&d)); fail_unless!(map.pop(&Slice("foo")).is_some()); - assert_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str()) + fail_unless_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str()) .to_owned_vec() .concat(), ~"abc50bcd51cde52def53"); diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 23c936b1a011e..50b104c755f1c 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -16,5 +16,5 @@ fn test(f: |uint| -> uint) -> uint { pub fn main() { let y = test(|x| 4u * x); - assert_eq!(y, 88u); + fail_unless_eq!(y, 88u); } diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index a39907d5c7ede..db6e0c376d792 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -20,7 +20,7 @@ fn test05() { let three = ~3; let fn_to_send: proc(int) = proc(n) { error!("{}", *three + n); // will copy x into the closure - assert_eq!(*three, 3); + fail_unless_eq!(*three, 3); }; task::spawn(proc() { test05_start(fn_to_send); diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index 289fa595c2dc6..778cfba62772a 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -21,6 +21,6 @@ pub fn main() { fail_unless!((~[1, 2, 3] <= ~[1, 2, 3])); fail_unless!((~[1, 2, 3] <= ~[1, 2, 3, 3])); fail_unless!((~[1, 2, 3, 4] > ~[1, 2, 3])); - assert_eq!(~[1, 2, 3], ~[1, 2, 3]); + fail_unless_eq!(~[1, 2, 3], ~[1, 2, 3]); fail_unless!((~[1, 2, 3] != ~[1, 1, 3])); } diff --git a/src/test/run-pass/shift.rs b/src/test/run-pass/shift.rs index 945bb885ad1bf..b4b7f2275bc26 100644 --- a/src/test/run-pass/shift.rs +++ b/src/test/run-pass/shift.rs @@ -18,64 +18,64 @@ pub fn main() { } fn test_misc() { - assert_eq!(1 << 1i8 << 1u8 << 1i16 << 1u8 << 1u64, 32); + fail_unless_eq!(1 << 1i8 << 1u8 << 1i16 << 1u8 << 1u64, 32); } fn test_expr() { let v10 = 10 as uint; let v4 = 4 as u8; let v2 = 2 as u8; - assert_eq!(v10 >> v2, v2 as uint); - assert_eq!(v10 << v4, 160 as uint); + fail_unless_eq!(v10 >> v2, v2 as uint); + fail_unless_eq!(v10 << v4, 160 as uint); let v10 = 10 as u8; let v4 = 4 as uint; let v2 = 2 as uint; - assert_eq!(v10 >> v2, v2 as u8); - assert_eq!(v10 << v4, 160 as u8); + fail_unless_eq!(v10 >> v2, v2 as u8); + fail_unless_eq!(v10 << v4, 160 as u8); let v10 = 10 as int; let v4 = 4 as i8; let v2 = 2 as i8; - assert_eq!(v10 >> v2, v2 as int); - assert_eq!(v10 << v4, 160 as int); + fail_unless_eq!(v10 >> v2, v2 as int); + fail_unless_eq!(v10 << v4, 160 as int); let v10 = 10 as i8; let v4 = 4 as int; let v2 = 2 as int; - assert_eq!(v10 >> v2, v2 as i8); - assert_eq!(v10 << v4, 160 as i8); + fail_unless_eq!(v10 >> v2, v2 as i8); + fail_unless_eq!(v10 << v4, 160 as i8); let v10 = 10 as uint; let v4 = 4 as int; let v2 = 2 as int; - assert_eq!(v10 >> v2, v2 as uint); - assert_eq!(v10 << v4, 160 as uint); + fail_unless_eq!(v10 >> v2, v2 as uint); + fail_unless_eq!(v10 << v4, 160 as uint); } fn test_const() { static r1_1: uint = 10u >> 2u8; static r2_1: uint = 10u << 4u8; - assert_eq!(r1_1, 2 as uint); - assert_eq!(r2_1, 160 as uint); + fail_unless_eq!(r1_1, 2 as uint); + fail_unless_eq!(r2_1, 160 as uint); static r1_2: u8 = 10u8 >> 2u; static r2_2: u8 = 10u8 << 4u; - assert_eq!(r1_2, 2 as u8); - assert_eq!(r2_2, 160 as u8); + fail_unless_eq!(r1_2, 2 as u8); + fail_unless_eq!(r2_2, 160 as u8); static r1_3: int = 10 >> 2i8; static r2_3: int = 10 << 4i8; - assert_eq!(r1_3, 2 as int); - assert_eq!(r2_3, 160 as int); + fail_unless_eq!(r1_3, 2 as int); + fail_unless_eq!(r2_3, 160 as int); static r1_4: i8 = 10i8 >> 2; static r2_4: i8 = 10i8 << 4; - assert_eq!(r1_4, 2 as i8); - assert_eq!(r2_4, 160 as i8); + fail_unless_eq!(r1_4, 2 as i8); + fail_unless_eq!(r2_4, 160 as i8); static r1_5: uint = 10u >> 2i8; static r2_5: uint = 10u << 4i8; - assert_eq!(r1_5, 2 as uint); - assert_eq!(r2_5, 160 as uint); + fail_unless_eq!(r1_5, 2 as uint); + fail_unless_eq!(r2_5, 160 as uint); } diff --git a/src/test/run-pass/signed-shift-const-eval.rs b/src/test/run-pass/signed-shift-const-eval.rs index 92c83c22085b0..604caecd3c57d 100644 --- a/src/test/run-pass/signed-shift-const-eval.rs +++ b/src/test/run-pass/signed-shift-const-eval.rs @@ -10,5 +10,5 @@ enum test { thing = -5 >> 1u } pub fn main() { - assert_eq!(thing as int, -3); + fail_unless_eq!(thing as int, -3); } diff --git a/src/test/run-pass/simd-binop.rs b/src/test/run-pass/simd-binop.rs index 85c6555d7ce18..8d7924f70dc4e 100644 --- a/src/test/run-pass/simd-binop.rs +++ b/src/test/run-pass/simd-binop.rs @@ -32,7 +32,7 @@ pub fn test_shift(e: u32) -> u32 { } pub fn main() { - assert_eq!(test_int(3i32), 9i32); - assert_eq!(test_float(3f32), 9f32); - assert_eq!(test_shift(3u32), 3u32); + fail_unless_eq!(test_int(3i32), 9i32); + fail_unless_eq!(test_float(3f32), 9f32); + fail_unless_eq!(test_shift(3u32), 3u32); } diff --git a/src/test/run-pass/simd-generics.rs b/src/test/run-pass/simd-generics.rs index 7ef8913a84753..92f35edc7ca8c 100644 --- a/src/test/run-pass/simd-generics.rs +++ b/src/test/run-pass/simd-generics.rs @@ -31,8 +31,8 @@ pub fn main() { // lame-o let f32x4(x, y, z, w) = add(lr, lr); - assert_eq!(x, 2.0f32); - assert_eq!(y, 4.0f32); - assert_eq!(z, 6.0f32); - assert_eq!(w, 8.0f32); + fail_unless_eq!(x, 2.0f32); + fail_unless_eq!(y, 4.0f32); + fail_unless_eq!(z, 6.0f32); + fail_unless_eq!(w, 8.0f32); } diff --git a/src/test/run-pass/small-enum-range-edge.rs b/src/test/run-pass/small-enum-range-edge.rs index a9fc13437abb4..bc17c7a315346 100644 --- a/src/test/run-pass/small-enum-range-edge.rs +++ b/src/test/run-pass/small-enum-range-edge.rs @@ -23,10 +23,10 @@ static CLs: Es = Ls; static CHs: Es = Hs; pub fn main() { - assert_eq!((Hu as u8) + 1, Lu as u8); - assert_eq!((Hs as i8) + 1, Ls as i8); - assert_eq!(CLu as u8, Lu as u8); - assert_eq!(CHu as u8, Hu as u8); - assert_eq!(CLs as i8, Ls as i8); - assert_eq!(CHs as i8, Hs as i8); + fail_unless_eq!((Hu as u8) + 1, Lu as u8); + fail_unless_eq!((Hs as i8) + 1, Ls as i8); + fail_unless_eq!(CLu as u8, Lu as u8); + fail_unless_eq!(CHu as u8, Hu as u8); + fail_unless_eq!(CLs as i8, Ls as i8); + fail_unless_eq!(CHs as i8, Hs as i8); } diff --git a/src/test/run-pass/small-enums-with-fields.rs b/src/test/run-pass/small-enums-with-fields.rs index 06b536b8391df..10f76d52db7f7 100644 --- a/src/test/run-pass/small-enums-with-fields.rs +++ b/src/test/run-pass/small-enums-with-fields.rs @@ -17,13 +17,13 @@ enum Either { Left(T), Right(U) } macro_rules! check { ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ - assert_eq!(size_of::<$t>(), $sz); + fail_unless_eq!(size_of::<$t>(), $sz); $({ static S: $t = $e; let v: $t = $e; - assert_eq!(S, v); - assert_eq!(format!("{:?}", v), ~$s); - assert_eq!(format!("{:?}", S), ~$s); + fail_unless_eq!(S, v); + fail_unless_eq!(format!("{:?}", v), ~$s); + fail_unless_eq!(format!("{:?}", S), ~$s); });* }} } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 67d1836b545cf..1baa65bba6b64 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -19,7 +19,7 @@ use std::task; type ctx = Chan; fn iotask(_cx: &ctx, ip: ~str) { - assert_eq!(ip, ~"localhost"); + fail_unless_eq!(ip, ~"localhost"); } pub fn main() { diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index 8530c583b1654..8704ea7014098 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -23,13 +23,13 @@ fn child(args: (int, int, int, int, int, int, int, int, int)) { error!("{}", i7); error!("{}", i8); error!("{}", i9); - assert_eq!(i1, 10); - assert_eq!(i2, 20); - assert_eq!(i3, 30); - assert_eq!(i4, 40); - assert_eq!(i5, 50); - assert_eq!(i6, 60); - assert_eq!(i7, 70); - assert_eq!(i8, 80); - assert_eq!(i9, 90); + fail_unless_eq!(i1, 10); + fail_unless_eq!(i2, 20); + fail_unless_eq!(i3, 30); + fail_unless_eq!(i4, 40); + fail_unless_eq!(i5, 50); + fail_unless_eq!(i6, 60); + fail_unless_eq!(i7, 70); + fail_unless_eq!(i8, 80); + fail_unless_eq!(i9, 90); } diff --git a/src/test/run-pass/stable-addr-of.rs b/src/test/run-pass/stable-addr-of.rs index 083d2e167a075..8c7071f777f80 100644 --- a/src/test/run-pass/stable-addr-of.rs +++ b/src/test/run-pass/stable-addr-of.rs @@ -12,5 +12,5 @@ pub fn main() { let foo = 1; - assert_eq!(&foo as *int, &foo as *int); + fail_unless_eq!(&foo as *int, &foo as *int); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index 38fcd485a58a0..790811f0f3bef 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -32,5 +32,5 @@ pub fn main() { } fail_unless!(path.exists()); - assert_eq!(path.stat().unwrap().size, 1000); + fail_unless_eq!(path.stat().unwrap().size, 1000); } diff --git a/src/test/run-pass/static-function-pointer-xc.rs b/src/test/run-pass/static-function-pointer-xc.rs index 8471b63379223..10120a4dab59c 100644 --- a/src/test/run-pass/static-function-pointer-xc.rs +++ b/src/test/run-pass/static-function-pointer-xc.rs @@ -15,12 +15,12 @@ extern crate aux = "static-function-pointer-aux"; fn f(x: int) -> int { x } pub fn main() { - assert_eq!(aux::F(42), -42); + fail_unless_eq!(aux::F(42), -42); unsafe { - assert_eq!(aux::MutF(42), -42); + fail_unless_eq!(aux::MutF(42), -42); aux::MutF = f; - assert_eq!(aux::MutF(42), 42); + fail_unless_eq!(aux::MutF(42), 42); aux::MutF = aux::f; - assert_eq!(aux::MutF(42), -42); + fail_unless_eq!(aux::MutF(42), -42); } } diff --git a/src/test/run-pass/static-function-pointer.rs b/src/test/run-pass/static-function-pointer.rs index f8a889113ac5c..ad18200efa513 100644 --- a/src/test/run-pass/static-function-pointer.rs +++ b/src/test/run-pass/static-function-pointer.rs @@ -15,10 +15,10 @@ static F: extern fn(int) -> int = f; static mut G: extern fn(int) -> int = f; pub fn main() { - assert_eq!(F(42), 42); + fail_unless_eq!(F(42), 42); unsafe { - assert_eq!(G(42), 42); + fail_unless_eq!(G(42), 42); G = g; - assert_eq!(G(42), 84); + fail_unless_eq!(G(42), 84); } } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index bdfd40e860054..0a024d5d3517b 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -56,13 +56,13 @@ impl vec_utils for ~[T] { } pub fn main() { - assert_eq!(10u.plus(), 30); - assert_eq!((~"hi").plus(), 200); + fail_unless_eq!(10u.plus(), 30); + fail_unless_eq!((~"hi").plus(), 200); - assert_eq!((~[1]).length_().str(), ~"1"); - assert_eq!((~[3, 4]).map_(|a| *a + 4 )[0], 7); - assert_eq!((~[3, 4]).map_::(|a| *a as uint + 4u )[0], 7u); + fail_unless_eq!((~[1]).length_().str(), ~"1"); + fail_unless_eq!((~[3, 4]).map_(|a| *a + 4 )[0], 7); + fail_unless_eq!((~[3, 4]).map_::(|a| *a as uint + 4u )[0], 7u); let mut x = 0u; 10u.multi(|_n| x += 2u ); - assert_eq!(x, 20u); + fail_unless_eq!(x, 20u); } diff --git a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs index d1fcc4659b937..600e1d5c587a0 100644 --- a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs +++ b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs @@ -31,5 +31,5 @@ impl Deserializer for FromThinAir { pub fn main() { let d = FromThinAir { dummy: () }; let i: int = Deserializable::deserialize(&d); - assert_eq!(i, 22); + fail_unless_eq!(i, 22); } diff --git a/src/test/run-pass/static-method-xcrate.rs b/src/test/run-pass/static-method-xcrate.rs index db3f61567d8b8..1517ff9d86516 100644 --- a/src/test/run-pass/static-method-xcrate.rs +++ b/src/test/run-pass/static-method-xcrate.rs @@ -17,7 +17,7 @@ use static_methods_crate::read; pub fn main() { let result: int = read(~"5"); - assert_eq!(result, 5); - assert_eq!(read::readMaybe(~"false"), Some(false)); - assert_eq!(read::readMaybe(~"foo"), None::); + fail_unless_eq!(result, 5); + fail_unless_eq!(read::readMaybe(~"false"), Some(false)); + fail_unless_eq!(read::readMaybe(~"foo"), None::); } diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index 180cd115c96e8..8223035d05fdc 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -29,6 +29,6 @@ mod a { pub fn main() { let x: int = a::Foo::foo(); let y: uint = a::Foo::foo(); - assert_eq!(x, 3); - assert_eq!(y, 5); + fail_unless_eq!(x, 3); + fail_unless_eq!(y, 5); } diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index c6ff57ac4e804..9c342f4c35a87 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -16,7 +16,7 @@ fn test1() { let mut s: ~str = ~"hello"; s.push_str("world"); info!("{}", s.clone()); - assert_eq!(s[9], 'd' as u8); + fail_unless_eq!(s[9], 'd' as u8); } fn test2() { @@ -27,8 +27,8 @@ fn test2() { let b: ~str = ~"ABC" + ff + "ABC"; info!("{}", a.clone()); info!("{}", b.clone()); - assert_eq!(a, ~"abcABCabc"); - assert_eq!(b, ~"ABCabcABC"); + fail_unless_eq!(a, ~"abcABCabc"); + fail_unless_eq!(b, ~"ABCabcABC"); } pub fn main() { test1(); test2(); } diff --git a/src/test/run-pass/str-concat.rs b/src/test/run-pass/str-concat.rs index 8b87682384b68..307a16dc19bb3 100644 --- a/src/test/run-pass/str-concat.rs +++ b/src/test/run-pass/str-concat.rs @@ -16,5 +16,5 @@ pub fn main() { let b: ~str = ~"world"; let s: ~str = a + b; info!("{}", s.clone()); - assert_eq!(s[9], 'd' as u8); + fail_unless_eq!(s[9], 'd' as u8); } diff --git a/src/test/run-pass/str-growth.rs b/src/test/run-pass/str-growth.rs index 0cdf1841331a8..e7256001dceef 100644 --- a/src/test/run-pass/str-growth.rs +++ b/src/test/run-pass/str-growth.rs @@ -13,12 +13,12 @@ pub fn main() { let mut s = ~"a"; s.push_char('b'); - assert_eq!(s[0], 'a' as u8); - assert_eq!(s[1], 'b' as u8); + fail_unless_eq!(s[0], 'a' as u8); + fail_unless_eq!(s[1], 'b' as u8); s.push_char('c'); s.push_char('d'); - assert_eq!(s[0], 'a' as u8); - assert_eq!(s[1], 'b' as u8); - assert_eq!(s[2], 'c' as u8); - assert_eq!(s[3], 'd' as u8); + fail_unless_eq!(s[0], 'a' as u8); + fail_unless_eq!(s[1], 'b' as u8); + fail_unless_eq!(s[2], 'c' as u8); + fail_unless_eq!(s[3], 'd' as u8); } diff --git a/src/test/run-pass/str-idx.rs b/src/test/run-pass/str-idx.rs index ebed8e24a4841..732b8a5214262 100644 --- a/src/test/run-pass/str-idx.rs +++ b/src/test/run-pass/str-idx.rs @@ -14,5 +14,5 @@ pub fn main() { let s = ~"hello"; let c: u8 = s[4]; info!("{:?}", c); - assert_eq!(c, 0x6f as u8); + fail_unless_eq!(c, 0x6f as u8); } diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index 3c5a860d6c832..df4e36540532d 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -20,6 +20,6 @@ is a test"; is \ another \ test"; - assert_eq!(a, ~"this is a test"); - assert_eq!(b, ~"this is another test"); + fail_unless_eq!(a, ~"this is a test"); + fail_unless_eq!(b, ~"this is another test"); } diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index 34a818879d0b6..b59e33fddcdbf 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -17,7 +17,7 @@ pub fn main() { let mut expected_len = 1u; while i > 0 { error!("{}", a.len()); - assert_eq!(a.len(), expected_len); + fail_unless_eq!(a.len(), expected_len); a = a + a; // FIXME(#3387)---can't write a += a i -= 1; expected_len *= 2u; diff --git a/src/test/run-pass/struct-destructuring-cross-crate.rs b/src/test/run-pass/struct-destructuring-cross-crate.rs index 31ba7149c29b4..74d0de9a62299 100644 --- a/src/test/run-pass/struct-destructuring-cross-crate.rs +++ b/src/test/run-pass/struct-destructuring-cross-crate.rs @@ -16,6 +16,6 @@ extern crate struct_destructuring_cross_crate; pub fn main() { let x = struct_destructuring_cross_crate::S { x: 1, y: 2 }; let struct_destructuring_cross_crate::S { x: a, y: b } = x; - assert_eq!(a, 1); - assert_eq!(b, 2); + fail_unless_eq!(a, 1); + fail_unless_eq!(b, 2); } diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index e15a4f419aed4..9e928258addb9 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -16,5 +16,5 @@ struct Foo<'a> { pub fn main() { let f = Foo { x: @3 }; - assert_eq!(*f.x, 3); + fail_unless_eq!(*f.x, 3); } diff --git a/src/test/run-pass/struct-like-variant-match.rs b/src/test/run-pass/struct-like-variant-match.rs index bb03f57be78e8..3d8e227eb88c1 100644 --- a/src/test/run-pass/struct-like-variant-match.rs +++ b/src/test/run-pass/struct-like-variant-match.rs @@ -24,12 +24,12 @@ enum Foo { fn f(x: &Foo) { match *x { Baz { x: x, y: y } => { - assert_eq!(x, 1.0); - assert_eq!(y, 2.0); + fail_unless_eq!(x, 1.0); + fail_unless_eq!(y, 2.0); } Bar { y: y, x: x } => { - assert_eq!(x, 1); - assert_eq!(y, 2); + fail_unless_eq!(x, 1); + fail_unless_eq!(y, 2); } } } diff --git a/src/test/run-pass/struct-lit-functional-update-no-fields.rs b/src/test/run-pass/struct-lit-functional-update-no-fields.rs index f63a729a5b86f..e33c146154d5a 100644 --- a/src/test/run-pass/struct-lit-functional-update-no-fields.rs +++ b/src/test/run-pass/struct-lit-functional-update-no-fields.rs @@ -22,7 +22,7 @@ pub fn main() { let foo_ = foo.clone(); let foo = Foo { ..foo }; - assert_eq!(foo, foo_); + fail_unless_eq!(foo, foo_); let foo = Foo { bar: ~"one", @@ -31,5 +31,5 @@ pub fn main() { let foo_ = foo.clone(); let foo = Foo { ..foo }; - assert_eq!(foo, foo_); + fail_unless_eq!(foo, foo_); } diff --git a/src/test/run-pass/struct-new-as-field-name.rs b/src/test/run-pass/struct-new-as-field-name.rs index 21eb0ae99b4af..0caa46fb9a634 100644 --- a/src/test/run-pass/struct-new-as-field-name.rs +++ b/src/test/run-pass/struct-new-as-field-name.rs @@ -14,5 +14,5 @@ struct Foo { pub fn main() { let foo = Foo{ new: 3 }; - assert_eq!(foo.new, 3); + fail_unless_eq!(foo.new, 3); } diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index c668981b40a7b..653bfc463de3b 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -34,10 +34,10 @@ fn test1() { error!("b: {:x}", qq.b as uint); error!("c: {:x}", qq.c as uint); error!("d: {:x}", qq.d as uint); - assert_eq!(qq.a, q.c + 1u64); - assert_eq!(qq.b, q.d - 1u64); - assert_eq!(qq.c, q.a + 1u64); - assert_eq!(qq.d, q.b - 1u64); + fail_unless_eq!(qq.a, q.c + 1u64); + fail_unless_eq!(qq.b, q.d - 1u64); + fail_unless_eq!(qq.c, q.a + 1u64); + fail_unless_eq!(qq.d, q.b - 1u64); } } @@ -51,9 +51,9 @@ fn test2() { error!("a: {}", ff.a as f64); error!("b: {}", ff.b as uint); error!("c: {}", ff.c as f64); - assert_eq!(ff.a, f.c + 1.0f64); - assert_eq!(ff.b, 0xff_u8); - assert_eq!(ff.c, f.a - 1.0f64); + fail_unless_eq!(ff.a, f.c + 1.0f64); + fail_unless_eq!(ff.b, 0xff_u8); + fail_unless_eq!(ff.c, f.a - 1.0f64); } } diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index 9579420df9aa0..b9e14019783ca 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -22,7 +22,7 @@ impl Eq for foo { pub fn main() { let a = (1, 2, 3); let b = (1, 2, 3); - assert_eq!(a, b); + fail_unless_eq!(a, b); fail_unless!((a != (1, 2, 4))); fail_unless!((a < (1, 2, 4))); fail_unless!((a <= (1, 2, 4))); @@ -31,6 +31,6 @@ pub fn main() { let x = large; let y = small; fail_unless!((x != y)); - assert_eq!(x, large); + fail_unless_eq!(x, large); fail_unless!((x != small)); } diff --git a/src/test/run-pass/supertrait-default-generics.rs b/src/test/run-pass/supertrait-default-generics.rs index 2cfc22111a73f..2f0c23465d50a 100644 --- a/src/test/run-pass/supertrait-default-generics.rs +++ b/src/test/run-pass/supertrait-default-generics.rs @@ -38,5 +38,5 @@ impl> Movable for Point {} pub fn main() { let mut p = Point{ x: 1, y: 2}; p.translate(3); - assert_eq!(p.X(), 4); + fail_unless_eq!(p.X(), 4); } diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 208700fde8a8c..4c3bfc5162ae5 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -13,10 +13,10 @@ use std::mem::swap; pub fn main() { let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6]; a.swap(2, 4); - assert_eq!(a[2], 4); - assert_eq!(a[4], 2); + fail_unless_eq!(a[2], 4); + fail_unless_eq!(a[4], 2); let mut n = 42; swap(&mut n, &mut a[0]); - assert_eq!(a[0], 42); - assert_eq!(n, 0); + fail_unless_eq!(a[0], 42); + fail_unless_eq!(n, 0); } diff --git a/src/test/run-pass/syntax-extension-bytes.rs b/src/test/run-pass/syntax-extension-bytes.rs index 5b66d5f28a926..33218d8d118d7 100644 --- a/src/test/run-pass/syntax-extension-bytes.rs +++ b/src/test/run-pass/syntax-extension-bytes.rs @@ -12,13 +12,13 @@ static static_vec: &'static [u8] = bytes!("abc", 0xFF, '!'); pub fn main() { let vec = bytes!("abc"); - assert_eq!(vec, &[97_u8, 98_u8, 99_u8]); + fail_unless_eq!(vec, &[97_u8, 98_u8, 99_u8]); let vec = bytes!("null", 0); - assert_eq!(vec, &[110_u8, 117_u8, 108_u8, 108_u8, 0_u8]); + fail_unless_eq!(vec, &[110_u8, 117_u8, 108_u8, 108_u8, 0_u8]); let vec = bytes!(' ', " ", 32, 32u8); - assert_eq!(vec, &[32_u8, 32_u8, 32_u8, 32_u8]); + fail_unless_eq!(vec, &[32_u8, 32_u8, 32_u8, 32_u8]); - assert_eq!(static_vec, &[97_u8, 98_u8, 99_u8, 255_u8, 33_u8]); + fail_unless_eq!(static_vec, &[97_u8, 98_u8, 99_u8, 255_u8, 33_u8]); } diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs index e89028de06252..249e24c75aa48 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/run-pass/syntax-extension-minor.rs @@ -14,7 +14,7 @@ pub fn main() { let asdf_fdsa = ~"<.<"; - assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<"); + fail_unless_eq!(concat_idents!(asd, f_f, dsa), ~"<.<"); fail_unless!(stringify!(use_mention_distinction) == "use_mention_distinction"); diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index af767cc927099..5f0b7f10af0b9 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -22,11 +22,11 @@ pub mod m1 { macro_rules! indirect_line( () => ( line!() ) ) pub fn main() { - assert_eq!(line!(), 25); + fail_unless_eq!(line!(), 25); //fail_unless!((col!() == 11)); - assert_eq!(indirect_line!(), 27); + fail_unless_eq!(indirect_line!(), 27); fail_unless!((file!().to_owned().ends_with("syntax-extension-source-utils.rs"))); - assert_eq!(stringify!((2*3) + 5).to_owned(), ~"( 2 * 3 ) + 5"); + fail_unless_eq!(stringify!((2*3) + 5).to_owned(), ~"( 2 * 3 ) + 5"); fail_unless!(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() == ~"victory robot 6"); diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index 78cc48e4ed4b3..0d927971fb3e6 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -23,5 +23,5 @@ pub fn main() { let x = t_rec {c8: 22u8, t: a_tag(44u64)}; let y = format!("{:?}", x); info!("y = {}", y); - assert_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}"); + fail_unless_eq!(y, ~"t_rec{c8: 22u8, t: a_tag(44u64)}"); } diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 5411a514991ae..afd23f4f470c9 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -19,7 +19,7 @@ enum color { pub fn main() { let act = format!("{:?}", red); println!("{}", act); - assert_eq!(~"red", act); - assert_eq!(~"green", format!("{:?}", green)); - assert_eq!(~"white", format!("{:?}", white)); + fail_unless_eq!(~"red", act); + fail_unless_eq!(~"green", format!("{:?}", green)); + fail_unless_eq!(~"white", format!("{:?}", white)); } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index c602156905840..286f73ae7aadc 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -39,8 +39,8 @@ pub fn main() { fn test_color(color: color, val: int, name: ~str) { //fail_unless!(unsafe::transmute(color) == val); - assert_eq!(color as int, val); - assert_eq!(color as f64, val as f64); + fail_unless_eq!(color as int, val); + fail_unless_eq!(color as f64, val as f64); fail_unless!(get_color_alt(color) == name); fail_unless!(get_color_if(color) == name); } diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index f02e3a17813f9..1785601bcac05 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -34,5 +34,5 @@ fn test05() { error!("{}", value); value = po.recv(); error!("{}", value); - assert_eq!(value, 30); + fail_unless_eq!(value, 30); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 42d445dc24c2e..7da99bcbdf5c1 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -19,9 +19,9 @@ fn test_rec() { ch.send(r0); let mut r1: R; r1 = po.recv(); - assert_eq!(r1.val0, 0); - assert_eq!(r1.val1, 1u8); - assert_eq!(r1.val2, '2'); + fail_unless_eq!(r1.val0, 0); + fail_unless_eq!(r1.val1, 1u8); + fail_unless_eq!(r1.val2, '2'); } fn test_vec() { @@ -29,9 +29,9 @@ fn test_vec() { let v0: ~[int] = ~[0, 1, 2]; ch.send(v0); let v1 = po.recv(); - assert_eq!(v1[0], 0); - assert_eq!(v1[1], 1); - assert_eq!(v1[2], 2); + fail_unless_eq!(v1[0], 0); + fail_unless_eq!(v1[1], 1); + fail_unless_eq!(v1[2], 2); } fn test_str() { @@ -39,10 +39,10 @@ fn test_str() { let s0 = ~"test"; ch.send(s0); let s1 = po.recv(); - assert_eq!(s1[0], 't' as u8); - assert_eq!(s1[1], 'e' as u8); - assert_eq!(s1[2], 's' as u8); - assert_eq!(s1[3], 't' as u8); + fail_unless_eq!(s1[0], 't' as u8); + fail_unless_eq!(s1[1], 'e' as u8); + fail_unless_eq!(s1[2], 's' as u8); + fail_unless_eq!(s1[3], 't' as u8); } enum t { @@ -85,11 +85,11 @@ fn test_tag() { ch.send(tag3(10, 11u8, 'A')); let mut t1: t; t1 = po.recv(); - assert_eq!(t1, tag1); + fail_unless_eq!(t1, tag1); t1 = po.recv(); - assert_eq!(t1, tag2(10)); + fail_unless_eq!(t1, tag2(10)); t1 = po.recv(); - assert_eq!(t1, tag3(10, 11u8, 'A')); + fail_unless_eq!(t1, tag3(10, 11u8, 'A')); } fn test_chan() { @@ -102,7 +102,7 @@ fn test_chan() { ch1.send(10); let mut i: int; i = po0.recv(); - assert_eq!(i, 10); + fail_unless_eq!(i, 10); } pub fn main() { diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index 732d72c11fec2..6b2a0125ee68c 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -71,5 +71,5 @@ fn test00() { error!("{:?}", sum); // assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) * // number_of_messages)); - assert_eq!(sum, 480); + fail_unless_eq!(sum, 480); } diff --git a/src/test/run-pass/task-comm-4.rs b/src/test/run-pass/task-comm-4.rs index 3ac4c0e008768..3e62334c13f70 100644 --- a/src/test/run-pass/task-comm-4.rs +++ b/src/test/run-pass/task-comm-4.rs @@ -48,5 +48,5 @@ fn test00() { r = p.recv(); sum += r; info!("{}", r); - assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8); + fail_unless_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8); } diff --git a/src/test/run-pass/task-comm-5.rs b/src/test/run-pass/task-comm-5.rs index 64ccf4f3df873..4ede3a52147d5 100644 --- a/src/test/run-pass/task-comm-5.rs +++ b/src/test/run-pass/task-comm-5.rs @@ -21,5 +21,5 @@ fn test00() { while i < number_of_messages { c.send(i + 0); i += 1; } i = 0; while i < number_of_messages { sum += p.recv(); i += 1; } - assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); + fail_unless_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); } diff --git a/src/test/run-pass/task-comm-6.rs b/src/test/run-pass/task-comm-6.rs index c63bf8bc85659..bbab1d640a326 100644 --- a/src/test/run-pass/task-comm-6.rs +++ b/src/test/run-pass/task-comm-6.rs @@ -41,7 +41,7 @@ fn test00() { sum += r; i += 1; } - assert_eq!(sum, 1998000); + fail_unless_eq!(sum, 1998000); // assert (sum == 4 * ((number_of_messages * // (number_of_messages - 1)) / 2)); diff --git a/src/test/run-pass/task-comm-7.rs b/src/test/run-pass/task-comm-7.rs index e72e5677776d0..a82db64e359be 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -60,5 +60,5 @@ fn test00() { i += 1; } - assert_eq!(sum, number_of_messages * 4 * (number_of_messages * 4 - 1) / 2); + fail_unless_eq!(sum, number_of_messages * 4 * (number_of_messages * 4 - 1) / 2); } diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index 4a053b0c47a3a..eab6d8eecaeec 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -43,5 +43,5 @@ fn test00() { result.recv(); - assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); + fail_unless_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); } diff --git a/src/test/run-pass/task-comm-chan-nil.rs b/src/test/run-pass/task-comm-chan-nil.rs index f5fe5be0d7613..492cba2c8615b 100644 --- a/src/test/run-pass/task-comm-chan-nil.rs +++ b/src/test/run-pass/task-comm-chan-nil.rs @@ -18,5 +18,5 @@ pub fn main() { let (po, ch) = Chan::new(); ch.send(()); let n: () = po.recv(); - assert_eq!(n, ()); + fail_unless_eq!(n, ()); } diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index 944c498ede37f..460c83ec941d5 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -22,5 +22,5 @@ pub fn main() { }); let x_in_child = p.recv(); - assert_eq!(x_in_parent, x_in_child); + fail_unless_eq!(x_in_parent, x_in_child); } diff --git a/src/test/run-pass/trait-bounds.rs b/src/test/run-pass/trait-bounds.rs index 7ec6ffbd46458..0c4f0382517d0 100644 --- a/src/test/run-pass/trait-bounds.rs +++ b/src/test/run-pass/trait-bounds.rs @@ -31,5 +31,5 @@ pub fn main() { let factory = (); let connection = factory.create(); let result = connection.read(); - assert_eq!(result, 43); + fail_unless_eq!(result, 43); } diff --git a/src/test/run-pass/trait-default-method-bound-subst.rs b/src/test/run-pass/trait-default-method-bound-subst.rs index ff0c23b2eed77..563b963f0049f 100644 --- a/src/test/run-pass/trait-default-method-bound-subst.rs +++ b/src/test/run-pass/trait-default-method-bound-subst.rs @@ -21,6 +21,6 @@ fn f>(i: V, j: T, k: U) -> (T, U) { } pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0u, 1, 2), (1, 2)); + fail_unless_eq!(f(0, 1, 2), (1, 2)); + fail_unless_eq!(f(0u, 1, 2), (1, 2)); } diff --git a/src/test/run-pass/trait-default-method-bound-subst2.rs b/src/test/run-pass/trait-default-method-bound-subst2.rs index 1ea3879e7faf8..d36b838c45409 100644 --- a/src/test/run-pass/trait-default-method-bound-subst2.rs +++ b/src/test/run-pass/trait-default-method-bound-subst2.rs @@ -20,5 +20,5 @@ fn f>(i: V, j: T) -> T { } pub fn main () { - assert_eq!(f(0, 2), 2); + fail_unless_eq!(f(0, 2), 2); } diff --git a/src/test/run-pass/trait-default-method-bound-subst3.rs b/src/test/run-pass/trait-default-method-bound-subst3.rs index aff20ffe962a2..3f9a428724a70 100644 --- a/src/test/run-pass/trait-default-method-bound-subst3.rs +++ b/src/test/run-pass/trait-default-method-bound-subst3.rs @@ -20,6 +20,6 @@ fn f(i: V, j: T, k: T) -> (T, T) { } pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); + fail_unless_eq!(f(0, 1, 2), (1, 2)); + fail_unless_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); } diff --git a/src/test/run-pass/trait-default-method-bound-subst4.rs b/src/test/run-pass/trait-default-method-bound-subst4.rs index fdc42e58f8cac..f18168b6dab44 100644 --- a/src/test/run-pass/trait-default-method-bound-subst4.rs +++ b/src/test/run-pass/trait-default-method-bound-subst4.rs @@ -20,6 +20,6 @@ fn f>(i: V, j: uint) -> uint { } pub fn main () { - assert_eq!(f::(0, 2u), 2u); - assert_eq!(f::(0, 2u), 2u); + fail_unless_eq!(f::(0, 2u), 2u); + fail_unless_eq!(f::(0, 2u), 2u); } diff --git a/src/test/run-pass/trait-default-method-bound.rs b/src/test/run-pass/trait-default-method-bound.rs index 8a2f1b1743b09..f0115a2e78eb9 100644 --- a/src/test/run-pass/trait-default-method-bound.rs +++ b/src/test/run-pass/trait-default-method-bound.rs @@ -16,7 +16,7 @@ trait A { impl A for int { } fn f(i: T) { - assert_eq!(i.g(), 10); + fail_unless_eq!(i.g(), 10); } pub fn main () { diff --git a/src/test/run-pass/trait-default-method-xc-2.rs b/src/test/run-pass/trait-default-method-xc-2.rs index ccd7c9b8a3af2..c1b626b387f86 100644 --- a/src/test/run-pass/trait-default-method-xc-2.rs +++ b/src/test/run-pass/trait-default-method-xc-2.rs @@ -24,12 +24,12 @@ pub fn main () { let a = a_struct { x: 0 }; let b = a_struct { x: 1 }; - assert_eq!(0i.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(b.g(), 10); - assert_eq!(b.h(), 11); - assert_eq!(A::lurr(&a, &b), 21); + fail_unless_eq!(0i.g(), 10); + fail_unless_eq!(a.g(), 10); + fail_unless_eq!(a.h(), 11); + fail_unless_eq!(b.g(), 10); + fail_unless_eq!(b.h(), 11); + fail_unless_eq!(A::lurr(&a, &b), 21); welp(&0); } diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index aa3ac523f75da..c7afcbb171e3a 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -16,7 +16,7 @@ use aux::{A, TestEquality, Something}; use aux::B; fn f(i: T) { - assert_eq!(i.g(), 10); + fail_unless_eq!(i.g(), 10); } fn welp(i: int, _x: &T) -> int { @@ -55,26 +55,26 @@ pub fn main () { // Some tests of random things f(0); - assert_eq!(A::lurr(&0, &1), 21); + fail_unless_eq!(A::lurr(&0, &1), 21); let a = stuff::thing { x: 0 }; let b = stuff::thing { x: 1 }; let c = Something { x: 1 }; - assert_eq!(0i.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(c.h(), 11); + fail_unless_eq!(0i.g(), 10); + fail_unless_eq!(a.g(), 10); + fail_unless_eq!(a.h(), 11); + fail_unless_eq!(c.h(), 11); - assert_eq!(0i.thing(3.14, 1), (3.14, 1)); - assert_eq!(B::staticthing(&0i, 3.14, 1), (3.14, 1)); - assert_eq!(B::::staticthing::(&0i, 3.14, 1), (3.14, 1)); + fail_unless_eq!(0i.thing(3.14, 1), (3.14, 1)); + fail_unless_eq!(B::staticthing(&0i, 3.14, 1), (3.14, 1)); + fail_unless_eq!(B::::staticthing::(&0i, 3.14, 1), (3.14, 1)); - assert_eq!(g(0i, 3.14, 1), (3.14, 1)); - assert_eq!(g(false, 3.14, 1), (3.14, 1)); + fail_unless_eq!(g(0i, 3.14, 1), (3.14, 1)); + fail_unless_eq!(g(false, 3.14, 1), (3.14, 1)); let obj = ~0i as ~A; - assert_eq!(obj.h(), 11); + fail_unless_eq!(obj.h(), 11); // Trying out a real one diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 12bf4eef44ae4..aa2d849c591ad 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -45,8 +45,8 @@ fn bar>(x: T) -> ~[~str] { } pub fn main() { - assert_eq!(foo(~[1]), ~[~"hi"]); - assert_eq!(bar::(~[4, 5]), ~[~"4", ~"5"]); - assert_eq!(bar::<~str, ~[~str]>(~[~"x", ~"y"]), ~[~"x", ~"y"]); - assert_eq!(bar::<(), ~[()]>(~[()]), ~[~"()"]); + fail_unless_eq!(foo(~[1]), ~[~"hi"]); + fail_unless_eq!(bar::(~[4, 5]), ~[~"4", ~"5"]); + fail_unless_eq!(bar::<~str, ~[~str]>(~[~"x", ~"y"]), ~[~"x", ~"y"]); + fail_unless_eq!(bar::<(), ~[()]>(~[()]), ~[~"()"]); } diff --git a/src/test/run-pass/trait-inheritance-auto-xc-2.rs b/src/test/run-pass/trait-inheritance-auto-xc-2.rs index bf6c429b6c80e..8e74e2c28819a 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc-2.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc-2.rs @@ -21,9 +21,9 @@ pub trait Quux: Foo + Bar + Baz { } impl Quux for T { } fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); + fail_unless_eq!(a.f(), 10); + fail_unless_eq!(a.g(), 20); + fail_unless_eq!(a.h(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-auto-xc.rs b/src/test/run-pass/trait-inheritance-auto-xc.rs index ef72611e76f15..3b381b8c20666 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc.rs @@ -22,9 +22,9 @@ impl Bar for A { fn g(&self) -> int { 20 } } impl Baz for A { fn h(&self) -> int { 30 } } fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); + fail_unless_eq!(a.f(), 10); + fail_unless_eq!(a.g(), 20); + fail_unless_eq!(a.h(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs index c5a7720e3c341..db82ff73201d9 100644 --- a/src/test/run-pass/trait-inheritance-auto.rs +++ b/src/test/run-pass/trait-inheritance-auto.rs @@ -25,9 +25,9 @@ impl Bar for A { fn g(&self) -> int { 20 } } impl Baz for A { fn h(&self) -> int { 30 } } fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); + fail_unless_eq!(a.f(), 10); + fail_unless_eq!(a.g(), 20); + fail_unless_eq!(a.h(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs index 46258902f9cae..de53231e5d5ba 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -23,5 +23,5 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert_eq!(gg(a), 10); + fail_unless_eq!(gg(a), 10); } diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs index 7b79ad42ed2b3..1d4bc1f4b4309 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -26,5 +26,5 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert_eq!(gg(a), 10); + fail_unless_eq!(gg(a), 10); } diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs index 68a31ba9dbe64..6c1234a696c93 100644 --- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs @@ -35,6 +35,6 @@ pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; - assert_eq!(afoo.f(), 10); - assert_eq!(abar.g(), 20); + fail_unless_eq!(afoo.f(), 10); + fail_unless_eq!(abar.g(), 20); } diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs index 4580fb7ab9919..2cd9c8dacae29 100644 --- a/src/test/run-pass/trait-inheritance-cast.rs +++ b/src/test/run-pass/trait-inheritance-cast.rs @@ -36,7 +36,7 @@ pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; - assert_eq!(afoo.f(), 10); - assert_eq!(abar.g(), 20); - assert_eq!(abar.f(), 10); + fail_unless_eq!(afoo.f(), 10); + fail_unless_eq!(abar.g(), 20); + fail_unless_eq!(abar.f(), 10); } diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs index cdc0c5a80a9ba..df32ef2632a77 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs @@ -25,5 +25,5 @@ impl Bar for aux::A { pub fn main() { let a = &aux::A { x: 3 }; - assert_eq!(a.g(), 10); + fail_unless_eq!(a.g(), 10); } diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs index 7b047b5cc800a..1f8fd4fec5bd6 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -22,5 +22,5 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - assert_eq!(a.g(), 10); + fail_unless_eq!(a.g(), 10); } diff --git a/src/test/run-pass/trait-inheritance-diamond.rs b/src/test/run-pass/trait-inheritance-diamond.rs index 253c10ac6f1b0..071bc64b35895 100644 --- a/src/test/run-pass/trait-inheritance-diamond.rs +++ b/src/test/run-pass/trait-inheritance-diamond.rs @@ -23,10 +23,10 @@ impl C for S { fn c(&self) -> int { 30 } } impl D for S { fn d(&self) -> int { 40 } } fn f(x: &T) { - assert_eq!(x.a(), 10); - assert_eq!(x.b(), 20); - assert_eq!(x.c(), 30); - assert_eq!(x.d(), 40); + fail_unless_eq!(x.a(), 10); + fail_unless_eq!(x.b(), 20); + fail_unless_eq!(x.c(), 30); + fail_unless_eq!(x.d(), 40); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-multiple-inheritors.rs b/src/test/run-pass/trait-inheritance-multiple-inheritors.rs index 6cd3d62473692..28e3b3b81b634 100644 --- a/src/test/run-pass/trait-inheritance-multiple-inheritors.rs +++ b/src/test/run-pass/trait-inheritance-multiple-inheritors.rs @@ -20,9 +20,9 @@ impl C for S { fn c(&self) -> int { 30 } } // Both B and C inherit from A fn f(x: &T) { - assert_eq!(x.a(), 10); - assert_eq!(x.b(), 20); - assert_eq!(x.c(), 30); + fail_unless_eq!(x.a(), 10); + fail_unless_eq!(x.b(), 20); + fail_unless_eq!(x.c(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-multiple-params.rs b/src/test/run-pass/trait-inheritance-multiple-params.rs index b5524c6dda6cd..594565fcaca71 100644 --- a/src/test/run-pass/trait-inheritance-multiple-params.rs +++ b/src/test/run-pass/trait-inheritance-multiple-params.rs @@ -20,11 +20,11 @@ impl C for S { fn c(&self) -> int { 30 } } // Multiple type params, multiple levels of inheritance fn f(x: &X, y: &Y, z: &Z) { - assert_eq!(x.a(), 10); - assert_eq!(y.a(), 10); - assert_eq!(y.b(), 20); - assert_eq!(z.a(), 10); - assert_eq!(z.c(), 30); + fail_unless_eq!(x.a(), 10); + fail_unless_eq!(y.a(), 10); + fail_unless_eq!(y.b(), 20); + fail_unless_eq!(z.a(), 10); + fail_unless_eq!(z.c(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index 30b1b26eaa1c9..132650ba988f0 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -30,5 +30,5 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); fail_unless!(x != y); - assert_eq!(x, z); + fail_unless_eq!(x, z); } diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index faadc68f135bd..0f431c54c4d0a 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -23,7 +23,7 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); - assert_eq!(a, mi(8)); - assert_eq!(b, mi(-2)); - assert_eq!(c, mi(15)); + fail_unless_eq!(a, mi(8)); + fail_unless_eq!(b, mi(-2)); + fail_unless_eq!(c, mi(15)); } diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index fb19bfa674fd8..6edcd5e6c5b9e 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -42,7 +42,7 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); - assert_eq!(a, mi(8)); - assert_eq!(b, mi(-2)); - assert_eq!(c, mi(15)); + fail_unless_eq!(a, mi(8)); + fail_unless_eq!(b, mi(-2)); + fail_unless_eq!(c, mi(15)); } diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index 113efa663afaf..6b99655c54612 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -26,6 +26,6 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert_eq!(ff(a), 10); - assert_eq!(gg(a), 20); + fail_unless_eq!(ff(a), 10); + fail_unless_eq!(gg(a), 20); } diff --git a/src/test/run-pass/trait-inheritance-static.rs b/src/test/run-pass/trait-inheritance-static.rs index 08543b236f3dc..065b40917ba50 100644 --- a/src/test/run-pass/trait-inheritance-static.rs +++ b/src/test/run-pass/trait-inheritance-static.rs @@ -30,5 +30,5 @@ fn greater_than_one() -> T { MyNum::from_int(1) } pub fn main() { let v: S = greater_than_one(); - assert_eq!(v.v, 1); + fail_unless_eq!(v.v, 1); } diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs index 95131176ce752..c54569a29f0d9 100644 --- a/src/test/run-pass/trait-inheritance-static2.rs +++ b/src/test/run-pass/trait-inheritance-static2.rs @@ -34,5 +34,5 @@ fn greater_than_one() -> T { MyNum::from_int(1) } pub fn main() { let v: S = greater_than_one(); - assert_eq!(v.v, 1); + fail_unless_eq!(v.v, 1); } diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index ebddfafc3b438..e8002c01ea0c7 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -41,5 +41,5 @@ fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y) = (mi(3), mi(5)); let z = f(x, y); - assert_eq!(z.val, 13); + fail_unless_eq!(z.val, 13); } diff --git a/src/test/run-pass/trait-inheritance-visibility.rs b/src/test/run-pass/trait-inheritance-visibility.rs index 3cdedd884a42c..d9e4a36f7c4ec 100644 --- a/src/test/run-pass/trait-inheritance-visibility.rs +++ b/src/test/run-pass/trait-inheritance-visibility.rs @@ -20,7 +20,7 @@ impl Quux for T { } // Foo is not in scope but because Quux is we can still access // Foo's methods on a Quux bound typaram fn f(x: &T) { - assert_eq!(x.f(), 10); + fail_unless_eq!(x.f(), 10); } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs index 7fa895ddf9888..94710a890f279 100644 --- a/src/test/run-pass/trait-inheritance2.rs +++ b/src/test/run-pass/trait-inheritance2.rs @@ -22,9 +22,9 @@ impl Baz for A { fn h(&self) -> int { 30 } } impl Quux for A {} fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); + fail_unless_eq!(a.f(), 10); + fail_unless_eq!(a.g(), 20); + fail_unless_eq!(a.h(), 30); } pub fn main() { diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index e2422a1dcf563..049dfa1e0498d 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -43,5 +43,5 @@ impl Trait for () { pub fn main() { let a = ~() as ~Trait; - assert_eq!(a.method(Constant), 0); + fail_unless_eq!(a.method(Constant), 0); } diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index 412fb6625e33f..a8cfa6f56c385 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -26,5 +26,5 @@ impl Foo for A { pub fn main() { let a = A { x: 3 }; let b = (&a) as &Foo; - assert_eq!(b.f(), 3); + fail_unless_eq!(b.f(), 3); } diff --git a/src/test/run-pass/trait-with-bounds-default.rs b/src/test/run-pass/trait-with-bounds-default.rs index ba2f32a04990b..f577a1ea9361d 100644 --- a/src/test/run-pass/trait-with-bounds-default.rs +++ b/src/test/run-pass/trait-with-bounds-default.rs @@ -35,6 +35,6 @@ impl Getter for Option { pub fn main() { - assert_eq!(3.do_get2(), (3, 3)); - assert_eq!(Some(~"hi").do_get2(), (~"hi", ~"hi")); + fail_unless_eq!(3.do_get2(), (3, 3)); + fail_unless_eq!(Some(~"hi").do_get2(), (~"hi", ~"hi")); } diff --git a/src/test/run-pass/traits-default-method-macro.rs b/src/test/run-pass/traits-default-method-macro.rs index 340d0bc71aa13..78983658df12b 100644 --- a/src/test/run-pass/traits-default-method-macro.rs +++ b/src/test/run-pass/traits-default-method-macro.rs @@ -24,5 +24,5 @@ impl Foo for Baz { pub fn main() { let q = Quux; - assert_eq!(q.bar(), ~"test"); + fail_unless_eq!(q.bar(), ~"test"); } diff --git a/src/test/run-pass/tup.rs b/src/test/run-pass/tup.rs index dd508d6e90ca0..cc5459c50a797 100644 --- a/src/test/run-pass/tup.rs +++ b/src/test/run-pass/tup.rs @@ -12,15 +12,15 @@ type point = (int, int); fn f(p: point, x: int, y: int) { let (a, b) = p; - assert_eq!(a, x); - assert_eq!(b, y); + fail_unless_eq!(a, x); + fail_unless_eq!(b, y); } pub fn main() { let p: point = (10, 20); let (a, b) = p; - assert_eq!(a, 10); - assert_eq!(b, 20); + fail_unless_eq!(a, 10); + fail_unless_eq!(b, 20); let p2: point = p; f(p, 10, 20); f(p2, 10, 20); diff --git a/src/test/run-pass/tuple-struct-constructor-pointer.rs b/src/test/run-pass/tuple-struct-constructor-pointer.rs index e51e6ffd52abc..45fe135386458 100644 --- a/src/test/run-pass/tuple-struct-constructor-pointer.rs +++ b/src/test/run-pass/tuple-struct-constructor-pointer.rs @@ -16,6 +16,6 @@ struct Bar(int, int); pub fn main() { let f: extern fn(int) -> Foo = Foo; let g: extern fn(int, int) -> Bar = Bar; - assert_eq!(f(42), Foo(42)); - assert_eq!(g(4, 7), Bar(4, 7)); + fail_unless_eq!(f(42), Foo(42)); + fail_unless_eq!(g(4, 7), Bar(4, 7)); } diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index ec7675abf8337..7aacb6ae1278f 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -14,6 +14,6 @@ pub fn main() { let x = Foo(1, 2); let Foo(y, z) = x; println!("{} {}", y, z); - assert_eq!(y, 1); - assert_eq!(z, 2); + fail_unless_eq!(y, 1); + fail_unless_eq!(z, 2); } diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index f50b04059532d..13d67d26c27ad 100644 --- a/src/test/run-pass/tuple-struct-matching.rs +++ b/src/test/run-pass/tuple-struct-matching.rs @@ -14,8 +14,8 @@ pub fn main() { let x = Foo(1, 2); match x { Foo(a, b) => { - assert_eq!(a, 1); - assert_eq!(b, 2); + fail_unless_eq!(a, 1); + fail_unless_eq!(b, 2); println!("{} {}", a, b); } } diff --git a/src/test/run-pass/tydesc-name.rs b/src/test/run-pass/tydesc-name.rs index ea337aae27bcb..958ab647197f9 100644 --- a/src/test/run-pass/tydesc-name.rs +++ b/src/test/run-pass/tydesc-name.rs @@ -18,8 +18,8 @@ struct Foo { pub fn main() { unsafe { - assert_eq!((*get_tydesc::()).name, "int"); - assert_eq!((*get_tydesc::<~[int]>()).name, "~[int]"); - assert_eq!((*get_tydesc::>()).name, "Foo"); + fail_unless_eq!((*get_tydesc::()).name, "int"); + fail_unless_eq!((*get_tydesc::<~[int]>()).name, "~[int]"); + fail_unless_eq!((*get_tydesc::>()).name, "Foo"); } } diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index 6d477816ba850..208d2b65c42ed 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -20,19 +20,19 @@ struct x {a: int, b: (), c: ()} struct y {x: int} pub fn main() { - assert_eq!(size_of::(), 1 as uint); - assert_eq!(size_of::(), 4 as uint); - assert_eq!(size_of::(), 4 as uint); - assert_eq!(size_of::(), 1 as uint); - assert_eq!(size_of::(), 4 as uint); - assert_eq!(size_of::(), 2 as uint); - assert_eq!(size_of::(), 3 as uint); + fail_unless_eq!(size_of::(), 1 as uint); + fail_unless_eq!(size_of::(), 4 as uint); + fail_unless_eq!(size_of::(), 4 as uint); + fail_unless_eq!(size_of::(), 1 as uint); + fail_unless_eq!(size_of::(), 4 as uint); + fail_unless_eq!(size_of::(), 2 as uint); + fail_unless_eq!(size_of::(), 3 as uint); // Alignment causes padding before the char and the u32. fail_unless!(size_of::() == 16 as uint); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), size_of::()); + fail_unless_eq!(size_of::(), size_of::()); } diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index 7ad9d8dfe0597..2267a345787f5 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -23,34 +23,34 @@ struct Test; pub fn main() { unsafe { - assert_eq!(intrinsics::type_id::(), other1::id_A()); - assert_eq!(intrinsics::type_id::(), other1::id_B()); - assert_eq!(intrinsics::type_id::(), other1::id_C()); - assert_eq!(intrinsics::type_id::(), other1::id_D()); - assert_eq!(intrinsics::type_id::(), other1::id_E()); - assert_eq!(intrinsics::type_id::(), other1::id_F()); - assert_eq!(intrinsics::type_id::(), other1::id_G()); - assert_eq!(intrinsics::type_id::(), other1::id_H()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_A()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_B()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_C()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_D()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_E()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_F()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_G()); + fail_unless_eq!(intrinsics::type_id::(), other1::id_H()); - assert_eq!(intrinsics::type_id::(), other2::id_A()); - assert_eq!(intrinsics::type_id::(), other2::id_B()); - assert_eq!(intrinsics::type_id::(), other2::id_C()); - assert_eq!(intrinsics::type_id::(), other2::id_D()); - assert_eq!(intrinsics::type_id::(), other2::id_E()); - assert_eq!(intrinsics::type_id::(), other2::id_F()); - assert_eq!(intrinsics::type_id::(), other2::id_G()); - assert_eq!(intrinsics::type_id::(), other2::id_H()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_A()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_B()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_C()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_D()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_E()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_F()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_G()); + fail_unless_eq!(intrinsics::type_id::(), other2::id_H()); - assert_eq!(other1::id_F(), other2::id_F()); - assert_eq!(other1::id_G(), other2::id_G()); - assert_eq!(other1::id_H(), other2::id_H()); + fail_unless_eq!(other1::id_F(), other2::id_F()); + fail_unless_eq!(other1::id_G(), other2::id_G()); + fail_unless_eq!(other1::id_H(), other2::id_H()); - assert_eq!(intrinsics::type_id::(), other2::foo::()); - assert_eq!(intrinsics::type_id::(), other1::foo::()); - assert_eq!(other2::foo::(), other1::foo::()); - assert_eq!(intrinsics::type_id::(), other2::foo::()); - assert_eq!(intrinsics::type_id::(), other1::foo::()); - assert_eq!(other2::foo::(), other1::foo::()); + fail_unless_eq!(intrinsics::type_id::(), other2::foo::()); + fail_unless_eq!(intrinsics::type_id::(), other1::foo::()); + fail_unless_eq!(other2::foo::(), other1::foo::()); + fail_unless_eq!(intrinsics::type_id::(), other2::foo::()); + fail_unless_eq!(intrinsics::type_id::(), other1::foo::()); + fail_unless_eq!(other2::foo::(), other1::foo::()); } // sanity test of TypeId @@ -63,12 +63,12 @@ pub fn main() { fail_unless!(a != c); fail_unless!(b != c); - assert_eq!(a, d); - assert_eq!(b, e); - assert_eq!(c, f); + fail_unless_eq!(a, d); + fail_unless_eq!(b, e); + fail_unless_eq!(c, f); // check it has a hash let (a, b) = (TypeId::of::(), TypeId::of::()); - assert_eq!(a.hash(), b.hash()); + fail_unless_eq!(a.hash(), b.hash()); } diff --git a/src/test/run-pass/u32-decr.rs b/src/test/run-pass/u32-decr.rs index 6ad320580dfec..3470044391821 100644 --- a/src/test/run-pass/u32-decr.rs +++ b/src/test/run-pass/u32-decr.rs @@ -14,5 +14,5 @@ pub fn main() { let mut word: u32 = 200000u32; word = word - 1u32; - assert_eq!(word, 199999u32); + fail_unless_eq!(word, 199999u32); } diff --git a/src/test/run-pass/u8-incr-decr.rs b/src/test/run-pass/u8-incr-decr.rs index 0a178b250af4f..643548506b8fd 100644 --- a/src/test/run-pass/u8-incr-decr.rs +++ b/src/test/run-pass/u8-incr-decr.rs @@ -23,5 +23,5 @@ pub fn main() { y = y - 9u8; // 0x9 - assert_eq!(x, y); + fail_unless_eq!(x, y); } diff --git a/src/test/run-pass/u8-incr.rs b/src/test/run-pass/u8-incr.rs index 90ed3a5eec3a2..b45cd1c98dca3 100644 --- a/src/test/run-pass/u8-incr.rs +++ b/src/test/run-pass/u8-incr.rs @@ -16,7 +16,7 @@ pub fn main() { let y: u8 = 12u8; x = x + 1u8; x = x - 1u8; - assert_eq!(x, y); + fail_unless_eq!(x, y); // x = 14u8; // x = x + 1u8; diff --git a/src/test/run-pass/unfold-cross-crate.rs b/src/test/run-pass/unfold-cross-crate.rs index 1c3eafb203291..75dbef764ae6b 100644 --- a/src/test/run-pass/unfold-cross-crate.rs +++ b/src/test/run-pass/unfold-cross-crate.rs @@ -27,8 +27,8 @@ pub fn main() { let mut it = Unfold::new(0, count); let mut i = 0; for counted in it { - assert_eq!(counted, i); + fail_unless_eq!(counted, i); i += 1; } - assert_eq!(i, 10); + fail_unless_eq!(i, 10); } diff --git a/src/test/run-pass/uniq-self-in-mut-slot.rs b/src/test/run-pass/uniq-self-in-mut-slot.rs index 7c2f52211761f..9eb34a1dccb75 100644 --- a/src/test/run-pass/uniq-self-in-mut-slot.rs +++ b/src/test/run-pass/uniq-self-in-mut-slot.rs @@ -26,5 +26,5 @@ impl Changer for X { pub fn main() { let x = ~X { a: 32 }; let new_x = x.change(); - assert_eq!(new_x.a, 55); + fail_unless_eq!(new_x.a, 55); } diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index e59fe469dec6f..d4477238128a7 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -15,6 +15,6 @@ pub fn main() { j = i.clone(); *i = 2; *j = 3; - assert_eq!(*i, 2); - assert_eq!(*j, 3); + fail_unless_eq!(*i, 2); + fail_unless_eq!(*j, 3); } diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index 9144ecc74f98a..7848d548dd7b0 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -15,5 +15,5 @@ pub fn main() { let mut j = ~2; // Should drop the previous value of j j = i; - assert_eq!(*j, 1); + fail_unless_eq!(*j, 1); } diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 8fb2b9b40f4fb..75e571ad96b3c 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -17,7 +17,7 @@ fn f(t: T) -> T { pub fn main() { let t = f(~100); - assert_eq!(t, ~100); + fail_unless_eq!(t, ~100); let t = f(~@~[100]); - assert_eq!(t, ~@~[100]); + fail_unless_eq!(t, ~@~[100]); } diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index 43df53c78a8dd..e874f7ad8a175 100644 --- a/src/test/run-pass/unique-assign.rs +++ b/src/test/run-pass/unique-assign.rs @@ -11,5 +11,5 @@ pub fn main() { let mut i; i = ~1; - assert_eq!(*i, 1); + fail_unless_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-autoderef-field.rs b/src/test/run-pass/unique-autoderef-field.rs index 6836ba4e79b00..eb0431d72ee8c 100644 --- a/src/test/run-pass/unique-autoderef-field.rs +++ b/src/test/run-pass/unique-autoderef-field.rs @@ -14,5 +14,5 @@ pub fn main() { let i = ~J { j: 100 }; - assert_eq!(i.j, 100); + fail_unless_eq!(i.j, 100); } diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 46f9ca794a9fe..a7358419b5025 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -10,5 +10,5 @@ pub fn main() { let i = ~~[100]; - assert_eq!(i[0], 100); + fail_unless_eq!(i[0], 100); } diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index 1ebd584aa5fa7..9cc0867c8c950 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -15,14 +15,14 @@ pub fn main() { /*alt *x { t1(a) { - assert_eq!(a, 10); + fail_unless_eq!(a, 10); } _ { fail!(); } }*/ /*alt x { ~t1(a) { - assert_eq!(a, 10); + fail_unless_eq!(a, 10); } _ { fail!(); } }*/ diff --git a/src/test/run-pass/unique-copy-box.rs b/src/test/run-pass/unique-copy-box.rs index 48a49996aeebb..576e28212bc0a 100644 --- a/src/test/run-pass/unique-copy-box.rs +++ b/src/test/run-pass/unique-copy-box.rs @@ -20,5 +20,5 @@ pub fn main() { let j = i.clone(); let rc2 = managed::refcount(*i); error!("rc1: {} rc2: {}", rc1, rc2); - assert_eq!(rc1 + 1u, rc2); + fail_unless_eq!(rc1 + 1u, rc2); } diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index 13594d86f6764..9dcfd148911b6 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -14,6 +14,6 @@ pub fn main() { let mut j = i.clone(); *i = 2; *j = 3; - assert_eq!(*i, 2); - assert_eq!(*j, 3); + fail_unless_eq!(*i, 2); + fail_unless_eq!(*j, 3); } diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index c507d19fac16b..4727dcb8165d1 100644 --- a/src/test/run-pass/unique-decl-init.rs +++ b/src/test/run-pass/unique-decl-init.rs @@ -11,5 +11,5 @@ pub fn main() { let i = ~1; let j = i; - assert_eq!(*j, 1); + fail_unless_eq!(*j, 1); } diff --git a/src/test/run-pass/unique-decl-move-temp.rs b/src/test/run-pass/unique-decl-move-temp.rs index 6cf781d735cfa..542780f6a43ef 100644 --- a/src/test/run-pass/unique-decl-move-temp.rs +++ b/src/test/run-pass/unique-decl-move-temp.rs @@ -10,5 +10,5 @@ pub fn main() { let i = ~100; - assert_eq!(*i, 100); + fail_unless_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index 335275ff7c102..7e53808947683 100644 --- a/src/test/run-pass/unique-decl-move.rs +++ b/src/test/run-pass/unique-decl-move.rs @@ -11,5 +11,5 @@ pub fn main() { let i = ~100; let j = i; - assert_eq!(*j, 100); + fail_unless_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 6cf781d735cfa..542780f6a43ef 100644 --- a/src/test/run-pass/unique-deref.rs +++ b/src/test/run-pass/unique-deref.rs @@ -10,5 +10,5 @@ pub fn main() { let i = ~100; - assert_eq!(*i, 100); + fail_unless_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-destructure.rs b/src/test/run-pass/unique-destructure.rs index 6c35cb4dba77b..eff0919b250e7 100644 --- a/src/test/run-pass/unique-destructure.rs +++ b/src/test/run-pass/unique-destructure.rs @@ -12,5 +12,5 @@ struct Foo { a: int, b: int } pub fn main() { let ~Foo{a, b} = ~Foo{a: 100, b: 200}; - assert_eq!(a + b, 300); + fail_unless_eq!(a + b, 300); } diff --git a/src/test/run-pass/unique-fn-arg-move.rs b/src/test/run-pass/unique-fn-arg-move.rs index 503bbae8c55a9..6dfd7a660f9a9 100644 --- a/src/test/run-pass/unique-fn-arg-move.rs +++ b/src/test/run-pass/unique-fn-arg-move.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f(i: ~int) { - assert_eq!(*i, 100); + fail_unless_eq!(*i, 100); } pub fn main() { diff --git a/src/test/run-pass/unique-fn-arg-mut.rs b/src/test/run-pass/unique-fn-arg-mut.rs index c2d78c3303902..2d4c5c1f785e4 100644 --- a/src/test/run-pass/unique-fn-arg-mut.rs +++ b/src/test/run-pass/unique-fn-arg-mut.rs @@ -15,5 +15,5 @@ fn f(i: &mut ~int) { pub fn main() { let mut i = ~100; f(&mut i); - assert_eq!(*i, 200); + fail_unless_eq!(*i, 200); } diff --git a/src/test/run-pass/unique-fn-arg.rs b/src/test/run-pass/unique-fn-arg.rs index 230131bae62bc..db12c5a3d9537 100644 --- a/src/test/run-pass/unique-fn-arg.rs +++ b/src/test/run-pass/unique-fn-arg.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f(i: ~int) { - assert_eq!(*i, 100); + fail_unless_eq!(*i, 100); } pub fn main() { diff --git a/src/test/run-pass/unique-fn-ret.rs b/src/test/run-pass/unique-fn-ret.rs index dd39e136fc9bb..13b68a141d9ac 100644 --- a/src/test/run-pass/unique-fn-ret.rs +++ b/src/test/run-pass/unique-fn-ret.rs @@ -13,5 +13,5 @@ fn f() -> ~int { } pub fn main() { - assert_eq!(f(), ~100); + fail_unless_eq!(f(), ~100); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index 3a27d7844bcad..3812550479472 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -12,12 +12,12 @@ pub fn main() { let mut a = ~[~10]; let b = a.clone(); - assert_eq!(*a[0], 10); - assert_eq!(*b[0], 10); + fail_unless_eq!(*a[0], 10); + fail_unless_eq!(*b[0], 10); // This should only modify the value in a, not b *a[0] = 20; - assert_eq!(*a[0], 20); - assert_eq!(*b[0], 10); + fail_unless_eq!(*a[0], 20); + fail_unless_eq!(*b[0], 10); } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 9176fbf94626a..3d3363746fd03 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -13,7 +13,7 @@ use std::cmp::Eq; fn sendable() { fn f(i: T, j: T) { - assert_eq!(i, j); + fail_unless_eq!(i, j); } fn g(i: T, j: T) { @@ -31,7 +31,7 @@ fn sendable() { fn copyable() { fn f(i: T, j: T) { - assert_eq!(i, j); + fail_unless_eq!(i, j); } fn g(i: T, j: T) { @@ -49,7 +49,7 @@ fn copyable() { fn noncopyable() { fn f(i: T, j: T) { - assert_eq!(i, j); + fail_unless_eq!(i, j); } fn g(i: T, j: T) { diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index cbef0044f8cf8..9df7d317c1bff 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -14,5 +14,5 @@ pub fn main() { let i = ~100; let j = ~200; let j = i; - assert_eq!(*j, 100); + fail_unless_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index 7c7ca1379ea29..c233178fb5b1a 100644 --- a/src/test/run-pass/unique-move-temp.rs +++ b/src/test/run-pass/unique-move-temp.rs @@ -11,5 +11,5 @@ pub fn main() { let mut i; i = ~100; - assert_eq!(*i, 100); + fail_unless_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index dbdfc5cb5bb5f..db4245f2389af 100644 --- a/src/test/run-pass/unique-move.rs +++ b/src/test/run-pass/unique-move.rs @@ -12,5 +12,5 @@ pub fn main() { let i = ~100; let mut j; j = i; - assert_eq!(*j, 100); + fail_unless_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index 4f353c566717c..d11e45d33dfc2 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -11,5 +11,5 @@ pub fn main() { let mut i = ~0; *i = 1; - assert_eq!(*i, 1); + fail_unless_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-rec.rs b/src/test/run-pass/unique-rec.rs index f740dd2a22cdb..65e0797a46ebd 100644 --- a/src/test/run-pass/unique-rec.rs +++ b/src/test/run-pass/unique-rec.rs @@ -13,5 +13,5 @@ struct X { x: int } pub fn main() { let x = ~X {x: 1}; let bar = x; - assert_eq!(bar.x, 1); + fail_unless_eq!(bar.x, 1); } diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index 299fed735ab18..561b3cac88703 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -32,5 +32,5 @@ pub fn main() { actual += *j; } - assert_eq!(expected, actual); + fail_unless_eq!(expected, actual); } diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index a1c0050e725b1..a1504bdeee8b6 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -12,5 +12,5 @@ pub fn main() { let (p, c) = Chan::new(); c.send(~100); let v = p.recv(); - assert_eq!(v, ~100); + fail_unless_eq!(v, ~100); } diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index 779606dba0ccf..5cbd9166043eb 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -14,6 +14,6 @@ pub fn main() { let mut i = ~100; let mut j = ~200; swap(&mut i, &mut j); - assert_eq!(i, ~200); - assert_eq!(j, ~100); + fail_unless_eq!(i, ~200); + fail_unless_eq!(j, ~100); } diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index 04507dd01ce5c..5497a2b50614e 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -26,5 +26,5 @@ pub fn main() { }); let s = x.unwrap_err().move::<&'static str>().unwrap(); - assert_eq!(s.as_slice(), "This failure should happen."); + fail_unless_eq!(s.as_slice(), "This failure should happen."); } diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs index 3385c6f6fef53..d6b796cc86ec8 100644 --- a/src/test/run-pass/unsafe-pointer-assignability.rs +++ b/src/test/run-pass/unsafe-pointer-assignability.rs @@ -10,7 +10,7 @@ fn f(x: *int) { unsafe { - assert_eq!(*x, 3); + fail_unless_eq!(*x, 3); } } diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index 1520a8b7e611c..68d7d1d4df4e8 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -15,14 +15,14 @@ pub fn main() { let y_diaeresis: char = 'ÿ'; // 0xff let pi: char = 'Π'; // 0x3a0 - assert_eq!(yen as int, 0xa5); - assert_eq!(c_cedilla as int, 0xe7); - assert_eq!(thorn as int, 0xfe); - assert_eq!(y_diaeresis as int, 0xff); - assert_eq!(pi as int, 0x3a0); + fail_unless_eq!(yen as int, 0xa5); + fail_unless_eq!(c_cedilla as int, 0xe7); + fail_unless_eq!(thorn as int, 0xfe); + fail_unless_eq!(y_diaeresis as int, 0xff); + fail_unless_eq!(pi as int, 0x3a0); - assert_eq!(pi as int, '\u03a0' as int); - assert_eq!('\x0a' as int, '\n' as int); + fail_unless_eq!(pi as int, '\u03a0' as int); + fail_unless_eq!('\x0a' as int, '\n' as int); let bhutan: ~str = ~"འབྲུག་ཡུལ།"; let japan: ~str = ~"日本"; @@ -37,7 +37,7 @@ pub fn main() { let austria_e: ~str = ~"\u00d6sterreich"; let oo: char = 'Ö'; - assert_eq!(oo as int, 0xd6); + fail_unless_eq!(oo as int, 0xd6); fn check_str_eq(a: ~str, b: ~str) { let mut i: int = 0; @@ -46,7 +46,7 @@ pub fn main() { info!("{}", ab); let bb: u8 = b[i]; info!("{}", bb); - assert_eq!(ab, bb); + fail_unless_eq!(ab, bb); i += 1; } } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 796a8c7c42614..f285a66416575 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -42,12 +42,12 @@ pub fn main() { fail_unless!((!str::is_utf8([0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]))); let mut stack = ~"a×c€"; - assert_eq!(stack.pop_char(), '€'); - assert_eq!(stack.pop_char(), 'c'); + fail_unless_eq!(stack.pop_char(), '€'); + fail_unless_eq!(stack.pop_char(), 'c'); stack.push_char('u'); fail_unless!(stack == ~"a×u"); - assert_eq!(stack.shift_char(), 'a'); - assert_eq!(stack.shift_char(), '×'); + fail_unless_eq!(stack.shift_char(), 'a'); + fail_unless_eq!(stack.shift_char(), '×'); stack.unshift_char('ß'); fail_unless!(stack == ~"ßu"); } diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index c166d158fb00b..3dd8cdc047bed 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -19,7 +19,7 @@ pub fn main() { let Π = 3.14; let लंच = Π * Π + 1.54; fail_unless!(num::abs((लंच - 1.54) - (Π * Π)) < ε); - assert_eq!(საჭმელად_გემრიელი_სადილი(), 0); + fail_unless_eq!(საჭმელად_გემრიელი_სადილი(), 0); } fn საჭმელად_გემრიელი_სადილი() -> int { @@ -43,9 +43,9 @@ fn საჭმელად_გემრიელი_სადილი() -> int // Lunchy arithmetic, mm. - assert_eq!(hádegismatur * ручек * обед, 1000); - assert_eq!(10, ארוחת_צהריי); - assert_eq!(ランチ + 午餐 + μεσημεριανό, 30); - assert_eq!(ăn_trưa + อาหารกลางวัน, 20); + fail_unless_eq!(hádegismatur * ручек * обед, 1000); + fail_unless_eq!(10, ארוחת_צהריי); + fail_unless_eq!(ランチ + 午餐 + μεσημεριανό, 30); + fail_unless_eq!(ăn_trưa + อาหารกลางวัน, 20); return (абед + լանչ) >> غداء; } diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs index 9cb2f22d38e94..1a088b56dec71 100644 --- a/src/test/run-pass/variadic-ffi.rs +++ b/src/test/run-pass/variadic-ffi.rs @@ -19,7 +19,7 @@ unsafe fn check(expected: &str, f: |*mut c_char| -> T) { let mut x = [0i8, ..50]; f(&mut x[0] as *mut c_char); let res = CString::new(&x[0], false); - assert_eq!(expected, res.as_str().unwrap()); + fail_unless_eq!(expected, res.as_str().unwrap()); } pub fn main() { diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index 7014ad5df141d..fca2f0a6c46a5 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -13,7 +13,7 @@ pub fn main() { let b: ~[int] = ~[6, 7, 8, 9, 0]; let v: ~[int] = a + b; info!("{}", v[9]); - assert_eq!(v[0], 1); - assert_eq!(v[7], 8); - assert_eq!(v[9], 0); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[7], 8); + fail_unless_eq!(v[9], 0); } diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index c9a4c57cc9d36..89be869f342b2 100644 --- a/src/test/run-pass/vec-growth.rs +++ b/src/test/run-pass/vec-growth.rs @@ -16,9 +16,9 @@ pub fn main() { v.push(3); v.push(4); v.push(5); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - assert_eq!(v[3], 4); - assert_eq!(v[4], 5); + fail_unless_eq!(v[0], 1); + fail_unless_eq!(v[1], 2); + fail_unless_eq!(v[2], 3); + fail_unless_eq!(v[3], 4); + fail_unless_eq!(v[4], 5); } diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index a2fc2c021bf03..36aa2a8cdc334 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -13,7 +13,7 @@ pub fn main() { match x { [2, _, _] => fail!(), [1, a, b] => { - assert_eq!([a, b], [2, 3]); + fail_unless_eq!([a, b], [2, 3]); } [_, _, _] => fail!(), } @@ -21,8 +21,8 @@ pub fn main() { let y = ([(1, true), (2, false)], 0.5); match y { ([(1, a), (b, false)], _) => { - assert_eq!(a, true); - assert_eq!(b, 2); + fail_unless_eq!(a, true); + fail_unless_eq!(b, 2); } ([_, _], 0.5) => fail!(), ([_, _], _) => fail!(), diff --git a/src/test/run-pass/vec-matching-fixed.rs b/src/test/run-pass/vec-matching-fixed.rs index 17633f12ce524..2b35f826fc32a 100644 --- a/src/test/run-pass/vec-matching-fixed.rs +++ b/src/test/run-pass/vec-matching-fixed.rs @@ -26,9 +26,9 @@ fn a() { } match x { [a, b, c] => { - assert_eq!(1, a); - assert_eq!(2, b); - assert_eq!(3, c); + fail_unless_eq!(1, a); + fail_unless_eq!(2, b); + fail_unless_eq!(3, c); } } } diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 5ba42b68f27c1..9560e083935c2 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -34,8 +34,8 @@ pub fn main() { let x = [1, 2, 3, 4, 5]; let product = foldl(x, 1, |a, b| a * *b); - assert_eq!(product, 120); + fail_unless_eq!(product, 120); let sum = foldr(x, 0, |a, b| *a + b); - assert_eq!(sum, 15); + fail_unless_eq!(sum, 15); } diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 175f774bdfde0..476312e45d372 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -12,7 +12,7 @@ fn a() { let x = [1]; match x { [a] => { - assert_eq!(a, 1); + fail_unless_eq!(a, 1); } } } @@ -21,30 +21,30 @@ fn b() { let x = [1, 2, 3]; match x { [a, b, ..c] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, &[3]); + fail_unless_eq!(a, 1); + fail_unless_eq!(b, 2); + fail_unless_eq!(c, &[3]); } } match x { [..a, b, c] => { - assert_eq!(a, &[1]); - assert_eq!(b, 2); - assert_eq!(c, 3); + fail_unless_eq!(a, &[1]); + fail_unless_eq!(b, 2); + fail_unless_eq!(c, 3); } } match x { [a, ..b, c] => { - assert_eq!(a, 1); - assert_eq!(b, &[2]); - assert_eq!(c, 3); + fail_unless_eq!(a, 1); + fail_unless_eq!(b, &[2]); + fail_unless_eq!(c, 3); } } match x { [a, b, c] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); + fail_unless_eq!(a, 1); + fail_unless_eq!(b, 2); + fail_unless_eq!(c, 3); } } } @@ -65,7 +65,7 @@ fn d() { [1, 2, ..] => 2, _ => 3 }; - assert_eq!(branch, 1); + fail_unless_eq!(branch, 1); } pub fn main() { diff --git a/src/test/run-pass/vec-self-append.rs b/src/test/run-pass/vec-self-append.rs index e9fcfaaf2837f..d94614090a63f 100644 --- a/src/test/run-pass/vec-self-append.rs +++ b/src/test/run-pass/vec-self-append.rs @@ -14,17 +14,17 @@ fn test_heap_to_heap() { // a spills onto the heap let mut a = ~[0, 1, 2, 3, 4]; a = a + a; // FIXME(#3387)---can't write a += a - assert_eq!(a.len(), 10u); - assert_eq!(a[0], 0); - assert_eq!(a[1], 1); - assert_eq!(a[2], 2); - assert_eq!(a[3], 3); - assert_eq!(a[4], 4); - assert_eq!(a[5], 0); - assert_eq!(a[6], 1); - assert_eq!(a[7], 2); - assert_eq!(a[8], 3); - assert_eq!(a[9], 4); + fail_unless_eq!(a.len(), 10u); + fail_unless_eq!(a[0], 0); + fail_unless_eq!(a[1], 1); + fail_unless_eq!(a[2], 2); + fail_unless_eq!(a[3], 3); + fail_unless_eq!(a[4], 4); + fail_unless_eq!(a[5], 0); + fail_unless_eq!(a[6], 1); + fail_unless_eq!(a[7], 2); + fail_unless_eq!(a[8], 3); + fail_unless_eq!(a[9], 4); } fn test_stack_to_heap() { @@ -32,13 +32,13 @@ fn test_stack_to_heap() { let mut a = ~[0, 1, 2]; // a spills to the heap a = a + a; // FIXME(#3387)---can't write a += a - assert_eq!(a.len(), 6u); - assert_eq!(a[0], 0); - assert_eq!(a[1], 1); - assert_eq!(a[2], 2); - assert_eq!(a[3], 0); - assert_eq!(a[4], 1); - assert_eq!(a[5], 2); + fail_unless_eq!(a.len(), 6u); + fail_unless_eq!(a[0], 0); + fail_unless_eq!(a[1], 1); + fail_unless_eq!(a[2], 2); + fail_unless_eq!(a[3], 0); + fail_unless_eq!(a[4], 1); + fail_unless_eq!(a[5], 2); } fn test_loop() { @@ -48,7 +48,7 @@ fn test_loop() { let mut expected_len = 1u; while i > 0 { error!("{}", a.len()); - assert_eq!(a.len(), expected_len); + fail_unless_eq!(a.len(), expected_len); a = a + a; // FIXME(#3387)---can't write a += a i -= 1; expected_len *= 2u; diff --git a/src/test/run-pass/vec-slice-drop.rs b/src/test/run-pass/vec-slice-drop.rs index f8e28dc792cfd..973c0a67ce994 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -34,7 +34,7 @@ pub fn main() { let x = @Cell::new(0); { let l = &[foo(x)]; - assert_eq!(l[0].x.get(), 0); + fail_unless_eq!(l[0].x.get(), 0); } - assert_eq!(x.get(), 1); + fail_unless_eq!(x.get(), 1); } diff --git a/src/test/run-pass/vec-slice.rs b/src/test/run-pass/vec-slice.rs index e3012b0862145..f4373aea0f840 100644 --- a/src/test/run-pass/vec-slice.rs +++ b/src/test/run-pass/vec-slice.rs @@ -11,6 +11,6 @@ pub fn main() { let v = ~[1,2,3,4,5]; let v2 = v.slice(1, 3); - assert_eq!(v2[0], 2); - assert_eq!(v2[1], 3); + fail_unless_eq!(v2[0], 2); + fail_unless_eq!(v2[1], 3); } diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 18afc13510147..6c647008d6929 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -22,7 +22,7 @@ pub fn main() { match x { [ref first, ..tail] => { fail_unless!(first.string == ~"foo"); - assert_eq!(tail.len(), 2); + fail_unless_eq!(tail.len(), 2); fail_unless!(tail[0].string == ~"bar"); fail_unless!(tail[1].string == ~"baz"); @@ -31,8 +31,8 @@ pub fn main() { unreachable!(); } [Foo { string: ref a }, Foo { string: ref b }] => { - assert_eq!("bar", a.slice(0, a.len())); - assert_eq!("baz", b.slice(0, b.len())); + fail_unless_eq!("bar", a.slice(0, a.len())); + fail_unless_eq!("baz", b.slice(0, b.len())); } _ => { unreachable!(); diff --git a/src/test/run-pass/vec-to_str.rs b/src/test/run-pass/vec-to_str.rs index e25b4de0a11c9..a5ab23d69510c 100644 --- a/src/test/run-pass/vec-to_str.rs +++ b/src/test/run-pass/vec-to_str.rs @@ -9,12 +9,12 @@ // except according to those terms. pub fn main() { - assert_eq!((~[0, 1]).to_str(), ~"[0, 1]"); - assert_eq!((&[1, 2]).to_str(), ~"[1, 2]"); + fail_unless_eq!((~[0, 1]).to_str(), ~"[0, 1]"); + fail_unless_eq!((&[1, 2]).to_str(), ~"[1, 2]"); let foo = ~[3, 4]; let bar = &[4, 5]; - assert_eq!(foo.to_str(), ~"[3, 4]"); - assert_eq!(bar.to_str(), ~"[4, 5]"); + fail_unless_eq!(foo.to_str(), ~"[3, 4]"); + fail_unless_eq!(bar.to_str(), ~"[4, 5]"); } diff --git a/src/test/run-pass/vec-trailing-comma.rs b/src/test/run-pass/vec-trailing-comma.rs index 426416f63d307..cff919d7aafd6 100644 --- a/src/test/run-pass/vec-trailing-comma.rs +++ b/src/test/run-pass/vec-trailing-comma.rs @@ -13,8 +13,8 @@ pub fn main() { let v1: ~[int] = ~[10, 20, 30,]; let v2: ~[int] = ~[10, 20, 30]; - assert_eq!(v1[2], v2[2]); + fail_unless_eq!(v1[2], v2[2]); let v3: ~[int] = ~[10,]; let v4: ~[int] = ~[10]; - assert_eq!(v3[0], v4[0]); + fail_unless_eq!(v3[0], v4[0]); } diff --git a/src/test/run-pass/vec.rs b/src/test/run-pass/vec.rs index cb67546dc1b00..c88646376b885 100644 --- a/src/test/run-pass/vec.rs +++ b/src/test/run-pass/vec.rs @@ -13,12 +13,12 @@ pub fn main() { let v: ~[int] = ~[10, 20]; - assert_eq!(v[0], 10); - assert_eq!(v[1], 20); + fail_unless_eq!(v[0], 10); + fail_unless_eq!(v[1], 20); let mut x: int = 0; - assert_eq!(v[x], 10); - assert_eq!(v[x + 1], 20); + fail_unless_eq!(v[x], 10); + fail_unless_eq!(v[x + 1], 20); x = x + 1; - assert_eq!(v[x], 20); - assert_eq!(v[x - 1], 10); + fail_unless_eq!(v[x], 20); + fail_unless_eq!(v[x - 1], 10); } diff --git a/src/test/run-pass/while-with-break.rs b/src/test/run-pass/while-with-break.rs index 57bc3bda9636a..28ca5fc353cb5 100644 --- a/src/test/run-pass/while-with-break.rs +++ b/src/test/run-pass/while-with-break.rs @@ -22,5 +22,5 @@ pub fn main() { break; } } - assert_eq!(i, 95); + fail_unless_eq!(i, 95); } diff --git a/src/test/run-pass/x86stdcall.rs b/src/test/run-pass/x86stdcall.rs index 01370ed12b443..c3a1929710513 100644 --- a/src/test/run-pass/x86stdcall.rs +++ b/src/test/run-pass/x86stdcall.rs @@ -26,7 +26,7 @@ pub fn main() { kernel32::SetLastError(expected); let actual = kernel32::GetLastError(); info!("actual = {}", actual); - assert_eq!(expected, actual); + fail_unless_eq!(expected, actual); } } diff --git a/src/test/run-pass/xcrate-address-insignificant.rs b/src/test/run-pass/xcrate-address-insignificant.rs index b231b859a066d..27e10d41b97a3 100644 --- a/src/test/run-pass/xcrate-address-insignificant.rs +++ b/src/test/run-pass/xcrate-address-insignificant.rs @@ -14,5 +14,5 @@ extern crate foo = "xcrate_address_insignificant"; pub fn main() { - assert_eq!(foo::foo::(), foo::bar()); + fail_unless_eq!(foo::foo::(), foo::bar()); }