From d7e74b5e91b0b6b6a5613f54479d2ef9fe9c392f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 6 Mar 2013 13:58:02 -0800 Subject: [PATCH] librustc: Convert all uses of `assert` over to `fail_unless!` --- doc/rust.md | 21 +- doc/tutorial-ffi.md | 2 +- doc/tutorial-tasks.md | 16 +- doc/tutorial.md | 12 +- src/compiletest/compiletest.rc | 2 +- src/compiletest/procsrv.rs | 2 +- src/libcore/at_vec.rs | 28 +- src/libcore/bool.rs | 8 +- src/libcore/cast.rs | 12 +- src/libcore/cell.rs | 8 +- src/libcore/char.rs | 114 +-- src/libcore/cmp.rs | 10 +- src/libcore/comm.rs | 2 +- src/libcore/condition.rs | 10 +- src/libcore/dlist.rs | 364 ++++----- src/libcore/either.rs | 38 +- src/libcore/flate.rs | 6 +- src/libcore/hash.rs | 44 +- src/libcore/hashmap.rs | 276 +++---- src/libcore/io.rs | 80 +- src/libcore/iter-trait/dlist.rs | 2 +- src/libcore/managed.rs | 8 +- src/libcore/mutable.rs | 14 +- src/libcore/num/f32.rs | 88 +-- src/libcore/num/f64.rs | 88 +-- src/libcore/num/float.rs | 332 ++++---- src/libcore/num/int-template.rs | 144 ++-- src/libcore/num/int-template/i16.rs | 78 +- src/libcore/num/int-template/i32.rs | 78 +- src/libcore/num/int-template/i64.rs | 78 +- src/libcore/num/int-template/i8.rs | 78 +- src/libcore/num/int-template/int.rs | 100 +-- src/libcore/num/num.rs | 2 +- src/libcore/num/uint-template.rs | 112 +-- src/libcore/num/uint-template/u16.rs | 78 +- src/libcore/num/uint-template/u32.rs | 78 +- src/libcore/num/uint-template/u64.rs | 78 +- src/libcore/num/uint-template/u8.rs | 78 +- src/libcore/num/uint-template/uint.rs | 172 ++-- src/libcore/option.rs | 16 +- src/libcore/os.rs | 87 ++- src/libcore/path.rs | 94 +-- src/libcore/pipes.rs | 26 +- src/libcore/ptr.rs | 44 +- src/libcore/rand.rs | 80 +- src/libcore/repr.rs | 4 +- src/libcore/result.rs | 28 +- src/libcore/run.rs | 4 +- src/libcore/str.rs | 736 +++++++++--------- src/libcore/sys.rs | 47 +- src/libcore/task/local_data.rs | 18 +- src/libcore/task/local_data_priv.rs | 2 +- src/libcore/task/mod.rs | 20 +- src/libcore/task/spawn.rs | 16 +- src/libcore/to_str.rs | 34 +- src/libcore/trie.rs | 64 +- src/libcore/tuple.rs | 10 +- src/libcore/unstable.rs | 18 +- src/libcore/unstable/at_exit.rs | 6 +- src/libcore/unstable/exchange_alloc.rs | 8 +- src/libcore/unstable/extfmt.rs | 76 +- src/libcore/unstable/finally.rs | 12 +- src/libcore/unstable/global.rs | 8 +- src/libcore/unstable/weak_task.rs | 4 +- src/libcore/util.rs | 14 +- src/libcore/vec.rs | 716 ++++++++--------- src/libfuzzer/ast_match.rs | 14 +- src/libfuzzer/cycles.rs | 4 +- src/libfuzzer/fuzzer.rc | 4 +- src/libfuzzer/rand_util.rs | 8 +- src/librustc/back/rpath.rs | 44 +- src/librustc/driver/driver.rs | 4 +- src/librustc/driver/session.rs | 14 +- src/librustc/lib/llvm.rs | 4 +- src/librustc/metadata/creader.rs | 2 +- src/librustc/metadata/cstore.rs | 2 +- src/librustc/metadata/decoder.rs | 2 +- src/librustc/metadata/encoder.rs | 12 +- src/librustc/metadata/tydecode.rs | 38 +- src/librustc/middle/astencode.rs | 12 +- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/lint.rs | 2 +- src/librustc/middle/liveness.rs | 10 +- src/librustc/middle/region.rs | 2 +- src/librustc/middle/resolve.rs | 20 +- src/librustc/middle/trans/_match.rs | 2 +- src/librustc/middle/trans/base.rs | 14 +- src/librustc/middle/trans/build.rs | 6 +- src/librustc/middle/trans/callee.rs | 14 +- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/common.rs | 2 +- src/librustc/middle/trans/consts.rs | 10 +- src/librustc/middle/trans/controlflow.rs | 2 +- src/librustc/middle/trans/datum.rs | 18 +- src/librustc/middle/trans/expr.rs | 8 +- src/librustc/middle/trans/glue.rs | 6 +- src/librustc/middle/trans/monomorphize.rs | 4 +- src/librustc/middle/trans/reflect.rs | 2 +- src/librustc/middle/trans/type_of.rs | 2 +- src/librustc/middle/ty.rs | 8 +- src/librustc/middle/typeck/check/mod.rs | 6 +- src/librustc/middle/typeck/check/regionck.rs | 4 +- src/librustc/middle/typeck/check/vtable.rs | 4 +- src/librustc/middle/typeck/coherence.rs | 2 +- src/librustc/middle/typeck/infer/mod.rs | 8 +- .../middle/typeck/infer/region_inference.rs | 16 +- src/librustc/middle/typeck/infer/resolve.rs | 4 +- src/librustc/middle/typeck/infer/test.rs | 2 +- src/librustc/middle/typeck/infer/unify.rs | 2 +- src/librustc/middle/typeck/rscope.rs | 6 +- src/librustdoc/astsrv.rs | 6 +- src/librustdoc/attr_parser.rs | 18 +- src/librustdoc/attr_pass.rs | 24 +- src/librustdoc/config.rs | 32 +- src/librustdoc/desc_to_brief_pass.rs | 26 +- src/librustdoc/escape_pass.rs | 2 +- src/librustdoc/extract.rs | 48 +- src/librustdoc/fold.rs | 8 +- src/librustdoc/markdown_index_pass.rs | 46 +- src/librustdoc/markdown_pass.rs | 100 +-- src/librustdoc/markdown_writer.rs | 10 +- src/librustdoc/page_pass.rs | 6 +- src/librustdoc/pass.rs | 2 +- src/librustdoc/path_pass.rs | 10 +- src/librustdoc/prune_hidden_pass.rs | 2 +- src/librustdoc/prune_private_pass.rs | 2 +- src/librustdoc/sectionalize_pass.rs | 24 +- src/librustdoc/sort_item_name_pass.rs | 4 +- src/librustdoc/sort_item_type_pass.rs | 18 +- src/librustdoc/sort_pass.rs | 16 +- src/librustdoc/text_pass.rs | 42 +- src/librustdoc/trim_pass.rs | 2 +- src/librustdoc/tystr_pass.rs | 30 +- src/librustdoc/unindent_pass.rs | 12 +- src/librustpkg/util.rs | 22 +- src/libstd/arc.rs | 60 +- src/libstd/base64.rs | 28 +- src/libstd/bigint.rs | 270 +++---- src/libstd/bitv.rs | 226 +++--- src/libstd/c_vec.rs | 14 +- src/libstd/cmp.rs | 20 +- src/libstd/comm.rs | 4 +- src/libstd/deque.rs | 110 +-- src/libstd/ebml.rs | 12 +- src/libstd/flatpipes.rs | 44 +- src/libstd/future.rs | 14 +- src/libstd/getopts.rs | 170 ++-- src/libstd/json.rs | 307 ++++---- src/libstd/list.rs | 42 +- src/libstd/md4.rs | 21 +- src/libstd/net_ip.rs | 12 +- src/libstd/net_tcp.rs | 30 +- src/libstd/net_url.rs | 334 ++++---- src/libstd/oldmap.rs | 164 ++-- src/libstd/par.rs | 8 +- src/libstd/priority_queue.rs | 96 +-- src/libstd/rope.rs | 40 +- src/libstd/semver.rs | 114 +-- src/libstd/sha1.rs | 22 +- src/libstd/smallintmap.rs | 44 +- src/libstd/sort.rs | 68 +- src/libstd/stats.rs | 8 +- src/libstd/sync.rs | 46 +- src/libstd/task_pool.rs | 2 +- src/libstd/tempfile.rs | 2 +- src/libstd/term.rs | 2 +- src/libstd/test.rs | 26 +- src/libstd/time.rs | 368 ++++----- src/libstd/timer.rs | 6 +- src/libstd/treemap.rs | 418 +++++----- src/libstd/unicode.rs | 16 +- src/libstd/uv_iotask.rs | 2 +- src/libstd/uv_ll.rs | 32 +- src/libsyntax/codemap.rs | 12 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/ext/pipes/pipec.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/parse/comments.rs | 8 +- src/libsyntax/parse/lexer.rs | 12 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 8 +- src/libsyntax/print/pp.rs | 20 +- src/libsyntax/print/pprust.rs | 8 +- src/libsyntax/util/interner.rs | 34 +- src/test/bench/core-map.rs | 24 +- src/test/bench/core-set.rs | 8 +- src/test/bench/core-vec-append.rs | 8 +- src/test/bench/graph500-bfs.rs | 8 +- 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 | 2 +- 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 +- src/test/compile-fail/autoderef-full-lval.rs | 4 +- .../compile-fail/bind-by-move-no-guards.rs | 2 +- .../block-arg-as-stmt-with-value.rs | 2 +- .../borrowck-loan-blocks-mut-uniq.rs | 4 +- .../compile-fail/borrowck-ref-mut-of-imm.rs | 2 +- src/test/compile-fail/cast-from-nil.rs | 2 +- src/test/compile-fail/crateresolve5.rs | 2 +- src/test/compile-fail/do2.rs | 2 +- src/test/compile-fail/issue-1896-1.rs | 2 +- src/test/compile-fail/issue-2467.rs | 2 +- src/test/compile-fail/issue-2548.rs | 4 +- src/test/compile-fail/issue-2969.rs | 2 +- src/test/compile-fail/issue-3888.rs | 6 +- src/test/compile-fail/issue-511.rs | 2 +- src/test/compile-fail/issue-818.rs | 2 +- .../kindck-owned-trait-contains.rs | 2 +- .../compile-fail/kindck-owned-trait-scoped.rs | 2 +- .../compile-fail/mod_file_correct_spans.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/mode-inference-fail.rs | 4 +- src/test/compile-fail/no-capture-arc.rs | 4 +- src/test/compile-fail/no-reuse-move-arc.rs | 4 +- .../compile-fail/noncopyable-match-pattern.rs | 2 +- .../compile-fail/omitted-arg-wrong-types.rs | 4 +- .../private-struct-field-cross-crate.rs | 2 +- src/test/compile-fail/private-struct-field.rs | 2 +- .../compile-fail/regions-glb-free-free.rs | 2 +- .../regions-infer-borrow-scope-too-big.rs | 2 +- .../regions-infer-borrow-scope-within-loop.rs | 4 +- src/test/compile-fail/regions-trait-1.rs | 2 +- .../regions-var-type-out-of-scope.rs | 2 +- src/test/compile-fail/tag-type-args.rs | 2 +- .../compile-fail/vtable-res-trait-param.rs | 2 +- src/test/pretty/alt-naked-expr-long.rs | 2 +- src/test/pretty/alt-naked-expr.rs | 2 +- src/test/pretty/record-trailing-comma.rs | 2 +- src/test/run-fail/fail.rs | 2 +- src/test/run-fail/linked-failure.rs | 2 +- src/test/run-fail/linked-failure4.rs | 2 +- src/test/run-fail/str-overrun.rs | 2 +- src/test/run-fail/task-spawn-barefn.rs | 2 +- src/test/run-fail/unwind-alt.rs | 2 +- src/test/run-fail/unwind-assert.rs | 2 +- src/test/run-fail/vec-overrun.rs | 4 +- src/test/run-fail/vec-underrun.rs | 4 +- src/test/run-fail/zip-different-lengths.rs | 6 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +- src/test/run-pass/alignment-gep-tup-like-2.rs | 4 +- src/test/run-pass/alt-implicit-copy-unique.rs | 2 +- src/test/run-pass/alt-pattern-drop.rs | 4 +- src/test/run-pass/alt-pattern-lit.rs | 2 +- .../run-pass/alt-ref-binding-in-guard-3256.rs | 2 +- .../run-pass/alt-ref-binding-mut-option.rs | 2 +- src/test/run-pass/alt-ref-binding-mut.rs | 2 +- src/test/run-pass/alt-ref-binding.rs | 2 +- src/test/run-pass/alt-str.rs | 2 +- src/test/run-pass/alt-tag.rs | 6 +- src/test/run-pass/alt-unique-bind.rs | 2 +- src/test/run-pass/alt-with-ret-arm.rs | 2 +- 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 | 36 +- src/test/run-pass/artificial-block.rs | 2 +- src/test/run-pass/assign-assign.rs | 12 +- src/test/run-pass/assignability-trait.rs | 10 +- src/test/run-pass/auto-encode.rs | 4 +- src/test/run-pass/auto-loop.rs | 2 +- src/test/run-pass/auto-ref-newtype.rs | 2 +- src/test/run-pass/auto-ref-sliceable.rs | 2 +- src/test/run-pass/autobind.rs | 4 +- src/test/run-pass/autoderef-method-newtype.rs | 2 +- .../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 +- src/test/run-pass/binops.rs | 92 +-- src/test/run-pass/bitwise.rs | 20 +- src/test/run-pass/block-arg-call-as.rs | 6 +- .../block-arg-can-be-followed-by-binop.rs | 2 +- .../block-arg-can-be-followed-by-block-arg.rs | 2 +- .../block-arg-can-be-followed-by-call.rs | 2 +- src/test/run-pass/block-arg-in-parentheses.rs | 8 +- src/test/run-pass/block-arg-used-as-any.rs | 2 +- src/test/run-pass/block-arg-used-as-lambda.rs | 4 +- src/test/run-pass/block-arg.rs | 16 +- 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 +- src/test/run-pass/block-vec-map2.rs | 2 +- src/test/run-pass/bool-not.rs | 4 +- .../run-pass/borrowck-borrow-from-at-vec.rs | 2 +- .../borrowck-borrow-from-expr-block.rs | 4 +- .../run-pass/borrowck-fixed-length-vecs.rs | 2 +- .../run-pass/borrowck-mut-vec-as-imm-slice.rs | 2 +- .../borrowck-preserve-box-in-discr.rs | 8 +- .../borrowck-preserve-box-in-field.rs | 10 +- .../run-pass/borrowck-preserve-box-in-pat.rs | 8 +- .../run-pass/borrowck-preserve-box-in-uniq.rs | 10 +- src/test/run-pass/borrowck-preserve-box.rs | 10 +- .../run-pass/borrowck-preserve-cond-box.rs | 4 +- .../run-pass/borrowck-preserve-expl-deref.rs | 10 +- src/test/run-pass/borrowck-univariant-enum.rs | 2 +- src/test/run-pass/borrowed-ptr-pattern-2.rs | 4 +- src/test/run-pass/borrowed-ptr-pattern-3.rs | 4 +- .../borrowed-ptr-pattern-infallible.rs | 6 +- .../run-pass/borrowed-ptr-pattern-option.rs | 2 +- src/test/run-pass/borrowed-ptr-pattern.rs | 6 +- src/test/run-pass/box-compare.rs | 6 +- src/test/run-pass/box-unbox.rs | 2 +- src/test/run-pass/box.rs | 2 +- src/test/run-pass/break.rs | 12 +- src/test/run-pass/by-val-and-by-move.rs | 2 +- src/test/run-pass/c-stack-returning-int64.rs | 2 +- .../call-closure-from-overloaded-op.rs | 2 +- src/test/run-pass/cap-clause-move.rs | 8 +- src/test/run-pass/cast.rs | 16 +- src/test/run-pass/cci_borrow.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_nested_exe.rs | 8 +- src/test/run-pass/cci_no_inline_exe.rs | 2 +- src/test/run-pass/char.rs | 14 +- .../class-cast-to-trait-cross-crate-2.rs | 2 +- .../class-cast-to-trait-cross-crate.rs | 2 +- .../class-cast-to-trait-multiple-types.rs | 4 +- src/test/run-pass/class-exports.rs | 2 +- .../class-impl-parameterized-trait.rs | 4 +- .../class-impl-very-parameterized-trait.rs | 10 +- .../class-implement-trait-cross-crate.rs | 4 +- src/test/run-pass/class-implement-traits.rs | 4 +- .../class-implements-multiple-traits.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/class-trait-bounded-param.rs | 2 +- src/test/run-pass/classes-cross-crate.rs | 4 +- .../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 +- src/test/run-pass/classes.rs | 4 +- 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 | 6 +- .../run-pass/coerce-reborrow-mut-vec-arg.rs | 2 +- .../run-pass/coerce-reborrow-mut-vec-rcvr.rs | 2 +- src/test/run-pass/comm.rs | 2 +- src/test/run-pass/compare-generic-enums.rs | 8 +- src/test/run-pass/conditional-compile.rs | 4 +- src/test/run-pass/const-big-enum.rs | 4 +- src/test/run-pass/const-const.rs | 2 +- src/test/run-pass/const-contents.rs | 12 +- src/test/run-pass/const-enum-newtype-align.rs | 2 +- src/test/run-pass/const-enum-struct.rs | 4 +- src/test/run-pass/const-enum-struct2.rs | 4 +- src/test/run-pass/const-enum-tuple.rs | 4 +- src/test/run-pass/const-enum-tuple2.rs | 4 +- src/test/run-pass/const-enum-tuplestruct.rs | 4 +- src/test/run-pass/const-enum-tuplestruct2.rs | 4 +- 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 +- src/test/run-pass/const-newtype-enum.rs | 4 +- .../run-pass/const-nullary-univariant-enum.rs | 4 +- src/test/run-pass/const-rec-and-tup.rs | 2 +- src/test/run-pass/const-region-ptrs.rs | 4 +- src/test/run-pass/const-struct.rs | 6 +- 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/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/crateresolve6.rs | 4 +- src/test/run-pass/crateresolve7.rs | 4 +- src/test/run-pass/deep.rs | 2 +- .../run-pass/deriving-via-extension-c-enum.rs | 8 +- .../run-pass/deriving-via-extension-enum.rs | 8 +- .../deriving-via-extension-struct-empty.rs | 4 +- ...-via-extension-struct-like-enum-variant.rs | 4 +- .../deriving-via-extension-struct-tuple.rs | 12 +- .../run-pass/deriving-via-extension-struct.rs | 8 +- .../deriving-via-extension-type-params.rs | 8 +- src/test/run-pass/div-mod.rs | 20 +- src/test/run-pass/do2.rs | 2 +- src/test/run-pass/do3.rs | 2 +- src/test/run-pass/dvec-test.rs | 12 +- src/test/run-pass/else-if.rs | 18 +- src/test/run-pass/empty-tag.rs | 2 +- src/test/run-pass/enum-disr-val-pretty.rs | 4 +- src/test/run-pass/estr-slice.rs | 38 +- src/test/run-pass/estr-uniq.rs | 4 +- src/test/run-pass/evec-internal-boxes.rs | 4 +- src/test/run-pass/evec-internal.rs | 34 +- src/test/run-pass/evec-slice.rs | 44 +- src/test/run-pass/exec-env.rs | 2 +- src/test/run-pass/explicit-self-generic.rs | 2 +- .../run-pass/explicit-self-objects-box.rs | 2 +- .../run-pass/explicit-self-objects-simple.rs | 2 +- .../run-pass/explicit-self-objects-uniq.rs | 2 +- src/test/run-pass/explicit-self.rs | 10 +- src/test/run-pass/export-unexported-dep.rs | 2 +- src/test/run-pass/expr-alt-box.rs | 4 +- src/test/run-pass/expr-alt-fail.rs | 4 +- src/test/run-pass/expr-alt-generic-box1.rs | 2 +- src/test/run-pass/expr-alt-generic-box2.rs | 2 +- src/test/run-pass/expr-alt-generic-unique1.rs | 2 +- src/test/run-pass/expr-alt-generic-unique2.rs | 2 +- src/test/run-pass/expr-alt-generic.rs | 2 +- src/test/run-pass/expr-alt-struct.rs | 4 +- src/test/run-pass/expr-alt-unique.rs | 2 +- src/test/run-pass/expr-alt.rs | 10 +- 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-slot.rs | 4 +- src/test/run-pass/expr-block-unique.rs | 2 +- src/test/run-pass/expr-block.rs | 6 +- 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 | 6 +- 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-struct.rs | 4 +- src/test/run-pass/expr-if-unique.rs | 2 +- src/test/run-pass/expr-if.rs | 18 +- src/test/run-pass/exterior.rs | 8 +- src/test/run-pass/extern-call-deep.rs | 2 +- src/test/run-pass/extern-call-deep2.rs | 2 +- src/test/run-pass/extern-call-scrub.rs | 2 +- src/test/run-pass/extern-call.rs | 2 +- src/test/run-pass/extern-crosscrate.rs | 2 +- src/test/run-pass/extern-stress.rs | 2 +- src/test/run-pass/extern-take-value.rs | 4 +- src/test/run-pass/extern-yield.rs | 2 +- src/test/run-pass/fact.rs | 2 +- src/test/run-pass/fixed-point-bind-box.rs | 4 +- src/test/run-pass/fixed-point-bind-unique.rs | 4 +- 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 | 130 ++-- src/test/run-pass/float2.rs | 18 +- src/test/run-pass/floatlits.rs | 8 +- .../run-pass/fn-assign-managed-to-bare-1.rs | 4 +- .../run-pass/fn-assign-managed-to-bare-2.rs | 8 +- src/test/run-pass/fn-bare-assign.rs | 4 +- 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 +- 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/fun-call-variants.rs | 2 +- src/test/run-pass/fun-indirect-call.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 +- 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-infer.rs | 2 +- src/test/run-pass/generic-fn.rs | 6 +- src/test/run-pass/generic-object.rs | 2 +- src/test/run-pass/generic-tag-alt.rs | 2 +- src/test/run-pass/generic-tag-values.rs | 6 +- src/test/run-pass/generic-temporary.rs | 2 +- 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/global-scope.rs | 2 +- src/test/run-pass/guards-not-exhaustive.rs | 2 +- src/test/run-pass/guards.rs | 4 +- src/test/run-pass/i32-sub.rs | 2 +- src/test/run-pass/i8-incr.rs | 2 +- src/test/run-pass/impl-variance.rs | 6 +- 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/int-conversion-coherence.rs | 2 +- src/test/run-pass/integral-indexing.rs | 20 +- src/test/run-pass/intrinsic-alignment.rs | 12 +- src/test/run-pass/intrinsic-atomics-cc.rs | 2 +- src/test/run-pass/intrinsic-atomics.rs | 40 +- src/test/run-pass/intrinsic-frame-address.rs | 2 +- src/test/run-pass/intrinsic-move-val.rs | 2 +- src/test/run-pass/intrinsics-integer.rs | 126 +-- src/test/run-pass/intrinsics-math.rs | 60 +- src/test/run-pass/issue-1112.rs | 12 +- src/test/run-pass/issue-1458.rs | 2 +- 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 | 4 +- src/test/run-pass/issue-2735-2.rs | 2 +- src/test/run-pass/issue-2735-3.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-3168.rs | 2 +- src/test/run-pass/issue-3176.rs | 2 +- src/test/run-pass/issue-3211.rs | 2 +- src/test/run-pass/issue-333.rs | 2 +- src/test/run-pass/issue-3424.rs | 2 +- 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-3683.rs | 2 +- src/test/run-pass/issue-3935.rs | 2 +- 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-4401.rs | 2 +- src/test/run-pass/issue-4448.rs | 2 +- src/test/run-pass/issue-979.rs | 2 +- src/test/run-pass/issue2378c.rs | 2 +- src/test/run-pass/istr.rs | 26 +- src/test/run-pass/iter-all.rs | 12 +- src/test/run-pass/iter-any.rs | 12 +- src/test/run-pass/iter-contains.rs | 16 +- src/test/run-pass/iter-count.rs | 14 +- src/test/run-pass/iter-eachi.rs | 8 +- src/test/run-pass/iter-filter-to-vec.rs | 10 +- src/test/run-pass/iter-flat-map-to-vec.rs | 20 +- src/test/run-pass/iter-foldl.rs | 10 +- src/test/run-pass/iter-map-to-vec.rs | 10 +- src/test/run-pass/iter-min-max.rs | 12 +- src/test/run-pass/iter-range.rs | 2 +- src/test/run-pass/iter-to-vec.rs | 10 +- src/test/run-pass/ivec-add.rs | 8 +- .../run-pass/kindck-owned-trait-contains-1.rs | 2 +- src/test/run-pass/last-use-in-cap-clause.rs | 2 +- src/test/run-pass/lazy-and-or.rs | 8 +- src/test/run-pass/let-destruct-fresh-mem.rs | 8 +- src/test/run-pass/let-destruct.rs | 2 +- src/test/run-pass/linear-for-loop.rs | 14 +- src/test/run-pass/log-degen-enum.rs | 2 +- .../log-knows-the-names-of-variants-in-std.rs | 4 +- .../log-knows-the-names-of-variants.rs | 8 +- src/test/run-pass/log-str.rs | 4 +- src/test/run-pass/loop-break-cont-1.rs | 2 +- src/test/run-pass/loop-break-cont.rs | 6 +- src/test/run-pass/loop-scope.rs | 2 +- src/test/run-pass/macro-interpolation.rs | 2 +- src/test/run-pass/macro-path.rs | 2 +- src/test/run-pass/macro-stmt.rs | 6 +- src/test/run-pass/mod-inside-fn.rs | 2 +- src/test/run-pass/mod-merge-hack.rs | 4 +- 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-trait-in-fn-at.rs | 2 +- src/test/run-pass/morestack-address.rs | 2 +- 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-2-unique.rs | 2 +- src/test/run-pass/move-2.rs | 2 +- src/test/run-pass/move-3-unique.rs | 4 +- src/test/run-pass/move-3.rs | 4 +- src/test/run-pass/move-4-unique.rs | 2 +- src/test/run-pass/move-4.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/move-scalar.rs | 2 +- src/test/run-pass/multi-let.rs | 2 +- src/test/run-pass/mut-function-arguments.rs | 4 +- ...ility-inherits-through-fixed-length-vec.rs | 4 +- src/test/run-pass/mutable-alias-vec.rs | 2 +- src/test/run-pass/nested-class.rs | 4 +- src/test/run-pass/nested-patterns.rs | 6 +- src/test/run-pass/newlambdas.rs | 6 +- src/test/run-pass/newtype-polymorphic.rs | 6 +- src/test/run-pass/newtype.rs | 2 +- src/test/run-pass/non-boolean-pure-fns.rs | 6 +- src/test/run-pass/non-legacy-modes.rs | 2 +- src/test/run-pass/nullary-or-pattern.rs | 4 +- .../run-pass/numeric-method-autoexport.rs | 26 +- src/test/run-pass/one-tuple.rs | 4 +- src/test/run-pass/opeq.rs | 8 +- src/test/run-pass/operator-associativity.rs | 2 +- .../operator-overloading-explicit-self.rs | 2 +- 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/pattern-bound-var-in-for-each.rs | 2 +- src/test/run-pass/pipe-peek.rs | 4 +- src/test/run-pass/pipe-select.rs | 4 +- src/test/run-pass/placement-new-arena.rs | 2 +- src/test/run-pass/private-class-field.rs | 2 +- .../propagate-expected-type-through-block.rs | 2 +- src/test/run-pass/rcvr-borrowed-to-region.rs | 10 +- src/test/run-pass/rcvr-borrowed-to-slice.rs | 6 +- src/test/run-pass/readalias.rs | 2 +- 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 +- src/test/run-pass/region-dependent-addr-of.rs | 18 +- .../region-return-interior-of-option.rs | 4 +- .../run-pass/regions-appearance-constraint.rs | 2 +- src/test/run-pass/regions-borrow-at.rs | 2 +- src/test/run-pass/regions-borrow-estr-uniq.rs | 4 +- src/test/run-pass/regions-borrow-evec-at.rs | 2 +- .../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-escape-into-other-fn.rs | 2 +- .../regions-infer-borrow-scope-addr-of.rs | 2 +- .../regions-infer-borrow-scope-view.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 +- .../run-pass/regions-infer-contravariance.rs | 2 +- ...-parameterization-self-types-issue-5224.rs | 2 +- src/test/run-pass/regions-params.rs | 2 +- src/test/run-pass/regions-trait.rs | 2 +- src/test/run-pass/resolve-issue-2428.rs | 2 +- .../run-pass/resource-assign-is-not-copy.rs | 2 +- src/test/run-pass/resource-destruct.rs | 4 +- src/test/run-pass/resource-generic.rs | 2 +- src/test/run-pass/resource-in-struct.rs | 2 +- src/test/run-pass/ret-break-cont-in-block.rs | 16 +- src/test/run-pass/rt-sched-1.rs | 6 +- src/test/run-pass/self-shadowing-import.rs | 2 +- src/test/run-pass/sendfn-generic-fn.rs | 8 +- 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 | 24 +- src/test/run-pass/shadow.rs | 2 +- src/test/run-pass/shift.rs | 42 +- src/test/run-pass/signed-shift-const-eval.rs | 2 +- src/test/run-pass/spawn-types.rs | 2 +- src/test/run-pass/spawn.rs | 2 +- src/test/run-pass/spawn2.rs | 18 +- src/test/run-pass/stable-addr-of.rs | 2 +- src/test/run-pass/stat.rs | 4 +- src/test/run-pass/static-impl.rs | 12 +- ...tic-method-in-trait-with-tps-intracrate.rs | 2 +- src/test/run-pass/static-method-test.rs | 14 +- 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 +- src/test/run-pass/struct-deref.rs | 2 +- .../struct-destructuring-cross-crate.rs | 4 +- .../run-pass/struct-field-assignability.rs | 2 +- .../run-pass/struct-like-variant-match.rs | 8 +- src/test/run-pass/struct-return.rs | 14 +- src/test/run-pass/structured-compare.rs | 18 +- src/test/run-pass/swap-1.rs | 2 +- src/test/run-pass/swap-2.rs | 8 +- src/test/run-pass/syntax-extension-fmt.rs | 14 +- src/test/run-pass/syntax-extension-minor.rs | 2 +- .../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-shape.rs | 2 +- src/test/run-pass/tag-align-u64.rs | 2 +- src/test/run-pass/tag-disr-val-shape.rs | 6 +- src/test/run-pass/tag-variant-disr-val.rs | 10 +- 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-0.rs | 2 +- src/test/run-pass/task-comm-10.rs | 4 +- 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 +- src/test/run-pass/trait-cast.rs | 4 +- .../trait-default-method-bound-subst.rs | 2 +- .../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 +- 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 | 4 +- .../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 +- .../run-pass/trait-region-pointer-simple.rs | 2 +- src/test/run-pass/trait-to-str.rs | 8 +- .../run-pass/traits-default-method-macro.rs | 2 +- .../run-pass/traits-default-method-self.rs | 2 +- .../run-pass/traits-default-method-trivial.rs | 2 +- src/test/run-pass/tup.rs | 8 +- .../run-pass/tuple-struct-destructuring.rs | 4 +- src/test/run-pass/tuple-struct-matching.rs | 4 +- src/test/run-pass/type-namespace.rs | 2 +- src/test/run-pass/type-sizes.rs | 22 +- .../run-pass/typeclasses-eq-example-static.rs | 12 +- src/test/run-pass/typeclasses-eq-example.rs | 12 +- src/test/run-pass/typestate-multi-decl.rs | 2 +- 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/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-cmp.rs | 10 +- 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-in-vec.rs | 2 +- src/test/run-pass/unique-kinds.rs | 12 +- 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-object.rs | 2 +- src/test/run-pass/unique-pinned-nocopy-2.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/unsafe-pointer-assignability.rs | 2 +- src/test/run-pass/unwind-resource.rs | 2 +- src/test/run-pass/utf8.rs | 18 +- src/test/run-pass/utf8_chars.rs | 32 +- src/test/run-pass/utf8_idents.rs | 12 +- src/test/run-pass/vec-concat.rs | 6 +- src/test/run-pass/vec-growth.rs | 10 +- src/test/run-pass/vec-matching-autoslice.rs | 8 +- src/test/run-pass/vec-matching.rs | 12 +- src/test/run-pass/vec-position.rs | 6 +- 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 | 12 +- src/test/run-pass/vec-to_str.rs | 12 +- src/test/run-pass/vec-trailing-comma.rs | 4 +- src/test/run-pass/vec.rs | 12 +- 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/while-with-break.rs | 2 +- src/test/run-pass/writealias.rs | 2 +- src/test/run-pass/x86stdcall.rs | 2 +- src/test/run-pass/x86stdcall2.rs | 4 +- src/test/run-pass/zip-same-length.rs | 8 +- 817 files changed, 6378 insertions(+), 6335 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index 4d42aa2b067..8924ee6f4f6 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -205,7 +205,7 @@ grammar as double-quoted strings. Other tokens have exact rules given. The keywords are the following strings: ~~~~~~~~ {.keyword} -as assert +as break const copy do drop @@ -2000,7 +2000,7 @@ let v = ~[1,2,3]; mutate(copy v); // Pass a copy -assert v[0] == 1; // Original was not modified +fail_unless!(v[0] == 1); // Original was not modified ~~~~ ### Unary move expressions @@ -2450,17 +2450,6 @@ In the future, logging will move into a library, and will no longer be a core ex It is therefore recommended to use the macro forms of logging (`error!`, `debug!`, etc.) to minimize disruption in code that uses logging. -### Assert expressions - -~~~~~~~~{.ebnf .gram} -assert_expr : "assert" expr ; -~~~~~~~~ - -> **Note:** In future versions of Rust, `assert` will be changed from a full expression to a macro. - -An `assert` expression causes the program to fail if its `expr` argument evaluates to `false`. -The failure carries string representation of the false expression. - # Type system ## Types @@ -2560,7 +2549,7 @@ An example of a tuple type and its use: type Pair<'self> = (int,&'self str); let p: Pair<'static> = (10,"hello"); let (a, b) = p; -assert b != "world"; +fail_unless!(b != "world"); ~~~~ @@ -2581,7 +2570,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 accessible elements of a vector are always initialized, and access to a vector is always bounds-checked. @@ -2986,7 +2975,7 @@ example of an _implicit dereference_ operation performed on box values: ~~~~~~~~ struct Foo { y: int } let x = @Foo{y: 10}; -assert x.y == 10; +fail_unless!(x.y == 10); ~~~~~~~~ Other operations act on box values as single-word-sized address values. For diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md index add3718ea7f..6660a4a7942 100644 --- a/doc/tutorial-ffi.md +++ b/doc/tutorial-ffi.md @@ -239,7 +239,7 @@ fn unix_time_in_microseconds() -> u64 { } } -# fn main() { assert fmt!("%?", unix_time_in_microseconds()) != ~""; } +# fn main() { fail_unless!(fmt!("%?", unix_time_in_microseconds()) != ~""); } ~~~~ The `#[nolink]` attribute indicates that there's no foreign library to diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index 52f63be984a..f5d3a482a9f 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -297,9 +297,9 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() ); 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!()` 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 +~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++, exceptions in Rust are unrecoverable within a single task: once a task fails, there is no way to "catch" the exception. @@ -339,7 +339,7 @@ let result: Result = do task::try { fail!(~"oops!"); } }; -assert result.is_err(); +fail_unless!(result.is_err()); ~~~ Unlike `spawn`, the function spawned using `try` may return a value, @@ -401,7 +401,7 @@ do spawn { // Bidirectionally linked // Wait for the supervised child task to exist. let message = receiver.recv(); // Kill both it and the parent task. - assert message != 42; + fail_unless!(message != 42); } do try { // Unidirectionally linked sender.send(42); @@ -507,13 +507,13 @@ do spawn { }; 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/doc/tutorial.md b/doc/tutorial.md index b1eceeab70e..79553d5aa6e 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -381,7 +381,7 @@ expression to the given type. ~~~~ let x: float = 4.0; let y: uint = x as uint; -assert y == 4u; +fail_unless!(y == 4u); ~~~~ ## Syntax extensions @@ -849,8 +849,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 @@ -1000,7 +1000,7 @@ let x = ~10; let y = copy x; let z = *x + *y; -assert z == 20; +fail_unless!(z == 20); ~~~~ When they do not contain any managed boxes, owned boxes can be sent @@ -1327,8 +1327,8 @@ and [`core::str`]. Here are some examples. let crayons = [Almond, AntiqueBrass, Apricot]; // Check the length of the vector -assert crayons.len() == 3; -assert !crayons.is_empty(); +fail_unless!(crayons.len() == 3); +fail_unless!(!crayons.is_empty()); // Iterate over a vector, obtaining a pointer to each element for crayons.each |crayon| { diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 531e2329b0e..7d53b29e040 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -63,7 +63,7 @@ pub fn parse_config(args: ~[~str]) -> config { getopts::optopt(~"logfile"), getopts::optflag(~"jit")]; - assert !args.is_empty(); + fail_unless!(!args.is_empty()); let args_ = vec::tail(args); let matches = &match getopts::getopts(args_, opts) { diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index f11e0ba74b6..b8e95c67e27 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -25,7 +25,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) + ~".libaux"; env = do vec::map(env) |pair| { diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index b6995c28319..7a2a15a5421 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -292,31 +292,31 @@ pub fn test() { } } - assert seq_range(10, 15) == @[10, 11, 12, 13, 14]; - assert from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]; - assert from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]; + fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]); + fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]); + fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]); } #[test] pub fn append_test() { - assert @[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]; + fail_unless!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]); } #[test] pub fn test_from_owned() { - assert from_owned::(~[]) == @[]; - assert from_owned(~[true]) == @[true]; - assert from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]; - assert from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]; - assert from_owned(~[~[42]]) == @[~[42]]; + fail_unless!(from_owned::(~[]) == @[]); + fail_unless!(from_owned(~[true]) == @[true]); + fail_unless!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); + fail_unless!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]); + fail_unless!(from_owned(~[~[42]]) == @[~[42]]); } #[test] pub fn test_from_slice() { - assert from_slice::([]) == @[]; - assert from_slice([true]) == @[true]; - assert from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]; - assert from_slice([@"abc", @"123"]) == @[@"abc", @"123"]; - assert from_slice([@[42]]) == @[@[42]]; + fail_unless!(from_slice::([]) == @[]); + fail_unless!(from_slice([true]) == @[true]); + fail_unless!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]); + fail_unless!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]); + fail_unless!(from_slice([@[42]]) == @[@[42]]); } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index b4300d98483..13b8d0fc907 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -86,20 +86,20 @@ pub fn test_bool_from_str() { use from_str::FromStr; do all_values |v| { - assert Some(v) == FromStr::from_str(to_str(v)) + fail_unless!(Some(v) == FromStr::from_str(to_str(v))) } } #[test] pub fn test_bool_to_str() { - assert to_str(false) == ~"false"; - assert to_str(true) == ~"true"; + fail_unless!(to_str(false) == ~"false"); + fail_unless!(to_str(true) == ~"true"); } #[test] pub fn test_bool_to_bit() { do all_values |v| { - assert to_bit(v) == if is_true(v) { 1u8 } else { 0u8 }; + fail_unless!(to_bit(v) == if is_true(v) { 1u8 } else { 0u8 }); } } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 9cd673e59a7..f17b04da503 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -48,7 +48,7 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } * * # Example * - * assert transmute("L") == ~[76u8, 0u8]; + * fail_unless!(transmute("L") == ~[76u8, 0u8]); */ #[inline(always)] pub unsafe fn transmute(thing: L) -> G { @@ -112,7 +112,7 @@ pub mod tests { #[test] pub fn test_reinterpret_cast() { - assert 1u == unsafe { reinterpret_cast(&1) }; + fail_unless!(1u == unsafe { reinterpret_cast(&1) }); } #[test] @@ -123,8 +123,8 @@ pub mod tests { let ptr: *int = transmute(box); // refcount 2 let _box1: @~str = reinterpret_cast(&ptr); let _box2: @~str = reinterpret_cast(&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. } @@ -136,7 +136,7 @@ pub mod tests { unsafe { let x = @100u8; let x: *BoxRepr = transmute(x); - assert (*x).data == 100; + fail_unless!((*x).data == 100); let _x: @int = transmute(x); } } @@ -144,7 +144,7 @@ pub mod tests { #[test] pub fn test_transmute2() { unsafe { - assert ~[76u8, 0u8] == transmute(~"L"); + fail_unless!(~[76u8, 0u8] == transmute(~"L")); } } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index a85ab1a29b7..8df0037b2af 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -65,12 +65,12 @@ pub impl Cell { #[test] fn test_basic() { let value_cell = Cell(~10); - assert !value_cell.is_empty(); + fail_unless!(!value_cell.is_empty()); let value = value_cell.take(); - assert value == ~10; - assert value_cell.is_empty(); + fail_unless!(value == ~10); + fail_unless!(value_cell.is_empty()); value_cell.put_back(value); - assert !value_cell.is_empty(); + fail_unless!(!value_cell.is_empty()); } #[test] diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 36b03af2d38..7922103029b 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -200,7 +200,7 @@ pub pure fn escape_unicode(c: char) -> ~str { let (c, pad) = (if c <= '\xff' { ('x', 2u) } else if c <= '\uffff' { ('u', 4u) } else { ('U', 8u) }); - assert str::len(s) <= pad; + fail_unless!(str::len(s) <= pad); let mut out = ~"\\"; unsafe { str::push_str(&mut out, str::from_char(c)); @@ -258,91 +258,91 @@ impl Eq for char { #[test] fn test_is_lowercase() { - assert is_lowercase('a'); - assert is_lowercase('ö'); - assert is_lowercase('ß'); - assert !is_lowercase('Ü'); - assert !is_lowercase('P'); + fail_unless!(is_lowercase('a')); + fail_unless!(is_lowercase('ö')); + fail_unless!(is_lowercase('ß')); + fail_unless!(!is_lowercase('Ü')); + fail_unless!(!is_lowercase('P')); } #[test] fn test_is_uppercase() { - assert !is_uppercase('h'); - assert !is_uppercase('ä'); - assert !is_uppercase('ß'); - assert is_uppercase('Ö'); - assert is_uppercase('T'); + fail_unless!(!is_uppercase('h')); + fail_unless!(!is_uppercase('ä')); + fail_unless!(!is_uppercase('ß')); + fail_unless!(is_uppercase('Ö')); + fail_unless!(is_uppercase('T')); } #[test] fn test_is_whitespace() { - assert is_whitespace(' '); - assert is_whitespace('\u2007'); - assert is_whitespace('\t'); - assert is_whitespace('\n'); + fail_unless!(is_whitespace(' ')); + fail_unless!(is_whitespace('\u2007')); + fail_unless!(is_whitespace('\t')); + fail_unless!(is_whitespace('\n')); - assert !is_whitespace('a'); - assert !is_whitespace('_'); - assert !is_whitespace('\u0000'); + fail_unless!(!is_whitespace('a')); + fail_unless!(!is_whitespace('_')); + fail_unless!(!is_whitespace('\u0000')); } #[test] fn test_to_digit() { - assert to_digit('0', 10u) == Some(0u); - assert to_digit('1', 2u) == Some(1u); - assert to_digit('2', 3u) == Some(2u); - assert to_digit('9', 10u) == Some(9u); - assert to_digit('a', 16u) == Some(10u); - assert to_digit('A', 16u) == Some(10u); - assert to_digit('b', 16u) == Some(11u); - assert to_digit('B', 16u) == Some(11u); - assert to_digit('z', 36u) == Some(35u); - assert to_digit('Z', 36u) == Some(35u); + fail_unless!(to_digit('0', 10u) == Some(0u)); + fail_unless!(to_digit('1', 2u) == Some(1u)); + fail_unless!(to_digit('2', 3u) == Some(2u)); + fail_unless!(to_digit('9', 10u) == Some(9u)); + fail_unless!(to_digit('a', 16u) == Some(10u)); + fail_unless!(to_digit('A', 16u) == Some(10u)); + fail_unless!(to_digit('b', 16u) == Some(11u)); + fail_unless!(to_digit('B', 16u) == Some(11u)); + fail_unless!(to_digit('z', 36u) == Some(35u)); + fail_unless!(to_digit('Z', 36u) == Some(35u)); - assert to_digit(' ', 10u).is_none(); - assert to_digit('$', 36u).is_none(); + fail_unless!(to_digit(' ', 10u).is_none()); + fail_unless!(to_digit('$', 36u).is_none()); } #[test] fn test_is_ascii() { - assert str::all(~"banana", is_ascii); - assert ! str::all(~"ประเทศไทย中华Việt Nam", is_ascii); + fail_unless!(str::all(~"banana", is_ascii)); + fail_unless!(! str::all(~"ประเทศไทย中华Việt Nam", is_ascii)); } #[test] fn test_is_digit() { - assert is_digit('2'); - assert is_digit('7'); - assert ! is_digit('c'); - assert ! is_digit('i'); - assert ! is_digit('z'); - assert ! is_digit('Q'); + fail_unless!(is_digit('2')); + fail_unless!(is_digit('7')); + fail_unless!(! is_digit('c')); + fail_unless!(! is_digit('i')); + fail_unless!(! is_digit('z')); + fail_unless!(! is_digit('Q')); } #[test] fn test_escape_default() { - assert escape_default('\n') == ~"\\n"; - assert escape_default('\r') == ~"\\r"; - assert escape_default('\'') == ~"\\'"; - assert escape_default('"') == ~"\\\""; - assert escape_default(' ') == ~" "; - assert escape_default('a') == ~"a"; - assert escape_default('~') == ~"~"; - assert escape_default('\x00') == ~"\\x00"; - assert escape_default('\x1f') == ~"\\x1f"; - assert escape_default('\x7f') == ~"\\x7f"; - assert escape_default('\xff') == ~"\\xff"; - assert escape_default('\u011b') == ~"\\u011b"; - assert escape_default('\U0001d4b6') == ~"\\U0001d4b6"; + fail_unless!(escape_default('\n') == ~"\\n"); + fail_unless!(escape_default('\r') == ~"\\r"); + fail_unless!(escape_default('\'') == ~"\\'"); + fail_unless!(escape_default('"') == ~"\\\""); + fail_unless!(escape_default(' ') == ~" "); + fail_unless!(escape_default('a') == ~"a"); + fail_unless!(escape_default('~') == ~"~"); + fail_unless!(escape_default('\x00') == ~"\\x00"); + fail_unless!(escape_default('\x1f') == ~"\\x1f"); + fail_unless!(escape_default('\x7f') == ~"\\x7f"); + fail_unless!(escape_default('\xff') == ~"\\xff"); + fail_unless!(escape_default('\u011b') == ~"\\u011b"); + fail_unless!(escape_default('\U0001d4b6') == ~"\\U0001d4b6"); } #[test] fn test_escape_unicode() { - assert escape_unicode('\x00') == ~"\\x00"; - assert escape_unicode('\n') == ~"\\x0a"; - assert escape_unicode(' ') == ~"\\x20"; - assert escape_unicode('a') == ~"\\x61"; - assert escape_unicode('\u011b') == ~"\\u011b"; - assert escape_unicode('\U0001d4b6') == ~"\\U0001d4b6"; + fail_unless!(escape_unicode('\x00') == ~"\\x00"); + fail_unless!(escape_unicode('\n') == ~"\\x0a"); + fail_unless!(escape_unicode(' ') == ~"\\x20"); + fail_unless!(escape_unicode('a') == ~"\\x61"); + fail_unless!(escape_unicode('\u011b') == ~"\\u011b"); + fail_unless!(escape_unicode('\U0001d4b6') == ~"\\U0001d4b6"); } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index ac2afc920ff..81f6a7e4266 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -172,10 +172,10 @@ pub pure fn max(v1: T, v2: T) -> T { mod test { #[test] fn test_int() { - assert 5.cmp(&10) == Less; - assert 10.cmp(&5) == Greater; - assert 5.cmp(&5) == Equal; - assert (-5).cmp(&12) == Less; - assert 12.cmp(-5) == Greater; + fail_unless!(5.cmp(&10) == Less); + fail_unless!(10.cmp(&5) == Greater); + fail_unless!(5.cmp(&5) == Equal); + fail_unless!((-5).cmp(&12) == Less); + fail_unless!(12.cmp(-5) == Greater); } } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 18e04978944..5b189abf4a3 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -464,6 +464,6 @@ pub mod test { let _chan = chan; } - assert !port.peek(); + fail_unless!(!port.peek()); } } diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index 566de2e880e..17d15a8886f 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -124,7 +124,7 @@ mod test { trouble(1); } - assert inner_trapped; + fail_unless!(inner_trapped); } #[test] @@ -140,7 +140,7 @@ mod test { trouble(1); } - assert outer_trapped; + fail_unless!(outer_trapped); } fn nested_reraise_trap_test_inner() { @@ -157,7 +157,7 @@ mod test { trouble(1); } - assert inner_trapped; + fail_unless!(inner_trapped); } #[test] @@ -172,7 +172,7 @@ mod test { nested_reraise_trap_test_inner(); } - assert outer_trapped; + fail_unless!(outer_trapped); } #[test] @@ -187,6 +187,6 @@ mod test { trouble(1); } - assert trapped; + fail_unless!(trapped); } } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 34a3c3e60af..5654d4b9c9b 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -170,7 +170,7 @@ priv impl DList { // Remove a node from the list. fn unlink(@mut self, nobe: @mut DListNode) { self.assert_mine(nobe); - assert self.size > 0; + fail_unless!(self.size > 0); self.link(nobe.prev, nobe.next); nobe.prev = None; // Release extraneous references. nobe.next = None; @@ -192,7 +192,7 @@ priv impl DList { nobe: DListLink, neighbour: @mut DListNode) { self.assert_mine(neighbour); - assert self.size > 0; + fail_unless!(self.size > 0); self.link(neighbour.prev, nobe); self.link(nobe, Some(neighbour)); self.size += 1; @@ -201,7 +201,7 @@ priv impl DList { neighbour: @mut DListNode, nobe: DListLink) { self.assert_mine(neighbour); - assert self.size > 0; + fail_unless!(self.size > 0); self.link(nobe, neighbour.next); self.link(Some(neighbour), nobe); self.size += 1; @@ -409,7 +409,7 @@ pub impl DList { /// Check data structure integrity. O(n). fn assert_consistent(@mut self) { if self.hd.is_none() || self.tl.is_none() { - assert self.hd.is_none() && self.tl.is_none(); + fail_unless!(self.hd.is_none() && self.tl.is_none()); } // iterate forwards let mut count = 0; @@ -417,7 +417,7 @@ pub impl DList { let mut rabbit = link; while link.is_some() { let nobe = link.get(); - assert nobe.linked; + fail_unless!(nobe.linked); // check cycle if rabbit.is_some() { rabbit = rabbit.get().next; @@ -426,19 +426,19 @@ pub impl DList { rabbit = rabbit.get().next; } if rabbit.is_some() { - assert !managed::mut_ptr_eq(rabbit.get(), nobe); + fail_unless!(!managed::mut_ptr_eq(rabbit.get(), nobe)); } // advance link = nobe.next_link(); count += 1; } - assert count == self.len(); + fail_unless!(count == self.len()); // iterate backwards - some of this is probably redundant. link = self.peek_tail_n(); rabbit = link; while link.is_some() { let nobe = link.get(); - assert nobe.linked; + fail_unless!(nobe.linked); // check cycle if rabbit.is_some() { rabbit = rabbit.get().prev; @@ -447,13 +447,13 @@ pub impl DList { rabbit = rabbit.get().prev; } if rabbit.is_some() { - assert !managed::mut_ptr_eq(rabbit.get(), nobe); + fail_unless!(!managed::mut_ptr_eq(rabbit.get(), nobe)); } // advance link = nobe.prev_link(); count -= 1; } - assert count == 0; + fail_unless!(count == 0); } } @@ -513,66 +513,66 @@ mod tests { let ab = from_vec(~[a,b]); let cd = from_vec(~[c,d]); let abcd = concat(concat(from_vec(~[ab,cd]))); - abcd.assert_consistent(); assert abcd.len() == 8; - abcd.assert_consistent(); assert abcd.pop().get() == 1; - abcd.assert_consistent(); assert abcd.pop().get() == 2; - abcd.assert_consistent(); assert abcd.pop().get() == 3; - abcd.assert_consistent(); assert abcd.pop().get() == 4; - abcd.assert_consistent(); assert abcd.pop().get() == 5; - abcd.assert_consistent(); assert abcd.pop().get() == 6; - abcd.assert_consistent(); assert abcd.pop().get() == 7; - abcd.assert_consistent(); assert abcd.pop().get() == 8; - abcd.assert_consistent(); assert abcd.is_empty(); + abcd.assert_consistent(); fail_unless!(abcd.len() == 8); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 1); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 2); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 3); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 4); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 5); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 6); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 7); + abcd.assert_consistent(); fail_unless!(abcd.pop().get() == 8); + abcd.assert_consistent(); fail_unless!(abcd.is_empty()); } #[test] pub fn test_dlist_append() { let a = from_vec(~[1,2,3]); let b = from_vec(~[4,5,6]); a.append(b); - assert a.len() == 6; - assert b.len() == 0; + fail_unless!(a.len() == 6); + fail_unless!(b.len() == 0); b.assert_consistent(); - a.assert_consistent(); assert a.pop().get() == 1; - a.assert_consistent(); assert a.pop().get() == 2; - a.assert_consistent(); assert a.pop().get() == 3; - a.assert_consistent(); assert a.pop().get() == 4; - a.assert_consistent(); assert a.pop().get() == 5; - a.assert_consistent(); assert a.pop().get() == 6; - a.assert_consistent(); assert a.is_empty(); + a.assert_consistent(); fail_unless!(a.pop().get() == 1); + a.assert_consistent(); fail_unless!(a.pop().get() == 2); + a.assert_consistent(); fail_unless!(a.pop().get() == 3); + a.assert_consistent(); fail_unless!(a.pop().get() == 4); + a.assert_consistent(); fail_unless!(a.pop().get() == 5); + a.assert_consistent(); fail_unless!(a.pop().get() == 6); + a.assert_consistent(); fail_unless!(a.is_empty()); } #[test] pub fn test_dlist_append_empty() { let a = from_vec(~[1,2,3]); let b = DList::(); a.append(b); - assert a.len() == 3; - assert b.len() == 0; + fail_unless!(a.len() == 3); + fail_unless!(b.len() == 0); b.assert_consistent(); - a.assert_consistent(); assert a.pop().get() == 1; - a.assert_consistent(); assert a.pop().get() == 2; - a.assert_consistent(); assert a.pop().get() == 3; - a.assert_consistent(); assert a.is_empty(); + a.assert_consistent(); fail_unless!(a.pop().get() == 1); + a.assert_consistent(); fail_unless!(a.pop().get() == 2); + a.assert_consistent(); fail_unless!(a.pop().get() == 3); + a.assert_consistent(); fail_unless!(a.is_empty()); } #[test] pub fn test_dlist_append_to_empty() { let a = DList::(); let b = from_vec(~[4,5,6]); a.append(b); - assert a.len() == 3; - assert b.len() == 0; + fail_unless!(a.len() == 3); + fail_unless!(b.len() == 0); b.assert_consistent(); - a.assert_consistent(); assert a.pop().get() == 4; - a.assert_consistent(); assert a.pop().get() == 5; - a.assert_consistent(); assert a.pop().get() == 6; - a.assert_consistent(); assert a.is_empty(); + a.assert_consistent(); fail_unless!(a.pop().get() == 4); + a.assert_consistent(); fail_unless!(a.pop().get() == 5); + a.assert_consistent(); fail_unless!(a.pop().get() == 6); + a.assert_consistent(); fail_unless!(a.is_empty()); } #[test] pub fn test_dlist_append_two_empty() { let a = DList::(); let b = DList::(); a.append(b); - assert a.len() == 0; - assert b.len() == 0; + fail_unless!(a.len() == 0); + fail_unless!(b.len() == 0); b.assert_consistent(); a.assert_consistent(); } @@ -595,34 +595,34 @@ mod tests { let a = from_vec(~[1,2,3]); let b = from_vec(~[4,5,6]); b.prepend(a); - assert a.len() == 0; - assert b.len() == 6; + fail_unless!(a.len() == 0); + fail_unless!(b.len() == 6); a.assert_consistent(); - b.assert_consistent(); assert b.pop().get() == 1; - b.assert_consistent(); assert b.pop().get() == 2; - b.assert_consistent(); assert b.pop().get() == 3; - b.assert_consistent(); assert b.pop().get() == 4; - b.assert_consistent(); assert b.pop().get() == 5; - b.assert_consistent(); assert b.pop().get() == 6; - b.assert_consistent(); assert b.is_empty(); + b.assert_consistent(); fail_unless!(b.pop().get() == 1); + b.assert_consistent(); fail_unless!(b.pop().get() == 2); + b.assert_consistent(); fail_unless!(b.pop().get() == 3); + b.assert_consistent(); fail_unless!(b.pop().get() == 4); + b.assert_consistent(); fail_unless!(b.pop().get() == 5); + b.assert_consistent(); fail_unless!(b.pop().get() == 6); + b.assert_consistent(); fail_unless!(b.is_empty()); } #[test] pub fn test_dlist_reverse() { let a = from_vec(~[5,4,3,2,1]); a.reverse(); - assert a.len() == 5; - a.assert_consistent(); assert a.pop().get() == 1; - a.assert_consistent(); assert a.pop().get() == 2; - a.assert_consistent(); assert a.pop().get() == 3; - a.assert_consistent(); assert a.pop().get() == 4; - a.assert_consistent(); assert a.pop().get() == 5; - a.assert_consistent(); assert a.is_empty(); + fail_unless!(a.len() == 5); + a.assert_consistent(); fail_unless!(a.pop().get() == 1); + a.assert_consistent(); fail_unless!(a.pop().get() == 2); + a.assert_consistent(); fail_unless!(a.pop().get() == 3); + a.assert_consistent(); fail_unless!(a.pop().get() == 4); + a.assert_consistent(); fail_unless!(a.pop().get() == 5); + a.assert_consistent(); fail_unless!(a.is_empty()); } #[test] pub fn test_dlist_reverse_empty() { let a = DList::(); a.reverse(); - assert a.len() == 0; + fail_unless!(a.len() == 0); a.assert_consistent(); } #[test] @@ -633,94 +633,94 @@ mod tests { a.insert_before(3, nobe); } } - assert a.len() == 6; - a.assert_consistent(); assert a.pop().get() == 1; - a.assert_consistent(); assert a.pop().get() == 2; - a.assert_consistent(); assert a.pop().get() == 3; - a.assert_consistent(); assert a.pop().get() == 4; - a.assert_consistent(); assert a.pop().get() == 3; - a.assert_consistent(); assert a.pop().get() == 5; - a.assert_consistent(); assert a.is_empty(); + fail_unless!(a.len() == 6); + a.assert_consistent(); fail_unless!(a.pop().get() == 1); + a.assert_consistent(); fail_unless!(a.pop().get() == 2); + a.assert_consistent(); fail_unless!(a.pop().get() == 3); + a.assert_consistent(); fail_unless!(a.pop().get() == 4); + a.assert_consistent(); fail_unless!(a.pop().get() == 3); + a.assert_consistent(); fail_unless!(a.pop().get() == 5); + a.assert_consistent(); fail_unless!(a.is_empty()); } #[test] pub fn test_dlist_clear() { let a = from_vec(~[5,4,3,2,1]); a.clear(); - assert a.len() == 0; + fail_unless!(a.len() == 0); a.assert_consistent(); } #[test] pub fn test_dlist_is_empty() { let empty = DList::(); let full1 = from_vec(~[1,2,3]); - assert empty.is_empty(); - assert !full1.is_empty(); + fail_unless!(empty.is_empty()); + fail_unless!(!full1.is_empty()); } #[test] pub fn test_dlist_head_tail() { let l = from_vec(~[1,2,3]); - assert l.head() == 1; - assert l.tail() == 3; - assert l.len() == 3; + fail_unless!(l.head() == 1); + fail_unless!(l.tail() == 3); + fail_unless!(l.len() == 3); } #[test] pub fn test_dlist_pop() { let l = from_vec(~[1,2,3]); - assert l.pop().get() == 1; - assert l.tail() == 3; - assert l.head() == 2; - assert l.pop().get() == 2; - assert l.tail() == 3; - assert l.head() == 3; - assert l.pop().get() == 3; - assert l.is_empty(); - assert l.pop().is_none(); + fail_unless!(l.pop().get() == 1); + fail_unless!(l.tail() == 3); + fail_unless!(l.head() == 2); + fail_unless!(l.pop().get() == 2); + fail_unless!(l.tail() == 3); + fail_unless!(l.head() == 3); + fail_unless!(l.pop().get() == 3); + fail_unless!(l.is_empty()); + fail_unless!(l.pop().is_none()); } #[test] pub fn test_dlist_pop_tail() { let l = from_vec(~[1,2,3]); - assert l.pop_tail().get() == 3; - assert l.tail() == 2; - assert l.head() == 1; - assert l.pop_tail().get() == 2; - assert l.tail() == 1; - assert l.head() == 1; - assert l.pop_tail().get() == 1; - assert l.is_empty(); - assert l.pop_tail().is_none(); + fail_unless!(l.pop_tail().get() == 3); + fail_unless!(l.tail() == 2); + fail_unless!(l.head() == 1); + fail_unless!(l.pop_tail().get() == 2); + fail_unless!(l.tail() == 1); + fail_unless!(l.head() == 1); + fail_unless!(l.pop_tail().get() == 1); + fail_unless!(l.is_empty()); + fail_unless!(l.pop_tail().is_none()); } #[test] pub fn test_dlist_push() { let l = DList::(); l.push(1); - assert l.head() == 1; - assert l.tail() == 1; + fail_unless!(l.head() == 1); + fail_unless!(l.tail() == 1); l.push(2); - assert l.head() == 1; - assert l.tail() == 2; + fail_unless!(l.head() == 1); + fail_unless!(l.tail() == 2); l.push(3); - assert l.head() == 1; - assert l.tail() == 3; - assert l.len() == 3; + fail_unless!(l.head() == 1); + fail_unless!(l.tail() == 3); + fail_unless!(l.len() == 3); } #[test] pub fn test_dlist_push_head() { let l = DList::(); l.push_head(3); - assert l.head() == 3; - assert l.tail() == 3; + fail_unless!(l.head() == 3); + fail_unless!(l.tail() == 3); l.push_head(2); - assert l.head() == 2; - assert l.tail() == 3; + fail_unless!(l.head() == 2); + fail_unless!(l.tail() == 3); l.push_head(1); - assert l.head() == 1; - assert l.tail() == 3; - assert l.len() == 3; + fail_unless!(l.head() == 1); + fail_unless!(l.tail() == 3); + fail_unless!(l.len() == 3); } #[test] pub fn test_dlist_foldl() { let l = from_vec(vec::from_fn(101, |x|x)); - assert iter::foldl(&l, 0, |accum,elem| *accum+*elem) == 5050; + fail_unless!(iter::foldl(&l, 0, |accum,elem| *accum+*elem) == 5050); } #[test] pub fn test_dlist_break_early() { @@ -730,7 +730,7 @@ mod tests { x += 1; if (*i == 3) { break; } } - assert x == 3; + fail_unless!(x == 3); } #[test] pub fn test_dlist_remove_head() { @@ -738,14 +738,14 @@ mod tests { l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); l.assert_consistent(); let _three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(one); - l.assert_consistent(); assert l.len() == 2; - l.assert_consistent(); assert l.head() == 2; - l.assert_consistent(); assert l.tail() == 3; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 2); + l.assert_consistent(); fail_unless!(l.head() == 2); + l.assert_consistent(); fail_unless!(l.tail() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_mid() { @@ -753,14 +753,14 @@ mod tests { l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); l.assert_consistent(); let _three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(two); - l.assert_consistent(); assert l.len() == 2; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 3; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 2); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_tail() { @@ -768,14 +768,14 @@ mod tests { l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); l.assert_consistent(); let three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(three); - l.assert_consistent(); assert l.len() == 2; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 2; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 2); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_one_two() { @@ -783,15 +783,15 @@ mod tests { l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); l.assert_consistent(); let _three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(one); l.assert_consistent(); l.remove(two); // and through and through, the vorpal blade went snicker-snack - l.assert_consistent(); assert l.len() == 1; - l.assert_consistent(); assert l.head() == 3; - l.assert_consistent(); assert l.tail() == 3; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 1); + l.assert_consistent(); fail_unless!(l.head() == 3); + l.assert_consistent(); fail_unless!(l.tail() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_one_three() { @@ -799,14 +799,14 @@ mod tests { l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); l.assert_consistent(); let three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(one); l.assert_consistent(); l.remove(three); - l.assert_consistent(); assert l.len() == 1; - l.assert_consistent(); assert l.head() == 2; - l.assert_consistent(); assert l.tail() == 2; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 1); + l.assert_consistent(); fail_unless!(l.head() == 2); + l.assert_consistent(); fail_unless!(l.tail() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_two_three() { @@ -814,14 +814,14 @@ mod tests { l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); l.assert_consistent(); let three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(two); l.assert_consistent(); l.remove(three); - l.assert_consistent(); assert l.len() == 1; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 1; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 1); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_remove_all() { @@ -829,12 +829,12 @@ mod tests { l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); l.assert_consistent(); let three = l.push_n(3); - l.assert_consistent(); assert l.len() == 3; + l.assert_consistent(); fail_unless!(l.len() == 3); l.assert_consistent(); l.remove(two); l.assert_consistent(); l.remove(three); l.assert_consistent(); l.remove(one); // Twenty-three is number one! - l.assert_consistent(); assert l.peek().is_none(); - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.peek().is_none()); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_insert_n_before() { @@ -842,15 +842,15 @@ mod tests { l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); l.assert_consistent(); let three = new_dlist_node(3); - l.assert_consistent(); assert l.len() == 2; + l.assert_consistent(); fail_unless!(l.len() == 2); l.assert_consistent(); l.insert_n_before(three, two); - l.assert_consistent(); assert l.len() == 3; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 2; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 3); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_insert_n_after() { @@ -858,45 +858,45 @@ mod tests { l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); l.assert_consistent(); let three = new_dlist_node(3); - l.assert_consistent(); assert l.len() == 2; + l.assert_consistent(); fail_unless!(l.len() == 2); l.assert_consistent(); l.insert_n_after(three, one); - l.assert_consistent(); assert l.len() == 3; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 2; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 3); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_insert_before_head() { let l = DList::(); l.assert_consistent(); let one = l.push_n(1); l.assert_consistent(); let _two = l.push_n(2); - l.assert_consistent(); assert l.len() == 2; + l.assert_consistent(); fail_unless!(l.len() == 2); l.assert_consistent(); l.insert_before(3, one); - l.assert_consistent(); assert l.len() == 3; - l.assert_consistent(); assert l.head() == 3; - l.assert_consistent(); assert l.tail() == 2; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 3); + l.assert_consistent(); fail_unless!(l.head() == 3); + l.assert_consistent(); fail_unless!(l.tail() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] pub fn test_dlist_insert_after_tail() { let l = DList::(); l.assert_consistent(); let _one = l.push_n(1); l.assert_consistent(); let two = l.push_n(2); - l.assert_consistent(); assert l.len() == 2; + l.assert_consistent(); fail_unless!(l.len() == 2); l.assert_consistent(); l.insert_after(3, two); - l.assert_consistent(); assert l.len() == 3; - l.assert_consistent(); assert l.head() == 1; - l.assert_consistent(); assert l.tail() == 3; - l.assert_consistent(); assert l.pop().get() == 1; - l.assert_consistent(); assert l.pop().get() == 2; - l.assert_consistent(); assert l.pop().get() == 3; - l.assert_consistent(); assert l.is_empty(); + l.assert_consistent(); fail_unless!(l.len() == 3); + l.assert_consistent(); fail_unless!(l.head() == 1); + l.assert_consistent(); fail_unless!(l.tail() == 3); + l.assert_consistent(); fail_unless!(l.pop().get() == 1); + l.assert_consistent(); fail_unless!(l.pop().get() == 2); + l.assert_consistent(); fail_unless!(l.pop().get() == 3); + l.assert_consistent(); fail_unless!(l.is_empty()); } #[test] #[should_fail] #[ignore(cfg(windows))] pub fn test_dlist_asymmetric_link() { diff --git a/src/libcore/either.rs b/src/libcore/either.rs index e5091cc8c34..e26f94261f9 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -176,7 +176,7 @@ fn test_either_left() { let val = Left(10); fn f_left(x: &int) -> bool { *x == 10 } fn f_right(_x: &uint) -> bool { false } - assert (either(f_left, f_right, &val)); + fail_unless!((either(f_left, f_right, &val))); } #[test] @@ -184,84 +184,84 @@ fn test_either_right() { let val = Right(10u); fn f_left(_x: &int) -> bool { false } fn f_right(x: &uint) -> bool { *x == 10u } - assert (either(f_left, f_right, &val)); + fail_unless!((either(f_left, f_right, &val))); } #[test] fn test_lefts() { let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)]; let result = lefts(input); - assert (result == ~[10, 12, 14]); + fail_unless!((result == ~[10, 12, 14])); } #[test] fn test_lefts_none() { let input: ~[Either] = ~[Right(10), Right(10)]; let result = lefts(input); - assert (vec::len(result) == 0u); + fail_unless!((vec::len(result) == 0u)); } #[test] fn test_lefts_empty() { let input: ~[Either] = ~[]; let result = lefts(input); - assert (vec::len(result) == 0u); + fail_unless!((vec::len(result) == 0u)); } #[test] fn test_rights() { let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)]; let result = rights(input); - assert (result == ~[11, 13]); + fail_unless!((result == ~[11, 13])); } #[test] fn test_rights_none() { let input: ~[Either] = ~[Left(10), Left(10)]; let result = rights(input); - assert (vec::len(result) == 0u); + fail_unless!((vec::len(result) == 0u)); } #[test] fn test_rights_empty() { let input: ~[Either] = ~[]; let result = rights(input); - assert (vec::len(result) == 0u); + fail_unless!((vec::len(result) == 0u)); } #[test] fn test_partition() { let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)]; let (lefts, rights) = partition(input); - assert (lefts[0] == 10); - assert (lefts[1] == 12); - assert (lefts[2] == 14); - assert (rights[0] == 11); - assert (rights[1] == 13); + fail_unless!((lefts[0] == 10)); + fail_unless!((lefts[1] == 12)); + fail_unless!((lefts[2] == 14)); + fail_unless!((rights[0] == 11)); + fail_unless!((rights[1] == 13)); } #[test] fn test_partition_no_lefts() { let input: ~[Either] = ~[Right(10), Right(11)]; let (lefts, rights) = partition(input); - assert (vec::len(lefts) == 0u); - assert (vec::len(rights) == 2u); + fail_unless!((vec::len(lefts) == 0u)); + fail_unless!((vec::len(rights) == 2u)); } #[test] fn test_partition_no_rights() { let input: ~[Either] = ~[Left(10), Left(11)]; let (lefts, rights) = partition(input); - assert (vec::len(lefts) == 2u); - assert (vec::len(rights) == 0u); + fail_unless!((vec::len(lefts) == 2u)); + fail_unless!((vec::len(rights) == 0u)); } #[test] fn test_partition_empty() { let input: ~[Either] = ~[]; let (lefts, rights) = partition(input); - assert (vec::len(lefts) == 0u); - assert (vec::len(rights) == 0u); + fail_unless!((vec::len(lefts) == 0u)); + fail_unless!((vec::len(rights) == 0u)); } // diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index 8f7925e368c..f9348ae5380 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -54,7 +54,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] { len as size_t, ptr::addr_of(&outsz), lz_norm); - 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); @@ -72,7 +72,7 @@ pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] { len as size_t, ptr::addr_of(&outsz), 0); - 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); @@ -101,6 +101,6 @@ fn test_flate_round_trip() { debug!("%u bytes deflated to %u (%.1f%% size)", in.len(), cmp.len(), 100.0 * ((cmp.len() as float) / (in.len() as float))); - assert(in == out); + fail_unless!((in == out)); } } diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 4c455e8d6b2..7f2189df20e 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -458,7 +458,7 @@ pub fn test_siphash() { let vec = u8to64_le!(vecs[t], 0); let out = buf.hash_keyed(k0, k1); debug!("got %?, expected %?", out, vec); - assert vec == out; + fail_unless!(vec == out); stream_full.reset(); stream_full.input(buf); @@ -467,7 +467,7 @@ pub fn test_siphash() { let v = to_hex_str(&vecs[t]); debug!("%d: (%s) => inc=%s full=%s", t, v, i, f); - assert f == i && f == v; + fail_unless!(f == i && f == v); buf += ~[t as u8]; stream_inc.input(~[t as u8]); @@ -479,20 +479,20 @@ pub fn test_siphash() { #[test] #[cfg(target_arch = "arm")] pub fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert (val as u64).hash() != (val as uint).hash(); - assert (val as u32).hash() == (val as uint).hash(); + fail_unless!((val as u64).hash() != (val as uint).hash()); + fail_unless!((val as u32).hash() == (val as uint).hash()); } #[test] #[cfg(target_arch = "x86_64")] pub fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert (val as u64).hash() == (val as uint).hash(); - assert (val as u32).hash() != (val as uint).hash(); + fail_unless!((val as u64).hash() == (val as uint).hash()); + fail_unless!((val as u32).hash() != (val as uint).hash()); } #[test] #[cfg(target_arch = "x86")] pub fn test_hash_uint() { let val = 0xdeadbeef_deadbeef_u64; - assert (val as u64).hash() != (val as uint).hash(); - assert (val as u32).hash() == (val as uint).hash(); + fail_unless!((val as u64).hash() != (val as uint).hash()); + fail_unless!((val as u32).hash() == (val as uint).hash()); } #[test] @@ -507,17 +507,17 @@ pub fn test_hash_idempotent() { pub 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)) } } @@ -526,13 +526,13 @@ pub fn test_hash_no_bytes_dropped_64() { pub 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)) } } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index c74e8ecee75..783f96d9b9e 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -642,119 +642,119 @@ pub mod linear { #[test] pub fn test_insert() { let mut m = LinearMap::new(); - assert m.insert(1, 2); - assert m.insert(2, 4); - assert *m.get(&1) == 2; - assert *m.get(&2) == 4; + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(2, 4)); + fail_unless!(*m.get(&1) == 2); + fail_unless!(*m.get(&2) == 4); } #[test] pub fn test_insert_overwrite() { let mut m = LinearMap::new(); - assert m.insert(1, 2); - assert *m.get(&1) == 2; - assert !m.insert(1, 3); - assert *m.get(&1) == 3; + fail_unless!(m.insert(1, 2)); + fail_unless!(*m.get(&1) == 2); + fail_unless!(!m.insert(1, 3)); + fail_unless!(*m.get(&1) == 3); } #[test] pub fn test_insert_conflicts() { let mut m = linear::linear_map_with_capacity(4); - assert m.insert(1, 2); - assert m.insert(5, 3); - assert m.insert(9, 4); - assert *m.get(&9) == 4; - assert *m.get(&5) == 3; - assert *m.get(&1) == 2; + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 4)); + fail_unless!(*m.get(&9) == 4); + fail_unless!(*m.get(&5) == 3); + fail_unless!(*m.get(&1) == 2); } #[test] pub fn test_conflict_remove() { let mut m = linear::linear_map_with_capacity(4); - assert m.insert(1, 2); - assert m.insert(5, 3); - assert m.insert(9, 4); - assert m.remove(&1); - assert *m.get(&9) == 4; - assert *m.get(&5) == 3; + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 4)); + fail_unless!(m.remove(&1)); + fail_unless!(*m.get(&9) == 4); + fail_unless!(*m.get(&5) == 3); } #[test] pub fn test_is_empty() { let mut m = linear::linear_map_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] pub fn test_pop() { let mut m = LinearMap::new(); m.insert(1, 2); - assert m.pop(&1) == Some(2); - assert m.pop(&1) == None; + fail_unless!(m.pop(&1) == Some(2)); + fail_unless!(m.pop(&1) == None); } #[test] pub fn test_swap() { let mut m = LinearMap::new(); - assert m.swap(1, 2) == None; - assert m.swap(1, 3) == Some(2); - assert m.swap(1, 4) == Some(3); + fail_unless!(m.swap(1, 2) == None); + fail_unless!(m.swap(1, 3) == Some(2)); + fail_unless!(m.swap(1, 4) == Some(3)); } #[test] pub fn test_find_or_insert() { let mut m = LinearMap::new::(); - assert m.find_or_insert(1, 2) == &2; - assert m.find_or_insert(1, 3) == &2; + fail_unless!(m.find_or_insert(1, 2) == &2); + fail_unless!(m.find_or_insert(1, 3) == &2); } #[test] pub fn test_find_or_insert_with() { let mut m = LinearMap::new::(); - assert m.find_or_insert_with(1, |_| 2) == &2; - assert m.find_or_insert_with(1, |_| 3) == &2; + fail_unless!(m.find_or_insert_with(1, |_| 2) == &2); + fail_unless!(m.find_or_insert_with(1, |_| 3) == &2); } #[test] pub fn test_consume() { let mut m = LinearMap::new(); - assert m.insert(1, 2); - assert m.insert(2, 3); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(2, 3)); let mut m2 = LinearMap::new(); do m.consume |k, v| { m2.insert(k, v); } - assert m.len() == 0; - assert m2.len() == 2; - assert m2.get(&1) == &2; - assert m2.get(&2) == &3; + fail_unless!(m.len() == 0); + fail_unless!(m2.len() == 2); + fail_unless!(m2.get(&1) == &2); + fail_unless!(m2.get(&2) == &3); } #[test] pub fn test_iterate() { let mut m = linear::linear_map_with_capacity(4); for uint::range(0, 32) |i| { - assert m.insert(i, i*2); + fail_unless!(m.insert(i, i*2)); } let mut observed = 0; for m.each |&(k, v)| { - assert *v == *k * 2; + fail_unless!(*v == *k * 2); observed |= (1 << *k); } - assert observed == 0xFFFF_FFFF; + fail_unless!(observed == 0xFFFF_FFFF); } #[test] pub fn test_find() { let mut m = LinearMap::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) } } @@ -769,19 +769,19 @@ pub mod linear { m2.insert(1, 2); m2.insert(2, 3); - assert m1 != m2; + fail_unless!(m1 != m2); m2.insert(3, 4); - assert m1 == m2; + fail_unless!(m1 == m2); } #[test] pub fn test_expand() { let mut m = LinearMap::new(); - assert m.len() == 0; - assert m.is_empty(); + fail_unless!(m.len() == 0); + fail_unless!(m.is_empty()); let mut i = 0u; let old_resize_at = m.resize_at; @@ -790,8 +790,8 @@ pub mod linear { i += 1; } - assert m.len() == i; - assert !m.is_empty(); + fail_unless!(m.len() == i); + fail_unless!(!m.is_empty()); } } @@ -805,51 +805,51 @@ pub mod linear { fn test_disjoint() { let mut xs = linear::LinearSet::new(); let mut ys = linear::LinearSet::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 = linear::LinearSet::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 = linear::LinearSet::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] @@ -857,29 +857,29 @@ pub mod linear { let mut a = linear::LinearSet::new(); let mut b = linear::LinearSet::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); + 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)); - 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!(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 a.intersection(&b) |x| { - assert vec::contains(expected, x); + fail_unless!(vec::contains(expected, x)); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -887,22 +887,22 @@ pub mod linear { let mut a = linear::LinearSet::new(); let mut b = linear::LinearSet::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 a.difference(&b) |x| { - assert vec::contains(expected, x); + fail_unless!(vec::contains(expected, x)); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -910,25 +910,25 @@ pub mod linear { let mut a = linear::LinearSet::new(); let mut b = linear::LinearSet::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 a.symmetric_difference(&b) |x| { - assert vec::contains(expected, x); + fail_unless!(vec::contains(expected, x)); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -936,29 +936,29 @@ pub mod linear { let mut a = linear::LinearSet::new(); let mut b = linear::LinearSet::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); + 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)); - 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!(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 a.union(&b) |x| { - assert vec::contains(expected, x); + fail_unless!(vec::contains(expected, x)); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 65f0c57db62..cc40b90d61a 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -247,7 +247,7 @@ impl ReaderUtil for T { let w = str::utf8_char_width(b0); let end = i + w; i += 1; - assert (w > 0); + fail_unless!((w > 0)); if w == 1 { chars.push(b0 as char); loop; @@ -260,8 +260,8 @@ impl ReaderUtil for T { while i < end { let next = bytes[i] as int; i += 1; - assert (next > -1); - assert (next & 192 == 128); + fail_unless!((next > -1)); + fail_unless!((next & 192 == 128)); val <<= 6; val += (next & 63) as uint; } @@ -302,7 +302,7 @@ impl ReaderUtil for T { if vec::len(c) == 0 { return -1 as char; // FIXME will this stay valid? // #2004 } - assert(vec::len(c) == 1); + fail_unless!((vec::len(c) == 1)); return c[0]; } @@ -337,7 +337,7 @@ impl ReaderUtil for T { // FIXME int reading methods need to deal with eof - issue #2004 fn read_le_uint_n(&self, nbytes: uint) -> u64 { - assert nbytes > 0 && nbytes <= 8; + fail_unless!(nbytes > 0 && nbytes <= 8); let mut val = 0u64, pos = 0, i = nbytes; while i > 0 { @@ -353,7 +353,7 @@ impl ReaderUtil for T { } fn read_be_uint_n(&self, nbytes: uint) -> u64 { - assert nbytes > 0 && nbytes <= 8; + fail_unless!(nbytes > 0 && nbytes <= 8); let mut val = 0u64, i = nbytes; while i > 0 { @@ -483,7 +483,7 @@ impl Reader for *libc::FILE { fn read(&self, bytes: &mut [u8], len: uint) -> uint { unsafe { do vec::as_mut_buf(bytes) |buf_p, buf_len| { - assert buf_len >= len; + fail_unless!(buf_len >= len); let count = libc::fread(buf_p as *mut c_void, 1u as size_t, len as size_t, *self); @@ -504,9 +504,9 @@ impl Reader for *libc::FILE { } fn seek(&self, offset: int, whence: SeekStyle) { unsafe { - assert libc::fseek(*self, - offset as c_long, - convert_whence(whence)) == 0 as c_int; + fail_unless!(libc::fseek(*self, + offset as c_long, + convert_whence(whence)) == 0 as c_int); } } fn tell(&self) -> uint { @@ -692,9 +692,9 @@ impl Writer for *libc::FILE { } fn seek(&self, offset: int, whence: SeekStyle) { unsafe { - assert libc::fseek(*self, - offset as c_long, - convert_whence(whence)) == 0 as c_int; + fail_unless!(libc::fseek(*self, + offset as c_long, + convert_whence(whence)) == 0 as c_int); } } fn tell(&self) -> uint { @@ -821,7 +821,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) pub fn u64_to_le_bytes(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { - assert size <= 8u; + fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), 2u => f(&[n as u8, @@ -853,7 +853,7 @@ pub fn u64_to_le_bytes(n: u64, size: uint, pub fn u64_to_be_bytes(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { - assert size <= 8u; + fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), 2u => f(&[(n >> 8) as u8, @@ -886,7 +886,7 @@ pub fn u64_to_be_bytes(n: u64, size: uint, pub fn u64_from_be_bytes(data: &[const u8], start: uint, size: uint) -> u64 { let mut sz = size; - assert (sz <= 8u); + fail_unless!((sz <= 8u)); let mut val = 0_u64; let mut pos = start; while sz > 0u { @@ -1163,7 +1163,7 @@ pub pure fn with_str_writer(f: fn(Writer)) -> ~str { // Make sure the vector has a trailing null and is proper utf8. v.push(0); } - assert str::is_utf8(v); + fail_unless!(str::is_utf8(v)); unsafe { ::cast::transmute(v) } } @@ -1235,7 +1235,7 @@ pub mod fsync { None => (), Some(level) => { // fail hard if not succesful - assert((self.arg.fsync_fn)(self.arg.val, level) != -1); + fail_unless!(((self.arg.fsync_fn)(self.arg.val, level) != -1)); } } } @@ -1320,14 +1320,14 @@ mod tests { let inp: io::Reader = result::get(&io::file_reader(tmpfile)); let frood2: ~str = inp.read_c_str(); log(debug, copy frood2); - assert frood == frood2; + fail_unless!(frood == frood2); } #[test] fn test_readchars_empty() { do io::with_str_reader(~"") |inp| { let res : ~[char] = inp.read_chars(128); - assert(vec::len(res) == 0); + fail_unless!((vec::len(res) == 0)); } } @@ -1335,7 +1335,7 @@ mod tests { fn test_read_line_utf8() { do io::with_str_reader(~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤") |inp| { let line = inp.read_line(); - assert line == ~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤"; + fail_unless!(line == ~"生锈的汤匙切肉汤hello生锈的汤匙切肉汤"); } } @@ -1352,10 +1352,10 @@ mod tests { do io::with_str_reader(s) |inp| { let res : ~[char] = inp.read_chars(len); if (len <= vec::len(ivals)) { - assert(vec::len(res) == len); + fail_unless!((vec::len(res) == len)); } - assert(vec::slice(ivals, 0u, vec::len(res)) == - vec::map(res, |x| *x as int)); + fail_unless!(vec::slice(ivals, 0u, vec::len(res)) == + vec::map(res, |x| *x as int)); } } let mut i = 0; @@ -1371,7 +1371,7 @@ mod tests { fn test_readchar() { do io::with_str_reader(~"生") |inp| { let res : char = inp.read_char(); - assert(res as int == 29983); + fail_unless!((res as int == 29983)); } } @@ -1379,7 +1379,7 @@ mod tests { fn test_readchar_empty() { do io::with_str_reader(~"") |inp| { let res : char = inp.read_char(); - assert(res as int == -1); + fail_unless!((res as int == -1)); } } @@ -1387,7 +1387,7 @@ mod tests { fn file_reader_not_exist() { match io::file_reader(&Path("not a file")) { result::Err(copy e) => { - assert e == ~"error opening not a file"; + fail_unless!(e == ~"error opening not a file"); } result::Ok(_) => fail!() } @@ -1428,7 +1428,7 @@ mod tests { fn file_writer_bad_name() { match io::file_writer(&Path("?/?"), ~[]) { result::Err(copy e) => { - assert str::starts_with(e, "error opening"); + fail_unless!(str::starts_with(e, "error opening")); } result::Ok(_) => fail!() } @@ -1438,7 +1438,7 @@ mod tests { fn buffered_file_writer_bad_name() { match io::buffered_file_writer(&Path("?/?")) { result::Err(copy e) => { - assert str::starts_with(e, "error opening"); + fail_unless!(str::starts_with(e, "error opening")); } result::Ok(_) => fail!() } @@ -1448,17 +1448,17 @@ mod tests { fn bytes_buffer_overwrite() { let wr = BytesWriter(); wr.write(~[0u8, 1u8, 2u8, 3u8]); - assert wr.bytes.borrow(|bytes| bytes == ~[0u8, 1u8, 2u8, 3u8]); + fail_unless!(wr.bytes.borrow(|bytes| bytes == ~[0u8, 1u8, 2u8, 3u8])); wr.seek(-2, SeekCur); wr.write(~[4u8, 5u8, 6u8, 7u8]); - assert wr.bytes.borrow(|bytes| bytes == - ~[0u8, 1u8, 4u8, 5u8, 6u8, 7u8]); + fail_unless!(wr.bytes.borrow(|bytes| bytes == + ~[0u8, 1u8, 4u8, 5u8, 6u8, 7u8])); wr.seek(-2, SeekEnd); wr.write(~[8u8]); wr.seek(1, SeekSet); wr.write(~[9u8]); - assert wr.bytes.borrow(|bytes| bytes == - ~[0u8, 9u8, 4u8, 5u8, 8u8, 7u8]); + fail_unless!(wr.bytes.borrow(|bytes| bytes == + ~[0u8, 9u8, 4u8, 5u8, 8u8, 7u8])); } #[test] @@ -1478,7 +1478,7 @@ mod tests { { let file = io::file_reader(&path).get(); for uints.each |i| { - assert file.read_le_u64() == *i; + fail_unless!(file.read_le_u64() == *i); } } } @@ -1500,7 +1500,7 @@ mod tests { { let file = io::file_reader(&path).get(); for uints.each |i| { - assert file.read_be_u64() == *i; + fail_unless!(file.read_be_u64() == *i); } } } @@ -1524,7 +1524,7 @@ mod tests { for ints.each |i| { // this tests that the sign extension is working // (comparing the values as i32 would not test this) - assert file.read_be_int_n(4) == *i as i64; + fail_unless!(file.read_be_int_n(4) == *i as i64); } } } @@ -1543,7 +1543,7 @@ mod tests { { let file = io::file_reader(&path).get(); let f = file.read_be_f32(); - assert f == 8.1250; + fail_unless!(f == 8.1250); } } @@ -1560,8 +1560,8 @@ mod tests { { let file = io::file_reader(&path).get(); - assert file.read_be_f32() == 8.1250; - assert file.read_le_f32() == 8.1250; + fail_unless!(file.read_be_f32() == 8.1250); + fail_unless!(file.read_le_f32() == 8.1250); } } } diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 41d509f1402..245c1db2bb4 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -28,7 +28,7 @@ mod inst { let mut link = self.peek_n(); while option::is_some(&link) { let nobe = option::get(link); - assert nobe.linked; + fail_unless!(nobe.linked); { let frozen_nobe = &*nobe; diff --git a/src/libcore/managed.rs b/src/libcore/managed.rs index 1f347371dfd..1bef895ea0b 100644 --- a/src/libcore/managed.rs +++ b/src/libcore/managed.rs @@ -72,8 +72,8 @@ impl Ord for @const 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))); } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index e4b8d204dd7..875d378b645 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -38,7 +38,7 @@ pub fn Mut(t: T) -> Mut { pub fn unwrap(m: Mut) -> T { // Borrowck should prevent us from calling unwrap while the value // is in use, as that would be a move from a borrowed value. - assert (m.mode as uint) == (ReadOnly as uint); + fail_unless!((m.mode as uint) == (ReadOnly as uint)); let Data {value: value, mode: _} = m; value } @@ -105,9 +105,9 @@ pub fn test_const_in_mut() { let m = @Mut(1); do m.borrow_mut |p| { do m.borrow_const |q| { - assert *p == *q; + fail_unless!(*p == *q); *p += 1; - assert *p == *q; + fail_unless!(*p == *q); } } } @@ -117,9 +117,9 @@ pub fn test_mut_in_const() { let m = @Mut(1); do m.borrow_const |p| { do m.borrow_mut |q| { - assert *p == *q; + fail_unless!(*p == *q); *q += 1; - assert *p == *q; + fail_unless!(*p == *q); } } } @@ -129,7 +129,7 @@ pub fn test_imm_in_const() { let m = @Mut(1); do m.borrow_const |p| { do m.borrow_imm |q| { - assert *p == *q; + fail_unless!(*p == *q); } } } @@ -139,7 +139,7 @@ pub fn test_const_in_imm() { let m = @Mut(1); do m.borrow_imm |p| { do m.borrow_const |q| { - assert *p == *q; + fail_unless!(*p == *q); } } } diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 5100021b954..54521abea9e 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -583,56 +583,56 @@ pub fn test_num() { let ten: f32 = num::cast(10); let two: f32 = num::cast(2); - assert (ten.add(&two) == num::cast(12)); - assert (ten.sub(&two) == num::cast(8)); - assert (ten.mul(&two) == num::cast(20)); - assert (ten.div(&two) == num::cast(5)); - assert (ten.modulo(&two) == num::cast(0)); + fail_unless!((ten.add(&two) == num::cast(12))); + fail_unless!((ten.sub(&two) == num::cast(8))); + fail_unless!((ten.mul(&two) == num::cast(20))); + fail_unless!((ten.div(&two) == num::cast(5))); + fail_unless!((ten.modulo(&two) == num::cast(0))); } #[test] fn test_numcast() { - assert (20u == 20f32.to_uint()); - assert (20u8 == 20f32.to_u8()); - assert (20u16 == 20f32.to_u16()); - assert (20u32 == 20f32.to_u32()); - assert (20u64 == 20f32.to_u64()); - assert (20i == 20f32.to_int()); - assert (20i8 == 20f32.to_i8()); - assert (20i16 == 20f32.to_i16()); - assert (20i32 == 20f32.to_i32()); - assert (20i64 == 20f32.to_i64()); - assert (20f == 20f32.to_float()); - assert (20f32 == 20f32.to_f32()); - assert (20f64 == 20f32.to_f64()); + fail_unless!((20u == 20f32.to_uint())); + fail_unless!((20u8 == 20f32.to_u8())); + fail_unless!((20u16 == 20f32.to_u16())); + fail_unless!((20u32 == 20f32.to_u32())); + fail_unless!((20u64 == 20f32.to_u64())); + fail_unless!((20i == 20f32.to_int())); + fail_unless!((20i8 == 20f32.to_i8())); + fail_unless!((20i16 == 20f32.to_i16())); + fail_unless!((20i32 == 20f32.to_i32())); + fail_unless!((20i64 == 20f32.to_i64())); + fail_unless!((20f == 20f32.to_float())); + fail_unless!((20f32 == 20f32.to_f32())); + fail_unless!((20f64 == 20f32.to_f64())); - assert (20f32 == NumCast::from(20u)); - assert (20f32 == NumCast::from(20u8)); - assert (20f32 == NumCast::from(20u16)); - assert (20f32 == NumCast::from(20u32)); - assert (20f32 == NumCast::from(20u64)); - assert (20f32 == NumCast::from(20i)); - assert (20f32 == NumCast::from(20i8)); - assert (20f32 == NumCast::from(20i16)); - assert (20f32 == NumCast::from(20i32)); - assert (20f32 == NumCast::from(20i64)); - assert (20f32 == NumCast::from(20f)); - assert (20f32 == NumCast::from(20f32)); - assert (20f32 == NumCast::from(20f64)); + fail_unless!((20f32 == NumCast::from(20u))); + fail_unless!((20f32 == NumCast::from(20u8))); + fail_unless!((20f32 == NumCast::from(20u16))); + fail_unless!((20f32 == NumCast::from(20u32))); + fail_unless!((20f32 == NumCast::from(20u64))); + fail_unless!((20f32 == NumCast::from(20i))); + fail_unless!((20f32 == NumCast::from(20i8))); + fail_unless!((20f32 == NumCast::from(20i16))); + fail_unless!((20f32 == NumCast::from(20i32))); + fail_unless!((20f32 == NumCast::from(20i64))); + fail_unless!((20f32 == NumCast::from(20f))); + fail_unless!((20f32 == NumCast::from(20f32))); + fail_unless!((20f32 == NumCast::from(20f64))); - assert (20f32 == num::cast(20u)); - assert (20f32 == num::cast(20u8)); - assert (20f32 == num::cast(20u16)); - assert (20f32 == num::cast(20u32)); - assert (20f32 == num::cast(20u64)); - assert (20f32 == num::cast(20i)); - assert (20f32 == num::cast(20i8)); - assert (20f32 == num::cast(20i16)); - assert (20f32 == num::cast(20i32)); - assert (20f32 == num::cast(20i64)); - assert (20f32 == num::cast(20f)); - assert (20f32 == num::cast(20f32)); - assert (20f32 == num::cast(20f64)); + fail_unless!((20f32 == num::cast(20u))); + fail_unless!((20f32 == num::cast(20u8))); + fail_unless!((20f32 == num::cast(20u16))); + fail_unless!((20f32 == num::cast(20u32))); + fail_unless!((20f32 == num::cast(20u64))); + fail_unless!((20f32 == num::cast(20i))); + fail_unless!((20f32 == num::cast(20i8))); + fail_unless!((20f32 == num::cast(20i16))); + fail_unless!((20f32 == num::cast(20i32))); + fail_unless!((20f32 == num::cast(20i64))); + fail_unless!((20f32 == num::cast(20f))); + fail_unless!((20f32 == num::cast(20f32))); + fail_unless!((20f32 == num::cast(20f64))); } // diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 9470922b881..a2cf629dc9f 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -607,56 +607,56 @@ pub fn test_num() { let ten: f64 = num::cast(10); let two: f64 = num::cast(2); - assert (ten.add(&two) == num::cast(12)); - assert (ten.sub(&two) == num::cast(8)); - assert (ten.mul(&two) == num::cast(20)); - assert (ten.div(&two) == num::cast(5)); - assert (ten.modulo(&two) == num::cast(0)); + fail_unless!((ten.add(&two) == num::cast(12))); + fail_unless!((ten.sub(&two) == num::cast(8))); + fail_unless!((ten.mul(&two) == num::cast(20))); + fail_unless!((ten.div(&two) == num::cast(5))); + fail_unless!((ten.modulo(&two) == num::cast(0))); } #[test] fn test_numcast() { - assert (20u == 20f64.to_uint()); - assert (20u8 == 20f64.to_u8()); - assert (20u16 == 20f64.to_u16()); - assert (20u32 == 20f64.to_u32()); - assert (20u64 == 20f64.to_u64()); - assert (20i == 20f64.to_int()); - assert (20i8 == 20f64.to_i8()); - assert (20i16 == 20f64.to_i16()); - assert (20i32 == 20f64.to_i32()); - assert (20i64 == 20f64.to_i64()); - assert (20f == 20f64.to_float()); - assert (20f32 == 20f64.to_f32()); - assert (20f64 == 20f64.to_f64()); + fail_unless!((20u == 20f64.to_uint())); + fail_unless!((20u8 == 20f64.to_u8())); + fail_unless!((20u16 == 20f64.to_u16())); + fail_unless!((20u32 == 20f64.to_u32())); + fail_unless!((20u64 == 20f64.to_u64())); + fail_unless!((20i == 20f64.to_int())); + fail_unless!((20i8 == 20f64.to_i8())); + fail_unless!((20i16 == 20f64.to_i16())); + fail_unless!((20i32 == 20f64.to_i32())); + fail_unless!((20i64 == 20f64.to_i64())); + fail_unless!((20f == 20f64.to_float())); + fail_unless!((20f32 == 20f64.to_f32())); + fail_unless!((20f64 == 20f64.to_f64())); - assert (20f64 == NumCast::from(20u)); - assert (20f64 == NumCast::from(20u8)); - assert (20f64 == NumCast::from(20u16)); - assert (20f64 == NumCast::from(20u32)); - assert (20f64 == NumCast::from(20u64)); - assert (20f64 == NumCast::from(20i)); - assert (20f64 == NumCast::from(20i8)); - assert (20f64 == NumCast::from(20i16)); - assert (20f64 == NumCast::from(20i32)); - assert (20f64 == NumCast::from(20i64)); - assert (20f64 == NumCast::from(20f)); - assert (20f64 == NumCast::from(20f32)); - assert (20f64 == NumCast::from(20f64)); + fail_unless!((20f64 == NumCast::from(20u))); + fail_unless!((20f64 == NumCast::from(20u8))); + fail_unless!((20f64 == NumCast::from(20u16))); + fail_unless!((20f64 == NumCast::from(20u32))); + fail_unless!((20f64 == NumCast::from(20u64))); + fail_unless!((20f64 == NumCast::from(20i))); + fail_unless!((20f64 == NumCast::from(20i8))); + fail_unless!((20f64 == NumCast::from(20i16))); + fail_unless!((20f64 == NumCast::from(20i32))); + fail_unless!((20f64 == NumCast::from(20i64))); + fail_unless!((20f64 == NumCast::from(20f))); + fail_unless!((20f64 == NumCast::from(20f32))); + fail_unless!((20f64 == NumCast::from(20f64))); - assert (20f64 == num::cast(20u)); - assert (20f64 == num::cast(20u8)); - assert (20f64 == num::cast(20u16)); - assert (20f64 == num::cast(20u32)); - assert (20f64 == num::cast(20u64)); - assert (20f64 == num::cast(20i)); - assert (20f64 == num::cast(20i8)); - assert (20f64 == num::cast(20i16)); - assert (20f64 == num::cast(20i32)); - assert (20f64 == num::cast(20i64)); - assert (20f64 == num::cast(20f)); - assert (20f64 == num::cast(20f32)); - assert (20f64 == num::cast(20f64)); + fail_unless!((20f64 == num::cast(20u))); + fail_unless!((20f64 == num::cast(20u8))); + fail_unless!((20f64 == num::cast(20u16))); + fail_unless!((20f64 == num::cast(20u32))); + fail_unless!((20f64 == num::cast(20u64))); + fail_unless!((20f64 == num::cast(20i))); + fail_unless!((20f64 == num::cast(20i8))); + fail_unless!((20f64 == num::cast(20i16))); + fail_unless!((20f64 == num::cast(20i32))); + fail_unless!((20f64 == num::cast(20i64))); + fail_unless!((20f64 == num::cast(20f))); + fail_unless!((20f64 == num::cast(20f32))); + fail_unless!((20f64 == num::cast(20f64))); } // diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 5d912472d7d..1cceddf51a1 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -180,7 +180,7 @@ pub pure fn to_str_exact(num: float, digits: uint) -> ~str { #[test] pub fn test_to_str_exact_do_decimal() { let s = to_str_exact(5.0, 4u); - assert s == ~"5.0000"; + fail_unless!(s == ~"5.0000"); } /** @@ -500,191 +500,191 @@ impl ops::Neg for float { #[test] pub fn test_from_str() { - assert from_str(~"3") == Some(3.); - assert from_str(~"3.14") == Some(3.14); - assert from_str(~"+3.14") == Some(3.14); - assert from_str(~"-3.14") == Some(-3.14); - assert from_str(~"2.5E10") == Some(25000000000.); - assert from_str(~"2.5e10") == Some(25000000000.); - assert from_str(~"25000000000.E-10") == Some(2.5); - assert from_str(~".") == Some(0.); - assert from_str(~".e1") == Some(0.); - assert from_str(~".e-1") == Some(0.); - assert from_str(~"5.") == Some(5.); - assert from_str(~".5") == Some(0.5); - assert from_str(~"0.5") == Some(0.5); - assert from_str(~"-.5") == Some(-0.5); - assert from_str(~"-5") == Some(-5.); - assert from_str(~"inf") == Some(infinity); - assert from_str(~"+inf") == Some(infinity); - assert from_str(~"-inf") == Some(neg_infinity); + fail_unless!(from_str(~"3") == Some(3.)); + fail_unless!(from_str(~"3.14") == Some(3.14)); + fail_unless!(from_str(~"+3.14") == Some(3.14)); + fail_unless!(from_str(~"-3.14") == Some(-3.14)); + fail_unless!(from_str(~"2.5E10") == Some(25000000000.)); + fail_unless!(from_str(~"2.5e10") == Some(25000000000.)); + fail_unless!(from_str(~"25000000000.E-10") == Some(2.5)); + fail_unless!(from_str(~".") == Some(0.)); + fail_unless!(from_str(~".e1") == Some(0.)); + fail_unless!(from_str(~".e-1") == Some(0.)); + fail_unless!(from_str(~"5.") == Some(5.)); + fail_unless!(from_str(~".5") == Some(0.5)); + fail_unless!(from_str(~"0.5") == Some(0.5)); + fail_unless!(from_str(~"-.5") == Some(-0.5)); + fail_unless!(from_str(~"-5") == Some(-5.)); + fail_unless!(from_str(~"inf") == Some(infinity)); + fail_unless!(from_str(~"+inf") == Some(infinity)); + fail_unless!(from_str(~"-inf") == Some(neg_infinity)); // note: NaN != NaN, hence this slightly complex test match from_str(~"NaN") { - Some(f) => assert is_NaN(f), + Some(f) => fail_unless!(is_NaN(f)), None => fail!() } // note: -0 == 0, hence these slightly more complex tests match from_str(~"-0") { - Some(v) if is_zero(v) => assert is_negative(v), + Some(v) if is_zero(v) => fail_unless!(is_negative(v)), _ => fail!() } match from_str(~"0") { - Some(v) if is_zero(v) => assert is_positive(v), + Some(v) if is_zero(v) => fail_unless!(is_positive(v)), _ => fail!() } - assert from_str(~"").is_none(); - assert from_str(~"x").is_none(); - assert from_str(~" ").is_none(); - assert from_str(~" ").is_none(); - assert from_str(~"e").is_none(); - assert from_str(~"E").is_none(); - assert from_str(~"E1").is_none(); - assert from_str(~"1e1e1").is_none(); - assert from_str(~"1e1.1").is_none(); - assert from_str(~"1e1-1").is_none(); + fail_unless!(from_str(~"").is_none()); + fail_unless!(from_str(~"x").is_none()); + fail_unless!(from_str(~" ").is_none()); + fail_unless!(from_str(~" ").is_none()); + fail_unless!(from_str(~"e").is_none()); + fail_unless!(from_str(~"E").is_none()); + fail_unless!(from_str(~"E1").is_none()); + fail_unless!(from_str(~"1e1e1").is_none()); + fail_unless!(from_str(~"1e1.1").is_none()); + fail_unless!(from_str(~"1e1-1").is_none()); } #[test] pub fn test_from_str_hex() { - assert from_str_hex(~"a4") == Some(164.); - assert from_str_hex(~"a4.fe") == Some(164.9921875); - assert from_str_hex(~"-a4.fe") == Some(-164.9921875); - assert from_str_hex(~"+a4.fe") == Some(164.9921875); - assert from_str_hex(~"ff0P4") == Some(0xff00 as float); - assert from_str_hex(~"ff0p4") == Some(0xff00 as float); - assert from_str_hex(~"ff0p-4") == Some(0xff as float); - assert from_str_hex(~".") == Some(0.); - assert from_str_hex(~".p1") == Some(0.); - assert from_str_hex(~".p-1") == Some(0.); - assert from_str_hex(~"f.") == Some(15.); - assert from_str_hex(~".f") == Some(0.9375); - assert from_str_hex(~"0.f") == Some(0.9375); - assert from_str_hex(~"-.f") == Some(-0.9375); - assert from_str_hex(~"-f") == Some(-15.); - assert from_str_hex(~"inf") == Some(infinity); - assert from_str_hex(~"+inf") == Some(infinity); - assert from_str_hex(~"-inf") == Some(neg_infinity); + fail_unless!(from_str_hex(~"a4") == Some(164.)); + fail_unless!(from_str_hex(~"a4.fe") == Some(164.9921875)); + fail_unless!(from_str_hex(~"-a4.fe") == Some(-164.9921875)); + fail_unless!(from_str_hex(~"+a4.fe") == Some(164.9921875)); + fail_unless!(from_str_hex(~"ff0P4") == Some(0xff00 as float)); + fail_unless!(from_str_hex(~"ff0p4") == Some(0xff00 as float)); + fail_unless!(from_str_hex(~"ff0p-4") == Some(0xff as float)); + fail_unless!(from_str_hex(~".") == Some(0.)); + fail_unless!(from_str_hex(~".p1") == Some(0.)); + fail_unless!(from_str_hex(~".p-1") == Some(0.)); + fail_unless!(from_str_hex(~"f.") == Some(15.)); + fail_unless!(from_str_hex(~".f") == Some(0.9375)); + fail_unless!(from_str_hex(~"0.f") == Some(0.9375)); + fail_unless!(from_str_hex(~"-.f") == Some(-0.9375)); + fail_unless!(from_str_hex(~"-f") == Some(-15.)); + fail_unless!(from_str_hex(~"inf") == Some(infinity)); + fail_unless!(from_str_hex(~"+inf") == Some(infinity)); + fail_unless!(from_str_hex(~"-inf") == Some(neg_infinity)); // note: NaN != NaN, hence this slightly complex test match from_str_hex(~"NaN") { - Some(f) => assert is_NaN(f), + Some(f) => fail_unless!(is_NaN(f)), None => fail!() } // note: -0 == 0, hence these slightly more complex tests match from_str_hex(~"-0") { - Some(v) if is_zero(v) => assert is_negative(v), + Some(v) if is_zero(v) => fail_unless!(is_negative(v)), _ => fail!() } match from_str_hex(~"0") { - Some(v) if is_zero(v) => assert is_positive(v), + Some(v) if is_zero(v) => fail_unless!(is_positive(v)), _ => fail!() } - assert from_str_hex(~"e") == Some(14.); - assert from_str_hex(~"E") == Some(14.); - assert from_str_hex(~"E1") == Some(225.); - assert from_str_hex(~"1e1e1") == Some(123361.); - assert from_str_hex(~"1e1.1") == Some(481.0625); + fail_unless!(from_str_hex(~"e") == Some(14.)); + fail_unless!(from_str_hex(~"E") == Some(14.)); + fail_unless!(from_str_hex(~"E1") == Some(225.)); + fail_unless!(from_str_hex(~"1e1e1") == Some(123361.)); + fail_unless!(from_str_hex(~"1e1.1") == Some(481.0625)); - assert from_str_hex(~"").is_none(); - assert from_str_hex(~"x").is_none(); - assert from_str_hex(~" ").is_none(); - assert from_str_hex(~" ").is_none(); - assert from_str_hex(~"p").is_none(); - assert from_str_hex(~"P").is_none(); - assert from_str_hex(~"P1").is_none(); - assert from_str_hex(~"1p1p1").is_none(); - assert from_str_hex(~"1p1.1").is_none(); - assert from_str_hex(~"1p1-1").is_none(); + fail_unless!(from_str_hex(~"").is_none()); + fail_unless!(from_str_hex(~"x").is_none()); + fail_unless!(from_str_hex(~" ").is_none()); + fail_unless!(from_str_hex(~" ").is_none()); + fail_unless!(from_str_hex(~"p").is_none()); + fail_unless!(from_str_hex(~"P").is_none()); + fail_unless!(from_str_hex(~"P1").is_none()); + fail_unless!(from_str_hex(~"1p1p1").is_none()); + fail_unless!(from_str_hex(~"1p1.1").is_none()); + fail_unless!(from_str_hex(~"1p1-1").is_none()); } #[test] pub fn test_to_str_hex() { - assert to_str_hex(164.) == ~"a4"; - assert to_str_hex(164.9921875) == ~"a4.fe"; - assert to_str_hex(-164.9921875) == ~"-a4.fe"; - assert to_str_hex(0xff00 as float) == ~"ff00"; - assert to_str_hex(-(0xff00 as float)) == ~"-ff00"; - assert to_str_hex(0.) == ~"0"; - assert to_str_hex(15.) == ~"f"; - assert to_str_hex(-15.) == ~"-f"; - assert to_str_hex(0.9375) == ~"0.f"; - assert to_str_hex(-0.9375) == ~"-0.f"; - assert to_str_hex(infinity) == ~"inf"; - assert to_str_hex(neg_infinity) == ~"-inf"; - assert to_str_hex(NaN) == ~"NaN"; - assert to_str_hex(0.) == ~"0"; - assert to_str_hex(-0.) == ~"-0"; + fail_unless!(to_str_hex(164.) == ~"a4"); + fail_unless!(to_str_hex(164.9921875) == ~"a4.fe"); + fail_unless!(to_str_hex(-164.9921875) == ~"-a4.fe"); + fail_unless!(to_str_hex(0xff00 as float) == ~"ff00"); + fail_unless!(to_str_hex(-(0xff00 as float)) == ~"-ff00"); + fail_unless!(to_str_hex(0.) == ~"0"); + fail_unless!(to_str_hex(15.) == ~"f"); + fail_unless!(to_str_hex(-15.) == ~"-f"); + fail_unless!(to_str_hex(0.9375) == ~"0.f"); + fail_unless!(to_str_hex(-0.9375) == ~"-0.f"); + fail_unless!(to_str_hex(infinity) == ~"inf"); + fail_unless!(to_str_hex(neg_infinity) == ~"-inf"); + fail_unless!(to_str_hex(NaN) == ~"NaN"); + fail_unless!(to_str_hex(0.) == ~"0"); + fail_unless!(to_str_hex(-0.) == ~"-0"); } #[test] pub fn test_to_str_radix() { - assert to_str_radix(36., 36u) == ~"10"; - assert to_str_radix(8.125, 2u) == ~"1000.001"; + fail_unless!(to_str_radix(36., 36u) == ~"10"); + fail_unless!(to_str_radix(8.125, 2u) == ~"1000.001"); } #[test] pub fn test_from_str_radix() { - assert from_str_radix(~"10", 36u) == Some(36.); - assert from_str_radix(~"1000.001", 2u) == Some(8.125); + fail_unless!(from_str_radix(~"10", 36u) == Some(36.)); + fail_unless!(from_str_radix(~"1000.001", 2u) == Some(8.125)); } #[test] pub fn test_positive() { - assert(is_positive(infinity)); - assert(is_positive(1.)); - assert(is_positive(0.)); - assert(!is_positive(-1.)); - assert(!is_positive(neg_infinity)); - assert(!is_positive(1./neg_infinity)); - assert(!is_positive(NaN)); + fail_unless!((is_positive(infinity))); + fail_unless!((is_positive(1.))); + fail_unless!((is_positive(0.))); + fail_unless!((!is_positive(-1.))); + fail_unless!((!is_positive(neg_infinity))); + fail_unless!((!is_positive(1./neg_infinity))); + fail_unless!((!is_positive(NaN))); } #[test] pub fn test_negative() { - assert(!is_negative(infinity)); - assert(!is_negative(1.)); - assert(!is_negative(0.)); - assert(is_negative(-1.)); - assert(is_negative(neg_infinity)); - assert(is_negative(1./neg_infinity)); - assert(!is_negative(NaN)); + fail_unless!((!is_negative(infinity))); + fail_unless!((!is_negative(1.))); + fail_unless!((!is_negative(0.))); + fail_unless!((is_negative(-1.))); + fail_unless!((is_negative(neg_infinity))); + fail_unless!((is_negative(1./neg_infinity))); + fail_unless!((!is_negative(NaN))); } #[test] pub fn test_nonpositive() { - assert(!is_nonpositive(infinity)); - assert(!is_nonpositive(1.)); - assert(!is_nonpositive(0.)); - assert(is_nonpositive(-1.)); - assert(is_nonpositive(neg_infinity)); - assert(is_nonpositive(1./neg_infinity)); - assert(!is_nonpositive(NaN)); + fail_unless!((!is_nonpositive(infinity))); + fail_unless!((!is_nonpositive(1.))); + fail_unless!((!is_nonpositive(0.))); + fail_unless!((is_nonpositive(-1.))); + fail_unless!((is_nonpositive(neg_infinity))); + fail_unless!((is_nonpositive(1./neg_infinity))); + fail_unless!((!is_nonpositive(NaN))); } #[test] pub fn test_nonnegative() { - assert(is_nonnegative(infinity)); - assert(is_nonnegative(1.)); - assert(is_nonnegative(0.)); - assert(!is_nonnegative(-1.)); - assert(!is_nonnegative(neg_infinity)); - assert(!is_nonnegative(1./neg_infinity)); - assert(!is_nonnegative(NaN)); + fail_unless!((is_nonnegative(infinity))); + fail_unless!((is_nonnegative(1.))); + fail_unless!((is_nonnegative(0.))); + fail_unless!((!is_nonnegative(-1.))); + fail_unless!((!is_nonnegative(neg_infinity))); + fail_unless!((!is_nonnegative(1./neg_infinity))); + fail_unless!((!is_nonnegative(NaN))); } #[test] pub fn test_to_str_inf() { - assert to_str_digits(infinity, 10u) == ~"inf"; - assert to_str_digits(-infinity, 10u) == ~"-inf"; + fail_unless!(to_str_digits(infinity, 10u) == ~"inf"); + fail_unless!(to_str_digits(-infinity, 10u) == ~"-inf"); } #[test] pub fn test_round() { - assert round(5.8) == 6.0; - assert round(5.2) == 5.0; - assert round(3.0) == 3.0; - assert round(2.5) == 3.0; - assert round(-3.5) == -4.0; + fail_unless!(round(5.8) == 6.0); + fail_unless!(round(5.2) == 5.0); + fail_unless!(round(3.0) == 3.0); + fail_unless!(round(2.5) == 3.0); + fail_unless!(round(-3.5) == -4.0); } #[test] @@ -692,56 +692,56 @@ pub fn test_num() { let ten: float = num::cast(10); let two: float = num::cast(2); - assert (ten.add(&two) == num::cast(12)); - assert (ten.sub(&two) == num::cast(8)); - assert (ten.mul(&two) == num::cast(20)); - assert (ten.div(&two) == num::cast(5)); - assert (ten.modulo(&two) == num::cast(0)); + fail_unless!((ten.add(&two) == num::cast(12))); + fail_unless!((ten.sub(&two) == num::cast(8))); + fail_unless!((ten.mul(&two) == num::cast(20))); + fail_unless!((ten.div(&two) == num::cast(5))); + fail_unless!((ten.modulo(&two) == num::cast(0))); } #[test] fn test_numcast() { - assert (20u == 20f.to_uint()); - assert (20u8 == 20f.to_u8()); - assert (20u16 == 20f.to_u16()); - assert (20u32 == 20f.to_u32()); - assert (20u64 == 20f.to_u64()); - assert (20i == 20f.to_int()); - assert (20i8 == 20f.to_i8()); - assert (20i16 == 20f.to_i16()); - assert (20i32 == 20f.to_i32()); - assert (20i64 == 20f.to_i64()); - assert (20f == 20f.to_float()); - assert (20f32 == 20f.to_f32()); - assert (20f64 == 20f.to_f64()); + fail_unless!((20u == 20f.to_uint())); + fail_unless!((20u8 == 20f.to_u8())); + fail_unless!((20u16 == 20f.to_u16())); + fail_unless!((20u32 == 20f.to_u32())); + fail_unless!((20u64 == 20f.to_u64())); + fail_unless!((20i == 20f.to_int())); + fail_unless!((20i8 == 20f.to_i8())); + fail_unless!((20i16 == 20f.to_i16())); + fail_unless!((20i32 == 20f.to_i32())); + fail_unless!((20i64 == 20f.to_i64())); + fail_unless!((20f == 20f.to_float())); + fail_unless!((20f32 == 20f.to_f32())); + fail_unless!((20f64 == 20f.to_f64())); - assert (20f == NumCast::from(20u)); - assert (20f == NumCast::from(20u8)); - assert (20f == NumCast::from(20u16)); - assert (20f == NumCast::from(20u32)); - assert (20f == NumCast::from(20u64)); - assert (20f == NumCast::from(20i)); - assert (20f == NumCast::from(20i8)); - assert (20f == NumCast::from(20i16)); - assert (20f == NumCast::from(20i32)); - assert (20f == NumCast::from(20i64)); - assert (20f == NumCast::from(20f)); - assert (20f == NumCast::from(20f32)); - assert (20f == NumCast::from(20f64)); + fail_unless!((20f == NumCast::from(20u))); + fail_unless!((20f == NumCast::from(20u8))); + fail_unless!((20f == NumCast::from(20u16))); + fail_unless!((20f == NumCast::from(20u32))); + fail_unless!((20f == NumCast::from(20u64))); + fail_unless!((20f == NumCast::from(20i))); + fail_unless!((20f == NumCast::from(20i8))); + fail_unless!((20f == NumCast::from(20i16))); + fail_unless!((20f == NumCast::from(20i32))); + fail_unless!((20f == NumCast::from(20i64))); + fail_unless!((20f == NumCast::from(20f))); + fail_unless!((20f == NumCast::from(20f32))); + fail_unless!((20f == NumCast::from(20f64))); - assert (20f == num::cast(20u)); - assert (20f == num::cast(20u8)); - assert (20f == num::cast(20u16)); - assert (20f == num::cast(20u32)); - assert (20f == num::cast(20u64)); - assert (20f == num::cast(20i)); - assert (20f == num::cast(20i8)); - assert (20f == num::cast(20i16)); - assert (20f == num::cast(20i32)); - assert (20f == num::cast(20i64)); - assert (20f == num::cast(20f)); - assert (20f == num::cast(20f32)); - assert (20f == num::cast(20f64)); + fail_unless!((20f == num::cast(20u))); + fail_unless!((20f == num::cast(20u8))); + fail_unless!((20f == num::cast(20u16))); + fail_unless!((20f == num::cast(20u32))); + fail_unless!((20f == num::cast(20u64))); + fail_unless!((20f == num::cast(20i))); + fail_unless!((20f == num::cast(20i8))); + fail_unless!((20f == num::cast(20i16))); + fail_unless!((20f == num::cast(20i32))); + fail_unless!((20f == num::cast(20i64))); + fail_unless!((20f == num::cast(20f))); + fail_unless!((20f == num::cast(20f32))); + fail_unless!((20f == num::cast(20f64))); } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index c0351e2c619..8096e6f99e7 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -41,18 +41,18 @@ pub pure fn div(x: T, y: T) -> T { x / y } * * # Examples * ~~~ - * assert int::rem(5 / 2) == 1; + * fail_unless!(int::rem(5 / 2) == 1); * ~~~ * * When faced with negative numbers, the result copies the sign of the * dividend. * * ~~~ - * assert int::rem(2 / -3) == 2; + * fail_unless!(int::rem(2 / -3) == 2); * ~~~ * * ~~~ - * assert int::rem(-2 / 3) == -2; + * fail_unless!(int::rem(-2 / 3) == -2); * ~~~ * */ @@ -95,7 +95,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } * for int::range(1, 5) |i| { * sum += i; * } - * assert sum == 10; + * fail_unless!(sum == 10); * ~~~ */ #[inline(always)] @@ -275,117 +275,117 @@ impl ToStrRadix for T { #[test] fn test_from_str() { - assert from_str(~"0") == Some(0 as T); - assert from_str(~"3") == Some(3 as T); - assert from_str(~"10") == Some(10 as T); - assert i32::from_str(~"123456789") == Some(123456789 as i32); - assert from_str(~"00100") == Some(100 as T); + fail_unless!(from_str(~"0") == Some(0 as T)); + fail_unless!(from_str(~"3") == Some(3 as T)); + fail_unless!(from_str(~"10") == Some(10 as T)); + fail_unless!(i32::from_str(~"123456789") == Some(123456789 as i32)); + fail_unless!(from_str(~"00100") == Some(100 as T)); - assert from_str(~"-1") == Some(-1 as T); - assert from_str(~"-3") == Some(-3 as T); - assert from_str(~"-10") == Some(-10 as T); - assert i32::from_str(~"-123456789") == Some(-123456789 as i32); - assert from_str(~"-00100") == Some(-100 as T); + fail_unless!(from_str(~"-1") == Some(-1 as T)); + fail_unless!(from_str(~"-3") == Some(-3 as T)); + fail_unless!(from_str(~"-10") == Some(-10 as T)); + fail_unless!(i32::from_str(~"-123456789") == Some(-123456789 as i32)); + fail_unless!(from_str(~"-00100") == Some(-100 as T)); - assert from_str(~" ").is_none(); - assert from_str(~"x").is_none(); + fail_unless!(from_str(~" ").is_none()); + fail_unless!(from_str(~"x").is_none()); } #[test] fn test_parse_bytes() { use str::to_bytes; - assert parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T); - assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T); - assert parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T); - assert i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32); - assert i32::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as i32); - assert i32::parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as i32); - assert parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T); - assert parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T); + fail_unless!(parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T)); + fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T)); + fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T)); + fail_unless!(i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32)); + fail_unless!(i32::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as i32)); + fail_unless!(i32::parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as i32)); + fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T)); + fail_unless!(parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T)); - assert parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T); - assert parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T); - assert parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T); - assert i32::parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as i32); - assert i32::parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as i32); - assert i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as i32); - assert parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T); - assert parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T); + fail_unless!(parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T)); + fail_unless!(parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T)); + fail_unless!(parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T)); + fail_unless!(i32::parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as i32)); + fail_unless!(i32::parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as i32)); + fail_unless!(i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as i32)); + fail_unless!(parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T)); + fail_unless!(parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T)); - assert parse_bytes(to_bytes(~"Z"), 35u).is_none(); - assert parse_bytes(to_bytes(~"-9"), 2u).is_none(); + fail_unless!(parse_bytes(to_bytes(~"Z"), 35u).is_none()); + fail_unless!(parse_bytes(to_bytes(~"-9"), 2u).is_none()); } #[test] fn test_to_str() { - assert (to_str_radix(0 as T, 10u) == ~"0"); - assert (to_str_radix(1 as T, 10u) == ~"1"); - assert (to_str_radix(-1 as T, 10u) == ~"-1"); - assert (to_str_radix(127 as T, 16u) == ~"7f"); - assert (to_str_radix(100 as T, 10u) == ~"100"); + fail_unless!((to_str_radix(0 as T, 10u) == ~"0")); + fail_unless!((to_str_radix(1 as T, 10u) == ~"1")); + fail_unless!((to_str_radix(-1 as T, 10u) == ~"-1")); + fail_unless!((to_str_radix(127 as T, 16u) == ~"7f")); + fail_unless!((to_str_radix(100 as T, 10u) == ~"100")); } #[test] fn test_int_to_str_overflow() { let mut i8_val: i8 = 127_i8; - assert (i8::to_str(i8_val) == ~"127"); + fail_unless!((i8::to_str(i8_val) == ~"127")); i8_val += 1 as i8; - assert (i8::to_str(i8_val) == ~"-128"); + fail_unless!((i8::to_str(i8_val) == ~"-128")); let mut i16_val: i16 = 32_767_i16; - assert (i16::to_str(i16_val) == ~"32767"); + fail_unless!((i16::to_str(i16_val) == ~"32767")); i16_val += 1 as i16; - assert (i16::to_str(i16_val) == ~"-32768"); + fail_unless!((i16::to_str(i16_val) == ~"-32768")); let mut i32_val: i32 = 2_147_483_647_i32; - assert (i32::to_str(i32_val) == ~"2147483647"); + fail_unless!((i32::to_str(i32_val) == ~"2147483647")); i32_val += 1 as i32; - assert (i32::to_str(i32_val) == ~"-2147483648"); + fail_unless!((i32::to_str(i32_val) == ~"-2147483648")); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert (i64::to_str(i64_val) == ~"9223372036854775807"); + fail_unless!((i64::to_str(i64_val) == ~"9223372036854775807")); i64_val += 1 as i64; - assert (i64::to_str(i64_val) == ~"-9223372036854775808"); + fail_unless!((i64::to_str(i64_val) == ~"-9223372036854775808")); } #[test] fn test_int_from_str_overflow() { let mut i8_val: i8 = 127_i8; - assert (i8::from_str(~"127") == Some(i8_val)); - assert (i8::from_str(~"128").is_none()); + fail_unless!((i8::from_str(~"127") == Some(i8_val))); + fail_unless!((i8::from_str(~"128").is_none())); i8_val += 1 as i8; - assert (i8::from_str(~"-128") == Some(i8_val)); - assert (i8::from_str(~"-129").is_none()); + fail_unless!((i8::from_str(~"-128") == Some(i8_val))); + fail_unless!((i8::from_str(~"-129").is_none())); let mut i16_val: i16 = 32_767_i16; - assert (i16::from_str(~"32767") == Some(i16_val)); - assert (i16::from_str(~"32768").is_none()); + fail_unless!((i16::from_str(~"32767") == Some(i16_val))); + fail_unless!((i16::from_str(~"32768").is_none())); i16_val += 1 as i16; - assert (i16::from_str(~"-32768") == Some(i16_val)); - assert (i16::from_str(~"-32769").is_none()); + fail_unless!((i16::from_str(~"-32768") == Some(i16_val))); + fail_unless!((i16::from_str(~"-32769").is_none())); let mut i32_val: i32 = 2_147_483_647_i32; - assert (i32::from_str(~"2147483647") == Some(i32_val)); - assert (i32::from_str(~"2147483648").is_none()); + fail_unless!((i32::from_str(~"2147483647") == Some(i32_val))); + fail_unless!((i32::from_str(~"2147483648").is_none())); i32_val += 1 as i32; - assert (i32::from_str(~"-2147483648") == Some(i32_val)); - assert (i32::from_str(~"-2147483649").is_none()); + fail_unless!((i32::from_str(~"-2147483648") == Some(i32_val))); + fail_unless!((i32::from_str(~"-2147483649").is_none())); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert (i64::from_str(~"9223372036854775807") == Some(i64_val)); - assert (i64::from_str(~"9223372036854775808").is_none()); + fail_unless!((i64::from_str(~"9223372036854775807") == Some(i64_val))); + fail_unless!((i64::from_str(~"9223372036854775808").is_none())); i64_val += 1 as i64; - assert (i64::from_str(~"-9223372036854775808") == Some(i64_val)); - assert (i64::from_str(~"-9223372036854775809").is_none()); + fail_unless!((i64::from_str(~"-9223372036854775808") == Some(i64_val))); + fail_unless!((i64::from_str(~"-9223372036854775809").is_none())); } #[test] @@ -393,11 +393,11 @@ pub fn test_num() { let ten: T = num::cast(10); let two: T = num::cast(2); - assert (ten.add(&two) == num::cast(12)); - assert (ten.sub(&two) == num::cast(8)); - assert (ten.mul(&two) == num::cast(20)); - assert (ten.div(&two) == num::cast(5)); - assert (ten.modulo(&two) == num::cast(0)); + fail_unless!((ten.add(&two) == num::cast(12))); + fail_unless!((ten.sub(&two) == num::cast(8))); + fail_unless!((ten.mul(&two) == num::cast(20))); + fail_unless!((ten.div(&two) == num::cast(5))); + fail_unless!((ten.modulo(&two) == num::cast(0))); } #[test] @@ -416,10 +416,10 @@ pub fn test_ranges() { for range_step(36,30,-2) |i| { l.push(i); } - assert l == ~[0,1,2, - 13,12,11, - 20,22,24, - 36,34,32]; + fail_unless!(l == ~[0,1,2, + 13,12,11, + 20,22,24, + 36,34,32]); // None of the `fail`s should execute. for range(10,0) |_i| { diff --git a/src/libcore/num/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index a3def10bda8..3c4ca532be7 100644 --- a/src/libcore/num/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs @@ -43,45 +43,45 @@ impl NumCast for i16 { #[test] fn test_numcast() { - assert (20u == 20i16.to_uint()); - assert (20u8 == 20i16.to_u8()); - assert (20u16 == 20i16.to_u16()); - assert (20u32 == 20i16.to_u32()); - assert (20u64 == 20i16.to_u64()); - assert (20i == 20i16.to_int()); - assert (20i8 == 20i16.to_i8()); - assert (20i16 == 20i16.to_i16()); - assert (20i32 == 20i16.to_i32()); - assert (20i64 == 20i16.to_i64()); - assert (20f == 20i16.to_float()); - assert (20f32 == 20i16.to_f32()); - assert (20f64 == 20i16.to_f64()); + fail_unless!((20u == 20i16.to_uint())); + fail_unless!((20u8 == 20i16.to_u8())); + fail_unless!((20u16 == 20i16.to_u16())); + fail_unless!((20u32 == 20i16.to_u32())); + fail_unless!((20u64 == 20i16.to_u64())); + fail_unless!((20i == 20i16.to_int())); + fail_unless!((20i8 == 20i16.to_i8())); + fail_unless!((20i16 == 20i16.to_i16())); + fail_unless!((20i32 == 20i16.to_i32())); + fail_unless!((20i64 == 20i16.to_i64())); + fail_unless!((20f == 20i16.to_float())); + fail_unless!((20f32 == 20i16.to_f32())); + fail_unless!((20f64 == 20i16.to_f64())); - assert (20i16 == NumCast::from(20u)); - assert (20i16 == NumCast::from(20u8)); - assert (20i16 == NumCast::from(20u16)); - assert (20i16 == NumCast::from(20u32)); - assert (20i16 == NumCast::from(20u64)); - assert (20i16 == NumCast::from(20i)); - assert (20i16 == NumCast::from(20i8)); - assert (20i16 == NumCast::from(20i16)); - assert (20i16 == NumCast::from(20i32)); - assert (20i16 == NumCast::from(20i64)); - assert (20i16 == NumCast::from(20f)); - assert (20i16 == NumCast::from(20f32)); - assert (20i16 == NumCast::from(20f64)); + fail_unless!((20i16 == NumCast::from(20u))); + fail_unless!((20i16 == NumCast::from(20u8))); + fail_unless!((20i16 == NumCast::from(20u16))); + fail_unless!((20i16 == NumCast::from(20u32))); + fail_unless!((20i16 == NumCast::from(20u64))); + fail_unless!((20i16 == NumCast::from(20i))); + fail_unless!((20i16 == NumCast::from(20i8))); + fail_unless!((20i16 == NumCast::from(20i16))); + fail_unless!((20i16 == NumCast::from(20i32))); + fail_unless!((20i16 == NumCast::from(20i64))); + fail_unless!((20i16 == NumCast::from(20f))); + fail_unless!((20i16 == NumCast::from(20f32))); + fail_unless!((20i16 == NumCast::from(20f64))); - assert (20i16 == num::cast(20u)); - assert (20i16 == num::cast(20u8)); - assert (20i16 == num::cast(20u16)); - assert (20i16 == num::cast(20u32)); - assert (20i16 == num::cast(20u64)); - assert (20i16 == num::cast(20i)); - assert (20i16 == num::cast(20i8)); - assert (20i16 == num::cast(20i16)); - assert (20i16 == num::cast(20i32)); - assert (20i16 == num::cast(20i64)); - assert (20i16 == num::cast(20f)); - assert (20i16 == num::cast(20f32)); - assert (20i16 == num::cast(20f64)); + fail_unless!((20i16 == num::cast(20u))); + fail_unless!((20i16 == num::cast(20u8))); + fail_unless!((20i16 == num::cast(20u16))); + fail_unless!((20i16 == num::cast(20u32))); + fail_unless!((20i16 == num::cast(20u64))); + fail_unless!((20i16 == num::cast(20i))); + fail_unless!((20i16 == num::cast(20i8))); + fail_unless!((20i16 == num::cast(20i16))); + fail_unless!((20i16 == num::cast(20i32))); + fail_unless!((20i16 == num::cast(20i64))); + fail_unless!((20i16 == num::cast(20f))); + fail_unless!((20i16 == num::cast(20f32))); + fail_unless!((20i16 == num::cast(20f64))); } diff --git a/src/libcore/num/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index eccd1f6ce3c..30eb4437d57 100644 --- a/src/libcore/num/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs @@ -43,45 +43,45 @@ impl NumCast for i32 { #[test] fn test_numcast() { - assert (20u == 20i32.to_uint()); - assert (20u8 == 20i32.to_u8()); - assert (20u16 == 20i32.to_u16()); - assert (20u32 == 20i32.to_u32()); - assert (20u64 == 20i32.to_u64()); - assert (20i == 20i32.to_int()); - assert (20i8 == 20i32.to_i8()); - assert (20i16 == 20i32.to_i16()); - assert (20i32 == 20i32.to_i32()); - assert (20i64 == 20i32.to_i64()); - assert (20f == 20i32.to_float()); - assert (20f32 == 20i32.to_f32()); - assert (20f64 == 20i32.to_f64()); + fail_unless!((20u == 20i32.to_uint())); + fail_unless!((20u8 == 20i32.to_u8())); + fail_unless!((20u16 == 20i32.to_u16())); + fail_unless!((20u32 == 20i32.to_u32())); + fail_unless!((20u64 == 20i32.to_u64())); + fail_unless!((20i == 20i32.to_int())); + fail_unless!((20i8 == 20i32.to_i8())); + fail_unless!((20i16 == 20i32.to_i16())); + fail_unless!((20i32 == 20i32.to_i32())); + fail_unless!((20i64 == 20i32.to_i64())); + fail_unless!((20f == 20i32.to_float())); + fail_unless!((20f32 == 20i32.to_f32())); + fail_unless!((20f64 == 20i32.to_f64())); - assert (20i32 == NumCast::from(20u)); - assert (20i32 == NumCast::from(20u8)); - assert (20i32 == NumCast::from(20u16)); - assert (20i32 == NumCast::from(20u32)); - assert (20i32 == NumCast::from(20u64)); - assert (20i32 == NumCast::from(20i)); - assert (20i32 == NumCast::from(20i8)); - assert (20i32 == NumCast::from(20i16)); - assert (20i32 == NumCast::from(20i32)); - assert (20i32 == NumCast::from(20i64)); - assert (20i32 == NumCast::from(20f)); - assert (20i32 == NumCast::from(20f32)); - assert (20i32 == NumCast::from(20f64)); + fail_unless!((20i32 == NumCast::from(20u))); + fail_unless!((20i32 == NumCast::from(20u8))); + fail_unless!((20i32 == NumCast::from(20u16))); + fail_unless!((20i32 == NumCast::from(20u32))); + fail_unless!((20i32 == NumCast::from(20u64))); + fail_unless!((20i32 == NumCast::from(20i))); + fail_unless!((20i32 == NumCast::from(20i8))); + fail_unless!((20i32 == NumCast::from(20i16))); + fail_unless!((20i32 == NumCast::from(20i32))); + fail_unless!((20i32 == NumCast::from(20i64))); + fail_unless!((20i32 == NumCast::from(20f))); + fail_unless!((20i32 == NumCast::from(20f32))); + fail_unless!((20i32 == NumCast::from(20f64))); - assert (20i32 == num::cast(20u)); - assert (20i32 == num::cast(20u8)); - assert (20i32 == num::cast(20u16)); - assert (20i32 == num::cast(20u32)); - assert (20i32 == num::cast(20u64)); - assert (20i32 == num::cast(20i)); - assert (20i32 == num::cast(20i8)); - assert (20i32 == num::cast(20i16)); - assert (20i32 == num::cast(20i32)); - assert (20i32 == num::cast(20i64)); - assert (20i32 == num::cast(20f)); - assert (20i32 == num::cast(20f32)); - assert (20i32 == num::cast(20f64)); + fail_unless!((20i32 == num::cast(20u))); + fail_unless!((20i32 == num::cast(20u8))); + fail_unless!((20i32 == num::cast(20u16))); + fail_unless!((20i32 == num::cast(20u32))); + fail_unless!((20i32 == num::cast(20u64))); + fail_unless!((20i32 == num::cast(20i))); + fail_unless!((20i32 == num::cast(20i8))); + fail_unless!((20i32 == num::cast(20i16))); + fail_unless!((20i32 == num::cast(20i32))); + fail_unless!((20i32 == num::cast(20i64))); + fail_unless!((20i32 == num::cast(20f))); + fail_unless!((20i32 == num::cast(20f32))); + fail_unless!((20i32 == num::cast(20f64))); } diff --git a/src/libcore/num/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index 05d529cbcf4..61736cf9587 100644 --- a/src/libcore/num/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs @@ -43,45 +43,45 @@ impl NumCast for i64 { #[test] fn test_numcast() { - assert (20u == 20i64.to_uint()); - assert (20u8 == 20i64.to_u8()); - assert (20u16 == 20i64.to_u16()); - assert (20u32 == 20i64.to_u32()); - assert (20u64 == 20i64.to_u64()); - assert (20i == 20i64.to_int()); - assert (20i8 == 20i64.to_i8()); - assert (20i16 == 20i64.to_i16()); - assert (20i32 == 20i64.to_i32()); - assert (20i64 == 20i64.to_i64()); - assert (20f == 20i64.to_float()); - assert (20f32 == 20i64.to_f32()); - assert (20f64 == 20i64.to_f64()); + fail_unless!((20u == 20i64.to_uint())); + fail_unless!((20u8 == 20i64.to_u8())); + fail_unless!((20u16 == 20i64.to_u16())); + fail_unless!((20u32 == 20i64.to_u32())); + fail_unless!((20u64 == 20i64.to_u64())); + fail_unless!((20i == 20i64.to_int())); + fail_unless!((20i8 == 20i64.to_i8())); + fail_unless!((20i16 == 20i64.to_i16())); + fail_unless!((20i32 == 20i64.to_i32())); + fail_unless!((20i64 == 20i64.to_i64())); + fail_unless!((20f == 20i64.to_float())); + fail_unless!((20f32 == 20i64.to_f32())); + fail_unless!((20f64 == 20i64.to_f64())); - assert (20i64 == NumCast::from(20u)); - assert (20i64 == NumCast::from(20u8)); - assert (20i64 == NumCast::from(20u16)); - assert (20i64 == NumCast::from(20u32)); - assert (20i64 == NumCast::from(20u64)); - assert (20i64 == NumCast::from(20i)); - assert (20i64 == NumCast::from(20i8)); - assert (20i64 == NumCast::from(20i16)); - assert (20i64 == NumCast::from(20i32)); - assert (20i64 == NumCast::from(20i64)); - assert (20i64 == NumCast::from(20f)); - assert (20i64 == NumCast::from(20f32)); - assert (20i64 == NumCast::from(20f64)); + fail_unless!((20i64 == NumCast::from(20u))); + fail_unless!((20i64 == NumCast::from(20u8))); + fail_unless!((20i64 == NumCast::from(20u16))); + fail_unless!((20i64 == NumCast::from(20u32))); + fail_unless!((20i64 == NumCast::from(20u64))); + fail_unless!((20i64 == NumCast::from(20i))); + fail_unless!((20i64 == NumCast::from(20i8))); + fail_unless!((20i64 == NumCast::from(20i16))); + fail_unless!((20i64 == NumCast::from(20i32))); + fail_unless!((20i64 == NumCast::from(20i64))); + fail_unless!((20i64 == NumCast::from(20f))); + fail_unless!((20i64 == NumCast::from(20f32))); + fail_unless!((20i64 == NumCast::from(20f64))); - assert (20i64 == num::cast(20u)); - assert (20i64 == num::cast(20u8)); - assert (20i64 == num::cast(20u16)); - assert (20i64 == num::cast(20u32)); - assert (20i64 == num::cast(20u64)); - assert (20i64 == num::cast(20i)); - assert (20i64 == num::cast(20i8)); - assert (20i64 == num::cast(20i16)); - assert (20i64 == num::cast(20i32)); - assert (20i64 == num::cast(20i64)); - assert (20i64 == num::cast(20f)); - assert (20i64 == num::cast(20f32)); - assert (20i64 == num::cast(20f64)); + fail_unless!((20i64 == num::cast(20u))); + fail_unless!((20i64 == num::cast(20u8))); + fail_unless!((20i64 == num::cast(20u16))); + fail_unless!((20i64 == num::cast(20u32))); + fail_unless!((20i64 == num::cast(20u64))); + fail_unless!((20i64 == num::cast(20i))); + fail_unless!((20i64 == num::cast(20i8))); + fail_unless!((20i64 == num::cast(20i16))); + fail_unless!((20i64 == num::cast(20i32))); + fail_unless!((20i64 == num::cast(20i64))); + fail_unless!((20i64 == num::cast(20f))); + fail_unless!((20i64 == num::cast(20f32))); + fail_unless!((20i64 == num::cast(20f64))); } diff --git a/src/libcore/num/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index d8819d4fed0..e70811adff1 100644 --- a/src/libcore/num/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs @@ -43,45 +43,45 @@ impl NumCast for i8 { #[test] fn test_numcast() { - assert (20u == 20i8.to_uint()); - assert (20u8 == 20i8.to_u8()); - assert (20u16 == 20i8.to_u16()); - assert (20u32 == 20i8.to_u32()); - assert (20u64 == 20i8.to_u64()); - assert (20i == 20i8.to_int()); - assert (20i8 == 20i8.to_i8()); - assert (20i16 == 20i8.to_i16()); - assert (20i32 == 20i8.to_i32()); - assert (20i64 == 20i8.to_i64()); - assert (20f == 20i8.to_float()); - assert (20f32 == 20i8.to_f32()); - assert (20f64 == 20i8.to_f64()); + fail_unless!((20u == 20i8.to_uint())); + fail_unless!((20u8 == 20i8.to_u8())); + fail_unless!((20u16 == 20i8.to_u16())); + fail_unless!((20u32 == 20i8.to_u32())); + fail_unless!((20u64 == 20i8.to_u64())); + fail_unless!((20i == 20i8.to_int())); + fail_unless!((20i8 == 20i8.to_i8())); + fail_unless!((20i16 == 20i8.to_i16())); + fail_unless!((20i32 == 20i8.to_i32())); + fail_unless!((20i64 == 20i8.to_i64())); + fail_unless!((20f == 20i8.to_float())); + fail_unless!((20f32 == 20i8.to_f32())); + fail_unless!((20f64 == 20i8.to_f64())); - assert (20i8 == NumCast::from(20u)); - assert (20i8 == NumCast::from(20u8)); - assert (20i8 == NumCast::from(20u16)); - assert (20i8 == NumCast::from(20u32)); - assert (20i8 == NumCast::from(20u64)); - assert (20i8 == NumCast::from(20i)); - assert (20i8 == NumCast::from(20i8)); - assert (20i8 == NumCast::from(20i16)); - assert (20i8 == NumCast::from(20i32)); - assert (20i8 == NumCast::from(20i64)); - assert (20i8 == NumCast::from(20f)); - assert (20i8 == NumCast::from(20f32)); - assert (20i8 == NumCast::from(20f64)); + fail_unless!((20i8 == NumCast::from(20u))); + fail_unless!((20i8 == NumCast::from(20u8))); + fail_unless!((20i8 == NumCast::from(20u16))); + fail_unless!((20i8 == NumCast::from(20u32))); + fail_unless!((20i8 == NumCast::from(20u64))); + fail_unless!((20i8 == NumCast::from(20i))); + fail_unless!((20i8 == NumCast::from(20i8))); + fail_unless!((20i8 == NumCast::from(20i16))); + fail_unless!((20i8 == NumCast::from(20i32))); + fail_unless!((20i8 == NumCast::from(20i64))); + fail_unless!((20i8 == NumCast::from(20f))); + fail_unless!((20i8 == NumCast::from(20f32))); + fail_unless!((20i8 == NumCast::from(20f64))); - assert (20i8 == num::cast(20u)); - assert (20i8 == num::cast(20u8)); - assert (20i8 == num::cast(20u16)); - assert (20i8 == num::cast(20u32)); - assert (20i8 == num::cast(20u64)); - assert (20i8 == num::cast(20i)); - assert (20i8 == num::cast(20i8)); - assert (20i8 == num::cast(20i16)); - assert (20i8 == num::cast(20i32)); - assert (20i8 == num::cast(20i64)); - assert (20i8 == num::cast(20f)); - assert (20i8 == num::cast(20f32)); - assert (20i8 == num::cast(20f64)); + fail_unless!((20i8 == num::cast(20u))); + fail_unless!((20i8 == num::cast(20u8))); + fail_unless!((20i8 == num::cast(20u16))); + fail_unless!((20i8 == num::cast(20u32))); + fail_unless!((20i8 == num::cast(20u64))); + fail_unless!((20i8 == num::cast(20i))); + fail_unless!((20i8 == num::cast(20i8))); + fail_unless!((20i8 == num::cast(20i16))); + fail_unless!((20i8 == num::cast(20i32))); + fail_unless!((20i8 == num::cast(20i64))); + fail_unless!((20i8 == num::cast(20f))); + fail_unless!((20i8 == num::cast(20f32))); + fail_unless!((20i8 == num::cast(20f64))); } diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index 7e376a47b89..f007cc5b119 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -40,21 +40,21 @@ mod inst { #[test] fn test_pow() { - assert (pow(0, 0u) == 1); - assert (pow(0, 1u) == 0); - assert (pow(0, 2u) == 0); - assert (pow(-1, 0u) == 1); - assert (pow(1, 0u) == 1); - assert (pow(-3, 2u) == 9); - assert (pow(-3, 3u) == -27); - assert (pow(4, 9u) == 262144); + fail_unless!((pow(0, 0u) == 1)); + fail_unless!((pow(0, 1u) == 0)); + fail_unless!((pow(0, 2u) == 0)); + fail_unless!((pow(-1, 0u) == 1)); + fail_unless!((pow(1, 0u) == 1)); + fail_unless!((pow(-3, 2u) == 9)); + fail_unless!((pow(-3, 3u) == -27)); + fail_unless!((pow(4, 9u) == 262144)); } #[test] fn test_overflows() { - assert (::int::max_value > 0); - assert (::int::min_value <= 0); - assert (::int::min_value + ::int::max_value + 1 == 0); + fail_unless!((::int::max_value > 0)); + fail_unless!((::int::min_value <= 0)); + fail_unless!((::int::min_value + ::int::max_value + 1 == 0)); } } @@ -84,45 +84,45 @@ impl NumCast for int { #[test] fn test_numcast() { - assert (20u == 20i.to_uint()); - assert (20u8 == 20i.to_u8()); - assert (20u16 == 20i.to_u16()); - assert (20u32 == 20i.to_u32()); - assert (20u64 == 20i.to_u64()); - assert (20i == 20i.to_int()); - assert (20i8 == 20i.to_i8()); - assert (20i16 == 20i.to_i16()); - assert (20i32 == 20i.to_i32()); - assert (20i64 == 20i.to_i64()); - assert (20f == 20i.to_float()); - assert (20f32 == 20i.to_f32()); - assert (20f64 == 20i.to_f64()); + fail_unless!((20u == 20i.to_uint())); + fail_unless!((20u8 == 20i.to_u8())); + fail_unless!((20u16 == 20i.to_u16())); + fail_unless!((20u32 == 20i.to_u32())); + fail_unless!((20u64 == 20i.to_u64())); + fail_unless!((20i == 20i.to_int())); + fail_unless!((20i8 == 20i.to_i8())); + fail_unless!((20i16 == 20i.to_i16())); + fail_unless!((20i32 == 20i.to_i32())); + fail_unless!((20i64 == 20i.to_i64())); + fail_unless!((20f == 20i.to_float())); + fail_unless!((20f32 == 20i.to_f32())); + fail_unless!((20f64 == 20i.to_f64())); - assert (20i == NumCast::from(20u)); - assert (20i == NumCast::from(20u8)); - assert (20i == NumCast::from(20u16)); - assert (20i == NumCast::from(20u32)); - assert (20i == NumCast::from(20u64)); - assert (20i == NumCast::from(20i)); - assert (20i == NumCast::from(20i8)); - assert (20i == NumCast::from(20i16)); - assert (20i == NumCast::from(20i32)); - assert (20i == NumCast::from(20i64)); - assert (20i == NumCast::from(20f)); - assert (20i == NumCast::from(20f32)); - assert (20i == NumCast::from(20f64)); + fail_unless!((20i == NumCast::from(20u))); + fail_unless!((20i == NumCast::from(20u8))); + fail_unless!((20i == NumCast::from(20u16))); + fail_unless!((20i == NumCast::from(20u32))); + fail_unless!((20i == NumCast::from(20u64))); + fail_unless!((20i == NumCast::from(20i))); + fail_unless!((20i == NumCast::from(20i8))); + fail_unless!((20i == NumCast::from(20i16))); + fail_unless!((20i == NumCast::from(20i32))); + fail_unless!((20i == NumCast::from(20i64))); + fail_unless!((20i == NumCast::from(20f))); + fail_unless!((20i == NumCast::from(20f32))); + fail_unless!((20i == NumCast::from(20f64))); - assert (20i == num::cast(20u)); - assert (20i == num::cast(20u8)); - assert (20i == num::cast(20u16)); - assert (20i == num::cast(20u32)); - assert (20i == num::cast(20u64)); - assert (20i == num::cast(20i)); - assert (20i == num::cast(20i8)); - assert (20i == num::cast(20i16)); - assert (20i == num::cast(20i32)); - assert (20i == num::cast(20i64)); - assert (20i == num::cast(20f)); - assert (20i == num::cast(20f32)); - assert (20i == num::cast(20f64)); + fail_unless!((20i == num::cast(20u))); + fail_unless!((20i == num::cast(20u8))); + fail_unless!((20i == num::cast(20u16))); + fail_unless!((20i == num::cast(20u32))); + fail_unless!((20i == num::cast(20u64))); + fail_unless!((20i == num::cast(20i))); + fail_unless!((20i == num::cast(20i8))); + fail_unless!((20i == num::cast(20i16))); + fail_unless!((20i == num::cast(20i32))); + fail_unless!((20i == num::cast(20i64))); + fail_unless!((20i == num::cast(20f))); + fail_unless!((20i == num::cast(20f32))); + fail_unless!((20i == num::cast(20f64))); } diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index c141820198f..a462aed8be0 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -55,7 +55,7 @@ pub enum RoundMode { * * ~~~ * let twenty: f32 = num::cast(0x14); - * assert twenty == 20f32; + * fail_unless!(twenty == 20f32); * ~~~ */ #[inline(always)] diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 0dbf7403e27..8346a45601e 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -238,102 +238,102 @@ impl ToStrRadix for T { #[test] pub fn test_to_str() { - assert to_str_radix(0 as T, 10u) == ~"0"; - assert to_str_radix(1 as T, 10u) == ~"1"; - assert to_str_radix(2 as T, 10u) == ~"2"; - assert to_str_radix(11 as T, 10u) == ~"11"; - assert to_str_radix(11 as T, 16u) == ~"b"; - assert to_str_radix(255 as T, 16u) == ~"ff"; - assert to_str_radix(0xff as T, 10u) == ~"255"; + fail_unless!(to_str_radix(0 as T, 10u) == ~"0"); + fail_unless!(to_str_radix(1 as T, 10u) == ~"1"); + fail_unless!(to_str_radix(2 as T, 10u) == ~"2"); + fail_unless!(to_str_radix(11 as T, 10u) == ~"11"); + fail_unless!(to_str_radix(11 as T, 16u) == ~"b"); + fail_unless!(to_str_radix(255 as T, 16u) == ~"ff"); + fail_unless!(to_str_radix(0xff as T, 10u) == ~"255"); } #[test] pub fn test_from_str() { - assert from_str(~"0") == Some(0u as T); - assert from_str(~"3") == Some(3u as T); - assert from_str(~"10") == Some(10u as T); - assert u32::from_str(~"123456789") == Some(123456789 as u32); - assert from_str(~"00100") == Some(100u as T); + fail_unless!(from_str(~"0") == Some(0u as T)); + fail_unless!(from_str(~"3") == Some(3u as T)); + fail_unless!(from_str(~"10") == Some(10u as T)); + fail_unless!(u32::from_str(~"123456789") == Some(123456789 as u32)); + fail_unless!(from_str(~"00100") == Some(100u as T)); - assert from_str(~"").is_none(); - assert from_str(~" ").is_none(); - assert from_str(~"x").is_none(); + fail_unless!(from_str(~"").is_none()); + fail_unless!(from_str(~" ").is_none()); + fail_unless!(from_str(~"x").is_none()); } #[test] pub fn test_parse_bytes() { use str::to_bytes; - assert parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T); - assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T); - assert parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T); - assert u16::parse_bytes(to_bytes(~"123"), 16u) == Some(291u as u16); - assert u16::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as u16); - assert parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T); + fail_unless!(parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T)); + fail_unless!(parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T)); + fail_unless!(parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T)); + fail_unless!(u16::parse_bytes(to_bytes(~"123"), 16u) == Some(291u as u16)); + fail_unless!(u16::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as u16)); + fail_unless!(parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T)); - assert parse_bytes(to_bytes(~"Z"), 10u).is_none(); - assert parse_bytes(to_bytes(~"_"), 2u).is_none(); + fail_unless!(parse_bytes(to_bytes(~"Z"), 10u).is_none()); + fail_unless!(parse_bytes(to_bytes(~"_"), 2u).is_none()); } #[test] fn test_uint_to_str_overflow() { let mut u8_val: u8 = 255_u8; - assert (u8::to_str(u8_val) == ~"255"); + fail_unless!((u8::to_str(u8_val) == ~"255")); u8_val += 1 as u8; - assert (u8::to_str(u8_val) == ~"0"); + fail_unless!((u8::to_str(u8_val) == ~"0")); let mut u16_val: u16 = 65_535_u16; - assert (u16::to_str(u16_val) == ~"65535"); + fail_unless!((u16::to_str(u16_val) == ~"65535")); u16_val += 1 as u16; - assert (u16::to_str(u16_val) == ~"0"); + fail_unless!((u16::to_str(u16_val) == ~"0")); let mut u32_val: u32 = 4_294_967_295_u32; - assert (u32::to_str(u32_val) == ~"4294967295"); + fail_unless!((u32::to_str(u32_val) == ~"4294967295")); u32_val += 1 as u32; - assert (u32::to_str(u32_val) == ~"0"); + fail_unless!((u32::to_str(u32_val) == ~"0")); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert (u64::to_str(u64_val) == ~"18446744073709551615"); + fail_unless!((u64::to_str(u64_val) == ~"18446744073709551615")); u64_val += 1 as u64; - assert (u64::to_str(u64_val) == ~"0"); + fail_unless!((u64::to_str(u64_val) == ~"0")); } #[test] fn test_uint_from_str_overflow() { let mut u8_val: u8 = 255_u8; - assert (u8::from_str(~"255") == Some(u8_val)); - assert (u8::from_str(~"256").is_none()); + fail_unless!((u8::from_str(~"255") == Some(u8_val))); + fail_unless!((u8::from_str(~"256").is_none())); u8_val += 1 as u8; - assert (u8::from_str(~"0") == Some(u8_val)); - assert (u8::from_str(~"-1").is_none()); + fail_unless!((u8::from_str(~"0") == Some(u8_val))); + fail_unless!((u8::from_str(~"-1").is_none())); let mut u16_val: u16 = 65_535_u16; - assert (u16::from_str(~"65535") == Some(u16_val)); - assert (u16::from_str(~"65536").is_none()); + fail_unless!((u16::from_str(~"65535") == Some(u16_val))); + fail_unless!((u16::from_str(~"65536").is_none())); u16_val += 1 as u16; - assert (u16::from_str(~"0") == Some(u16_val)); - assert (u16::from_str(~"-1").is_none()); + fail_unless!((u16::from_str(~"0") == Some(u16_val))); + fail_unless!((u16::from_str(~"-1").is_none())); let mut u32_val: u32 = 4_294_967_295_u32; - assert (u32::from_str(~"4294967295") == Some(u32_val)); - assert (u32::from_str(~"4294967296").is_none()); + fail_unless!((u32::from_str(~"4294967295") == Some(u32_val))); + fail_unless!((u32::from_str(~"4294967296").is_none())); u32_val += 1 as u32; - assert (u32::from_str(~"0") == Some(u32_val)); - assert (u32::from_str(~"-1").is_none()); + fail_unless!((u32::from_str(~"0") == Some(u32_val))); + fail_unless!((u32::from_str(~"-1").is_none())); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert (u64::from_str(~"18446744073709551615") == Some(u64_val)); - assert (u64::from_str(~"18446744073709551616").is_none()); + fail_unless!((u64::from_str(~"18446744073709551615") == Some(u64_val))); + fail_unless!((u64::from_str(~"18446744073709551616").is_none())); u64_val += 1 as u64; - assert (u64::from_str(~"0") == Some(u64_val)); - assert (u64::from_str(~"-1").is_none()); + fail_unless!((u64::from_str(~"0") == Some(u64_val))); + fail_unless!((u64::from_str(~"-1").is_none())); } #[test] @@ -367,10 +367,10 @@ pub fn test_ranges() { l.push(i); } - assert l == ~[0,1,2, - 13,12,11, - 20,22,24, - 36,34,32]; + fail_unless!(l == ~[0,1,2, + 13,12,11, + 20,22,24, + 36,34,32]); // None of the `fail`s should execute. for range(0,0) |_i| { @@ -392,11 +392,11 @@ pub fn test_num() { let ten: T = num::cast(10); let two: T = num::cast(2); - assert (ten.add(&two) == num::cast(12)); - assert (ten.sub(&two) == num::cast(8)); - assert (ten.mul(&two) == num::cast(20)); - assert (ten.div(&two) == num::cast(5)); - assert (ten.modulo(&two) == num::cast(0)); + fail_unless!((ten.add(&two) == num::cast(12))); + fail_unless!((ten.sub(&two) == num::cast(8))); + fail_unless!((ten.mul(&two) == num::cast(20))); + fail_unless!((ten.div(&two) == num::cast(5))); + fail_unless!((ten.modulo(&two) == num::cast(0))); } #[test] diff --git a/src/libcore/num/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index 01ec0cc77bf..16a1d620929 100644 --- a/src/libcore/num/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs @@ -45,45 +45,45 @@ impl NumCast for u16 { #[test] fn test_numcast() { - assert (20u == 20u16.to_uint()); - assert (20u8 == 20u16.to_u8()); - assert (20u16 == 20u16.to_u16()); - assert (20u32 == 20u16.to_u32()); - assert (20u64 == 20u16.to_u64()); - assert (20i == 20u16.to_int()); - assert (20i8 == 20u16.to_i8()); - assert (20i16 == 20u16.to_i16()); - assert (20i32 == 20u16.to_i32()); - assert (20i64 == 20u16.to_i64()); - assert (20f == 20u16.to_float()); - assert (20f32 == 20u16.to_f32()); - assert (20f64 == 20u16.to_f64()); + fail_unless!((20u == 20u16.to_uint())); + fail_unless!((20u8 == 20u16.to_u8())); + fail_unless!((20u16 == 20u16.to_u16())); + fail_unless!((20u32 == 20u16.to_u32())); + fail_unless!((20u64 == 20u16.to_u64())); + fail_unless!((20i == 20u16.to_int())); + fail_unless!((20i8 == 20u16.to_i8())); + fail_unless!((20i16 == 20u16.to_i16())); + fail_unless!((20i32 == 20u16.to_i32())); + fail_unless!((20i64 == 20u16.to_i64())); + fail_unless!((20f == 20u16.to_float())); + fail_unless!((20f32 == 20u16.to_f32())); + fail_unless!((20f64 == 20u16.to_f64())); - assert (20u16 == NumCast::from(20u)); - assert (20u16 == NumCast::from(20u8)); - assert (20u16 == NumCast::from(20u16)); - assert (20u16 == NumCast::from(20u32)); - assert (20u16 == NumCast::from(20u64)); - assert (20u16 == NumCast::from(20i)); - assert (20u16 == NumCast::from(20i8)); - assert (20u16 == NumCast::from(20i16)); - assert (20u16 == NumCast::from(20i32)); - assert (20u16 == NumCast::from(20i64)); - assert (20u16 == NumCast::from(20f)); - assert (20u16 == NumCast::from(20f32)); - assert (20u16 == NumCast::from(20f64)); + fail_unless!((20u16 == NumCast::from(20u))); + fail_unless!((20u16 == NumCast::from(20u8))); + fail_unless!((20u16 == NumCast::from(20u16))); + fail_unless!((20u16 == NumCast::from(20u32))); + fail_unless!((20u16 == NumCast::from(20u64))); + fail_unless!((20u16 == NumCast::from(20i))); + fail_unless!((20u16 == NumCast::from(20i8))); + fail_unless!((20u16 == NumCast::from(20i16))); + fail_unless!((20u16 == NumCast::from(20i32))); + fail_unless!((20u16 == NumCast::from(20i64))); + fail_unless!((20u16 == NumCast::from(20f))); + fail_unless!((20u16 == NumCast::from(20f32))); + fail_unless!((20u16 == NumCast::from(20f64))); - assert (20u16 == num::cast(20u)); - assert (20u16 == num::cast(20u8)); - assert (20u16 == num::cast(20u16)); - assert (20u16 == num::cast(20u32)); - assert (20u16 == num::cast(20u64)); - assert (20u16 == num::cast(20i)); - assert (20u16 == num::cast(20i8)); - assert (20u16 == num::cast(20i16)); - assert (20u16 == num::cast(20i32)); - assert (20u16 == num::cast(20i64)); - assert (20u16 == num::cast(20f)); - assert (20u16 == num::cast(20f32)); - assert (20u16 == num::cast(20f64)); + fail_unless!((20u16 == num::cast(20u))); + fail_unless!((20u16 == num::cast(20u8))); + fail_unless!((20u16 == num::cast(20u16))); + fail_unless!((20u16 == num::cast(20u32))); + fail_unless!((20u16 == num::cast(20u64))); + fail_unless!((20u16 == num::cast(20i))); + fail_unless!((20u16 == num::cast(20i8))); + fail_unless!((20u16 == num::cast(20i16))); + fail_unless!((20u16 == num::cast(20i32))); + fail_unless!((20u16 == num::cast(20i64))); + fail_unless!((20u16 == num::cast(20f))); + fail_unless!((20u16 == num::cast(20f32))); + fail_unless!((20u16 == num::cast(20f64))); } diff --git a/src/libcore/num/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 772ef51d30d..cf92feb6427 100644 --- a/src/libcore/num/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs @@ -45,45 +45,45 @@ impl NumCast for u32 { #[test] fn test_numcast() { - assert (20u == 20u64.to_uint()); - assert (20u8 == 20u64.to_u8()); - assert (20u16 == 20u64.to_u16()); - assert (20u32 == 20u64.to_u32()); - assert (20u64 == 20u64.to_u64()); - assert (20i == 20u64.to_int()); - assert (20i8 == 20u64.to_i8()); - assert (20i16 == 20u64.to_i16()); - assert (20i32 == 20u64.to_i32()); - assert (20i64 == 20u64.to_i64()); - assert (20f == 20u64.to_float()); - assert (20f32 == 20u64.to_f32()); - assert (20f64 == 20u64.to_f64()); + fail_unless!((20u == 20u64.to_uint())); + fail_unless!((20u8 == 20u64.to_u8())); + fail_unless!((20u16 == 20u64.to_u16())); + fail_unless!((20u32 == 20u64.to_u32())); + fail_unless!((20u64 == 20u64.to_u64())); + fail_unless!((20i == 20u64.to_int())); + fail_unless!((20i8 == 20u64.to_i8())); + fail_unless!((20i16 == 20u64.to_i16())); + fail_unless!((20i32 == 20u64.to_i32())); + fail_unless!((20i64 == 20u64.to_i64())); + fail_unless!((20f == 20u64.to_float())); + fail_unless!((20f32 == 20u64.to_f32())); + fail_unless!((20f64 == 20u64.to_f64())); - assert (20u64 == NumCast::from(20u)); - assert (20u64 == NumCast::from(20u8)); - assert (20u64 == NumCast::from(20u16)); - assert (20u64 == NumCast::from(20u32)); - assert (20u64 == NumCast::from(20u64)); - assert (20u64 == NumCast::from(20i)); - assert (20u64 == NumCast::from(20i8)); - assert (20u64 == NumCast::from(20i16)); - assert (20u64 == NumCast::from(20i32)); - assert (20u64 == NumCast::from(20i64)); - assert (20u64 == NumCast::from(20f)); - assert (20u64 == NumCast::from(20f32)); - assert (20u64 == NumCast::from(20f64)); + fail_unless!((20u64 == NumCast::from(20u))); + fail_unless!((20u64 == NumCast::from(20u8))); + fail_unless!((20u64 == NumCast::from(20u16))); + fail_unless!((20u64 == NumCast::from(20u32))); + fail_unless!((20u64 == NumCast::from(20u64))); + fail_unless!((20u64 == NumCast::from(20i))); + fail_unless!((20u64 == NumCast::from(20i8))); + fail_unless!((20u64 == NumCast::from(20i16))); + fail_unless!((20u64 == NumCast::from(20i32))); + fail_unless!((20u64 == NumCast::from(20i64))); + fail_unless!((20u64 == NumCast::from(20f))); + fail_unless!((20u64 == NumCast::from(20f32))); + fail_unless!((20u64 == NumCast::from(20f64))); - assert (20u64 == num::cast(20u)); - assert (20u64 == num::cast(20u8)); - assert (20u64 == num::cast(20u16)); - assert (20u64 == num::cast(20u32)); - assert (20u64 == num::cast(20u64)); - assert (20u64 == num::cast(20i)); - assert (20u64 == num::cast(20i8)); - assert (20u64 == num::cast(20i16)); - assert (20u64 == num::cast(20i32)); - assert (20u64 == num::cast(20i64)); - assert (20u64 == num::cast(20f)); - assert (20u64 == num::cast(20f32)); - assert (20u64 == num::cast(20f64)); + fail_unless!((20u64 == num::cast(20u))); + fail_unless!((20u64 == num::cast(20u8))); + fail_unless!((20u64 == num::cast(20u16))); + fail_unless!((20u64 == num::cast(20u32))); + fail_unless!((20u64 == num::cast(20u64))); + fail_unless!((20u64 == num::cast(20i))); + fail_unless!((20u64 == num::cast(20i8))); + fail_unless!((20u64 == num::cast(20i16))); + fail_unless!((20u64 == num::cast(20i32))); + fail_unless!((20u64 == num::cast(20i64))); + fail_unless!((20u64 == num::cast(20f))); + fail_unless!((20u64 == num::cast(20f32))); + fail_unless!((20u64 == num::cast(20f64))); } diff --git a/src/libcore/num/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index ec7301a01e4..269d8e185f3 100644 --- a/src/libcore/num/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs @@ -45,45 +45,45 @@ impl NumCast for u64 { #[test] fn test_numcast() { - assert (20u == 20u64.to_uint()); - assert (20u8 == 20u64.to_u8()); - assert (20u16 == 20u64.to_u16()); - assert (20u32 == 20u64.to_u32()); - assert (20u64 == 20u64.to_u64()); - assert (20i == 20u64.to_int()); - assert (20i8 == 20u64.to_i8()); - assert (20i16 == 20u64.to_i16()); - assert (20i32 == 20u64.to_i32()); - assert (20i64 == 20u64.to_i64()); - assert (20f == 20u64.to_float()); - assert (20f32 == 20u64.to_f32()); - assert (20f64 == 20u64.to_f64()); + fail_unless!((20u == 20u64.to_uint())); + fail_unless!((20u8 == 20u64.to_u8())); + fail_unless!((20u16 == 20u64.to_u16())); + fail_unless!((20u32 == 20u64.to_u32())); + fail_unless!((20u64 == 20u64.to_u64())); + fail_unless!((20i == 20u64.to_int())); + fail_unless!((20i8 == 20u64.to_i8())); + fail_unless!((20i16 == 20u64.to_i16())); + fail_unless!((20i32 == 20u64.to_i32())); + fail_unless!((20i64 == 20u64.to_i64())); + fail_unless!((20f == 20u64.to_float())); + fail_unless!((20f32 == 20u64.to_f32())); + fail_unless!((20f64 == 20u64.to_f64())); - assert (20u64 == NumCast::from(20u)); - assert (20u64 == NumCast::from(20u8)); - assert (20u64 == NumCast::from(20u16)); - assert (20u64 == NumCast::from(20u32)); - assert (20u64 == NumCast::from(20u64)); - assert (20u64 == NumCast::from(20i)); - assert (20u64 == NumCast::from(20i8)); - assert (20u64 == NumCast::from(20i16)); - assert (20u64 == NumCast::from(20i32)); - assert (20u64 == NumCast::from(20i64)); - assert (20u64 == NumCast::from(20f)); - assert (20u64 == NumCast::from(20f32)); - assert (20u64 == NumCast::from(20f64)); + fail_unless!((20u64 == NumCast::from(20u))); + fail_unless!((20u64 == NumCast::from(20u8))); + fail_unless!((20u64 == NumCast::from(20u16))); + fail_unless!((20u64 == NumCast::from(20u32))); + fail_unless!((20u64 == NumCast::from(20u64))); + fail_unless!((20u64 == NumCast::from(20i))); + fail_unless!((20u64 == NumCast::from(20i8))); + fail_unless!((20u64 == NumCast::from(20i16))); + fail_unless!((20u64 == NumCast::from(20i32))); + fail_unless!((20u64 == NumCast::from(20i64))); + fail_unless!((20u64 == NumCast::from(20f))); + fail_unless!((20u64 == NumCast::from(20f32))); + fail_unless!((20u64 == NumCast::from(20f64))); - assert (20u64 == num::cast(20u)); - assert (20u64 == num::cast(20u8)); - assert (20u64 == num::cast(20u16)); - assert (20u64 == num::cast(20u32)); - assert (20u64 == num::cast(20u64)); - assert (20u64 == num::cast(20i)); - assert (20u64 == num::cast(20i8)); - assert (20u64 == num::cast(20i16)); - assert (20u64 == num::cast(20i32)); - assert (20u64 == num::cast(20i64)); - assert (20u64 == num::cast(20f)); - assert (20u64 == num::cast(20f32)); - assert (20u64 == num::cast(20f64)); + fail_unless!((20u64 == num::cast(20u))); + fail_unless!((20u64 == num::cast(20u8))); + fail_unless!((20u64 == num::cast(20u16))); + fail_unless!((20u64 == num::cast(20u32))); + fail_unless!((20u64 == num::cast(20u64))); + fail_unless!((20u64 == num::cast(20i))); + fail_unless!((20u64 == num::cast(20i8))); + fail_unless!((20u64 == num::cast(20i16))); + fail_unless!((20u64 == num::cast(20i32))); + fail_unless!((20u64 == num::cast(20i64))); + fail_unless!((20u64 == num::cast(20f))); + fail_unless!((20u64 == num::cast(20f32))); + fail_unless!((20u64 == num::cast(20f64))); } diff --git a/src/libcore/num/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index 53e4be70727..44428abdb4f 100644 --- a/src/libcore/num/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs @@ -52,45 +52,45 @@ impl NumCast for u8 { #[test] fn test_numcast() { - assert (20u == 20u8.to_uint()); - assert (20u8 == 20u8.to_u8()); - assert (20u16 == 20u8.to_u16()); - assert (20u32 == 20u8.to_u32()); - assert (20u64 == 20u8.to_u64()); - assert (20i == 20u8.to_int()); - assert (20i8 == 20u8.to_i8()); - assert (20i16 == 20u8.to_i16()); - assert (20i32 == 20u8.to_i32()); - assert (20i64 == 20u8.to_i64()); - assert (20f == 20u8.to_float()); - assert (20f32 == 20u8.to_f32()); - assert (20f64 == 20u8.to_f64()); + fail_unless!((20u == 20u8.to_uint())); + fail_unless!((20u8 == 20u8.to_u8())); + fail_unless!((20u16 == 20u8.to_u16())); + fail_unless!((20u32 == 20u8.to_u32())); + fail_unless!((20u64 == 20u8.to_u64())); + fail_unless!((20i == 20u8.to_int())); + fail_unless!((20i8 == 20u8.to_i8())); + fail_unless!((20i16 == 20u8.to_i16())); + fail_unless!((20i32 == 20u8.to_i32())); + fail_unless!((20i64 == 20u8.to_i64())); + fail_unless!((20f == 20u8.to_float())); + fail_unless!((20f32 == 20u8.to_f32())); + fail_unless!((20f64 == 20u8.to_f64())); - assert (20u8 == NumCast::from(20u)); - assert (20u8 == NumCast::from(20u8)); - assert (20u8 == NumCast::from(20u16)); - assert (20u8 == NumCast::from(20u32)); - assert (20u8 == NumCast::from(20u64)); - assert (20u8 == NumCast::from(20i)); - assert (20u8 == NumCast::from(20i8)); - assert (20u8 == NumCast::from(20i16)); - assert (20u8 == NumCast::from(20i32)); - assert (20u8 == NumCast::from(20i64)); - assert (20u8 == NumCast::from(20f)); - assert (20u8 == NumCast::from(20f32)); - assert (20u8 == NumCast::from(20f64)); + fail_unless!((20u8 == NumCast::from(20u))); + fail_unless!((20u8 == NumCast::from(20u8))); + fail_unless!((20u8 == NumCast::from(20u16))); + fail_unless!((20u8 == NumCast::from(20u32))); + fail_unless!((20u8 == NumCast::from(20u64))); + fail_unless!((20u8 == NumCast::from(20i))); + fail_unless!((20u8 == NumCast::from(20i8))); + fail_unless!((20u8 == NumCast::from(20i16))); + fail_unless!((20u8 == NumCast::from(20i32))); + fail_unless!((20u8 == NumCast::from(20i64))); + fail_unless!((20u8 == NumCast::from(20f))); + fail_unless!((20u8 == NumCast::from(20f32))); + fail_unless!((20u8 == NumCast::from(20f64))); - assert (20u8 == num::cast(20u)); - assert (20u8 == num::cast(20u8)); - assert (20u8 == num::cast(20u16)); - assert (20u8 == num::cast(20u32)); - assert (20u8 == num::cast(20u64)); - assert (20u8 == num::cast(20i)); - assert (20u8 == num::cast(20i8)); - assert (20u8 == num::cast(20i16)); - assert (20u8 == num::cast(20i32)); - assert (20u8 == num::cast(20i64)); - assert (20u8 == num::cast(20f)); - assert (20u8 == num::cast(20f32)); - assert (20u8 == num::cast(20f64)); + fail_unless!((20u8 == num::cast(20u))); + fail_unless!((20u8 == num::cast(20u8))); + fail_unless!((20u8 == num::cast(20u16))); + fail_unless!((20u8 == num::cast(20u32))); + fail_unless!((20u8 == num::cast(20u64))); + fail_unless!((20u8 == num::cast(20i))); + fail_unless!((20u8 == num::cast(20i8))); + fail_unless!((20u8 == num::cast(20i16))); + fail_unless!((20u8 == num::cast(20i32))); + fail_unless!((20u8 == num::cast(20i64))); + fail_unless!((20u8 == num::cast(20f))); + fail_unless!((20u8 == num::cast(20f32))); + fail_unless!((20u8 == num::cast(20f64))); } diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 206f8c0f6ca..6814b0e7541 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -143,61 +143,61 @@ pub mod inst { #[test] fn test_next_power_of_two() { - assert (next_power_of_two(0u) == 0u); - assert (next_power_of_two(1u) == 1u); - assert (next_power_of_two(2u) == 2u); - assert (next_power_of_two(3u) == 4u); - assert (next_power_of_two(4u) == 4u); - assert (next_power_of_two(5u) == 8u); - assert (next_power_of_two(6u) == 8u); - assert (next_power_of_two(7u) == 8u); - assert (next_power_of_two(8u) == 8u); - assert (next_power_of_two(9u) == 16u); - assert (next_power_of_two(10u) == 16u); - assert (next_power_of_two(11u) == 16u); - assert (next_power_of_two(12u) == 16u); - assert (next_power_of_two(13u) == 16u); - assert (next_power_of_two(14u) == 16u); - assert (next_power_of_two(15u) == 16u); - assert (next_power_of_two(16u) == 16u); - assert (next_power_of_two(17u) == 32u); - assert (next_power_of_two(18u) == 32u); - assert (next_power_of_two(19u) == 32u); - assert (next_power_of_two(20u) == 32u); - assert (next_power_of_two(21u) == 32u); - assert (next_power_of_two(22u) == 32u); - assert (next_power_of_two(23u) == 32u); - assert (next_power_of_two(24u) == 32u); - assert (next_power_of_two(25u) == 32u); - assert (next_power_of_two(26u) == 32u); - assert (next_power_of_two(27u) == 32u); - assert (next_power_of_two(28u) == 32u); - assert (next_power_of_two(29u) == 32u); - assert (next_power_of_two(30u) == 32u); - assert (next_power_of_two(31u) == 32u); - assert (next_power_of_two(32u) == 32u); - assert (next_power_of_two(33u) == 64u); - assert (next_power_of_two(34u) == 64u); - assert (next_power_of_two(35u) == 64u); - assert (next_power_of_two(36u) == 64u); - assert (next_power_of_two(37u) == 64u); - assert (next_power_of_two(38u) == 64u); - assert (next_power_of_two(39u) == 64u); + fail_unless!((next_power_of_two(0u) == 0u)); + fail_unless!((next_power_of_two(1u) == 1u)); + fail_unless!((next_power_of_two(2u) == 2u)); + fail_unless!((next_power_of_two(3u) == 4u)); + fail_unless!((next_power_of_two(4u) == 4u)); + fail_unless!((next_power_of_two(5u) == 8u)); + fail_unless!((next_power_of_two(6u) == 8u)); + fail_unless!((next_power_of_two(7u) == 8u)); + fail_unless!((next_power_of_two(8u) == 8u)); + fail_unless!((next_power_of_two(9u) == 16u)); + fail_unless!((next_power_of_two(10u) == 16u)); + fail_unless!((next_power_of_two(11u) == 16u)); + fail_unless!((next_power_of_two(12u) == 16u)); + fail_unless!((next_power_of_two(13u) == 16u)); + fail_unless!((next_power_of_two(14u) == 16u)); + fail_unless!((next_power_of_two(15u) == 16u)); + fail_unless!((next_power_of_two(16u) == 16u)); + fail_unless!((next_power_of_two(17u) == 32u)); + fail_unless!((next_power_of_two(18u) == 32u)); + fail_unless!((next_power_of_two(19u) == 32u)); + fail_unless!((next_power_of_two(20u) == 32u)); + fail_unless!((next_power_of_two(21u) == 32u)); + fail_unless!((next_power_of_two(22u) == 32u)); + fail_unless!((next_power_of_two(23u) == 32u)); + fail_unless!((next_power_of_two(24u) == 32u)); + fail_unless!((next_power_of_two(25u) == 32u)); + fail_unless!((next_power_of_two(26u) == 32u)); + fail_unless!((next_power_of_two(27u) == 32u)); + fail_unless!((next_power_of_two(28u) == 32u)); + fail_unless!((next_power_of_two(29u) == 32u)); + fail_unless!((next_power_of_two(30u) == 32u)); + fail_unless!((next_power_of_two(31u) == 32u)); + fail_unless!((next_power_of_two(32u) == 32u)); + fail_unless!((next_power_of_two(33u) == 64u)); + fail_unless!((next_power_of_two(34u) == 64u)); + fail_unless!((next_power_of_two(35u) == 64u)); + fail_unless!((next_power_of_two(36u) == 64u)); + fail_unless!((next_power_of_two(37u) == 64u)); + fail_unless!((next_power_of_two(38u) == 64u)); + fail_unless!((next_power_of_two(39u) == 64u)); } #[test] fn test_overflows() { use uint; - assert (uint::max_value > 0u); - assert (uint::min_value <= 0u); - assert (uint::min_value + uint::max_value + 1u == 0u); + fail_unless!((uint::max_value > 0u)); + fail_unless!((uint::min_value <= 0u)); + fail_unless!((uint::min_value + uint::max_value + 1u == 0u)); } #[test] fn test_div() { - assert(div_floor(3u, 4u) == 0u); - assert(div_ceil(3u, 4u) == 1u); - assert(div_round(3u, 4u) == 1u); + fail_unless!((div_floor(3u, 4u) == 0u)); + fail_unless!((div_ceil(3u, 4u) == 1u)); + fail_unless!((div_round(3u, 4u) == 1u)); } #[test] @@ -206,7 +206,7 @@ pub mod inst { let ten = 10 as uint; let mut accum = 0; for ten.times { accum += 1; } - assert (accum == 10); + fail_unless!((accum == 10)); } } @@ -236,45 +236,45 @@ impl NumCast for uint { #[test] fn test_numcast() { - assert (20u == 20u.to_uint()); - assert (20u8 == 20u.to_u8()); - assert (20u16 == 20u.to_u16()); - assert (20u32 == 20u.to_u32()); - assert (20u64 == 20u.to_u64()); - assert (20i == 20u.to_int()); - assert (20i8 == 20u.to_i8()); - assert (20i16 == 20u.to_i16()); - assert (20i32 == 20u.to_i32()); - assert (20i64 == 20u.to_i64()); - assert (20f == 20u.to_float()); - assert (20f32 == 20u.to_f32()); - assert (20f64 == 20u.to_f64()); + fail_unless!((20u == 20u.to_uint())); + fail_unless!((20u8 == 20u.to_u8())); + fail_unless!((20u16 == 20u.to_u16())); + fail_unless!((20u32 == 20u.to_u32())); + fail_unless!((20u64 == 20u.to_u64())); + fail_unless!((20i == 20u.to_int())); + fail_unless!((20i8 == 20u.to_i8())); + fail_unless!((20i16 == 20u.to_i16())); + fail_unless!((20i32 == 20u.to_i32())); + fail_unless!((20i64 == 20u.to_i64())); + fail_unless!((20f == 20u.to_float())); + fail_unless!((20f32 == 20u.to_f32())); + fail_unless!((20f64 == 20u.to_f64())); - assert (20u == NumCast::from(20u)); - assert (20u == NumCast::from(20u8)); - assert (20u == NumCast::from(20u16)); - assert (20u == NumCast::from(20u32)); - assert (20u == NumCast::from(20u64)); - assert (20u == NumCast::from(20i)); - assert (20u == NumCast::from(20i8)); - assert (20u == NumCast::from(20i16)); - assert (20u == NumCast::from(20i32)); - assert (20u == NumCast::from(20i64)); - assert (20u == NumCast::from(20f)); - assert (20u == NumCast::from(20f32)); - assert (20u == NumCast::from(20f64)); + fail_unless!((20u == NumCast::from(20u))); + fail_unless!((20u == NumCast::from(20u8))); + fail_unless!((20u == NumCast::from(20u16))); + fail_unless!((20u == NumCast::from(20u32))); + fail_unless!((20u == NumCast::from(20u64))); + fail_unless!((20u == NumCast::from(20i))); + fail_unless!((20u == NumCast::from(20i8))); + fail_unless!((20u == NumCast::from(20i16))); + fail_unless!((20u == NumCast::from(20i32))); + fail_unless!((20u == NumCast::from(20i64))); + fail_unless!((20u == NumCast::from(20f))); + fail_unless!((20u == NumCast::from(20f32))); + fail_unless!((20u == NumCast::from(20f64))); - assert (20u == num::cast(20u)); - assert (20u == num::cast(20u8)); - assert (20u == num::cast(20u16)); - assert (20u == num::cast(20u32)); - assert (20u == num::cast(20u64)); - assert (20u == num::cast(20i)); - assert (20u == num::cast(20i8)); - assert (20u == num::cast(20i16)); - assert (20u == num::cast(20i32)); - assert (20u == num::cast(20i64)); - assert (20u == num::cast(20f)); - assert (20u == num::cast(20f32)); - assert (20u == num::cast(20f64)); + fail_unless!((20u == num::cast(20u))); + fail_unless!((20u == num::cast(20u8))); + fail_unless!((20u == num::cast(20u16))); + fail_unless!((20u == num::cast(20u32))); + fail_unless!((20u == num::cast(20u64))); + fail_unless!((20u == num::cast(20i))); + fail_unless!((20u == num::cast(20i8))); + fail_unless!((20u == num::cast(20i16))); + fail_unless!((20u == num::cast(20i32))); + fail_unless!((20u == num::cast(20i64))); + fail_unless!((20u == num::cast(20f))); + fail_unless!((20u == num::cast(20f32))); + fail_unless!((20u == num::cast(20f64))); } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index cffb21c6809..7b0e4d07b53 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -437,7 +437,7 @@ fn test_unwrap_ptr() { let opt = Some(x); let y = unwrap(opt); let addr_y = ptr::addr_of(&(*y)); - assert addr_x == addr_y; + fail_unless!(addr_x == addr_y); } #[test] @@ -447,7 +447,7 @@ fn test_unwrap_str() { let opt = Some(x); let y = unwrap(opt); let addr_y = str::as_buf(y, |buf, _len| buf); - assert addr_x == addr_y; + fail_unless!(addr_x == addr_y); } #[test] @@ -472,7 +472,7 @@ fn test_unwrap_resource() { let opt = Some(x); let _y = unwrap(opt); } - assert *i == 1; + fail_unless!(*i == 1); } #[test] @@ -483,8 +483,8 @@ fn test_option_dance() { for x.each |_x| { y2 = swap_unwrap(&mut y); } - assert y2 == 5; - assert y.is_none(); + fail_unless!(y2 == 5); + fail_unless!(y.is_none()); } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_option_too_much_dance() { @@ -504,15 +504,15 @@ fn test_option_while_some() { None } } - assert i == 11; + fail_unless!(i == 11); } #[test] fn test_get_or_zero() { let some_stuff = Some(42); - assert some_stuff.get_or_zero() == 42; + fail_unless!(some_stuff.get_or_zero() == 42); let no_stuff: Option = None; - assert no_stuff.get_or_zero() == 0; + fail_unless!(no_stuff.get_or_zero() == 0); } // Local Variables: diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 39fe090433c..97715c41f92 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -173,7 +173,7 @@ pub fn env() -> ~[(~str,~str)] { let mut pairs = ~[]; for vec::each(rust_env_pairs()) |p| { let vs = str::splitn_char(*p, '=', 1u); - assert vec::len(vs) == 2u; + fail_unless!(vec::len(vs) == 2u); pairs.push((copy vs[0], copy vs[1])); } pairs @@ -313,7 +313,7 @@ pub fn waitpid(pid: pid_t) -> c_int { use libc::funcs::posix01::wait::*; let mut status = 0 as c_int; - assert (waitpid(pid, &mut status, 0 as c_int) != (-1 as c_int)); + fail_unless!((waitpid(pid, &mut status, 0 as c_int) != (-1 as c_int))); return status; } } @@ -326,7 +326,7 @@ pub fn pipe() -> Pipe { unsafe { let mut fds = Pipe {in: 0 as c_int, out: 0 as c_int }; - assert (libc::pipe(&mut fds.in) == (0 as c_int)); + fail_unless!((libc::pipe(&mut fds.in) == (0 as c_int))); return Pipe {in: fds.in, out: fds.out}; } } @@ -345,9 +345,9 @@ pub fn pipe() -> Pipe { out: 0 as c_int }; let res = libc::pipe(&mut fds.in, 1024 as c_uint, (libc::O_BINARY | libc::O_NOINHERIT) as c_int); - assert (res == 0 as c_int); - assert (fds.in != -1 as c_int && fds.in != 0 as c_int); - assert (fds.out != -1 as c_int && fds.in != 0 as c_int); + fail_unless!((res == 0 as c_int)); + fail_unless!((fds.in != -1 as c_int && fds.in != 0 as c_int)); + fail_unless!((fds.out != -1 as c_int && fds.in != 0 as c_int)); return Pipe {in: fds.in, out: fds.out}; } } @@ -1142,13 +1142,13 @@ mod tests { #[test] pub fn test_args() { let a = real_args(); - assert a.len() >= 1; + fail_unless!(a.len() >= 1); } fn make_rand_name() -> ~str { let rng: rand::Rng = rand::Rng(); let n = ~"TEST" + rng.gen_str(10u); - assert getenv(n).is_none(); + fail_unless!(getenv(n).is_none()); n } @@ -1156,7 +1156,7 @@ mod tests { fn test_setenv() { let n = make_rand_name(); setenv(n, ~"VALUE"); - assert getenv(n) == option::Some(~"VALUE"); + fail_unless!(getenv(n) == option::Some(~"VALUE")); } #[test] @@ -1166,9 +1166,9 @@ mod tests { let n = make_rand_name(); setenv(n, ~"1"); setenv(n, ~"2"); - assert getenv(n) == option::Some(~"2"); + fail_unless!(getenv(n) == option::Some(~"2")); setenv(n, ~""); - assert getenv(n) == option::Some(~""); + fail_unless!(getenv(n) == option::Some(~"")); } // Windows GetEnvironmentVariable requires some extra work to make sure @@ -1183,25 +1183,25 @@ mod tests { let n = make_rand_name(); setenv(n, s); log(debug, copy s); - assert getenv(n) == option::Some(s); + fail_unless!(getenv(n) == option::Some(s)); } #[test] fn test_self_exe_path() { let path = os::self_exe_path(); - assert path.is_some(); + fail_unless!(path.is_some()); let path = path.get(); log(debug, copy path); // Hard to test this function - assert path.is_absolute; + fail_unless!(path.is_absolute); } #[test] #[ignore] fn test_env_getenv() { let e = env(); - assert vec::len(e) > 0u; + fail_unless!(vec::len(e) > 0u); for vec::each(e) |p| { let (n, v) = copy *p; log(debug, copy n); @@ -1209,7 +1209,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)); } } @@ -1219,15 +1219,15 @@ mod tests { let mut e = env(); setenv(n, ~"VALUE"); - assert !vec::contains(e, &(copy n, ~"VALUE")); + fail_unless!(!vec::contains(e, &(copy n, ~"VALUE"))); e = env(); - assert vec::contains(e, &(n, ~"VALUE")); + fail_unless!(vec::contains(e, &(n, ~"VALUE"))); } #[test] fn test() { - assert (!Path("test-path").is_absolute); + fail_unless!((!Path("test-path").is_absolute)); log(debug, ~"Current working directory: " + getcwd().to_str()); @@ -1241,10 +1241,10 @@ mod tests { let oldhome = getenv(~"HOME"); setenv(~"HOME", ~"/home/MountainView"); - assert os::homedir() == Some(Path("/home/MountainView")); + fail_unless!(os::homedir() == Some(Path("/home/MountainView"))); setenv(~"HOME", ~""); - assert os::homedir().is_none(); + fail_unless!(os::homedir().is_none()); for oldhome.each |s| { setenv(~"HOME", *s) } } @@ -1259,19 +1259,19 @@ mod tests { setenv(~"HOME", ~""); setenv(~"USERPROFILE", ~""); - assert os::homedir().is_none(); + fail_unless!(os::homedir().is_none()); setenv(~"HOME", ~"/home/MountainView"); - assert os::homedir() == Some(Path("/home/MountainView")); + fail_unless!(os::homedir() == Some(Path("/home/MountainView"))); setenv(~"HOME", ~""); setenv(~"USERPROFILE", ~"/home/MountainView"); - assert os::homedir() == Some(Path("/home/MountainView")); + fail_unless!(os::homedir() == Some(Path("/home/MountainView"))); setenv(~"HOME", ~"/home/MountainView"); setenv(~"USERPROFILE", ~"/home/PaloAlto"); - assert os::homedir() == Some(Path("/home/MountainView")); + fail_unless!(os::homedir() == Some(Path("/home/MountainView"))); option::iter(&oldhome, |s| setenv(~"HOME", *s)); option::iter(&olduserprofile, @@ -1280,7 +1280,7 @@ mod tests { #[test] fn tmpdir() { - assert !str::is_empty(os::tmpdir().to_str()); + fail_unless!(!str::is_empty(os::tmpdir().to_str())); } // Issue #712 @@ -1293,7 +1293,7 @@ mod tests { fn list_dir() { let dirs = os::list_dir(&Path(".")); // Just assuming that we've got some contents in the current directory - assert (vec::len(dirs) > 0u); + fail_unless!((vec::len(dirs) > 0u)); for vec::each(dirs) |dir| { log(debug, copy *dir); @@ -1302,21 +1302,21 @@ mod tests { #[test] fn path_is_dir() { - assert (os::path_is_dir(&Path("."))); - assert (!os::path_is_dir(&Path("test/stdtest/fs.rs"))); + fail_unless!((os::path_is_dir(&Path(".")))); + fail_unless!((!os::path_is_dir(&Path("test/stdtest/fs.rs")))); } #[test] fn path_exists() { - assert (os::path_exists(&Path("."))); - assert (!os::path_exists(&Path("test/nonexistent-bogus-path"))); + fail_unless!((os::path_exists(&Path(".")))); + fail_unless!((!os::path_exists(&Path("test/nonexistent-bogus-path")))); } #[test] fn copy_file_does_not_exist() { - assert !os::copy_file(&Path("test/nonexistent-bogus-path"), - &Path("test/other-bogus-path")); - assert !os::path_exists(&Path("test/other-bogus-path")); + fail_unless!(!os::copy_file(&Path("test/nonexistent-bogus-path"), + &Path("test/other-bogus-path"))); + fail_unless!(!os::path_exists(&Path("test/other-bogus-path"))); } #[test] @@ -1324,7 +1324,7 @@ mod tests { unsafe { let tempdir = getcwd(); // would like to use $TMPDIR, // doesn't seem to work on Linux - assert (str::len(tempdir.to_str()) > 0u); + fail_unless!((str::len(tempdir.to_str()) > 0u)); let in = tempdir.push("in.txt"); let out = tempdir.push("out.txt"); @@ -1334,23 +1334,24 @@ mod tests { libc::fopen(fromp, modebuf) } }; - assert (ostream as uint != 0u); + fail_unless!((ostream as uint != 0u)); let s = ~"hello"; let mut buf = str::to_bytes(s) + ~[0 as u8]; do vec::as_mut_buf(buf) |b, _len| { - assert (libc::fwrite(b as *c_void, 1u as size_t, + fail_unless!((libc::fwrite(b as *c_void, 1u as size_t, (str::len(s) + 1u) as size_t, ostream) - == buf.len() as size_t)}; - assert (libc::fclose(ostream) == (0u as c_int)); + == buf.len() as size_t)) + } + fail_unless!((libc::fclose(ostream) == (0u as c_int))); let rs = os::copy_file(&in, &out); if (!os::path_exists(&in)) { fail!(fmt!("%s doesn't exist", in.to_str())); } - assert(rs); + fail_unless!((rs)); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); - assert (rslt == 0); - assert (remove_file(&in)); - assert (remove_file(&out)); + fail_unless!((rslt == 0)); + fail_unless!((remove_file(&in))); + fail_unless!((remove_file(&out))); } } } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index eed6e8540f0..c6886074007 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -439,7 +439,7 @@ impl GenericPath for PosixPath { pure fn with_filename(&self, f: &str) -> PosixPath { unsafe { - assert ! str::any(f, |c| windows::is_sep(c as u8)); + fail_unless!(! str::any(f, |c| windows::is_sep(c as u8))); self.dir_path().push(f) } } @@ -484,7 +484,7 @@ impl GenericPath for PosixPath { } pure fn push_rel(&self, other: &PosixPath) -> PosixPath { - assert !other.is_absolute; + fail_unless!(!other.is_absolute); self.push_many(other.components) } @@ -650,7 +650,7 @@ impl GenericPath for WindowsPath { } pure fn with_filename(&self, f: &str) -> WindowsPath { - assert ! str::any(f, |c| windows::is_sep(c as u8)); + fail_unless!(! str::any(f, |c| windows::is_sep(c as u8))); self.dir_path().push(f) } @@ -697,7 +697,7 @@ impl GenericPath for WindowsPath { } pure fn push_rel(&self, other: &WindowsPath) -> WindowsPath { - assert !other.is_absolute; + fail_unless!(!other.is_absolute); self.push_many(other.components) } @@ -880,30 +880,30 @@ mod tests { let path = PosixPath("tmp/"); let path = path.push("/hmm"); let path = path.normalize(); - assert ~"tmp/hmm" == path.to_str(); + fail_unless!(~"tmp/hmm" == path.to_str()); let path = WindowsPath("tmp/"); let path = path.push("/hmm"); let path = path.normalize(); - assert ~"tmp\\hmm" == path.to_str(); + fail_unless!(~"tmp\\hmm" == path.to_str()); } #[test] fn test_filetype_foo_bar() { let wp = PosixPath("foo.bar"); - assert wp.filetype() == Some(~".bar"); + fail_unless!(wp.filetype() == Some(~".bar")); let wp = WindowsPath("foo.bar"); - assert wp.filetype() == Some(~".bar"); + fail_unless!(wp.filetype() == Some(~".bar")); } #[test] fn test_filetype_foo() { let wp = PosixPath("foo"); - assert wp.filetype() == None; + fail_unless!(wp.filetype() == None); let wp = WindowsPath("foo"); - assert wp.filetype() == None; + fail_unless!(wp.filetype() == None); } #[test] @@ -914,7 +914,7 @@ mod tests { if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); - assert ss == sss; + fail_unless!(ss == sss); } } @@ -972,7 +972,7 @@ mod tests { if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); - assert ss == sss; + fail_unless!(ss == sss); } } @@ -988,37 +988,43 @@ mod tests { #[test] fn test_extract_unc_prefixes() { - assert windows::extract_unc_prefix("\\\\").is_none(); - assert windows::extract_unc_prefix("//").is_none(); - assert windows::extract_unc_prefix("\\\\hi").is_none(); - assert windows::extract_unc_prefix("//hi").is_none(); - assert windows::extract_unc_prefix("\\\\hi\\") == - Some((~"hi", ~"\\")); - assert windows::extract_unc_prefix("//hi\\") == - Some((~"hi", ~"\\")); - assert windows::extract_unc_prefix("\\\\hi\\there") == - Some((~"hi", ~"\\there")); - assert windows::extract_unc_prefix("//hi/there") == - Some((~"hi", ~"/there")); - assert windows::extract_unc_prefix("\\\\hi\\there\\friends.txt") == - Some((~"hi", ~"\\there\\friends.txt")); - assert windows::extract_unc_prefix("//hi\\there\\friends.txt") == - Some((~"hi", ~"\\there\\friends.txt")); + fail_unless!(windows::extract_unc_prefix("\\\\").is_none()); + fail_unless!(windows::extract_unc_prefix("//").is_none()); + fail_unless!(windows::extract_unc_prefix("\\\\hi").is_none()); + fail_unless!(windows::extract_unc_prefix("//hi").is_none()); + fail_unless!(windows::extract_unc_prefix("\\\\hi\\") == + Some((~"hi", ~"\\"))); + fail_unless!(windows::extract_unc_prefix("//hi\\") == + Some((~"hi", ~"\\"))); + fail_unless!(windows::extract_unc_prefix("\\\\hi\\there") == + Some((~"hi", ~"\\there"))); + fail_unless!(windows::extract_unc_prefix("//hi/there") == + Some((~"hi", ~"/there"))); + fail_unless!(windows::extract_unc_prefix( + "\\\\hi\\there\\friends.txt") == + Some((~"hi", ~"\\there\\friends.txt"))); + fail_unless!(windows::extract_unc_prefix( + "//hi\\there\\friends.txt") == + Some((~"hi", ~"\\there\\friends.txt"))); } #[test] fn test_extract_drive_prefixes() { - assert windows::extract_drive_prefix("c").is_none(); - assert windows::extract_drive_prefix("c:") == Some((~"c", ~"")); - assert windows::extract_drive_prefix("d:") == Some((~"d", ~"")); - assert windows::extract_drive_prefix("z:") == Some((~"z", ~"")); - assert windows::extract_drive_prefix("c:\\hi") == - Some((~"c", ~"\\hi")); - assert windows::extract_drive_prefix("d:hi") == Some((~"d", ~"hi")); - assert windows::extract_drive_prefix("c:hi\\there.txt") == - Some((~"c", ~"hi\\there.txt")); - assert windows::extract_drive_prefix("c:\\hi\\there.txt") == - Some((~"c", ~"\\hi\\there.txt")); + fail_unless!(windows::extract_drive_prefix("c").is_none()); + fail_unless!(windows::extract_drive_prefix("c:") == + Some((~"c", ~""))); + fail_unless!(windows::extract_drive_prefix("d:") == + Some((~"d", ~""))); + fail_unless!(windows::extract_drive_prefix("z:") == + Some((~"z", ~""))); + fail_unless!(windows::extract_drive_prefix("c:\\hi") == + Some((~"c", ~"\\hi"))); + fail_unless!(windows::extract_drive_prefix("d:hi") == + Some((~"d", ~"hi"))); + fail_unless!(windows::extract_drive_prefix("c:hi\\there.txt") == + Some((~"c", ~"hi\\there.txt"))); + fail_unless!(windows::extract_drive_prefix("c:\\hi\\there.txt") == + Some((~"c", ~"\\hi\\there.txt"))); } #[test] @@ -1029,7 +1035,7 @@ mod tests { if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); - assert ss == sss; + fail_unless!(ss == sss); } } @@ -1114,9 +1120,9 @@ mod tests { #[test] fn test_windows_path_restrictions() { - assert WindowsPath("hi").is_restricted() == false; - assert WindowsPath("C:\\NUL").is_restricted() == true; - assert WindowsPath("C:\\COM1.TXT").is_restricted() == true; - assert WindowsPath("c:\\prn.exe").is_restricted() == true; + fail_unless!(WindowsPath("hi").is_restricted() == false); + fail_unless!(WindowsPath("C:\\NUL").is_restricted() == true); + fail_unless!(WindowsPath("C:\\COM1.TXT").is_restricted() == true); + fail_unless!(WindowsPath("c:\\prn.exe").is_restricted() == true); } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index d0fa9c3793c..afb7aef25a3 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -161,7 +161,7 @@ pub impl PacketHeader { unsafe fn mark_blocked(&self, this: *rust_task) -> State { rustrt::rust_task_ref(this); let old_task = swap_task(&mut self.blocked_task, this); - assert old_task.is_null(); + fail_unless!(old_task.is_null()); swap_state_acq(&mut self.state, Blocked) } @@ -183,7 +183,7 @@ pub impl PacketHeader { // continuum. It ends making multiple unique pointers to the same // thing. You'll proobably want to forget them when you're done. unsafe fn buf_header(&self) -> ~BufferHeader { - assert self.buffer.is_not_null(); + fail_unless!(self.buffer.is_not_null()); reinterpret_cast(&self.buffer) } @@ -386,8 +386,8 @@ pub fn send(p: SendPacketBuffered, payload: T) -> bool { let header = p.header(); let p_ = p.unwrap(); let p = unsafe { &*p_ }; - assert ptr::addr_of(&(p.header)) == header; - assert p.payload.is_none(); + fail_unless!(ptr::addr_of(&(p.header)) == header); + fail_unless!(p.payload.is_none()); p.payload = Some(payload); let old_state = swap_state_rel(&mut p.header.state, Full); match old_state { @@ -488,7 +488,7 @@ pub fn try_recv(p: RecvPacketBuffered) debug!("blocked = %x this = %x old_task = %x", p.header.blocked_task as uint, this as uint, old_task as uint); - assert old_task.is_null(); + fail_unless!(old_task.is_null()); let mut first = true; let mut count = SPIN_COUNT; loop { @@ -533,7 +533,7 @@ pub fn try_recv(p: RecvPacketBuffered) Terminated => { // This assert detects when we've accidentally unsafely // casted too big of a number to a state. - assert old_state == Terminated; + fail_unless!(old_state == Terminated); let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); if !old_task.is_null() { @@ -582,7 +582,7 @@ fn sender_terminate(p: *Packet) { fail!(~"you dun goofed") } Terminated => { - assert p.header.blocked_task.is_null(); + fail_unless!(p.header.blocked_task.is_null()); // I have to clean up, use drop_glue } } @@ -593,7 +593,7 @@ fn receiver_terminate(p: *Packet) { let p = unsafe { &*p }; match swap_state_rel(&mut p.header.state, Terminated) { Empty => { - assert p.header.blocked_task.is_null(); + fail_unless!(p.header.blocked_task.is_null()); // the sender will clean up } Blocked => { @@ -601,12 +601,12 @@ fn receiver_terminate(p: *Packet) { if !old_task.is_null() { unsafe { rustrt::rust_task_deref(old_task); - assert old_task == rustrt::rust_get_task(); + fail_unless!(old_task == rustrt::rust_get_task()); } } } Terminated | Full => { - assert p.header.blocked_task.is_null(); + fail_unless!(p.header.blocked_task.is_null()); // I have to clean up, use drop_glue } } @@ -669,8 +669,8 @@ pub fn wait_many(pkts: &[T]) -> uint { debug!("%?, %?", ready_packet, pkts[ready_packet]); unsafe { - assert (*pkts[ready_packet].header()).state == Full - || (*pkts[ready_packet].header()).state == Terminated; + fail_unless!((*pkts[ready_packet].header()).state == Full + || (*pkts[ready_packet].header()).state == Terminated); } ready_packet @@ -999,6 +999,6 @@ pub mod test { let _chan = chan; } - assert !port.peek(); + fail_unless!(!port.peek()); } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c10e12953a7..49dd3443443 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -310,28 +310,28 @@ pub fn test() { let mut p = Pair {fst: 10, snd: 20}; let pptr: *mut Pair = &mut p; let iptr: *mut int = cast::reinterpret_cast(&pptr); - assert (*iptr == 10);; + fail_unless!((*iptr == 10));; *iptr = 30; - assert (*iptr == 30); - assert (p.fst == 30);; + fail_unless!((*iptr == 30)); + fail_unless!((p.fst == 30));; *pptr = Pair {fst: 50, snd: 60}; - assert (*iptr == 50); - assert (p.fst == 50); - assert (p.snd == 60); + fail_unless!((*iptr == 50)); + fail_unless!((p.fst == 50)); + fail_unless!((p.snd == 60)); let mut v0 = ~[32000u16, 32001u16, 32002u16]; let mut v1 = ~[0u16, 0u16, 0u16]; copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 1u), offset(vec::raw::to_ptr(v0), 1u), 1u); - assert (v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16); + fail_unless!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16)); copy_memory(vec::raw::to_mut_ptr(v1), offset(vec::raw::to_ptr(v0), 2u), 1u); - assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16); + fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16)); copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u), vec::raw::to_ptr(v0), 1u); - assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16); + fail_unless!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16)); } } @@ -342,9 +342,9 @@ pub fn test_position() { let s = ~"hello"; unsafe { - assert 2u == as_c_str(s, |p| position(p, |c| *c == 'l' as c_char)); - assert 4u == as_c_str(s, |p| position(p, |c| *c == 'o' as c_char)); - assert 5u == as_c_str(s, |p| position(p, |c| *c == 0 as c_char)); + fail_unless!(2u == as_c_str(s, |p| position(p, |c| *c == 'l' as c_char))); + fail_unless!(4u == as_c_str(s, |p| position(p, |c| *c == 'o' as c_char))); + fail_unless!(5u == as_c_str(s, |p| position(p, |c| *c == 0 as c_char))); } } @@ -358,8 +358,8 @@ pub fn test_buf_len() { do str::as_c_str(s2) |p2| { let v = ~[p0, p1, p2, null()]; do vec::as_imm_buf(v) |vp, len| { - assert unsafe { buf_len(vp) } == 3u; - assert len == 4u; + fail_unless!(unsafe { buf_len(vp) } == 3u); + fail_unless!(len == 4u); } } } @@ -369,18 +369,18 @@ pub fn test_buf_len() { #[test] pub 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 = offset(p, 1u); - 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 = mp.offset(1u); - assert !mq.is_null(); - assert mq.is_not_null(); + fail_unless!(!mq.is_null()); + fail_unless!(mq.is_not_null()); } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 6be435355ea..cf90edf86f4 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -162,7 +162,7 @@ pub impl Rng { * failing if start >= end */ fn gen_int_range(&self, start: int, end: int) -> int { - assert start < end; + fail_unless!(start < end); start + int::abs(self.gen_int() % (end - start)) } @@ -196,7 +196,7 @@ pub impl Rng { * failing if start >= end */ fn gen_uint_range(&self, start: uint, end: uint) -> uint { - assert start < end; + fail_unless!(start < end); start + (self.gen_uint() % (end - start)) } @@ -248,7 +248,7 @@ pub impl Rng { * Return a char randomly chosen from chars, failing if chars is empty */ fn gen_char_from(&self, chars: &str) -> char { - assert !chars.is_empty(); + fail_unless!(!chars.is_empty()); self.choose(str::chars(chars)) } @@ -503,7 +503,7 @@ pub mod tests { let seed = rand::seed(); let ra = rand::seeded_rng(seed); let rb = rand::seeded_rng(seed); - assert ra.gen_str(100u) == rb.gen_str(100u); + fail_unless!(ra.gen_str(100u) == rb.gen_str(100u)); } #[test] @@ -512,7 +512,7 @@ pub mod tests { let seed = [2u8, 32u8, 4u8, 32u8, 51u8]; let ra = rand::seeded_rng(seed); let rb = rand::seeded_rng(seed); - assert ra.gen_str(100u) == rb.gen_str(100u); + fail_unless!(ra.gen_str(100u) == rb.gen_str(100u)); } #[test] @@ -522,17 +522,17 @@ pub mod tests { // Regression test that isaac is actually using the above vector let r = ra.next(); error!("%?", r); - assert r == 890007737u32 // on x86_64 - || r == 2935188040u32; // on x86 + fail_unless!(r == 890007737u32 // on x86_64 + || r == 2935188040u32); // on x86 } #[test] pub fn gen_int_range() { let r = rand::Rng(); let a = r.gen_int_range(-3, 42); - assert a >= -3 && a < 42; - assert r.gen_int_range(0, 1) == 0; - assert r.gen_int_range(-12, -11) == -12; + fail_unless!(a >= -3 && a < 42); + fail_unless!(r.gen_int_range(0, 1) == 0); + fail_unless!(r.gen_int_range(-12, -11) == -12); } #[test] @@ -546,9 +546,9 @@ pub mod tests { pub fn gen_uint_range() { let r = rand::Rng(); let a = r.gen_uint_range(3u, 42u); - assert a >= 3u && a < 42u; - assert r.gen_uint_range(0u, 1u) == 0u; - assert r.gen_uint_range(12u, 13u) == 12u; + fail_unless!(a >= 3u && a < 42u); + fail_unless!(r.gen_uint_range(0u, 1u) == 0u); + fail_unless!(r.gen_uint_range(12u, 13u) == 12u); } #[test] @@ -569,8 +569,8 @@ pub mod tests { #[test] pub fn gen_weighted_bool() { let r = rand::Rng(); - assert r.gen_weighted_bool(0u) == true; - assert r.gen_weighted_bool(1u) == true; + fail_unless!(r.gen_weighted_bool(0u) == true); + fail_unless!(r.gen_weighted_bool(1u) == true); } #[test] @@ -579,85 +579,85 @@ pub mod tests { log(debug, r.gen_str(10u)); log(debug, r.gen_str(10u)); log(debug, r.gen_str(10u)); - assert r.gen_str(0u).len() == 0u; - assert r.gen_str(10u).len() == 10u; - assert r.gen_str(16u).len() == 16u; + fail_unless!(r.gen_str(0u).len() == 0u); + fail_unless!(r.gen_str(10u).len() == 10u); + fail_unless!(r.gen_str(16u).len() == 16u); } #[test] pub fn gen_bytes() { let r = rand::Rng(); - assert r.gen_bytes(0u).len() == 0u; - assert r.gen_bytes(10u).len() == 10u; - assert r.gen_bytes(16u).len() == 16u; + fail_unless!(r.gen_bytes(0u).len() == 0u); + fail_unless!(r.gen_bytes(10u).len() == 10u); + fail_unless!(r.gen_bytes(16u).len() == 16u); } #[test] pub fn choose() { let r = rand::Rng(); - assert r.choose([1, 1, 1]) == 1; + fail_unless!(r.choose([1, 1, 1]) == 1); } #[test] pub fn choose_option() { let r = rand::Rng(); let x: Option = r.choose_option([]); - assert x.is_none(); - assert r.choose_option([1, 1, 1]) == Some(1); + fail_unless!(x.is_none()); + fail_unless!(r.choose_option([1, 1, 1]) == Some(1)); } #[test] pub fn choose_weighted() { let r = rand::Rng(); - assert r.choose_weighted(~[ + fail_unless!(r.choose_weighted(~[ rand::Weighted { weight: 1u, item: 42 }, - ]) == 42; - assert r.choose_weighted(~[ + ]) == 42); + fail_unless!(r.choose_weighted(~[ rand::Weighted { weight: 0u, item: 42 }, rand::Weighted { weight: 1u, item: 43 }, - ]) == 43; + ]) == 43); } #[test] pub fn choose_weighted_option() { let r = rand::Rng(); - assert r.choose_weighted_option(~[ + fail_unless!(r.choose_weighted_option(~[ rand::Weighted { weight: 1u, item: 42 }, - ]) == Some(42); - assert r.choose_weighted_option(~[ + ]) == Some(42)); + fail_unless!(r.choose_weighted_option(~[ rand::Weighted { weight: 0u, item: 42 }, rand::Weighted { weight: 1u, item: 43 }, - ]) == Some(43); + ]) == Some(43)); let v: Option = r.choose_weighted_option([]); - assert v.is_none(); + fail_unless!(v.is_none()); } #[test] pub fn weighted_vec() { let r = rand::Rng(); let empty: ~[int] = ~[]; - assert r.weighted_vec(~[]) == empty; - assert r.weighted_vec(~[ + fail_unless!(r.weighted_vec(~[]) == empty); + fail_unless!(r.weighted_vec(~[ rand::Weighted { weight: 0u, item: 3u }, rand::Weighted { weight: 1u, item: 2u }, rand::Weighted { weight: 2u, item: 1u }, - ]) == ~[2u, 1u, 1u]; + ]) == ~[2u, 1u, 1u]); } #[test] pub fn shuffle() { let r = rand::Rng(); let empty: ~[int] = ~[]; - assert r.shuffle(~[]) == empty; - assert r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]; + fail_unless!(r.shuffle(~[]) == empty); + fail_unless!(r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]); } #[test] pub fn task_rng() { let r = rand::task_rng(); r.gen_int(); - assert r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]; - assert r.gen_uint_range(0u, 1u) == 0u; + fail_unless!(r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]); + fail_unless!(r.gen_uint_range(0u, 1u) == 0u); } #[test] diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index e68ba26c4c1..eaae9d03e8e 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -231,7 +231,7 @@ pub impl ReprVisitor { } else if mtbl == 1 { // skip, this is ast::m_imm } else { - assert mtbl == 2; + fail_unless!(mtbl == 2); self.writer.write_str("const "); } } @@ -590,7 +590,7 @@ fn test_repr() { error!("expected '%s', got '%s'", e, s); } - assert s == e; + fail_unless!(s == e); } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 26d91777bd8..dd9b55e6725 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -294,7 +294,7 @@ pub impl Result { * else { return ok(x+1u); } * } * map(~[1u, 2u, 3u], inc_conditionally).chain {|incd| - * assert incd == ~[2u, 3u, 4u]; + * fail_unless!(incd == ~[2u, 3u, 4u]); * } */ #[inline(always)] @@ -337,7 +337,7 @@ pub fn map_opt( pub fn map_vec2(ss: &[S], ts: &[T], op: fn(&S,&T) -> Result) -> Result<~[V],U> { - assert vec::same_length(ss, ts); + fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); let mut vs = vec::with_capacity(n); let mut i = 0u; @@ -360,7 +360,7 @@ pub fn map_vec2(ss: &[S], ts: &[T], pub fn iter_vec2(ss: &[S], ts: &[T], op: fn(&S,&T) -> Result<(),U>) -> Result<(),U> { - assert vec::same_length(ss, ts); + fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); let mut i = 0u; while i < n { @@ -407,50 +407,50 @@ mod tests { #[test] pub fn chain_success() { - assert get(&chain(op1(), op2)) == 667u; + fail_unless!(get(&chain(op1(), op2)) == 667u); } #[test] pub fn chain_failure() { - assert get_err(&chain(op3(), op2)) == ~"sadface"; + fail_unless!(get_err(&chain(op3(), op2)) == ~"sadface"); } #[test] pub fn test_impl_iter() { let mut valid = false; Ok::<~str, ~str>(~"a").iter(|_x| valid = true); - assert valid; + fail_unless!(valid); Err::<~str, ~str>(~"b").iter(|_x| valid = false); - assert valid; + fail_unless!(valid); } #[test] pub fn test_impl_iter_err() { let mut valid = true; Ok::<~str, ~str>(~"a").iter_err(|_x| valid = false); - assert valid; + fail_unless!(valid); valid = false; Err::<~str, ~str>(~"b").iter_err(|_x| valid = true); - assert valid; + fail_unless!(valid); } #[test] pub fn test_impl_map() { - assert Ok::<~str, ~str>(~"a").map(|_x| ~"b") == Ok(~"b"); - assert Err::<~str, ~str>(~"a").map(|_x| ~"b") == Err(~"a"); + fail_unless!(Ok::<~str, ~str>(~"a").map(|_x| ~"b") == Ok(~"b")); + fail_unless!(Err::<~str, ~str>(~"a").map(|_x| ~"b") == Err(~"a")); } #[test] pub fn test_impl_map_err() { - assert Ok::<~str, ~str>(~"a").map_err(|_x| ~"b") == Ok(~"a"); - assert Err::<~str, ~str>(~"a").map_err(|_x| ~"b") == Err(~"b"); + fail_unless!(Ok::<~str, ~str>(~"a").map_err(|_x| ~"b") == Ok(~"a")); + fail_unless!(Err::<~str, ~str>(~"a").map_err(|_x| ~"b") == Err(~"b")); } #[test] pub fn test_get_ref_method() { let foo: Result = Ok(100); - assert *foo.get_ref() == 100; + fail_unless!(*foo.get_ref() == 100); } } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 8afd3e06b7c..bebcc909dc6 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -496,7 +496,7 @@ mod tests { log(debug, copy expected); log(debug, copy actual); - assert (expected == actual); + fail_unless!((expected == actual)); } #[test] @@ -505,7 +505,7 @@ mod tests { &None, &None, 0i32, 0i32, 0i32); let status = run::waitpid(pid); - assert status == 1; + fail_unless!(status == 1); } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 4b76b2b89f2..a6c893f2104 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -43,7 +43,7 @@ Section: Creating a string * Fails if invalid UTF-8 */ pub pure fn from_bytes(vv: &[const u8]) -> ~str { - assert is_utf8(vv); + fail_unless!(is_utf8(vv)); return unsafe { raw::from_bytes(vv) }; } @@ -60,7 +60,7 @@ pub pure fn from_slice(s: &str) -> ~str { * Fails if invalid UTF-8 */ pub pure fn from_byte(b: u8) -> ~str { - assert b < 128u8; + fail_unless!(b < 128u8); unsafe { ::cast::transmute(~[b, 0u8]) } } @@ -249,7 +249,7 @@ Section: Adding to and removing from a string */ pub fn pop_char(s: &mut ~str) -> char { let end = len(*s); - assert end > 0u; + fail_unless!(end > 0u); let CharRange {ch, next} = char_range_at_reverse(*s, end); unsafe { raw::set_len(s, next); } return ch; @@ -417,8 +417,8 @@ pub pure fn substr(s: &str, begin: uint, n: uint) -> ~str { * beyond the last character of the string */ pub pure fn slice(s: &str, begin: uint, end: uint) -> ~str { - assert is_char_boundary(s, begin); - assert is_char_boundary(s, end); + fail_unless!(is_char_boundary(s, begin)); + fail_unless!(is_char_boundary(s, end)); unsafe { raw::slice_bytes(s, begin, end) } } @@ -429,8 +429,8 @@ pub pure fn slice(s: &str, begin: uint, end: uint) -> ~str { * the last character of the string */ pub pure fn view(s: &a/str, begin: uint, end: uint) -> &a/str { - assert is_char_boundary(s, begin); - assert is_char_boundary(s, end); + fail_unless!(is_char_boundary(s, begin)); + fail_unless!(is_char_boundary(s, end)); unsafe { raw::view_bytes(s, begin, end) } } @@ -528,7 +528,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, // See Issue #1932 for why this is a naive search pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { let sep_len = len(sep), l = len(s); - assert sep_len > 0u; + fail_unless!(sep_len > 0u); let mut i = 0u, match_start = 0u, match_i = 0u; while i < l { @@ -568,7 +568,7 @@ pure fn iter_between_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { * # Example * * ~~~ - * assert ["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".") + * fail_unless!(["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".")) * ~~~ */ pub pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] { @@ -1088,8 +1088,8 @@ pub pure fn find_char_from(s: &str, c: char, start: uint) -> Option { pub pure fn find_char_between(s: &str, c: char, start: uint, end: uint) -> Option { if c < 128u as char { - assert start <= end; - assert end <= len(s); + fail_unless!(start <= end); + fail_unless!(end <= len(s)); let mut i = start; let b = c as u8; while i < end { @@ -1167,8 +1167,8 @@ pub pure fn rfind_char_from(s: &str, c: char, start: uint) -> Option { pub pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) -> Option { if c < 128u as char { - assert start >= end; - assert start <= len(s); + fail_unless!(start >= end); + fail_unless!(start <= len(s)); let mut i = start; let b = c as u8; while i > end { @@ -1248,9 +1248,9 @@ pub pure fn find_from(s: &str, start: uint, f: fn(char) */ pub pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) -> Option { - assert start <= end; - assert end <= len(s); - assert is_char_boundary(s, start); + fail_unless!(start <= end); + fail_unless!(end <= len(s)); + fail_unless!(is_char_boundary(s, start)); let mut i = start; while i < end { let CharRange {ch, next} = char_range_at(s, i); @@ -1328,9 +1328,9 @@ pub pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) pub pure fn rfind_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) -> Option { - assert start >= end; - assert start <= len(s); - assert is_char_boundary(s, start); + fail_unless!(start >= end); + fail_unless!(start <= len(s)); + fail_unless!(is_char_boundary(s, start)); let mut i = start; while i > end { let CharRange {ch, next: prev} = char_range_at_reverse(s, i); @@ -1412,7 +1412,7 @@ pub pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, end:uint) -> Option { // See Issue #1932 for why this is a naive search - assert end <= len(haystack); + fail_unless!(end <= len(haystack)); let needle_len = len(needle); if needle_len == 0u { return Some(start); } if needle_len > end { return None; } @@ -1574,11 +1574,11 @@ pub pure fn to_utf16(s: &str) -> ~[u16] { 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); @@ -1601,8 +1601,8 @@ pub pure fn utf16_chars(v: &[u16], f: fn(char)) { } else { let u2 = v[i+1u]; - assert u >= 0xD800_u16 && u <= 0xDBFF_u16; - assert u2 >= 0xDC00_u16 && u2 <= 0xDFFF_u16; + fail_unless!(u >= 0xD800_u16 && u <= 0xDBFF_u16); + fail_unless!(u2 >= 0xDC00_u16 && u2 <= 0xDFFF_u16); let mut c = (u - 0xD800_u16) as char; c = c << 10; c |= (u2 - 0xDC00_u16) as char; @@ -1643,8 +1643,8 @@ pub pure fn with_capacity(capacity: uint) -> ~str { * The number of Unicode characters in `s` between the given indices. */ pub pure fn count_chars(s: &str, start: uint, end: uint) -> uint { - assert is_char_boundary(s, start); - assert is_char_boundary(s, end); + fail_unless!(is_char_boundary(s, start)); + fail_unless!(is_char_boundary(s, end)); let mut i = start, len = 0u; while i < end { let next = char_range_at(s, i).next; @@ -1656,11 +1656,11 @@ pub pure fn count_chars(s: &str, start: uint, end: uint) -> uint { /// Counts the number of bytes taken by the `n` in `s` starting from `start`. pub pure fn count_bytes(s: &b/str, start: uint, n: uint) -> uint { - assert is_char_boundary(s, start); + fail_unless!(is_char_boundary(s, start)); let mut end = start, cnt = n; let l = len(s); while cnt > 0u { - assert end < l; + fail_unless!(end < l); let next = char_range_at(s, end).next; cnt -= 1u; end = next; @@ -1743,14 +1743,14 @@ pub pure fn is_char_boundary(s: &str, index: uint) -> bool { pub pure fn char_range_at(s: &str, i: uint) -> CharRange { let b0 = s[i]; let w = utf8_char_width(b0); - assert (w != 0u); + fail_unless!((w != 0u)); if w == 1u { return CharRange {ch: b0 as char, next: i + 1u}; } let mut val = 0u; let end = i + w; let mut i = i + 1u; while i < end { let byte = s[i]; - assert (byte & 192u8 == tag_cont_u8); + fail_unless!((byte & 192u8 == tag_cont_u8)); val <<= 6u; val += (byte & 63u8) as uint; i += 1u; @@ -1816,7 +1816,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { */ pub pure fn all_between(s: &str, start: uint, end: uint, it: fn(char) -> bool) -> bool { - assert is_char_boundary(s, start); + fail_unless!(is_char_boundary(s, start)); let mut i = start; while i < end { let CharRange {ch, next} = char_range_at(s, i); @@ -1924,7 +1924,7 @@ pub pure fn as_bytes_slice(s: &a/str) -> &a/[u8] { pub pure fn as_c_str(s: &str, f: fn(*libc::c_char) -> T) -> T { do as_buf(s) |buf, len| { // NB: len includes the trailing null. - assert len > 0; + fail_unless!(len > 0); if unsafe { *(ptr::offset(buf,len-1)) != 0 } { as_c_str(from_slice(s), f) } else { @@ -2005,7 +2005,7 @@ pub fn reserve_at_least(s: &mut ~str, n: uint) { pub pure fn capacity(s: &const ~str) -> uint { do as_bytes(s) |buf| { let vcap = vec::capacity(buf); - assert vcap > 0u; + fail_unless!(vcap > 0u); vcap - 1u } } @@ -2062,7 +2062,7 @@ pub mod raw { vec::raw::set_len(&mut v, len); v.push(0u8); - assert is_utf8(v); + fail_unless!(is_utf8(v)); return ::cast::transmute(v); } @@ -2090,7 +2090,7 @@ pub mod raw { pub unsafe fn buf_as_slice(buf: *u8, len: uint, f: fn(v: &str) -> T) -> T { let v = (buf, len + 1); - assert is_utf8(::cast::reinterpret_cast(&v)); + fail_unless!(is_utf8(::cast::reinterpret_cast(&v))); f(::cast::transmute(v)) } @@ -2106,8 +2106,8 @@ pub mod raw { */ pub unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str { do as_buf(s) |sbuf, n| { - assert (begin <= end); - assert (end <= n); + fail_unless!((begin <= end)); + fail_unless!((end <= n)); let mut v = vec::with_capacity(end - begin + 1u); unsafe { @@ -2136,8 +2136,8 @@ pub mod raw { #[inline] pub unsafe fn view_bytes(s: &str, begin: uint, end: uint) -> &str { do as_buf(s) |sbuf, n| { - assert (begin <= end); - assert (end <= n); + fail_unless!((begin <= end)); + fail_unless!((end <= n)); let tuple = (ptr::offset(sbuf, begin), end - begin + 1); ::cast::reinterpret_cast(&tuple) @@ -2165,7 +2165,7 @@ pub mod raw { /// Removes the last byte from a string and returns it. (Not UTF-8 safe). pub unsafe fn pop_byte(s: &mut ~str) -> u8 { let len = len(*s); - assert (len > 0u); + fail_unless!((len > 0u)); let b = s[len - 1u]; unsafe { set_len(s, len - 1u) }; return b; @@ -2174,7 +2174,7 @@ pub mod raw { /// Removes the first byte from a string and returns it. (Not UTF-8 safe). pub unsafe fn shift_byte(s: &mut ~str) -> u8 { let len = len(*s); - assert (len > 0u); + fail_unless!((len > 0u)); let b = s[0]; *s = unsafe { raw::slice_bytes(*s, 1u, len) }; return b; @@ -2196,7 +2196,7 @@ pub mod raw { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::raw::to_ptr(a); let c = from_buf_len(b, 3u); - assert (c == ~"AAA"); + fail_unless!((c == ~"AAA")); } } @@ -2441,69 +2441,69 @@ 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(view("foobar", 0, 3), "foo")); - assert (eq_slice(view("barfoo", 3, 6), "foo")); - assert (!eq_slice("foo1", "foo2")); + fail_unless!((eq_slice(view("foobar", 0, 3), "foo"))); + fail_unless!((eq_slice(view("barfoo", 3, 6), "foo"))); + fail_unless!((!eq_slice("foo1", "foo2"))); } #[test] fn test_le() { - assert (le(&"", &"")); - assert (le(&"", &"foo")); - assert (le(&"foo", &"foo")); - assert (!eq(&~"foo", &~"bar")); + fail_unless!((le(&"", &""))); + fail_unless!((le(&"", &"foo"))); + fail_unless!((le(&"foo", &"foo"))); + fail_unless!((!eq(&~"foo", &~"bar"))); } #[test] fn test_len() { - assert (len(~"") == 0u); - assert (len(~"hello world") == 11u); - assert (len(~"\x63") == 1u); - assert (len(~"\xa2") == 2u); - assert (len(~"\u03c0") == 2u); - assert (len(~"\u2620") == 3u); - assert (len(~"\U0001d11e") == 4u); + fail_unless!((len(~"") == 0u)); + fail_unless!((len(~"hello world") == 11u)); + fail_unless!((len(~"\x63") == 1u)); + fail_unless!((len(~"\xa2") == 2u)); + fail_unless!((len(~"\u03c0") == 2u)); + fail_unless!((len(~"\u2620") == 3u)); + fail_unless!((len(~"\U0001d11e") == 4u)); - assert (char_len(~"") == 0u); - assert (char_len(~"hello world") == 11u); - assert (char_len(~"\x63") == 1u); - assert (char_len(~"\xa2") == 1u); - assert (char_len(~"\u03c0") == 1u); - assert (char_len(~"\u2620") == 1u); - assert (char_len(~"\U0001d11e") == 1u); - assert (char_len(~"ประเทศไทย中华Việt Nam") == 19u); + fail_unless!((char_len(~"") == 0u)); + fail_unless!((char_len(~"hello world") == 11u)); + fail_unless!((char_len(~"\x63") == 1u)); + fail_unless!((char_len(~"\xa2") == 1u)); + fail_unless!((char_len(~"\u03c0") == 1u)); + fail_unless!((char_len(~"\u2620") == 1u)); + fail_unless!((char_len(~"\U0001d11e") == 1u)); + fail_unless!((char_len(~"ประเทศไทย中华Việt Nam") == 19u)); } #[test] fn test_rfind_char() { - assert rfind_char(~"hello", 'l') == Some(3u); - assert rfind_char(~"hello", 'o') == Some(4u); - assert rfind_char(~"hello", 'h') == Some(0u); - assert rfind_char(~"hello", 'z').is_none(); - assert rfind_char(~"ประเทศไทย中华Việt Nam", '华') == Some(30u); + fail_unless!(rfind_char(~"hello", 'l') == Some(3u)); + fail_unless!(rfind_char(~"hello", 'o') == Some(4u)); + fail_unless!(rfind_char(~"hello", 'h') == Some(0u)); + fail_unless!(rfind_char(~"hello", 'z').is_none()); + fail_unless!(rfind_char(~"ประเทศไทย中华Việt Nam", '华') == Some(30u)); } #[test] fn test_pop_char() { let mut data = ~"ประเทศไทย中华"; let cc = pop_char(&mut data); - assert ~"ประเทศไทย中" == data; - assert '华' == cc; + fail_unless!(~"ประเทศไทย中" == data); + fail_unless!('华' == cc); } #[test] fn test_pop_char_2() { let mut data2 = ~"华"; let cc2 = pop_char(&mut data2); - assert ~"" == data2; - assert '华' == cc2; + fail_unless!(~"" == data2); + fail_unless!('华' == cc2); } #[test] @@ -2520,27 +2520,27 @@ mod tests { log(debug, ~"split_byte: " + s); let v = split_char(s, c); debug!("split_byte to: %?", v); - assert vec::all2(v, u, |a,b| a == b); + fail_unless!(vec::all2(v, u, |a,b| a == b)); } t(~"abc.hello.there", '.', ~[~"abc", ~"hello", ~"there"]); t(~".hello.there", '.', ~[~"", ~"hello", ~"there"]); t(~"...hello.there.", '.', ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); - assert ~[~"", ~"", ~"", ~"hello", ~"there", ~""] - == split_char(~"...hello.there.", '.'); + fail_unless!(~[~"", ~"", ~"", ~"hello", ~"there", ~""] + == split_char(~"...hello.there.", '.')); - assert ~[~""] == split_char(~"", 'z'); - assert ~[~"",~""] == split_char(~"z", 'z'); - assert ~[~"ok"] == split_char(~"ok", 'z'); + fail_unless!(~[~""] == split_char(~"", 'z')); + fail_unless!(~[~"",~""] == split_char(~"z", 'z')); + fail_unless!(~[~"ok"] == split_char(~"ok", 'z')); } #[test] fn test_split_char_2() { let data = ~"ประเทศไทย中华Việt Nam"; - assert ~[~"ประเทศไทย中华", ~"iệt Nam"] - == split_char(data, 'V'); - assert ~[~"ประเ", ~"ศไ", ~"ย中华Việt Nam"] - == split_char(data, 'ท'); + fail_unless!(~[~"ประเทศไทย中华", ~"iệt Nam"] + == split_char(data, 'V')); + fail_unless!(~[~"ประเ", ~"ศไ", ~"ย中华Việt Nam"] + == split_char(data, 'ท')); } #[test] @@ -2550,7 +2550,7 @@ mod tests { let v = splitn_char(s, c, n); debug!("split_byte to: %?", v); debug!("comparing vs. %?", u); - assert vec::all2(v, u, |a,b| a == b); + fail_unless!(vec::all2(v, u, |a,b| a == b)); } t(~"abc.hello.there", '.', 0u, ~[~"abc.hello.there"]); t(~"abc.hello.there", '.', 1u, ~[~"abc", ~"hello.there"]); @@ -2562,35 +2562,35 @@ mod tests { t(~"...hello.there.", '.', 5u, ~[~"", ~"", ~"", ~"hello", ~"there", ~""]); - assert ~[~""] == splitn_char(~"", 'z', 5u); - assert ~[~"",~""] == splitn_char(~"z", 'z', 5u); - assert ~[~"ok"] == splitn_char(~"ok", 'z', 5u); - assert ~[~"z"] == splitn_char(~"z", 'z', 0u); - assert ~[~"w.x.y"] == splitn_char(~"w.x.y", '.', 0u); - assert ~[~"w",~"x.y"] == splitn_char(~"w.x.y", '.', 1u); + fail_unless!(~[~""] == splitn_char(~"", 'z', 5u)); + fail_unless!(~[~"",~""] == splitn_char(~"z", 'z', 5u)); + fail_unless!(~[~"ok"] == splitn_char(~"ok", 'z', 5u)); + fail_unless!(~[~"z"] == splitn_char(~"z", 'z', 0u)); + fail_unless!(~[~"w.x.y"] == splitn_char(~"w.x.y", '.', 0u)); + fail_unless!(~[~"w",~"x.y"] == splitn_char(~"w.x.y", '.', 1u)); } #[test] fn test_splitn_char_2 () { let data = ~"ประเทศไทย中华Việt Nam"; - assert ~[~"ประเทศไทย中", ~"Việt Nam"] - == splitn_char(data, '华', 1u); + fail_unless!(~[~"ประเทศไทย中", ~"Việt Nam"] + == splitn_char(data, '华', 1u)); - assert ~[~"", ~"", ~"XXX", ~"YYYzWWWz"] - == splitn_char(~"zzXXXzYYYzWWWz", 'z', 3u); - assert ~[~"",~""] == splitn_char(~"z", 'z', 5u); - assert ~[~""] == splitn_char(~"", 'z', 5u); - assert ~[~"ok"] == splitn_char(~"ok", 'z', 5u); + fail_unless!(~[~"", ~"", ~"XXX", ~"YYYzWWWz"] + == splitn_char(~"zzXXXzYYYzWWWz", 'z', 3u)); + fail_unless!(~[~"",~""] == splitn_char(~"z", 'z', 5u)); + fail_unless!(~[~""] == splitn_char(~"", 'z', 5u)); + fail_unless!(~[~"ok"] == splitn_char(~"ok", 'z', 5u)); } #[test] fn test_splitn_char_3() { let data = ~"ประเทศไทย中华Việt Nam"; - assert ~[~"ประเทศไทย中华", ~"iệt Nam"] - == splitn_char(data, 'V', 1u); - assert ~[~"ประเ", ~"ศไทย中华Việt Nam"] - == splitn_char(data, 'ท', 1u); + fail_unless!(~[~"ประเทศไทย中华", ~"iệt Nam"] + == splitn_char(data, 'V', 1u)); + fail_unless!(~[~"ประเ", ~"ศไทย中华Việt Nam"] + == splitn_char(data, 'ท', 1u)); } @@ -2599,7 +2599,7 @@ mod tests { fn t(s: &str, sep: &a/str, i: int, k: &str) { fn borrow(x: &a/str) -> &a/str { x } let v = split_str(s, sep); - assert borrow(v[i]) == k; + fail_unless!(borrow(v[i]) == k); } t(~"--1233345--", ~"12345", 0, ~"--1233345--"); @@ -2611,40 +2611,40 @@ mod tests { t(~"::hello::there::", ~"::", 3, ~""); let data = ~"ประเทศไทย中华Việt Nam"; - assert ~[~"ประเทศไทย", ~"Việt Nam"] - == split_str (data, ~"中华"); + fail_unless!(~[~"ประเทศไทย", ~"Việt Nam"] + == split_str (data, ~"中华")); - assert ~[~"", ~"XXX", ~"YYY", ~""] - == split_str(~"zzXXXzzYYYzz", ~"zz"); + fail_unless!(~[~"", ~"XXX", ~"YYY", ~""] + == split_str(~"zzXXXzzYYYzz", ~"zz")); - assert ~[~"zz", ~"zYYYz"] - == split_str(~"zzXXXzYYYz", ~"XXX"); + fail_unless!(~[~"zz", ~"zYYYz"] == split_str(~"zzXXXzYYYz", ~"XXX")); - assert ~[~"", ~"XXX", ~"YYY", ~""] == split_str(~".XXX.YYY.", ~"."); - assert ~[~""] == split_str(~"", ~"."); - assert ~[~"",~""] == split_str(~"zz", ~"zz"); - assert ~[~"ok"] == split_str(~"ok", ~"z"); - assert ~[~"",~"z"] == split_str(~"zzz", ~"zz"); - assert ~[~"",~"",~"z"] == split_str(~"zzzzz", ~"zz"); + fail_unless!(~[~"", ~"XXX", ~"YYY", ~""] == + split_str(~".XXX.YYY.", ~".")); + fail_unless!(~[~""] == split_str(~"", ~".")); + fail_unless!(~[~"",~""] == split_str(~"zz", ~"zz")); + fail_unless!(~[~"ok"] == split_str(~"ok", ~"z")); + fail_unless!(~[~"",~"z"] == split_str(~"zzz", ~"zz")); + fail_unless!(~[~"",~"",~"z"] == split_str(~"zzzzz", ~"zz")); } #[test] fn test_split() { let data = ~"ประเทศไทย中华Việt Nam"; - assert ~[~"ประเทศไทย中", ~"Việt Nam"] - == split (data, |cc| cc == '华'); + fail_unless!(~[~"ประเทศไทย中", ~"Việt Nam"] + == split (data, |cc| cc == '华')); - assert ~[~"", ~"", ~"XXX", ~"YYY", ~""] - == split(~"zzXXXzYYYz", char::is_lowercase); + fail_unless!(~[~"", ~"", ~"XXX", ~"YYY", ~""] + == split(~"zzXXXzYYYz", char::is_lowercase)); - assert ~[~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"] - == split(~"zzXXXzYYYz", char::is_uppercase); + fail_unless!(~[~"zz", ~"", ~"", ~"z", ~"", ~"", ~"z"] + == split(~"zzXXXzYYYz", char::is_uppercase)); - assert ~[~"",~""] == split(~"z", |cc| cc == 'z'); - assert ~[~""] == split(~"", |cc| cc == 'z'); - assert ~[~"ok"] == split(~"ok", |cc| cc == 'z'); + fail_unless!(~[~"",~""] == split(~"z", |cc| cc == 'z')); + fail_unless!(~[~""] == split(~"", |cc| cc == 'z')); + fail_unless!(~[~"ok"] == split(~"ok", |cc| cc == 'z')); } #[test] @@ -2652,105 +2652,107 @@ mod tests { let lf = ~"\nMary had a little lamb\nLittle lamb\n"; let crlf = ~"\r\nMary had a little lamb\r\nLittle lamb\r\n"; - assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] - == lines(lf); + fail_unless!(~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] + == lines(lf)); - assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] - == lines_any(lf); + fail_unless!(~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] + == lines_any(lf)); - assert ~[~"\r", ~"Mary had a little lamb\r", ~"Little lamb\r", ~""] - == lines(crlf); + fail_unless!(~[~"\r", ~"Mary had a little lamb\r", + ~"Little lamb\r", ~""] + == lines(crlf)); - assert ~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] - == lines_any(crlf); + fail_unless!(~[~"", ~"Mary had a little lamb", ~"Little lamb", ~""] + == lines_any(crlf)); - assert ~[~""] == lines (~""); - assert ~[~""] == lines_any(~""); - assert ~[~"",~""] == lines (~"\n"); - assert ~[~"",~""] == lines_any(~"\n"); - assert ~[~"banana"] == lines (~"banana"); - assert ~[~"banana"] == lines_any(~"banana"); + fail_unless!(~[~""] == lines (~"")); + fail_unless!(~[~""] == lines_any(~"")); + fail_unless!(~[~"",~""] == lines (~"\n")); + fail_unless!(~[~"",~""] == lines_any(~"\n")); + fail_unless!(~[~"banana"] == lines (~"banana")); + fail_unless!(~[~"banana"] == lines_any(~"banana")); } #[test] fn test_words () { let data = ~"\nMary had a little lamb\nLittle lamb\n"; - assert ~[~"Mary",~"had",~"a",~"little",~"lamb",~"Little",~"lamb"] - == words(data); + fail_unless!(~[ + ~"Mary",~"had",~"a",~"little",~"lamb",~"Little",~"lamb"] + == words(data)); - assert ~[~"ok"] == words(~"ok"); - assert ~[] == words(~""); + fail_unless!(~[~"ok"] == words(~"ok")); + fail_unless!(~[] == words(~"")); } #[test] fn test_split_within() { - assert split_within(~"", 0) == ~[]; - assert split_within(~"", 15) == ~[]; - assert split_within(~"hello", 15) == ~[~"hello"]; + fail_unless!(split_within(~"", 0) == ~[]); + fail_unless!(split_within(~"", 15) == ~[]); + fail_unless!(split_within(~"hello", 15) == ~[~"hello"]); let data = ~"\nMary had a little lamb\nLittle lamb\n"; error!("~~~~ %?", split_within(data, 15)); - assert split_within(data, 15) == ~[~"Mary had a", - ~"little lamb", - ~"Little lamb"]; + fail_unless!(split_within(data, 15) == ~[~"Mary had a", + ~"little lamb", + ~"Little lamb"]); } #[test] fn test_find_str() { // byte positions - assert find_str(~"banana", ~"apple pie").is_none(); - assert find_str(~"", ~"") == Some(0u); + fail_unless!(find_str(~"banana", ~"apple pie").is_none()); + fail_unless!(find_str(~"", ~"") == Some(0u)); let data = ~"ประเทศไทย中华Việt Nam"; - assert find_str(data, ~"") == Some(0u); - assert find_str(data, ~"ประเ") == Some( 0u); - assert find_str(data, ~"ะเ") == Some( 6u); - assert find_str(data, ~"中华") == Some(27u); - assert find_str(data, ~"ไท华").is_none(); + fail_unless!(find_str(data, ~"") == Some(0u)); + fail_unless!(find_str(data, ~"ประเ") == Some( 0u)); + fail_unless!(find_str(data, ~"ะเ") == Some( 6u)); + fail_unless!(find_str(data, ~"中华") == Some(27u)); + fail_unless!(find_str(data, ~"ไท华").is_none()); } #[test] fn test_find_str_between() { // byte positions - assert find_str_between(~"", ~"", 0u, 0u) == Some(0u); + fail_unless!(find_str_between(~"", ~"", 0u, 0u) == Some(0u)); let data = ~"abcabc"; - assert find_str_between(data, ~"ab", 0u, 6u) == Some(0u); - assert find_str_between(data, ~"ab", 2u, 6u) == Some(3u); - assert find_str_between(data, ~"ab", 2u, 4u).is_none(); + fail_unless!(find_str_between(data, ~"ab", 0u, 6u) == Some(0u)); + fail_unless!(find_str_between(data, ~"ab", 2u, 6u) == Some(3u)); + fail_unless!(find_str_between(data, ~"ab", 2u, 4u).is_none()); let mut data = ~"ประเทศไทย中华Việt Nam"; data = data + data; - assert find_str_between(data, ~"", 0u, 43u) == Some(0u); - assert find_str_between(data, ~"", 6u, 43u) == Some(6u); + fail_unless!(find_str_between(data, ~"", 0u, 43u) == Some(0u)); + fail_unless!(find_str_between(data, ~"", 6u, 43u) == Some(6u)); - assert find_str_between(data, ~"ประ", 0u, 43u) == Some( 0u); - assert find_str_between(data, ~"ทศไ", 0u, 43u) == Some(12u); - assert find_str_between(data, ~"ย中", 0u, 43u) == Some(24u); - assert find_str_between(data, ~"iệt", 0u, 43u) == Some(34u); - assert find_str_between(data, ~"Nam", 0u, 43u) == Some(40u); + fail_unless!(find_str_between(data, ~"ประ", 0u, 43u) == Some( 0u)); + fail_unless!(find_str_between(data, ~"ทศไ", 0u, 43u) == Some(12u)); + fail_unless!(find_str_between(data, ~"ย中", 0u, 43u) == Some(24u)); + fail_unless!(find_str_between(data, ~"iệt", 0u, 43u) == Some(34u)); + fail_unless!(find_str_between(data, ~"Nam", 0u, 43u) == Some(40u)); - assert find_str_between(data, ~"ประ", 43u, 86u) == Some(43u); - assert find_str_between(data, ~"ทศไ", 43u, 86u) == Some(55u); - assert find_str_between(data, ~"ย中", 43u, 86u) == Some(67u); - assert find_str_between(data, ~"iệt", 43u, 86u) == Some(77u); - assert find_str_between(data, ~"Nam", 43u, 86u) == Some(83u); + fail_unless!(find_str_between(data, ~"ประ", 43u, 86u) == Some(43u)); + fail_unless!(find_str_between(data, ~"ทศไ", 43u, 86u) == Some(55u)); + fail_unless!(find_str_between(data, ~"ย中", 43u, 86u) == Some(67u)); + fail_unless!(find_str_between(data, ~"iệt", 43u, 86u) == Some(77u)); + fail_unless!(find_str_between(data, ~"Nam", 43u, 86u) == Some(83u)); } #[test] fn test_substr() { fn t(a: &str, b: &str, start: int) { - assert substr(a, start as uint, len(b)) == b.to_str(); + fail_unless!(substr(a, start as uint, len(b)) == b.to_str()); } t(~"hello", ~"llo", 2); t(~"hello", ~"el", 1); - assert ~"ะเทศไท" == substr(~"ประเทศไทย中华Việt Nam", 6u, 6u); + fail_unless!(~"ะเทศไท" == substr(~"ประเทศไทย中华Việt Nam", 6u, 6u)); } #[test] fn test_concat() { fn t(v: &[~str], s: &str) { - assert concat(v) == s.to_str(); + fail_unless!(concat(v) == s.to_str()); } t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], ~"youknowI'mnogood"); let v: ~[~str] = ~[]; @@ -2761,7 +2763,7 @@ mod tests { #[test] fn test_connect() { fn t(v: &[~str], sep: &str, s: &str) { - assert connect(v, sep) == s.to_str(); + fail_unless!(connect(v, sep) == s.to_str()); } t(~[~"you", ~"know", ~"I'm", ~"no", ~"good"], ~" ", ~"you know I'm no good"); @@ -2773,7 +2775,7 @@ mod tests { #[test] fn test_connect_slices() { fn t(v: &[&str], sep: &str, s: &str) { - assert connect_slices(v, sep) == s.to_str(); + fail_unless!(connect_slices(v, sep) == s.to_str()); } t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); @@ -2783,11 +2785,11 @@ mod tests { #[test] fn test_repeat() { - assert repeat(~"x", 4) == ~"xxxx"; - assert repeat(~"hi", 4) == ~"hihihihi"; - assert repeat(~"ไท华", 3) == ~"ไท华ไท华ไท华"; - assert repeat(~"", 4) == ~""; - assert repeat(~"hi", 0) == ~""; + fail_unless!(repeat(~"x", 4) == ~"xxxx"); + fail_unless!(repeat(~"hi", 4) == ~"hihihihi"); + fail_unless!(repeat(~"ไท华", 3) == ~"ไท华ไท华ไท华"); + fail_unless!(repeat(~"", 4) == ~""); + fail_unless!(repeat(~"hi", 0) == ~""); } #[test] @@ -2799,24 +2801,24 @@ mod tests { let input = ~"abcDEF" + unicode + ~"xyz:.;"; let expected = ~"ABCDEF" + unicode + ~"XYZ:.;"; let actual = to_upper(input); - assert expected == actual; + fail_unless!(expected == actual); } #[test] fn test_to_lower() { unsafe { - assert ~"" == map(~"", |c| libc::tolower(c as c_char) as char); - assert ~"ymca" == map(~"YMCA", - |c| libc::tolower(c as c_char) as char); + fail_unless!(~"" == map(~"", |c| libc::tolower(c as c_char) as char)); + fail_unless!(~"ymca" == map(~"YMCA", + |c| libc::tolower(c as c_char) as char)); } } #[test] fn test_unsafe_slice() { unsafe { - assert ~"ab" == raw::slice_bytes(~"abc", 0, 2); - assert ~"bc" == raw::slice_bytes(~"abc", 1, 3); - assert ~"" == raw::slice_bytes(~"abc", 1, 1); + fail_unless!(~"ab" == raw::slice_bytes(~"abc", 0, 2)); + fail_unless!(~"bc" == raw::slice_bytes(~"abc", 1, 3)); + fail_unless!(~"" == raw::slice_bytes(~"abc", 1, 1)); fn a_million_letter_a() -> ~str { let mut i = 0; let mut rs = ~""; @@ -2829,44 +2831,44 @@ mod tests { while i < 100000 { push_str(&mut rs, ~"aaaaa"); i += 1; } rs } - assert half_a_million_letter_a() == - raw::slice_bytes(a_million_letter_a(), 0u, 500000); + fail_unless!(half_a_million_letter_a() == + raw::slice_bytes(a_million_letter_a(), 0u, 500000)); } } #[test] fn test_starts_with() { - assert (starts_with(~"", ~"")); - assert (starts_with(~"abc", ~"")); - assert (starts_with(~"abc", ~"a")); - assert (!starts_with(~"a", ~"abc")); - assert (!starts_with(~"", ~"abc")); + fail_unless!((starts_with(~"", ~""))); + fail_unless!((starts_with(~"abc", ~""))); + fail_unless!((starts_with(~"abc", ~"a"))); + fail_unless!((!starts_with(~"a", ~"abc"))); + fail_unless!((!starts_with(~"", ~"abc"))); } #[test] fn test_ends_with() { - assert (ends_with(~"", ~"")); - assert (ends_with(~"abc", ~"")); - assert (ends_with(~"abc", ~"c")); - assert (!ends_with(~"a", ~"abc")); - assert (!ends_with(~"", ~"abc")); + fail_unless!((ends_with(~"", ~""))); + fail_unless!((ends_with(~"abc", ~""))); + fail_unless!((ends_with(~"abc", ~"c"))); + fail_unless!((!ends_with(~"a", ~"abc"))); + fail_unless!((!ends_with(~"", ~"abc"))); } #[test] fn test_is_empty() { - assert (is_empty(~"")); - assert (!is_empty(~"a")); + fail_unless!((is_empty(~""))); + fail_unless!((!is_empty(~"a"))); } #[test] fn test_replace() { let a = ~"a"; - assert replace(~"", a, ~"b") == ~""; - assert replace(~"a", a, ~"b") == ~"b"; - assert replace(~"ab", a, ~"b") == ~"bb"; + fail_unless!(replace(~"", a, ~"b") == ~""); + fail_unless!(replace(~"a", a, ~"b") == ~"b"); + fail_unless!(replace(~"ab", a, ~"b") == ~"bb"); let test = ~"test"; - assert replace(~" test test ", test, ~"toast") == ~" toast toast "; - assert replace(~" test test ", test, ~"") == ~" "; + fail_unless!(replace(~" test test ", test, ~"toast") == ~" toast toast "); + fail_unless!(replace(~" test test ", test, ~"") == ~" "); } #[test] @@ -2876,7 +2878,7 @@ mod tests { let a = ~"ประเ"; let A = ~"دولة الكويتทศไทย中华"; - assert (replace(data, a, repl) == A); + fail_unless!((replace(data, a, repl) == A)); } #[test] @@ -2886,7 +2888,7 @@ mod tests { let b = ~"ะเ"; let B = ~"ปรدولة الكويتทศไทย中华"; - assert (replace(data, b, repl) == B); + fail_unless!((replace(data, b, repl) == B)); } #[test] @@ -2896,7 +2898,7 @@ mod tests { let c = ~"中华"; let C = ~"ประเทศไทยدولة الكويت"; - assert (replace(data, c, repl) == C); + fail_unless!((replace(data, c, repl) == C)); } #[test] @@ -2905,21 +2907,21 @@ mod tests { let repl = ~"دولة الكويت"; let d = ~"ไท华"; - assert (replace(data, d, repl) == data); + fail_unless!((replace(data, d, repl) == data)); } #[test] fn test_slice() { - assert ~"ab" == slice(~"abc", 0, 2); - assert ~"bc" == slice(~"abc", 1, 3); - assert ~"" == slice(~"abc", 1, 1); - assert ~"\u65e5" == slice(~"\u65e5\u672c", 0, 3); + fail_unless!(~"ab" == slice(~"abc", 0, 2)); + fail_unless!(~"bc" == slice(~"abc", 1, 3)); + fail_unless!(~"" == slice(~"abc", 1, 1)); + fail_unless!(~"\u65e5" == slice(~"\u65e5\u672c", 0, 3)); let data = ~"ประเทศไทย中华"; - assert ~"ป" == slice(data, 0, 3); - assert ~"ร" == slice(data, 3, 6); - assert ~"" == slice(data, 3, 3); - assert ~"华" == slice(data, 30, 33); + fail_unless!(~"ป" == slice(data, 0, 3)); + fail_unless!(~"ร" == slice(data, 3, 6)); + fail_unless!(~"" == slice(data, 3, 3)); + fail_unless!(~"华" == slice(data, 30, 33)); fn a_million_letter_X() -> ~str { let mut i = 0; @@ -2936,24 +2938,24 @@ mod tests { while i < 100000 { push_str(&mut rs, ~"华华华华华"); i += 1; } rs } - assert half_a_million_letter_X() == - slice(a_million_letter_X(), 0u, 3u * 500000u); + fail_unless!(half_a_million_letter_X() == + slice(a_million_letter_X(), 0u, 3u * 500000u)); } #[test] fn test_slice_2() { let ss = ~"中华Việt Nam"; - assert ~"华" == slice(ss, 3u, 6u); - assert ~"Việt Nam" == slice(ss, 6u, 16u); + fail_unless!(~"华" == slice(ss, 3u, 6u)); + fail_unless!(~"Việt Nam" == slice(ss, 6u, 16u)); - assert ~"ab" == slice(~"abc", 0u, 2u); - assert ~"bc" == slice(~"abc", 1u, 3u); - assert ~"" == slice(~"abc", 1u, 1u); + fail_unless!(~"ab" == slice(~"abc", 0u, 2u)); + fail_unless!(~"bc" == slice(~"abc", 1u, 3u)); + fail_unless!(~"" == slice(~"abc", 1u, 1u)); - assert ~"中" == slice(ss, 0u, 3u); - assert ~"华V" == slice(ss, 3u, 7u); - assert ~"" == slice(ss, 3u, 3u); + fail_unless!(~"中" == slice(ss, 0u, 3u)); + fail_unless!(~"华V" == slice(ss, 3u, 7u)); + fail_unless!(~"" == slice(ss, 3u, 3u)); /*0: 中 3: 华 6: V @@ -2975,95 +2977,95 @@ mod tests { #[test] fn test_trim_left_chars() { - assert trim_left_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "; - assert trim_left_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo *** "; - assert trim_left_chars(~" *** *** ", ~['*', ' ']) == ~""; - assert trim_left_chars(~"foo *** ", ~['*', ' ']) == ~"foo *** "; + fail_unless!(trim_left_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "); + fail_unless!(trim_left_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo *** "); + fail_unless!(trim_left_chars(~" *** *** ", ~['*', ' ']) == ~""); + fail_unless!(trim_left_chars(~"foo *** ", ~['*', ' ']) == ~"foo *** "); } #[test] fn test_trim_right_chars() { - assert trim_right_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "; - assert trim_right_chars(~" *** foo *** ", ~['*', ' ']) == ~" *** foo"; - assert trim_right_chars(~" *** *** ", ~['*', ' ']) == ~""; - assert trim_right_chars(~" *** foo", ~['*', ' ']) == ~" *** foo"; + fail_unless!(trim_right_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "); + fail_unless!(trim_right_chars(~" *** foo *** ", ~['*', ' ']) == ~" *** foo"); + fail_unless!(trim_right_chars(~" *** *** ", ~['*', ' ']) == ~""); + fail_unless!(trim_right_chars(~" *** foo", ~['*', ' ']) == ~" *** foo"); } #[test] fn test_trim_chars() { - assert trim_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "; - assert trim_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo"; - assert trim_chars(~" *** *** ", ~['*', ' ']) == ~""; - assert trim_chars(~"foo", ~['*', ' ']) == ~"foo"; + fail_unless!(trim_chars(~" *** foo *** ", ~[]) == ~" *** foo *** "); + fail_unless!(trim_chars(~" *** foo *** ", ~['*', ' ']) == ~"foo"); + fail_unless!(trim_chars(~" *** *** ", ~['*', ' ']) == ~""); + fail_unless!(trim_chars(~"foo", ~['*', ' ']) == ~"foo"); } #[test] fn test_trim_left() { - assert (trim_left(~"") == ~""); - assert (trim_left(~"a") == ~"a"); - assert (trim_left(~" ") == ~""); - assert (trim_left(~" blah") == ~"blah"); - assert (trim_left(~" \u3000 wut") == ~"wut"); - assert (trim_left(~"hey ") == ~"hey "); + fail_unless!((trim_left(~"") == ~"")); + fail_unless!((trim_left(~"a") == ~"a")); + fail_unless!((trim_left(~" ") == ~"")); + fail_unless!((trim_left(~" blah") == ~"blah")); + fail_unless!((trim_left(~" \u3000 wut") == ~"wut")); + fail_unless!((trim_left(~"hey ") == ~"hey ")); } #[test] fn test_trim_right() { - assert (trim_right(~"") == ~""); - assert (trim_right(~"a") == ~"a"); - assert (trim_right(~" ") == ~""); - assert (trim_right(~"blah ") == ~"blah"); - assert (trim_right(~"wut \u3000 ") == ~"wut"); - assert (trim_right(~" hey") == ~" hey"); + fail_unless!((trim_right(~"") == ~"")); + fail_unless!((trim_right(~"a") == ~"a")); + fail_unless!((trim_right(~" ") == ~"")); + fail_unless!((trim_right(~"blah ") == ~"blah")); + fail_unless!((trim_right(~"wut \u3000 ") == ~"wut")); + fail_unless!((trim_right(~" hey") == ~" hey")); } #[test] fn test_trim() { - assert (trim(~"") == ~""); - assert (trim(~"a") == ~"a"); - assert (trim(~" ") == ~""); - assert (trim(~" blah ") == ~"blah"); - assert (trim(~"\nwut \u3000 ") == ~"wut"); - assert (trim(~" hey dude ") == ~"hey dude"); + fail_unless!((trim(~"") == ~"")); + fail_unless!((trim(~"a") == ~"a")); + fail_unless!((trim(~" ") == ~"")); + fail_unless!((trim(~" blah ") == ~"blah")); + fail_unless!((trim(~"\nwut \u3000 ") == ~"wut")); + fail_unless!((trim(~" hey dude ") == ~"hey dude")); } #[test] fn test_is_whitespace() { - assert (is_whitespace(~"")); - assert (is_whitespace(~" ")); - assert (is_whitespace(~"\u2009")); // Thin space - assert (is_whitespace(~" \n\t ")); - assert (!is_whitespace(~" _ ")); + fail_unless!((is_whitespace(~""))); + fail_unless!((is_whitespace(~" "))); + fail_unless!((is_whitespace(~"\u2009"))); // Thin space + fail_unless!((is_whitespace(~" \n\t "))); + fail_unless!((!is_whitespace(~" _ "))); } #[test] fn test_is_ascii() { - assert (is_ascii(~"")); - assert (is_ascii(~"a")); - assert (!is_ascii(~"\u2009")); + fail_unless!((is_ascii(~""))); + fail_unless!((is_ascii(~"a"))); + fail_unless!((!is_ascii(~"\u2009"))); } #[test] fn test_shift_byte() { let mut s = ~"ABC"; let b = unsafe { raw::shift_byte(&mut s) }; - assert (s == ~"BC"); - assert (b == 65u8); + fail_unless!((s == ~"BC")); + fail_unless!((b == 65u8)); } #[test] fn test_pop_byte() { let mut s = ~"ABC"; let b = unsafe { raw::pop_byte(&mut s) }; - assert (s == ~"AB"); - assert (b == 67u8); + fail_unless!((s == ~"AB")); + fail_unless!((b == 67u8)); } #[test] fn test_unsafe_from_bytes() { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]; let b = unsafe { raw::from_bytes(a) }; - assert (b == ~"AAAAAAA"); + fail_unless!((b == ~"AAAAAAA")); } #[test] @@ -3080,7 +3082,7 @@ mod tests { 0x20_u8, 0x4e_u8, 0x61_u8, 0x6d_u8]; - assert ss == from_bytes(bb); + fail_unless!(ss == from_bytes(bb)); } #[test] @@ -3107,7 +3109,7 @@ mod tests { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::raw::to_ptr(a); let c = raw::from_buf(b); - assert (c == ~"AAAAAAA"); + fail_unless!((c == ~"AAAAAAA")); } } @@ -3123,20 +3125,20 @@ mod tests { fn test_as_buf() { let a = ~"Abcdefg"; let b = as_buf(a, |buf, _l| { - assert unsafe { *buf } == 65u8; + fail_unless!(unsafe { *buf } == 65u8); 100 }); - assert (b == 100); + fail_unless!((b == 100)); } #[test] fn test_as_buf_small() { let a = ~"A"; let b = as_buf(a, |buf, _l| { - assert unsafe { *buf } == 65u8; + fail_unless!(unsafe { *buf } == 65u8); 100 }); - assert (b == 100); + fail_unless!((b == 100)); } #[test] @@ -3145,7 +3147,7 @@ mod tests { let s = ~"hello"; let sb = as_buf(s, |b, _l| b); let s_cstr = raw::from_buf(sb); - assert s_cstr == s; + fail_unless!(s_cstr == s); } } @@ -3154,11 +3156,11 @@ mod tests { let a = ~"hello"; do as_buf(a) |buf, len| { unsafe { - assert a[0] == 'h' as u8; - assert *buf == 'h' as u8; - assert len == 6u; - assert *ptr::offset(buf,4u) == 'o' as u8; - assert *ptr::offset(buf,5u) == 0u8; + fail_unless!(a[0] == 'h' as u8); + fail_unless!(*buf == 'h' as u8); + fail_unless!(len == 6u); + fail_unless!(*ptr::offset(buf,4u) == 'o' as u8); + fail_unless!(*ptr::offset(buf,5u) == 0u8); } } } @@ -3172,40 +3174,40 @@ mod tests { let mut i: uint = 0u; let n1: uint = len(s1); let n2: uint = vec::len::(v); - assert (n1 == n2); + fail_unless!((n1 == n2)); while i < n1 { let a: u8 = s1[i]; let b: u8 = s2[i]; log(debug, a); log(debug, b); - assert (a == b); + fail_unless!((a == b)); i += 1u; } } #[test] fn test_contains() { - assert contains(~"abcde", ~"bcd"); - assert contains(~"abcde", ~"abcd"); - assert contains(~"abcde", ~"bcde"); - assert contains(~"abcde", ~""); - assert contains(~"", ~""); - assert !contains(~"abcde", ~"def"); - assert !contains(~"", ~"a"); + fail_unless!(contains(~"abcde", ~"bcd")); + fail_unless!(contains(~"abcde", ~"abcd")); + fail_unless!(contains(~"abcde", ~"bcde")); + fail_unless!(contains(~"abcde", ~"")); + fail_unless!(contains(~"", ~"")); + fail_unless!(!contains(~"abcde", ~"def")); + fail_unless!(!contains(~"", ~"a")); let data = ~"ประเทศไทย中华Việt Nam"; - assert contains(data, ~"ประเ"); - assert contains(data, ~"ะเ"); - assert contains(data, ~"中华"); - assert !contains(data, ~"ไท华"); + fail_unless!(contains(data, ~"ประเ")); + fail_unless!(contains(data, ~"ะเ")); + fail_unless!(contains(data, ~"中华")); + fail_unless!(!contains(data, ~"ไท华")); } #[test] fn test_contains_char() { - assert contains_char(~"abc", 'b'); - assert contains_char(~"a", 'a'); - assert !contains_char(~"abc", 'd'); - assert !contains_char(~"", 'a'); + fail_unless!(contains_char(~"abc", 'b')); + fail_unless!(contains_char(~"a", 'a')); + fail_unless!(!contains_char(~"abc", 'd')); + fail_unless!(!contains_char(~"", 'a')); } #[test] @@ -3213,9 +3215,9 @@ mod tests { let mut i = 0; for chars_each(~"x\u03c0y") |ch| { match i { - 0 => assert ch == 'x', - 1 => assert ch == '\u03c0', - 2 => assert ch == 'y', + 0 => fail_unless!(ch == 'x'), + 1 => fail_unless!(ch == '\u03c0'), + 2 => fail_unless!(ch == 'y'), _ => fail!(~"test_chars_each failed") } i += 1; @@ -3230,16 +3232,16 @@ mod tests { for bytes_each(~"xyz") |bb| { match i { - 0 => assert bb == 'x' as u8, - 1 => assert bb == 'y' as u8, - 2 => assert bb == 'z' as u8, + 0 => fail_unless!(bb == 'x' as u8), + 1 => fail_unless!(bb == 'y' as u8), + 2 => fail_unless!(bb == 'z' as u8), _ => fail!(~"test_bytes_each failed") } i += 1; } for bytes_each(~"") |bb| { - assert bb == 0u8; + fail_unless!(bb == 0u8); } } @@ -3251,10 +3253,10 @@ mod tests { for split_char_each(data, ' ') |xx| { match ii { - 0 => assert "\nMary" == xx, - 1 => assert "had" == xx, - 2 => assert "a" == xx, - 3 => assert "little" == xx, + 0 => fail_unless!("\nMary" == xx), + 1 => fail_unless!("had" == xx), + 2 => fail_unless!("a" == xx), + 3 => fail_unless!("little" == xx), _ => () } ii += 1; @@ -3269,9 +3271,9 @@ mod tests { for splitn_char_each(data, ' ', 2u) |xx| { match ii { - 0 => assert "\nMary" == xx, - 1 => assert "had" == xx, - 2 => assert "a little lamb\nLittle lamb\n" == xx, + 0 => fail_unless!("\nMary" == xx), + 1 => fail_unless!("had" == xx), + 2 => fail_unless!("a little lamb\nLittle lamb\n" == xx), _ => () } ii += 1; @@ -3286,10 +3288,10 @@ mod tests { for words_each(data) |ww| { match ii { - 0 => assert "Mary" == ww, - 1 => assert "had" == ww, - 2 => assert "a" == ww, - 3 => assert "little" == ww, + 0 => fail_unless!("Mary" == ww), + 1 => fail_unless!("had" == ww), + 2 => fail_unless!("a" == ww), + 3 => fail_unless!("little" == ww), _ => () } ii += 1; @@ -3306,10 +3308,10 @@ mod tests { for lines_each(lf) |x| { match ii { - 0 => assert "" == x, - 1 => assert "Mary had a little lamb" == x, - 2 => assert "Little lamb" == x, - 3 => assert "" == x, + 0 => fail_unless!("" == x), + 1 => fail_unless!("Mary had a little lamb" == x), + 2 => fail_unless!("Little lamb" == x), + 3 => fail_unless!("" == x), _ => () } ii += 1; @@ -3319,35 +3321,36 @@ mod tests { #[test] fn test_map() { unsafe { - assert ~"" == map(~"", |c| libc::toupper(c as c_char) as char); - assert ~"YMCA" == map(~"ymca", - |c| libc::toupper(c as c_char) as char); + fail_unless!(~"" == map(~"", |c| libc::toupper(c as c_char) as char)); + fail_unless!(~"YMCA" == map(~"ymca", + |c| libc::toupper(c as c_char) as char)); } } #[test] fn test_all() { - assert true == all(~"", char::is_uppercase); - assert false == all(~"ymca", char::is_uppercase); - assert true == all(~"YMCA", char::is_uppercase); - assert false == all(~"yMCA", char::is_uppercase); - assert false == all(~"YMCy", char::is_uppercase); + fail_unless!(true == all(~"", char::is_uppercase)); + fail_unless!(false == all(~"ymca", char::is_uppercase)); + fail_unless!(true == all(~"YMCA", char::is_uppercase)); + fail_unless!(false == all(~"yMCA", char::is_uppercase)); + fail_unless!(false == all(~"YMCy", char::is_uppercase)); } #[test] fn test_any() { - assert false == any(~"", char::is_uppercase); - assert false == any(~"ymca", char::is_uppercase); - assert true == any(~"YMCA", char::is_uppercase); - assert true == any(~"yMCA", char::is_uppercase); - assert true == any(~"Ymcy", char::is_uppercase); + fail_unless!(false == any(~"", char::is_uppercase)); + fail_unless!(false == any(~"ymca", char::is_uppercase)); + fail_unless!(true == any(~"YMCA", char::is_uppercase)); + fail_unless!(true == any(~"yMCA", char::is_uppercase)); + fail_unless!(true == any(~"Ymcy", char::is_uppercase)); } #[test] fn test_chars() { let ss = ~"ศไทย中华Việt Nam"; - assert ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'] - == chars(ss); + fail_unless!(~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a', + 'm'] + == chars(ss)); } #[test] @@ -3391,10 +3394,10 @@ mod tests { for vec::each(pairs) |p| { let (s, u) = copy *p; - assert to_utf16(s) == u; - assert from_utf16(u) == s; - assert from_utf16(to_utf16(s)) == s; - assert to_utf16(from_utf16(u)) == u; + fail_unless!(to_utf16(s) == u); + fail_unless!(from_utf16(u) == s); + fail_unless!(from_utf16(to_utf16(s)) == s); + fail_unless!(to_utf16(from_utf16(u)) == u); } } @@ -3408,40 +3411,41 @@ mod tests { break; } } - assert found_b; + fail_unless!(found_b); } #[test] fn test_escape_unicode() { - assert escape_unicode(~"abc") == ~"\\x61\\x62\\x63"; - assert escape_unicode(~"a c") == ~"\\x61\\x20\\x63"; - assert escape_unicode(~"\r\n\t") == ~"\\x0d\\x0a\\x09"; - assert escape_unicode(~"'\"\\") == ~"\\x27\\x22\\x5c"; - assert escape_unicode(~"\x00\x01\xfe\xff") == ~"\\x00\\x01\\xfe\\xff"; - assert escape_unicode(~"\u0100\uffff") == ~"\\u0100\\uffff"; - assert escape_unicode(~"\U00010000\U0010ffff") == - ~"\\U00010000\\U0010ffff"; - assert escape_unicode(~"ab\ufb00") == ~"\\x61\\x62\\ufb00"; - assert escape_unicode(~"\U0001d4ea\r") == ~"\\U0001d4ea\\x0d"; + fail_unless!(escape_unicode(~"abc") == ~"\\x61\\x62\\x63"); + fail_unless!(escape_unicode(~"a c") == ~"\\x61\\x20\\x63"); + fail_unless!(escape_unicode(~"\r\n\t") == ~"\\x0d\\x0a\\x09"); + fail_unless!(escape_unicode(~"'\"\\") == ~"\\x27\\x22\\x5c"); + fail_unless!(escape_unicode(~"\x00\x01\xfe\xff") == + ~"\\x00\\x01\\xfe\\xff"); + fail_unless!(escape_unicode(~"\u0100\uffff") == ~"\\u0100\\uffff"); + fail_unless!(escape_unicode(~"\U00010000\U0010ffff") == + ~"\\U00010000\\U0010ffff"); + fail_unless!(escape_unicode(~"ab\ufb00") == ~"\\x61\\x62\\ufb00"); + fail_unless!(escape_unicode(~"\U0001d4ea\r") == ~"\\U0001d4ea\\x0d"); } #[test] fn test_escape_default() { - assert escape_default(~"abc") == ~"abc"; - assert escape_default(~"a c") == ~"a c"; - assert escape_default(~"\r\n\t") == ~"\\r\\n\\t"; - assert escape_default(~"'\"\\") == ~"\\'\\\"\\\\"; - assert escape_default(~"\u0100\uffff") == ~"\\u0100\\uffff"; - assert escape_default(~"\U00010000\U0010ffff") == - ~"\\U00010000\\U0010ffff"; - assert escape_default(~"ab\ufb00") == ~"ab\\ufb00"; - assert escape_default(~"\U0001d4ea\r") == ~"\\U0001d4ea\\r"; + fail_unless!(escape_default(~"abc") == ~"abc"); + fail_unless!(escape_default(~"a c") == ~"a c"); + fail_unless!(escape_default(~"\r\n\t") == ~"\\r\\n\\t"); + fail_unless!(escape_default(~"'\"\\") == ~"\\'\\\"\\\\"); + fail_unless!(escape_default(~"\u0100\uffff") == ~"\\u0100\\uffff"); + fail_unless!(escape_default(~"\U00010000\U0010ffff") == + ~"\\U00010000\\U0010ffff"); + fail_unless!(escape_default(~"ab\ufb00") == ~"ab\\ufb00"); + fail_unless!(escape_default(~"\U0001d4ea\r") == ~"\\U0001d4ea\\r"); } #[test] fn test_to_managed() { - assert (~"abc").to_managed() == @"abc"; - assert view("abcdef", 1, 5).to_managed() == @"bcde"; + fail_unless!((~"abc").to_managed() == @"abc"); + fail_unless!(view("abcdef", 1, 5).to_managed() == @"bcde"); } #[test] diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index bbcbd73aabd..d4db61f4519 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -156,6 +156,13 @@ pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { } } +pub pure fn fail_assert(msg: &str, file: &str, line: uint) -> ! { + unsafe { + let (msg, file) = (msg.to_owned(), file.to_owned()); + begin_unwind(~"assertion failed: " + msg, file, line) + } +} + #[cfg(test)] pub mod tests { use cast; @@ -163,10 +170,10 @@ pub mod tests { #[test] pub fn size_of_basic() { - assert size_of::() == 1u; - assert size_of::() == 2u; - assert size_of::() == 4u; - assert size_of::() == 8u; + fail_unless!(size_of::() == 1u); + fail_unless!(size_of::() == 2u); + fail_unless!(size_of::() == 4u); + fail_unless!(size_of::() == 8u); } #[test] @@ -174,30 +181,30 @@ pub mod tests { #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] pub fn size_of_32() { - assert size_of::() == 4u; - assert size_of::<*uint>() == 4u; + fail_unless!(size_of::() == 4u); + fail_unless!(size_of::<*uint>() == 4u); } #[test] #[cfg(target_arch = "x86_64")] pub fn size_of_64() { - assert size_of::() == 8u; - assert size_of::<*uint>() == 8u; + fail_unless!(size_of::() == 8u); + fail_unless!(size_of::<*uint>() == 8u); } #[test] pub fn nonzero_size_of_basic() { type Z = [i8 * 0]; - assert size_of::() == 0u; - assert nonzero_size_of::() == 1u; - assert nonzero_size_of::() == size_of::(); + fail_unless!(size_of::() == 0u); + fail_unless!(nonzero_size_of::() == 1u); + fail_unless!(nonzero_size_of::() == size_of::()); } #[test] pub fn align_of_basic() { - assert pref_align_of::() == 1u; - assert pref_align_of::() == 2u; - assert pref_align_of::() == 4u; + fail_unless!(pref_align_of::() == 1u); + fail_unless!(pref_align_of::() == 2u); + fail_unless!(pref_align_of::() == 4u); } #[test] @@ -205,15 +212,15 @@ pub mod tests { #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] pub fn align_of_32() { - assert pref_align_of::() == 4u; - assert pref_align_of::<*uint>() == 4u; + fail_unless!(pref_align_of::() == 4u); + fail_unless!(pref_align_of::<*uint>() == 4u); } #[test] #[cfg(target_arch = "x86_64")] pub fn align_of_64() { - assert pref_align_of::() == 8u; - assert pref_align_of::<*uint>() == 8u; + fail_unless!(pref_align_of::() == 8u); + fail_unless!(pref_align_of::<*uint>() == 8u); } #[test] @@ -222,7 +229,7 @@ pub mod tests { let x = 10; let f: fn(int) -> int = |y| x + y; - assert f(20) == 30; + fail_unless!(f(20) == 30); let original_closure: Closure = cast::transmute(f); @@ -235,7 +242,7 @@ pub mod tests { }; let new_f: fn(int) -> int = cast::transmute(new_closure); - assert new_f(20) == 30; + fail_unless!(new_f(20) == 30); } } } diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 725bb4ff89f..b0b597182e1 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -92,16 +92,16 @@ fn test_tls_multitask() { do task::spawn { unsafe { // TLS shouldn't carry over. - assert local_data_get(my_key).is_none(); + fail_unless!(local_data_get(my_key).is_none()); local_data_set(my_key, @~"child data"); - assert *(local_data_get(my_key).get()) == ~"child data"; + fail_unless!(*(local_data_get(my_key).get()) == ~"child data"); // should be cleaned up for us } } // Must work multiple times - assert *(local_data_get(my_key).get()) == ~"parent data"; - assert *(local_data_get(my_key).get()) == ~"parent data"; - assert *(local_data_get(my_key).get()) == ~"parent data"; + fail_unless!(*(local_data_get(my_key).get()) == ~"parent data"); + fail_unless!(*(local_data_get(my_key).get()) == ~"parent data"); + fail_unless!(*(local_data_get(my_key).get()) == ~"parent data"); } } @@ -111,7 +111,7 @@ fn test_tls_overwrite() { fn my_key(_x: @~str) { } local_data_set(my_key, @~"first data"); local_data_set(my_key, @~"next data"); // Shouldn't leak. - assert *(local_data_get(my_key).get()) == ~"next data"; + fail_unless!(*(local_data_get(my_key).get()) == ~"next data"); } } @@ -120,9 +120,9 @@ fn test_tls_pop() { unsafe { fn my_key(_x: @~str) { } local_data_set(my_key, @~"weasel"); - assert *(local_data_pop(my_key).get()) == ~"weasel"; + fail_unless!(*(local_data_pop(my_key).get()) == ~"weasel"); // Pop must remove the data from the map. - assert local_data_pop(my_key).is_none(); + fail_unless!(local_data_pop(my_key).is_none()); } } @@ -143,7 +143,7 @@ fn test_tls_modify() { None => fail!(~"missing value") } }); - assert *(local_data_pop(my_key).get()) == ~"next data"; + fail_unless!(*(local_data_pop(my_key).get()) == ~"next data"); } } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index fc152765322..cb1283019eb 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -43,7 +43,7 @@ type TaskLocalMap = @dvec::DVec>; extern fn cleanup_task_local_map(map_ptr: *libc::c_void) { unsafe { - assert !map_ptr.is_null(); + fail_unless!(!map_ptr.is_null()); // Get and keep the single reference that was created at the // beginning. let _map: TaskLocalMap = cast::reinterpret_cast(&map_ptr); diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 0a471e6dfa0..a6aa365ac33 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -848,14 +848,14 @@ fn test_add_wrapper() { fn test_future_result() { let mut result = None; do task().future_result(|+r| { result = Some(r); }).spawn { } - assert option::unwrap(result).recv() == Success; + fail_unless!(option::unwrap(result).recv() == Success); result = None; do task().future_result(|+r| { result = Some(r); }).unlinked().spawn { fail!(); } - assert option::unwrap(result).recv() == Failure; + fail_unless!(option::unwrap(result).recv() == Failure); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -901,7 +901,7 @@ fn test_spawn_sched() { do spawn_sched(SingleThreaded) { let child_sched_id = unsafe { rt::rust_get_sched_id() }; - assert parent_sched_id != child_sched_id; + fail_unless!(parent_sched_id != child_sched_id); if (i == 0) { ch.send(()); @@ -929,8 +929,8 @@ fn test_spawn_sched_childs_on_default_sched() { do spawn { let ch = ch.f.swap_unwrap(); let child_sched_id = unsafe { rt::rust_get_sched_id() }; - assert parent_sched_id != child_sched_id; - assert child_sched_id == default_id; + fail_unless!(parent_sched_id != child_sched_id); + fail_unless!(child_sched_id == default_id); ch.send(()); }; }; @@ -1022,7 +1022,7 @@ fn avoid_copying_the_body(spawnfn: &fn(v: ~fn())) { } let x_in_child = p.recv(); - assert x_in_parent == x_in_child; + fail_unless!(x_in_parent == x_in_child); } #[test] @@ -1177,7 +1177,7 @@ fn test_sched_thread_per_core() { unsafe { let cores = rt::rust_num_threads(); let reported_threads = rt::rust_sched_threads(); - assert(cores as uint == reported_threads as uint); + fail_unless!((cores as uint == reported_threads as uint)); chan.send(()); } } @@ -1192,9 +1192,9 @@ fn test_spawn_thread_on_demand() { do spawn_sched(ManualThreads(2)) || { unsafe { let max_threads = rt::rust_sched_threads(); - assert(max_threads as int == 2); + fail_unless!((max_threads as int == 2)); let running_threads = rt::rust_sched_current_nonlazy_threads(); - assert(running_threads as int == 1); + fail_unless!((running_threads as int == 1)); let (port2, chan2) = comm::stream(); @@ -1203,7 +1203,7 @@ fn test_spawn_thread_on_demand() { } let running_threads2 = rt::rust_sched_current_nonlazy_threads(); - assert(running_threads2 as int == 2); + fail_unless!((running_threads2 as int == 2)); port2.recv(); chan.send(()); diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 9605e4a4356..7b7ec769fa9 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -102,11 +102,11 @@ fn new_taskset() -> TaskSet { } fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) { let didnt_overwrite = tasks.insert(task); - assert didnt_overwrite; + fail_unless!(didnt_overwrite); } fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); - assert was_present; + fail_unless!(was_present); } pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { tasks.each(|k| blk(*k)) @@ -230,7 +230,7 @@ fn each_ancestor(list: &mut AncestorList, // NB: Takes a lock! (this ancestor node) do access_ancestors(ancestor_arc) |nobe| { // Check monotonicity - assert last_generation > nobe.generation; + fail_unless!(last_generation > nobe.generation); /*##########################################################* * Step 1: Look at this ancestor group (call iterator block). *##########################################################*/ @@ -422,7 +422,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { } } for taskset_each(&group.descendants) |child| { - assert child != me; + fail_unless!(child != me); rt::rust_task_kill_other(child); } // Only one task should ever do this. @@ -497,7 +497,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) } None => 0 // the actual value doesn't really matter. }; - assert new_generation < uint::max_value; + fail_unless!(new_generation < uint::max_value); // Build a new node in the ancestor list. AncestorList(Some(unstable::exclusive(AncestorNode { generation: new_generation, @@ -544,7 +544,7 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) { DefaultScheduler => rt::new_task(), _ => new_task_in_sched(opts.sched) }; - assert !new_task.is_null(); + fail_unless!(!new_task.is_null()); // Getting killed after here would leak the task. let mut notify_chan = if opts.notify_chan.is_none() { None @@ -716,7 +716,7 @@ fn test_spawn_raw_notify_success() { }; do spawn_raw(opts) { } - assert notify_po.recv() == Success; + fail_unless!(notify_po.recv() == Success); } #[test] @@ -733,5 +733,5 @@ fn test_spawn_raw_notify_failure() { do spawn_raw(opts) { fail!(); } - assert notify_po.recv() == Failure; + fail_unless!(notify_po.recv() == Failure); } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 3b5d1f9e2ae..8215152ef74 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -140,31 +140,31 @@ impl ToStr for @[A] { mod tests { #[test] fn test_simple_types() { - assert 1i.to_str() == ~"1"; - assert (-1i).to_str() == ~"-1"; - assert 200u.to_str() == ~"200"; - assert 2u8.to_str() == ~"2"; - assert true.to_str() == ~"true"; - assert false.to_str() == ~"false"; - assert ().to_str() == ~"()"; - assert (~"hi").to_str() == ~"hi"; - assert (@"hi").to_str() == ~"hi"; + fail_unless!(1i.to_str() == ~"1"); + fail_unless!((-1i).to_str() == ~"-1"); + fail_unless!(200u.to_str() == ~"200"); + fail_unless!(2u8.to_str() == ~"2"); + fail_unless!(true.to_str() == ~"true"); + fail_unless!(false.to_str() == ~"false"); + fail_unless!(().to_str() == ~"()"); + fail_unless!((~"hi").to_str() == ~"hi"); + fail_unless!((@"hi").to_str() == ~"hi"); } #[test] fn test_tuple_types() { - assert (1, 2).to_str() == ~"(1, 2)"; - assert (~"a", ~"b", false).to_str() == ~"(a, b, false)"; - assert ((), ((), 100)).to_str() == ~"((), ((), 100))"; + fail_unless!((1, 2).to_str() == ~"(1, 2)"); + fail_unless!((~"a", ~"b", false).to_str() == ~"(a, b, false)"); + fail_unless!(((), ((), 100)).to_str() == ~"((), ((), 100))"); } #[test] fn test_vectors() { let x: ~[int] = ~[]; - assert x.to_str() == ~"[]"; - assert (~[1]).to_str() == ~"[1]"; - assert (~[1, 2, 3]).to_str() == ~"[1, 2, 3]"; - assert (~[~[], ~[1], ~[1, 1]]).to_str() == - ~"[[], [1], [1, 1]]"; + fail_unless!(x.to_str() == ~"[]"); + fail_unless!((~[1]).to_str() == ~"[1]"); + fail_unless!((~[1, 2, 3]).to_str() == ~"[1, 2, 3]"); + fail_unless!((~[~[], ~[1], ~[1, 1]]).to_str() == + ~"[[], [1], [1, 1]]"); } } diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 02c14b155bb..395772df571 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -327,7 +327,7 @@ fn remove(count: &mut uint, child: &mut Child, key: uint, #[cfg(test)] pub fn check_integrity(trie: &TrieNode) { - assert trie.count != 0; + fail_unless!(trie.count != 0); let mut sum = 0; @@ -342,7 +342,7 @@ pub fn check_integrity(trie: &TrieNode) { } } - assert sum == trie.count; + fail_unless!(sum == trie.count); } #[cfg(test)] @@ -356,32 +356,32 @@ mod tests { let n = 300; for uint::range_step(1, n, 2) |x| { - 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 uint::range_step(0, n, 2) |x| { - 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 uint::range(0, n) |x| { - 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 uint::range_step(1, n, 2) |x| { - 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 uint::range_step(0, n, 2) |x| { - 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); } } @@ -390,16 +390,16 @@ mod tests { fn test_each() { 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 = 0; for m.each |&(k, v)| { - assert k == n; - assert *v == n * 2; + fail_unless!(k == n); + fail_unless!(*v == n * 2); n += 1; } } @@ -415,10 +415,10 @@ mod tests { let mut n = uint::max_value - 9999; for m.each |&(k, v)| { if n == uint::max_value - 5000 { break } - assert n < uint::max_value - 5000; + fail_unless!(n < uint::max_value - 5000); - assert k == n; - assert *v == n / 2; + fail_unless!(k == n); + fail_unless!(*v == n / 2); n += 1; } } @@ -427,16 +427,16 @@ mod tests { 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; for m.each_reverse |&(k, v)| { - assert k == n; - assert *v == n * 2; + fail_unless!(k == n); + fail_unless!(*v == n * 2); n -= 1; } } @@ -452,10 +452,10 @@ mod tests { let mut n = uint::max_value; for m.each_reverse |&(k, v)| { if n == uint::max_value - 5000 { break } - assert n > uint::max_value - 5000; + fail_unless!(n > uint::max_value - 5000); - assert k == n; - assert *v == n / 2; + fail_unless!(k == n); + fail_unless!(*v == n / 2); n -= 1; } } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 14d35078d0d..e41ff424012 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -202,15 +202,15 @@ impl Ord for (A, B, C) { #[test] fn test_tuple_ref() { let x = (~"foo", ~"bar"); - assert x.first_ref() == &~"foo"; - assert x.second_ref() == &~"bar"; + fail_unless!(x.first_ref() == &~"foo"); + fail_unless!(x.second_ref() == &~"bar"); } #[test] #[allow(non_implicitly_copyable_typarams)] fn test_tuple() { - assert (948, 4039.48).first() == 948; - assert (34.5, ~"foo").second() == ~"foo"; - assert ('a', 2).swap() == (2, 'a'); + fail_unless!((948, 4039.48).first() == 948); + fail_unless!((34.5, ~"foo").second() == ~"foo"); + fail_unless!(('a', 2).swap() == (2, 'a')); } diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index 8f084343c1a..96cd732d815 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -83,7 +83,7 @@ fn test_run_in_bare_thread() { unsafe { let i = 100; do run_in_bare_thread { - assert i == 100; + fail_unless!(i == 100); } } } @@ -94,7 +94,7 @@ fn test_run_in_bare_thread_exchange() { // Does the exchange heap work without the runtime? let i = ~100; do run_in_bare_thread { - assert i == ~100; + fail_unless!(i == ~100); } } } @@ -127,7 +127,7 @@ impl Drop for ArcDestruct{ let data: ~ArcData = cast::reinterpret_cast(&self.data); let new_count = intrinsics::atomic_xsub(&mut data.count, 1) - 1; - assert new_count >= 0; + fail_unless!(new_count >= 0); if new_count == 0 { // drop glue takes over. } else { @@ -167,7 +167,7 @@ pub unsafe fn get_shared_mutable_state( { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); - assert ptr.count > 0; + fail_unless!(ptr.count > 0); let r = cast::transmute(option::get_ref(&ptr.data)); cast::forget(ptr); return r; @@ -178,7 +178,7 @@ pub unsafe fn get_shared_immutable_state( rc: &a/SharedMutableState) -> &a/T { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); - assert ptr.count > 0; + fail_unless!(ptr.count > 0); // Cast us back into the correct region let r = cast::transmute_region(option::get_ref(&ptr.data)); cast::forget(ptr); @@ -191,7 +191,7 @@ pub unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); let new_count = intrinsics::atomic_xadd(&mut ptr.count, 1) + 1; - assert new_count >= 2; + fail_unless!(new_count >= 2); cast::forget(ptr); } ArcDestruct((*rc).data) @@ -342,7 +342,7 @@ pub mod tests { for futures.each |f| { f.recv() } do total.with |total| { - assert **total == num_tasks * count + fail_unless!(**total == num_tasks * count) }; } @@ -354,11 +354,11 @@ pub mod tests { let x2 = x.clone(); do task::try || { do x2.with |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do x.with |one| { - assert *one == 1; + fail_unless!(*one == 1); } } } diff --git a/src/libcore/unstable/at_exit.rs b/src/libcore/unstable/at_exit.rs index 58aba77e41e..f878161eca1 100644 --- a/src/libcore/unstable/at_exit.rs +++ b/src/libcore/unstable/at_exit.rs @@ -79,7 +79,7 @@ fn test_at_exit() { let i = 10; do at_exit { debug!("at_exit1"); - assert i == 10; + fail_unless!(i == 10); } } @@ -89,8 +89,8 @@ fn test_at_exit_many() { for uint::range(20, 100) |j| { do at_exit { debug!("at_exit2"); - assert i == 10; - assert j > i; + fail_unless!(i == 10); + fail_unless!(j > i); } } } diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs index f59037445eb..a2815cebc51 100644 --- a/src/libcore/unstable/exchange_alloc.rs +++ b/src/libcore/unstable/exchange_alloc.rs @@ -20,11 +20,11 @@ use intrinsic::TyDesc; pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void { unsafe { - assert td.is_not_null(); + fail_unless!(td.is_not_null()); let total_size = get_box_size(size, (*td).align); let p = c_malloc(total_size as size_t); - assert p.is_not_null(); + fail_unless!(p.is_not_null()); // FIXME #3475: Converting between our two different tydesc types let td: *TyDesc = transmute(td); @@ -46,7 +46,7 @@ pub unsafe fn free(ptr: *c_void) { let exchange_count = &mut *rust_get_exchange_count_ptr(); atomic_xsub(exchange_count, 1); - assert ptr.is_not_null(); + fail_unless!(ptr.is_not_null()); c_free(ptr); } @@ -60,7 +60,7 @@ fn get_box_size(body_size: uint, body_align: uint) -> uint { // Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power // of two. fn align_to(size: uint, align: uint) -> uint { - assert align != 0; + fail_unless!(align != 0); (size + align - 1) & !(align - 1) } diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index 08328c5af8a..b682f88b70e 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -340,11 +340,11 @@ pub mod ct { parse_count(s, 0, s.len()) == Parsed::new(count, next) } - assert test("", CountImplied, 0); - assert test("*", CountIsNextParam, 1); - assert test("*1", CountIsNextParam, 1); - assert test("*1$", CountIsParam(1), 3); - assert test("123", CountIs(123), 3); + fail_unless!(test("", CountImplied, 0)); + fail_unless!(test("*", CountIsNextParam, 1)); + fail_unless!(test("*1", CountIsNextParam, 1)); + fail_unless!(test("*1$", CountIsParam(1), 3)); + fail_unless!(test("123", CountIs(123), 3)); } #[test] @@ -355,8 +355,8 @@ pub mod ct { fn test(s: &str, flags: &[Flag], next: uint) { let f = parse_flags(s, 0, s.len()); - assert pack(f.val) == pack(flags); - assert f.next == next; + fail_unless!(pack(f.val) == pack(flags)); + fail_unless!(f.next == next); } test("", [], 0); @@ -367,7 +367,7 @@ pub mod ct { #[test] fn test_parse_fmt_string() { - assert parse_fmt_string("foo %s bar", die) == ~[ + fail_unless!(parse_fmt_string("foo %s bar", die) == ~[ PieceString(~"foo "), PieceConv(Conv { param: None, @@ -376,19 +376,19 @@ pub mod ct { precision: CountImplied, ty: TyStr, }), - PieceString(~" bar")]; + PieceString(~" bar")]); - assert parse_fmt_string("%s", die) == ~[ + fail_unless!(parse_fmt_string("%s", die) == ~[ PieceConv(Conv { param: None, flags: ~[], width: CountImplied, precision: CountImplied, ty: TyStr, - })]; + })]); - assert parse_fmt_string("%%%%", die) == ~[ - PieceString(~"%"), PieceString(~"%")]; + fail_unless!(parse_fmt_string("%%%%", die) == ~[ + PieceString(~"%"), PieceString(~"%")]); } #[test] @@ -397,10 +397,10 @@ pub mod ct { parse_parameter(s, 0, s.len()) == Parsed::new(param, next) } - assert test("", None, 0); - assert test("foo", None, 0); - assert test("123", None, 0); - assert test("123$", Some(123), 4); + fail_unless!(test("", None, 0)); + fail_unless!(test("foo", None, 0)); + fail_unless!(test("123", None, 0)); + fail_unless!(test("123$", Some(123), 4)); } #[test] @@ -409,12 +409,12 @@ pub mod ct { parse_precision(s, 0, s.len()) == Parsed::new(count, next) } - assert test("", CountImplied, 0); - assert test(".", CountIs(0), 1); - assert test(".*", CountIsNextParam, 2); - assert test(".*1", CountIsNextParam, 2); - assert test(".*1$", CountIsParam(1), 4); - assert test(".123", CountIs(123), 4); + fail_unless!(test("", CountImplied, 0)); + fail_unless!(test(".", CountIs(0), 1)); + fail_unless!(test(".*", CountIsNextParam, 2)); + fail_unless!(test(".*1", CountIsNextParam, 2)); + fail_unless!(test(".*1$", CountIsParam(1), 4)); + fail_unless!(test(".123", CountIs(123), 4)); } #[test] @@ -423,17 +423,17 @@ pub mod ct { parse_type(s, 0, s.len(), die) == Parsed::new(ty, 1) } - assert test("b", TyBool); - assert test("c", TyChar); - assert test("d", TyInt(Signed)); - assert test("f", TyFloat); - assert test("i", TyInt(Signed)); - assert test("o", TyOctal); - assert test("s", TyStr); - assert test("t", TyBits); - assert test("x", TyHex(CaseLower)); - assert test("X", TyHex(CaseUpper)); - assert test("?", TyPoly); + fail_unless!(test("b", TyBool)); + fail_unless!(test("c", TyChar)); + fail_unless!(test("d", TyInt(Signed))); + fail_unless!(test("f", TyFloat)); + fail_unless!(test("i", TyInt(Signed))); + fail_unless!(test("o", TyOctal)); + fail_unless!(test("s", TyStr)); + fail_unless!(test("t", TyBits)); + fail_unless!(test("x", TyHex(CaseLower))); + fail_unless!(test("X", TyHex(CaseUpper))); + fail_unless!(test("?", TyPoly)); } #[test] @@ -453,16 +453,16 @@ pub mod ct { #[test] fn test_peek_num() { let s1 = ""; - assert peek_num(s1, 0, s1.len()).is_none(); + fail_unless!(peek_num(s1, 0, s1.len()).is_none()); let s2 = "foo"; - assert peek_num(s2, 0, s2.len()).is_none(); + fail_unless!(peek_num(s2, 0, s2.len()).is_none()); let s3 = "123"; - assert peek_num(s3, 0, s3.len()) == Some(Parsed::new(123, 3)); + fail_unless!(peek_num(s3, 0, s3.len()) == Some(Parsed::new(123, 3))); let s4 = "123foo"; - assert peek_num(s4, 0, s4.len()) == Some(Parsed::new(123, 3)); + fail_unless!(peek_num(s4, 0, s4.len()) == Some(Parsed::new(123, 3))); } } diff --git a/src/libcore/unstable/finally.rs b/src/libcore/unstable/finally.rs index 3ad580389df..5089470e6ef 100644 --- a/src/libcore/unstable/finally.rs +++ b/src/libcore/unstable/finally.rs @@ -57,11 +57,11 @@ fn test_success() { do (|| { i = 10; }).finally { - assert !failing(); - assert i == 10; + fail_unless!(!failing()); + fail_unless!(i == 10); i = 20; } - assert i == 20; + fail_unless!(i == 20); } #[test] @@ -73,8 +73,8 @@ fn test_fail() { i = 10; fail!(); }).finally { - assert failing(); - assert i == 10; + fail_unless!(failing()); + fail_unless!(i == 10); } } @@ -82,7 +82,7 @@ fn test_fail() { fn test_retval() { let closure: &fn() -> int = || 10; let i = do closure.finally { }; - assert i == 10; + fail_unless!(i == 10); } #[test] diff --git a/src/libcore/unstable/global.rs b/src/libcore/unstable/global.rs index ac42e26fedd..654bf18a5b6 100644 --- a/src/libcore/unstable/global.rs +++ b/src/libcore/unstable/global.rs @@ -187,7 +187,7 @@ fn get_global_state() -> Exclusive { let prev_i = unsafe { atomic_cxchg(&mut *global_ptr, 0, state_i) }; // Sanity check that we're not trying to reinitialize after shutdown - assert prev_i != POISON; + fail_unless!(prev_i != POISON); if prev_i == 0 { // Successfully installed the global pointer @@ -201,7 +201,7 @@ fn get_global_state() -> Exclusive { let prev_i = unsafe { atomic_cxchg(&mut *global_ptr, state_i, POISON) }; - assert prev_i == state_i; + fail_unless!(prev_i == state_i); // Capture the global state object in the at_exit closure // so that it is destroyed at the right time @@ -245,7 +245,7 @@ fn test_clone_rc() { ~shared_mutable_state(10) }; - assert get_shared_immutable_state(&val) == &10; + fail_unless!(get_shared_immutable_state(&val) == &10); } } } @@ -273,7 +273,7 @@ fn test_modify() { match v { Some(sms) => { let v = get_shared_immutable_state(sms); - assert *v == 10; + fail_unless!(*v == 10); None }, _ => fail!() diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs index 7f420123465..7e9742fecbb 100644 --- a/src/libcore/unstable/weak_task.rs +++ b/src/libcore/unstable/weak_task.rs @@ -40,7 +40,7 @@ pub unsafe fn weaken_task(f: &fn(Port)) { let shutdown_port = Cell(shutdown_port); let task = get_task_id(); // Expect the weak task service to be alive - assert service.try_send(RegisterWeakTask(task, shutdown_chan)); + fail_unless!(service.try_send(RegisterWeakTask(task, shutdown_chan))); unsafe { rust_dec_kernel_live_count(); } do (|| { f(shutdown_port.take()) @@ -102,7 +102,7 @@ fn run_weak_task_service(port: Port) { RegisterWeakTask(task, shutdown_chan) => { let previously_unregistered = shutdown_map.insert(task, shutdown_chan); - assert previously_unregistered; + fail_unless!(previously_unregistered); } UnregisterWeakTask(task) => { match shutdown_map.pop(&task) { diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 742eee7dc27..214a9dea8d1 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -82,7 +82,7 @@ terminate normally, but instead directly return from a function. ~~~ fn choose_weighted_item(v: &[Item]) -> Item { - assert !v.is_empty(); + fail_unless!(!v.is_empty()); let mut so_far = 0u; for v.each |item| { so_far += item.weight; @@ -110,23 +110,23 @@ mod tests { pub fn identity_crisis() { // Writing a test for the identity function. How did it come to this? let x = ~[(5, false)]; - //FIXME #3387 assert x.eq(id(copy x)); + //FIXME #3387 fail_unless!(x.eq(id(copy x))); let y = copy x; - assert x.eq(&id(y)); + fail_unless!(x.eq(&id(y))); } #[test] pub fn test_swap() { let mut x = 31337; let mut y = 42; swap(&mut x, &mut y); - assert x == 42; - assert y == 31337; + fail_unless!(x == 42); + fail_unless!(y == 31337); } #[test] pub fn test_replace() { let mut x = Some(NonCopyable()); 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/libcore/vec.rs b/src/libcore/vec.rs index c749cbad3de..1a8a2518ab0 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -257,8 +257,8 @@ pub pure fn last_opt(v: &r/[T]) -> Option<&r/T> { /// Return a slice that points into another slice. #[inline(always)] pub pure fn slice(v: &r/[T], start: uint, end: uint) -> &r/[T] { - assert (start <= end); - assert (end <= len(v)); + fail_unless!((start <= end)); + fail_unless!((end <= len(v))); do as_imm_buf(v) |p, _len| { unsafe { ::cast::reinterpret_cast( @@ -274,8 +274,8 @@ pub pure fn mut_slice(v: &r/mut [T], start: uint, end: uint) -> &r/mut [T] { - assert (start <= end); - assert (end <= len(v)); + fail_unless!((start <= end)); + fail_unless!((end <= len(v))); do as_mut_buf(v) |p, _len| { unsafe { ::cast::reinterpret_cast( @@ -291,8 +291,8 @@ pub pure fn const_slice(v: &r/[const T], start: uint, end: uint) -> &r/[const T] { - assert (start <= end); - assert (end <= len(v)); + fail_unless!((start <= end)); + fail_unless!((end <= len(v))); do as_const_buf(v) |p, _len| { unsafe { ::cast::reinterpret_cast( @@ -448,7 +448,7 @@ pub pure fn partitioned(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { /// Removes the first element from a vector and return it pub fn shift(v: &mut ~[T]) -> T { unsafe { - assert !v.is_empty(); + fail_unless!(!v.is_empty()); if v.len() == 1 { return v.pop() } @@ -465,7 +465,7 @@ pub fn shift(v: &mut ~[T]) -> T { // Save the last element. We're going to overwrite its position let mut work_elt = v.pop(); // We still should have room to work where what last element was - assert capacity(v) >= ln; + fail_unless!(capacity(v) >= ln); // Pretend like we have the original length so we can use // the vector copy_memory to overwrite the hole we just made raw::set_len(&mut *v, ln); @@ -511,7 +511,7 @@ pub fn unshift(v: &mut ~[T], x: T) { /// elements after position i one position to the right. pub fn insert(v: &mut ~[T], i: uint, x: T) { let len = v.len(); - assert i <= len; + fail_unless!(i <= len); v.push(x); let mut j = len; @@ -525,7 +525,7 @@ pub fn insert(v: &mut ~[T], i: uint, x: T) { /// all elements after position i one position to the left. pub fn remove(v: &mut ~[T], i: uint) -> T { let len = v.len(); - assert i < len; + fail_unless!(i < len); let mut j = i; while j < len - 1 { @@ -650,7 +650,7 @@ pub fn push_all_move(v: &mut ~[T], mut rhs: ~[T]) { /// Shorten a vector, dropping excess elements. pub fn truncate(v: &mut ~[T], newlen: uint) { do as_mut_buf(*v) |p, oldlen| { - assert(newlen <= oldlen); + fail_unless!((newlen <= oldlen)); unsafe { // This loop is optimized out for non-drop types. for uint::range(newlen, oldlen) |i| { @@ -1148,8 +1148,8 @@ pub pure fn position(v: &[T], f: fn(t: &T) -> bool) -> Option { */ pub pure fn position_between(v: &[T], start: uint, end: uint, f: fn(t: &T) -> bool) -> Option { - assert start <= end; - assert end <= len(v); + fail_unless!(start <= end); + fail_unless!(end <= len(v)); let mut i = start; while i < end { if f(&v[i]) { return Some::(i); } i += 1u; } return None; @@ -1181,8 +1181,8 @@ pub pure fn rposition(v: &[T], f: fn(t: &T) -> bool) -> Option { */ pub pure fn rposition_between(v: &[T], start: uint, end: uint, f: fn(t: &T) -> bool) -> Option { - assert start <= end; - assert end <= len(v); + fail_unless!(start <= end); + fail_unless!(end <= len(v)); let mut i = end; while i > start { if f(&v[i - 1u]) { return Some::(i - 1u); } @@ -1238,7 +1238,7 @@ pub pure fn zip_slice(v: &[const T], u: &[const U]) let mut zipped = ~[]; let sz = len(v); let mut i = 0u; - assert sz == len(u); + fail_unless!(sz == len(u)); while i < sz { unsafe { zipped.push((v[i], u[i])); i += 1u; } } @@ -1253,7 +1253,7 @@ pub pure fn zip_slice(v: &[const T], u: &[const U]) */ pub pure fn zip(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] { let mut i = len(v); - assert i == len(u); + fail_unless!(i == len(u)); let mut w = with_capacity(i); while i > 0 { unsafe { w.push((v.pop(),u.pop())); } @@ -1432,7 +1432,7 @@ pub pure fn rev_eachi(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) { */ #[inline] pub pure fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { - assert len(v1) == len(v2); + fail_unless!(len(v1) == len(v2)); for uint::range(0u, len(v1)) |i| { if !f(&v1[i], &v2[i]) { return; @@ -1476,7 +1476,7 @@ pub pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) { pub pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { let mut ww = ~[]; - assert 1u <= nn; + fail_unless!(1u <= nn); for vec::eachi (xx) |ii, _x| { let len = vec::len(xx); if ii+nn <= len { @@ -2195,8 +2195,8 @@ pub mod raw { #[inline(always)] pub unsafe fn copy_memory(dst: &mut [T], src: &[const T], count: uint) { - assert dst.len() >= count; - assert src.len() >= count; + fail_unless!(dst.len() >= count); + fail_unless!(src.len() >= count); do as_mut_buf(dst) |p_dst, _len_dst| { do as_const_buf(src) |p_src, _len_src| { @@ -2522,21 +2522,21 @@ mod tests { let a = ~[1, 2, 3]; let mut ptr = raw::to_ptr(a); let b = from_buf(ptr, 3u); - assert (len(b) == 3u); - assert (b[0] == 1); - assert (b[1] == 2); - assert (b[2] == 3); + fail_unless!((len(b) == 3u)); + fail_unless!((b[0] == 1)); + fail_unless!((b[1] == 2)); + fail_unless!((b[2] == 3)); // Test on-heap copy-from-buf. let c = ~[1, 2, 3, 4, 5]; ptr = raw::to_ptr(c); let d = from_buf(ptr, 5u); - assert (len(d) == 5u); - assert (d[0] == 1); - assert (d[1] == 2); - assert (d[2] == 3); - assert (d[3] == 4); - assert (d[4] == 5); + fail_unless!((len(d) == 5u)); + fail_unless!((d[0] == 1)); + fail_unless!((d[1] == 2)); + fail_unless!((d[2] == 3)); + fail_unless!((d[3] == 4)); + fail_unless!((d[4] == 5)); } } @@ -2544,43 +2544,43 @@ mod tests { fn test_from_fn() { // Test on-stack from_fn. let mut v = from_fn(3u, square); - assert (len(v) == 3u); - assert (v[0] == 0u); - assert (v[1] == 1u); - assert (v[2] == 4u); + fail_unless!((len(v) == 3u)); + fail_unless!((v[0] == 0u)); + fail_unless!((v[1] == 1u)); + fail_unless!((v[2] == 4u)); // Test on-heap from_fn. v = from_fn(5u, square); - assert (len(v) == 5u); - assert (v[0] == 0u); - assert (v[1] == 1u); - assert (v[2] == 4u); - assert (v[3] == 9u); - assert (v[4] == 16u); + fail_unless!((len(v) == 5u)); + fail_unless!((v[0] == 0u)); + fail_unless!((v[1] == 1u)); + fail_unless!((v[2] == 4u)); + fail_unless!((v[3] == 9u)); + fail_unless!((v[4] == 16u)); } #[test] fn test_from_elem() { // Test on-stack from_elem. let mut v = from_elem(2u, 10u); - assert (len(v) == 2u); - assert (v[0] == 10u); - assert (v[1] == 10u); + fail_unless!((len(v) == 2u)); + fail_unless!((v[0] == 10u)); + fail_unless!((v[1] == 10u)); // Test on-heap from_elem. v = from_elem(6u, 20u); - assert (v[0] == 20u); - assert (v[1] == 20u); - assert (v[2] == 20u); - assert (v[3] == 20u); - assert (v[4] == 20u); - assert (v[5] == 20u); + fail_unless!((v[0] == 20u)); + fail_unless!((v[1] == 20u)); + fail_unless!((v[2] == 20u)); + fail_unless!((v[3] == 20u)); + fail_unless!((v[4] == 20u)); + fail_unless!((v[5] == 20u)); } #[test] fn test_is_empty() { - assert (is_empty::(~[])); - assert (!is_empty(~[0])); + fail_unless!((is_empty::(~[]))); + fail_unless!((!is_empty(~[0]))); } #[test] @@ -2589,18 +2589,18 @@ mod tests { let v0 : &[Z] = &[]; let v1 : &[Z] = &[[]]; let v2 : &[Z] = &[[], []]; - assert(sys::size_of::() == 0); - assert(len(v0) == 0); - assert(len(v1) == 1); - assert(len(v2) == 2); + fail_unless!((sys::size_of::() == 0)); + fail_unless!((len(v0) == 0)); + fail_unless!((len(v1) == 1)); + fail_unless!((len(v2) == 2)); } #[test] fn test_head() { let mut a = ~[11]; - assert a.head() == &11; + fail_unless!(a.head() == &11); a = ~[11, 12]; - assert a.head() == &11; + fail_unless!(a.head() == &11); } #[test] @@ -2614,19 +2614,19 @@ mod tests { #[test] fn test_head_opt() { let mut a = ~[]; - assert a.head_opt() == None; + fail_unless!(a.head_opt() == None); a = ~[11]; - assert a.head_opt().unwrap() == &11; + fail_unless!(a.head_opt().unwrap() == &11); a = ~[11, 12]; - assert a.head_opt().unwrap() == &11; + fail_unless!(a.head_opt().unwrap() == &11); } #[test] fn test_tail() { let mut a = ~[11]; - assert a.tail() == &[]; + fail_unless!(a.tail() == &[]); a = ~[11, 12]; - assert a.tail() == &[12]; + fail_unless!(a.tail() == &[12]); } #[test] @@ -2640,9 +2640,9 @@ mod tests { #[test] fn test_tailn() { let mut a = ~[11, 12, 13]; - assert a.tailn(0) == &[11, 12, 13]; + fail_unless!(a.tailn(0) == &[11, 12, 13]); a = ~[11, 12, 13]; - assert a.tailn(2) == &[13]; + fail_unless!(a.tailn(2) == &[13]); } #[test] @@ -2656,9 +2656,9 @@ mod tests { #[test] fn test_init() { let mut a = ~[11]; - assert a.init() == &[]; + fail_unless!(a.init() == &[]); a = ~[11, 12]; - assert a.init() == &[11]; + fail_unless!(a.init() == &[11]); } #[init] @@ -2672,9 +2672,9 @@ mod tests { #[test] fn test_initn() { let mut a = ~[11, 12, 13]; - assert a.initn(0) == &[11, 12, 13]; + fail_unless!(a.initn(0) == &[11, 12, 13]); a = ~[11, 12, 13]; - assert a.initn(2) == &[11]; + fail_unless!(a.initn(2) == &[11]); } #[init] @@ -2688,9 +2688,9 @@ mod tests { #[test] fn test_last() { let mut a = ~[11]; - assert a.last() == &11; + fail_unless!(a.last() == &11); a = ~[11, 12]; - assert a.last() == &12; + fail_unless!(a.last() == &12); } #[test] @@ -2703,11 +2703,11 @@ mod tests { #[test] fn test_last_opt() { let mut a = ~[]; - assert a.last_opt() == None; + fail_unless!(a.last_opt() == None); a = ~[11]; - assert a.last_opt().unwrap() == &11; + fail_unless!(a.last_opt().unwrap() == &11); a = ~[11, 12]; - assert a.last_opt().unwrap() == &12; + fail_unless!(a.last_opt().unwrap() == &12); } #[test] @@ -2715,35 +2715,35 @@ mod tests { // Test fixed length vector. let vec_fixed = [1, 2, 3, 4]; let v_a = slice(vec_fixed, 1u, len(vec_fixed)).to_vec(); - assert (len(v_a) == 3u); - assert (v_a[0] == 2); - assert (v_a[1] == 3); - assert (v_a[2] == 4); + fail_unless!((len(v_a) == 3u)); + fail_unless!((v_a[0] == 2)); + fail_unless!((v_a[1] == 3)); + fail_unless!((v_a[2] == 4)); // Test on stack. let vec_stack = &[1, 2, 3]; let v_b = slice(vec_stack, 1u, 3u).to_vec(); - assert (len(v_b) == 2u); - assert (v_b[0] == 2); - assert (v_b[1] == 3); + fail_unless!((len(v_b) == 2u)); + fail_unless!((v_b[0] == 2)); + fail_unless!((v_b[1] == 3)); // Test on managed heap. let vec_managed = @[1, 2, 3, 4, 5]; let v_c = slice(vec_managed, 0u, 3u).to_vec(); - assert (len(v_c) == 3u); - assert (v_c[0] == 1); - assert (v_c[1] == 2); - assert (v_c[2] == 3); + fail_unless!((len(v_c) == 3u)); + fail_unless!((v_c[0] == 1)); + fail_unless!((v_c[1] == 2)); + fail_unless!((v_c[2] == 3)); // Test on exchange heap. let vec_unique = ~[1, 2, 3, 4, 5, 6]; let v_d = slice(vec_unique, 1u, 6u).to_vec(); - assert (len(v_d) == 5u); - assert (v_d[0] == 2); - assert (v_d[1] == 3); - assert (v_d[2] == 4); - assert (v_d[3] == 5); - assert (v_d[4] == 6); + fail_unless!((len(v_d) == 5u)); + fail_unless!((v_d[0] == 2)); + fail_unless!((v_d[1] == 3)); + fail_unless!((v_d[2] == 4)); + fail_unless!((v_d[3] == 5)); + fail_unless!((v_d[4] == 6)); } #[test] @@ -2751,27 +2751,27 @@ mod tests { // Test on-heap pop. let mut v = ~[1, 2, 3, 4, 5]; let e = v.pop(); - assert (len(v) == 4u); - assert (v[0] == 1); - assert (v[1] == 2); - assert (v[2] == 3); - assert (v[3] == 4); - assert (e == 5); + fail_unless!((len(v) == 4u)); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 2)); + fail_unless!((v[2] == 3)); + fail_unless!((v[3] == 4)); + fail_unless!((e == 5)); } #[test] fn test_swap_remove() { let mut v = ~[1, 2, 3, 4, 5]; let mut e = v.swap_remove(0); - assert (len(v) == 4); - assert e == 1; - assert (v[0] == 5); + fail_unless!((len(v) == 4)); + fail_unless!(e == 1); + fail_unless!((v[0] == 5)); e = v.swap_remove(3); - assert (len(v) == 3); - assert e == 4; - assert (v[0] == 5); - assert (v[1] == 2); - assert (v[2] == 3); + fail_unless!((len(v) == 3)); + fail_unless!(e == 4); + fail_unless!((v[0] == 5)); + fail_unless!((v[1] == 2)); + fail_unless!((v[2] == 3)); } #[test] @@ -2780,11 +2780,11 @@ mod tests { let mut v = ~[::unstable::exclusive(()), ::unstable::exclusive(()), ::unstable::exclusive(())]; let mut _e = v.swap_remove(0); - assert (len(v) == 2); + fail_unless!((len(v) == 2)); _e = v.swap_remove(1); - assert (len(v) == 1); + fail_unless!((len(v) == 1)); _e = v.swap_remove(0); - assert (len(v) == 0); + fail_unless!((len(v) == 0)); } #[test] @@ -2792,14 +2792,14 @@ mod tests { // Test on-stack push(). let mut v = ~[]; v.push(1); - assert (len(v) == 1u); - assert (v[0] == 1); + fail_unless!((len(v) == 1u)); + fail_unless!((v[0] == 1)); // Test on-heap push(). v.push(2); - assert (len(v) == 2u); - assert (v[0] == 1); - assert (v[1] == 2); + fail_unless!((len(v) == 2u)); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 2)); } #[test] @@ -2807,48 +2807,48 @@ mod tests { // Test on-stack grow(). let mut v = ~[]; v.grow(2u, &1); - assert (len(v) == 2u); - assert (v[0] == 1); - assert (v[1] == 1); + fail_unless!((len(v) == 2u)); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 1)); // Test on-heap grow(). v.grow(3u, &2); - assert (len(v) == 5u); - assert (v[0] == 1); - assert (v[1] == 1); - assert (v[2] == 2); - assert (v[3] == 2); - assert (v[4] == 2); + fail_unless!((len(v) == 5u)); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 1)); + fail_unless!((v[2] == 2)); + fail_unless!((v[3] == 2)); + fail_unless!((v[4] == 2)); } #[test] fn test_grow_fn() { let mut v = ~[]; v.grow_fn(3u, square); - assert (len(v) == 3u); - assert (v[0] == 0u); - assert (v[1] == 1u); - assert (v[2] == 4u); + fail_unless!((len(v) == 3u)); + fail_unless!((v[0] == 0u)); + fail_unless!((v[1] == 1u)); + fail_unless!((v[2] == 4u)); } #[test] fn test_grow_set() { let mut v = ~[1, 2, 3]; v.grow_set(4u, &4, 5); - assert (len(v) == 5u); - assert (v[0] == 1); - assert (v[1] == 2); - assert (v[2] == 3); - assert (v[3] == 4); - assert (v[4] == 5); + fail_unless!((len(v) == 5u)); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 2)); + fail_unless!((v[2] == 3)); + fail_unless!((v[3] == 4)); + fail_unless!((v[4] == 5)); } #[test] fn test_truncate() { let mut v = ~[@6,@5,@4]; v.truncate(1); - assert(v.len() == 1); - assert(*(v[0]) == 6); + fail_unless!((v.len() == 1)); + fail_unless!((*(v[0]) == 6)); // If the unsafe block didn't drop things properly, we blow up here. } @@ -2856,7 +2856,7 @@ mod tests { fn test_clear() { let mut v = ~[@6,@5,@4]; v.clear(); - assert(v.len() == 0); + fail_unless!((v.len() == 0)); // If the unsafe block didn't drop things properly, we blow up here. } @@ -2865,7 +2865,7 @@ mod tests { fn case(a: ~[uint], b: ~[uint]) { let mut v = a; v.dedup(); - assert(v == b); + fail_unless!((v == b)); } case(~[], ~[]); case(~[1], ~[1]); @@ -2910,20 +2910,20 @@ mod tests { // Test on-stack map. let mut v = ~[1u, 2u, 3u]; let mut w = map(v, square_ref); - assert (len(w) == 3u); - assert (w[0] == 1u); - assert (w[1] == 4u); - assert (w[2] == 9u); + fail_unless!((len(w) == 3u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 4u)); + fail_unless!((w[2] == 9u)); // Test on-heap map. v = ~[1u, 2u, 3u, 4u, 5u]; w = map(v, square_ref); - assert (len(w) == 5u); - assert (w[0] == 1u); - assert (w[1] == 4u); - assert (w[2] == 9u); - assert (w[3] == 16u); - assert (w[4] == 25u); + fail_unless!((len(w) == 5u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 4u)); + fail_unless!((w[2] == 9u)); + fail_unless!((w[3] == 16u)); + fail_unless!((w[4] == 25u)); } #[test] @@ -2934,7 +2934,7 @@ mod tests { let v1 = ~[5, 4, 3, 2, 1]; let u = map2::(v0, v1, f); let mut i = 0; - while i < 5 { assert (v0[i] * v1[i] == u[i]); i += 1; } + while i < 5 { fail_unless!((v0[i] * v1[i] == u[i])); i += 1; } } #[test] @@ -2942,17 +2942,17 @@ mod tests { // Test on-stack filter-map. let mut v = ~[1u, 2u, 3u]; let mut w = filter_mapped(v, square_if_odd_r); - assert (len(w) == 2u); - assert (w[0] == 1u); - assert (w[1] == 9u); + fail_unless!((len(w) == 2u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 9u)); // Test on-heap filter-map. v = ~[1u, 2u, 3u, 4u, 5u]; w = filter_mapped(v, square_if_odd_r); - assert (len(w) == 3u); - assert (w[0] == 1u); - assert (w[1] == 9u); - assert (w[2] == 25u); + fail_unless!((len(w) == 3u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 9u)); + fail_unless!((w[2] == 25u)); fn halve(i: &int) -> Option { if *i % 2 == 0 { @@ -2967,11 +2967,11 @@ mod tests { let all_odd2: ~[int] = ~[]; let mix: ~[int] = ~[9, 2, 6, 7, 1, 0, 0, 3]; let mix_dest: ~[int] = ~[1, 3, 0, 0]; - assert (filter_mapped(all_even, halve) == - map(all_even, halve_for_sure)); - assert (filter_mapped(all_odd1, halve) == ~[]); - assert (filter_mapped(all_odd2, halve) == ~[]); - assert (filter_mapped(mix, halve) == mix_dest); + fail_unless!(filter_mapped(all_even, halve) == + map(all_even, halve_for_sure)); + fail_unless!((filter_mapped(all_odd1, halve) == ~[])); + fail_unless!((filter_mapped(all_odd2, halve) == ~[])); + fail_unless!((filter_mapped(mix, halve) == mix_dest)); } #[test] @@ -2979,17 +2979,17 @@ mod tests { // Test on-stack filter-map. let mut v = ~[1u, 2u, 3u]; let mut w = filter_map(v, square_if_odd_v); - assert (len(w) == 2u); - assert (w[0] == 1u); - assert (w[1] == 9u); + fail_unless!((len(w) == 2u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 9u)); // Test on-heap filter-map. v = ~[1u, 2u, 3u, 4u, 5u]; w = filter_map(v, square_if_odd_v); - assert (len(w) == 3u); - assert (w[0] == 1u); - assert (w[1] == 9u); - assert (w[2] == 25u); + fail_unless!((len(w) == 3u)); + fail_unless!((w[0] == 1u)); + fail_unless!((w[1] == 9u)); + fail_unless!((w[2] == 25u)); fn halve(i: int) -> Option { if i % 2 == 0 { @@ -3005,24 +3005,24 @@ mod tests { let all_odd2: ~[int] = ~[]; let mix: ~[int] = ~[9, 2, 6, 7, 1, 0, 0, 3]; let mix_dest: ~[int] = ~[1, 3, 0, 0]; - assert (filter_map(all_even, halve) == - map(all_even0, halve_for_sure)); - assert (filter_map(all_odd1, halve) == ~[]); - assert (filter_map(all_odd2, halve) == ~[]); - assert (filter_map(mix, halve) == mix_dest); + fail_unless!(filter_map(all_even, halve) == + map(all_even0, halve_for_sure)); + fail_unless!((filter_map(all_odd1, halve) == ~[])); + fail_unless!((filter_map(all_odd2, halve) == ~[])); + fail_unless!((filter_map(mix, halve) == mix_dest)); } #[test] fn test_filter() { - assert filter(~[1u, 2u, 3u], is_odd) == ~[1u, 3u]; - assert filter(~[1u, 2u, 4u, 8u, 16u], is_three) == ~[]; + fail_unless!(filter(~[1u, 2u, 3u], is_odd) == ~[1u, 3u]); + fail_unless!(filter(~[1u, 2u, 4u, 8u, 16u], is_three) == ~[]); } #[test] fn test_retain() { let mut v = ~[1, 2, 3, 4, 5]; v.retain(is_odd); - assert v == ~[1, 3, 5]; + fail_unless!(v == ~[1, 3, 5]); } #[test] @@ -3030,12 +3030,12 @@ mod tests { // Test on-stack fold. let mut v = ~[1u, 2u, 3u]; let mut sum = foldl(0u, v, add); - assert (sum == 6u); + fail_unless!((sum == 6u)); // Test on-heap fold. v = ~[1u, 2u, 3u, 4u, 5u]; sum = foldl(0u, v, add); - assert (sum == 15u); + fail_unless!((sum == 15u)); } #[test] @@ -3045,7 +3045,7 @@ mod tests { } let mut v = ~[1, 2, 3, 4]; let sum = foldl(0, v, sub); - assert sum == -10; + fail_unless!(sum == -10); } #[test] @@ -3055,7 +3055,7 @@ mod tests { } let mut v = ~[1, 2, 3, 4]; let sum = foldr(v, 0, sub); - assert sum == -2; + fail_unless!(sum == -2); } #[test] @@ -3071,18 +3071,18 @@ mod tests { for each(~[1, 2, 3]) |v| { i += *v; } - assert i == 6; + fail_unless!(i == 6); } #[test] fn test_iteri() { let mut i = 0; for eachi(~[1, 2, 3]) |j, v| { - if i == 0 { assert *v == 1; } - assert j + 1u == *v as uint; + if i == 0 { fail_unless!(*v == 1); } + fail_unless!(j + 1u == *v as uint); i += *v; } - assert i == 6; + fail_unless!(i == 6); } #[test] @@ -3096,21 +3096,21 @@ mod tests { fn test_reach_nonempty() { let mut i = 0; for rev_each(~[1, 2, 3]) |v| { - if i == 0 { assert *v == 3; } + if i == 0 { fail_unless!(*v == 3); } i += *v } - assert i == 6; + fail_unless!(i == 6); } #[test] fn test_reachi() { let mut i = 0; for rev_eachi(~[0, 1, 2]) |j, v| { - if i == 0 { assert *v == 2; } - assert j == *v as uint; + if i == 0 { fail_unless!(*v == 2); } + fail_unless!(j == *v as uint); i += *v; } - assert i == 3; + fail_unless!(i == 3); } #[test] @@ -3119,47 +3119,47 @@ mod tests { results = ~[]; for each_permutation(~[]) |v| { results.push(from_slice(v)); } - assert results == ~[~[]]; + fail_unless!(results == ~[~[]]); results = ~[]; for each_permutation(~[7]) |v| { results.push(from_slice(v)); } - assert results == ~[~[7]]; + fail_unless!(results == ~[~[7]]); results = ~[]; for each_permutation(~[1,1]) |v| { results.push(from_slice(v)); } - assert results == ~[~[1,1],~[1,1]]; + fail_unless!(results == ~[~[1,1],~[1,1]]); results = ~[]; for each_permutation(~[5,2,0]) |v| { results.push(from_slice(v)); } - assert results == - ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]; + fail_unless!(results == + ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]); } #[test] fn test_any_and_all() { - assert (any(~[1u, 2u, 3u], is_three)); - assert (!any(~[0u, 1u, 2u], is_three)); - assert (any(~[1u, 2u, 3u, 4u, 5u], is_three)); - assert (!any(~[1u, 2u, 4u, 5u, 6u], is_three)); + fail_unless!((any(~[1u, 2u, 3u], is_three))); + fail_unless!((!any(~[0u, 1u, 2u], is_three))); + fail_unless!((any(~[1u, 2u, 3u, 4u, 5u], is_three))); + fail_unless!((!any(~[1u, 2u, 4u, 5u, 6u], is_three))); - assert (all(~[3u, 3u, 3u], is_three)); - assert (!all(~[3u, 3u, 2u], is_three)); - assert (all(~[3u, 3u, 3u, 3u, 3u], is_three)); - assert (!all(~[3u, 3u, 0u, 1u, 2u], is_three)); + fail_unless!((all(~[3u, 3u, 3u], is_three))); + fail_unless!((!all(~[3u, 3u, 2u], is_three))); + fail_unless!((all(~[3u, 3u, 3u, 3u, 3u], is_three))); + fail_unless!((!all(~[3u, 3u, 0u, 1u, 2u], is_three))); } #[test] fn test_any2_and_all2() { - assert (any2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal)); - assert (any2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal)); - assert (!any2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal)); - assert (any2(~[2u, 4u, 6u], ~[2u, 4u], is_equal)); + fail_unless!((any2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal))); + fail_unless!((any2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal))); + fail_unless!((!any2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal))); + fail_unless!((any2(~[2u, 4u, 6u], ~[2u, 4u], is_equal))); - assert (all2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal)); - assert (!all2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal)); - assert (!all2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal)); - assert (!all2(~[2u, 4u, 6u], ~[2u, 4u], is_equal)); + fail_unless!((all2(~[2u, 4u, 6u], ~[2u, 4u, 6u], is_equal))); + fail_unless!((!all2(~[1u, 2u, 3u], ~[4u, 5u, 3u], is_equal))); + fail_unless!((!all2(~[1u, 2u, 3u], ~[4u, 5u, 6u], is_equal))); + fail_unless!((!all2(~[2u, 4u, 6u], ~[2u, 4u], is_equal))); } #[test] @@ -3169,26 +3169,26 @@ mod tests { let z1 = zip(v1, v2); - assert ((1, 4) == z1[0]); - assert ((2, 5) == z1[1]); - assert ((3, 6) == z1[2]); + fail_unless!(((1, 4) == z1[0])); + fail_unless!(((2, 5) == z1[1])); + fail_unless!(((3, 6) == z1[2])); let (left, right) = unzip(z1); - assert ((1, 4) == (left[0], right[0])); - assert ((2, 5) == (left[1], right[1])); - assert ((3, 6) == (left[2], right[2])); + fail_unless!(((1, 4) == (left[0], right[0]))); + fail_unless!(((2, 5) == (left[1], right[1]))); + fail_unless!(((3, 6) == (left[2], right[2]))); } #[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 position_elem(v1, &1) == Some(0u); - assert position_elem(v1, &2) == Some(1u); - assert position_elem(v1, &5) == Some(5u); - assert position_elem(v1, &4).is_none(); + fail_unless!(position_elem(v1, &1) == Some(0u)); + fail_unless!(position_elem(v1, &2) == Some(1u)); + fail_unless!(position_elem(v1, &5) == Some(5u)); + fail_unless!(position_elem(v1, &4).is_none()); } #[test] @@ -3196,178 +3196,178 @@ mod tests { fn less_than_three(i: &int) -> bool { return *i < 3; } fn is_eighteen(i: &int) -> bool { return *i == 18; } - assert position(~[], less_than_three).is_none(); + fail_unless!(position(~[], less_than_three).is_none()); let v1 = ~[5, 4, 3, 2, 1]; - assert position(v1, less_than_three) == Some(3u); - assert position(v1, is_eighteen).is_none(); + fail_unless!(position(v1, less_than_three) == Some(3u)); + fail_unless!(position(v1, is_eighteen).is_none()); } #[test] fn test_position_between() { - assert position_between(~[], 0u, 0u, f).is_none(); + fail_unless!(position_between(~[], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert position_between(v, 0u, 0u, f).is_none(); - assert position_between(v, 0u, 1u, f).is_none(); - assert position_between(v, 0u, 2u, f) == Some(1u); - assert position_between(v, 0u, 3u, f) == Some(1u); - assert position_between(v, 0u, 4u, f) == Some(1u); + fail_unless!(position_between(v, 0u, 0u, f).is_none()); + fail_unless!(position_between(v, 0u, 1u, f).is_none()); + fail_unless!(position_between(v, 0u, 2u, f) == Some(1u)); + fail_unless!(position_between(v, 0u, 3u, f) == Some(1u)); + fail_unless!(position_between(v, 0u, 4u, f) == Some(1u)); - assert position_between(v, 1u, 1u, f).is_none(); - assert position_between(v, 1u, 2u, f) == Some(1u); - assert position_between(v, 1u, 3u, f) == Some(1u); - assert position_between(v, 1u, 4u, f) == Some(1u); + fail_unless!(position_between(v, 1u, 1u, f).is_none()); + fail_unless!(position_between(v, 1u, 2u, f) == Some(1u)); + fail_unless!(position_between(v, 1u, 3u, f) == Some(1u)); + fail_unless!(position_between(v, 1u, 4u, f) == Some(1u)); - assert position_between(v, 2u, 2u, f).is_none(); - assert position_between(v, 2u, 3u, f).is_none(); - assert position_between(v, 2u, 4u, f) == Some(3u); + fail_unless!(position_between(v, 2u, 2u, f).is_none()); + fail_unless!(position_between(v, 2u, 3u, f).is_none()); + fail_unless!(position_between(v, 2u, 4u, f) == Some(3u)); - assert position_between(v, 3u, 3u, f).is_none(); - assert position_between(v, 3u, 4u, f) == Some(3u); + fail_unless!(position_between(v, 3u, 3u, f).is_none()); + fail_unless!(position_between(v, 3u, 4u, f) == Some(3u)); - assert position_between(v, 4u, 4u, f).is_none(); + fail_unless!(position_between(v, 4u, 4u, f).is_none()); } #[test] fn test_find() { - assert find(~[], f).is_none(); + fail_unless!(find(~[], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert find(v, f) == Some((1, 'b')); - assert find(v, g).is_none(); + fail_unless!(find(v, f) == Some((1, 'b'))); + fail_unless!(find(v, g).is_none()); } #[test] fn test_find_between() { - assert find_between(~[], 0u, 0u, f).is_none(); + fail_unless!(find_between(~[], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert find_between(v, 0u, 0u, f).is_none(); - assert find_between(v, 0u, 1u, f).is_none(); - assert find_between(v, 0u, 2u, f) == Some((1, 'b')); - assert find_between(v, 0u, 3u, f) == Some((1, 'b')); - assert find_between(v, 0u, 4u, f) == Some((1, 'b')); + fail_unless!(find_between(v, 0u, 0u, f).is_none()); + fail_unless!(find_between(v, 0u, 1u, f).is_none()); + fail_unless!(find_between(v, 0u, 2u, f) == Some((1, 'b'))); + fail_unless!(find_between(v, 0u, 3u, f) == Some((1, 'b'))); + fail_unless!(find_between(v, 0u, 4u, f) == Some((1, 'b'))); - assert find_between(v, 1u, 1u, f).is_none(); - assert find_between(v, 1u, 2u, f) == Some((1, 'b')); - assert find_between(v, 1u, 3u, f) == Some((1, 'b')); - assert find_between(v, 1u, 4u, f) == Some((1, 'b')); + fail_unless!(find_between(v, 1u, 1u, f).is_none()); + fail_unless!(find_between(v, 1u, 2u, f) == Some((1, 'b'))); + fail_unless!(find_between(v, 1u, 3u, f) == Some((1, 'b'))); + fail_unless!(find_between(v, 1u, 4u, f) == Some((1, 'b'))); - assert find_between(v, 2u, 2u, f).is_none(); - assert find_between(v, 2u, 3u, f).is_none(); - assert find_between(v, 2u, 4u, f) == Some((3, 'b')); + fail_unless!(find_between(v, 2u, 2u, f).is_none()); + fail_unless!(find_between(v, 2u, 3u, f).is_none()); + fail_unless!(find_between(v, 2u, 4u, f) == Some((3, 'b'))); - assert find_between(v, 3u, 3u, f).is_none(); - assert find_between(v, 3u, 4u, f) == Some((3, 'b')); + fail_unless!(find_between(v, 3u, 3u, f).is_none()); + fail_unless!(find_between(v, 3u, 4u, f) == Some((3, 'b'))); - assert find_between(v, 4u, 4u, f).is_none(); + fail_unless!(find_between(v, 4u, 4u, f).is_none()); } #[test] fn test_rposition() { - assert find(~[], f).is_none(); + fail_unless!(find(~[], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert position(v, f) == Some(1u); - assert position(v, g).is_none(); + fail_unless!(position(v, f) == Some(1u)); + fail_unless!(position(v, g).is_none()); } #[test] fn test_rposition_between() { - assert rposition_between(~[], 0u, 0u, f).is_none(); + fail_unless!(rposition_between(~[], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert rposition_between(v, 0u, 0u, f).is_none(); - assert rposition_between(v, 0u, 1u, f).is_none(); - assert rposition_between(v, 0u, 2u, f) == Some(1u); - assert rposition_between(v, 0u, 3u, f) == Some(1u); - assert rposition_between(v, 0u, 4u, f) == Some(3u); + fail_unless!(rposition_between(v, 0u, 0u, f).is_none()); + fail_unless!(rposition_between(v, 0u, 1u, f).is_none()); + fail_unless!(rposition_between(v, 0u, 2u, f) == Some(1u)); + fail_unless!(rposition_between(v, 0u, 3u, f) == Some(1u)); + fail_unless!(rposition_between(v, 0u, 4u, f) == Some(3u)); - assert rposition_between(v, 1u, 1u, f).is_none(); - assert rposition_between(v, 1u, 2u, f) == Some(1u); - assert rposition_between(v, 1u, 3u, f) == Some(1u); - assert rposition_between(v, 1u, 4u, f) == Some(3u); + fail_unless!(rposition_between(v, 1u, 1u, f).is_none()); + fail_unless!(rposition_between(v, 1u, 2u, f) == Some(1u)); + fail_unless!(rposition_between(v, 1u, 3u, f) == Some(1u)); + fail_unless!(rposition_between(v, 1u, 4u, f) == Some(3u)); - assert rposition_between(v, 2u, 2u, f).is_none(); - assert rposition_between(v, 2u, 3u, f).is_none(); - assert rposition_between(v, 2u, 4u, f) == Some(3u); + fail_unless!(rposition_between(v, 2u, 2u, f).is_none()); + fail_unless!(rposition_between(v, 2u, 3u, f).is_none()); + fail_unless!(rposition_between(v, 2u, 4u, f) == Some(3u)); - assert rposition_between(v, 3u, 3u, f).is_none(); - assert rposition_between(v, 3u, 4u, f) == Some(3u); + fail_unless!(rposition_between(v, 3u, 3u, f).is_none()); + fail_unless!(rposition_between(v, 3u, 4u, f) == Some(3u)); - assert rposition_between(v, 4u, 4u, f).is_none(); + fail_unless!(rposition_between(v, 4u, 4u, f).is_none()); } #[test] fn test_rfind() { - assert rfind(~[], f).is_none(); + fail_unless!(rfind(~[], f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert rfind(v, f) == Some((3, 'b')); - assert rfind(v, g).is_none(); + fail_unless!(rfind(v, f) == Some((3, 'b'))); + fail_unless!(rfind(v, g).is_none()); } #[test] fn test_rfind_between() { - assert rfind_between(~[], 0u, 0u, f).is_none(); + fail_unless!(rfind_between(~[], 0u, 0u, f).is_none()); fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } let mut v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert rfind_between(v, 0u, 0u, f).is_none(); - assert rfind_between(v, 0u, 1u, f).is_none(); - assert rfind_between(v, 0u, 2u, f) == Some((1, 'b')); - assert rfind_between(v, 0u, 3u, f) == Some((1, 'b')); - assert rfind_between(v, 0u, 4u, f) == Some((3, 'b')); + fail_unless!(rfind_between(v, 0u, 0u, f).is_none()); + fail_unless!(rfind_between(v, 0u, 1u, f).is_none()); + fail_unless!(rfind_between(v, 0u, 2u, f) == Some((1, 'b'))); + fail_unless!(rfind_between(v, 0u, 3u, f) == Some((1, 'b'))); + fail_unless!(rfind_between(v, 0u, 4u, f) == Some((3, 'b'))); - assert rfind_between(v, 1u, 1u, f).is_none(); - assert rfind_between(v, 1u, 2u, f) == Some((1, 'b')); - assert rfind_between(v, 1u, 3u, f) == Some((1, 'b')); - assert rfind_between(v, 1u, 4u, f) == Some((3, 'b')); + fail_unless!(rfind_between(v, 1u, 1u, f).is_none()); + fail_unless!(rfind_between(v, 1u, 2u, f) == Some((1, 'b'))); + fail_unless!(rfind_between(v, 1u, 3u, f) == Some((1, 'b'))); + fail_unless!(rfind_between(v, 1u, 4u, f) == Some((3, 'b'))); - assert rfind_between(v, 2u, 2u, f).is_none(); - assert rfind_between(v, 2u, 3u, f).is_none(); - assert rfind_between(v, 2u, 4u, f) == Some((3, 'b')); + fail_unless!(rfind_between(v, 2u, 2u, f).is_none()); + fail_unless!(rfind_between(v, 2u, 3u, f).is_none()); + fail_unless!(rfind_between(v, 2u, 4u, f) == Some((3, 'b'))); - assert rfind_between(v, 3u, 3u, f).is_none(); - assert rfind_between(v, 3u, 4u, f) == Some((3, 'b')); + fail_unless!(rfind_between(v, 3u, 3u, f).is_none()); + fail_unless!(rfind_between(v, 3u, 4u, f) == Some((3, 'b'))); - assert rfind_between(v, 4u, 4u, f).is_none(); + fail_unless!(rfind_between(v, 4u, 4u, f).is_none()); } #[test] fn reverse_and_reversed() { let mut v: ~[int] = ~[10, 20]; - assert (v[0] == 10); - assert (v[1] == 20); + fail_unless!((v[0] == 10)); + fail_unless!((v[1] == 20)); reverse(v); - assert (v[0] == 20); - assert (v[1] == 10); + fail_unless!((v[0] == 20)); + fail_unless!((v[1] == 10)); let v2 = reversed::(~[10, 20]); - assert (v2[0] == 20); - assert (v2[1] == 10); + fail_unless!((v2[0] == 20)); + fail_unless!((v2[1] == 10)); v[0] = 30; - assert (v2[0] == 20); + fail_unless!((v2[0] == 20)); // Make sure they work with 0-length vectors too. let v4 = reversed::(~[]); - assert (v4 == ~[]); + fail_unless!((v4 == ~[])); let mut v3: ~[int] = ~[]; reverse::(v3); } @@ -3375,95 +3375,95 @@ mod tests { #[test] fn reversed_mut() { let mut v2 = reversed::(~[10, 20]); - assert (v2[0] == 20); - assert (v2[1] == 10); + fail_unless!((v2[0] == 20)); + fail_unless!((v2[1] == 10)); } #[test] fn test_split() { fn f(x: &int) -> bool { *x == 3 } - assert split(~[], f) == ~[]; - assert split(~[1, 2], f) == ~[~[1, 2]]; - assert split(~[3, 1, 2], f) == ~[~[], ~[1, 2]]; - assert split(~[1, 2, 3], f) == ~[~[1, 2], ~[]]; - assert split(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]; + fail_unless!(split(~[], f) == ~[]); + fail_unless!(split(~[1, 2], f) == ~[~[1, 2]]); + fail_unless!(split(~[3, 1, 2], f) == ~[~[], ~[1, 2]]); + fail_unless!(split(~[1, 2, 3], f) == ~[~[1, 2], ~[]]); + fail_unless!(split(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]); } #[test] fn test_splitn() { fn f(x: &int) -> bool { *x == 3 } - assert splitn(~[], 1u, f) == ~[]; - assert splitn(~[1, 2], 1u, f) == ~[~[1, 2]]; - assert splitn(~[3, 1, 2], 1u, f) == ~[~[], ~[1, 2]]; - assert splitn(~[1, 2, 3], 1u, f) == ~[~[1, 2], ~[]]; - assert splitn(~[1, 2, 3, 4, 3, 5], 1u, f) == - ~[~[1, 2], ~[4, 3, 5]]; + fail_unless!(splitn(~[], 1u, f) == ~[]); + fail_unless!(splitn(~[1, 2], 1u, f) == ~[~[1, 2]]); + fail_unless!(splitn(~[3, 1, 2], 1u, f) == ~[~[], ~[1, 2]]); + fail_unless!(splitn(~[1, 2, 3], 1u, f) == ~[~[1, 2], ~[]]); + fail_unless!(splitn(~[1, 2, 3, 4, 3, 5], 1u, f) == + ~[~[1, 2], ~[4, 3, 5]]); } #[test] fn test_rsplit() { fn f(x: &int) -> bool { *x == 3 } - assert rsplit(~[], f) == ~[]; - assert rsplit(~[1, 2], f) == ~[~[1, 2]]; - assert rsplit(~[1, 2, 3], f) == ~[~[1, 2], ~[]]; - assert rsplit(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]; + fail_unless!(rsplit(~[], f) == ~[]); + fail_unless!(rsplit(~[1, 2], f) == ~[~[1, 2]]); + fail_unless!(rsplit(~[1, 2, 3], f) == ~[~[1, 2], ~[]]); + fail_unless!(rsplit(~[1, 2, 3, 4, 3, 5], f) == ~[~[1, 2], ~[4], ~[5]]); } #[test] fn test_rsplitn() { fn f(x: &int) -> bool { *x == 3 } - assert rsplitn(~[], 1u, f) == ~[]; - assert rsplitn(~[1, 2], 1u, f) == ~[~[1, 2]]; - assert rsplitn(~[1, 2, 3], 1u, f) == ~[~[1, 2], ~[]]; - assert rsplitn(~[1, 2, 3, 4, 3, 5], 1u, f) == - ~[~[1, 2, 3, 4], ~[5]]; + fail_unless!(rsplitn(~[], 1u, f) == ~[]); + fail_unless!(rsplitn(~[1, 2], 1u, f) == ~[~[1, 2]]); + fail_unless!(rsplitn(~[1, 2, 3], 1u, f) == ~[~[1, 2], ~[]]); + fail_unless!(rsplitn(~[1, 2, 3, 4, 3, 5], 1u, f) == + ~[~[1, 2, 3, 4], ~[5]]); } #[test] fn test_partition() { // FIXME (#4355 maybe): using v.partition here crashes - assert partition(~[], |x: &int| *x < 3) == (~[], ~[]); - assert partition(~[1, 2, 3], |x: &int| *x < 4) == (~[1, 2, 3], ~[]); - assert partition(~[1, 2, 3], |x: &int| *x < 2) == (~[1], ~[2, 3]); - assert partition(~[1, 2, 3], |x: &int| *x < 0) == (~[], ~[1, 2, 3]); + fail_unless!(partition(~[], |x: &int| *x < 3) == (~[], ~[])); + fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 4) == (~[1, 2, 3], ~[])); + fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 2) == (~[1], ~[2, 3])); + fail_unless!(partition(~[1, 2, 3], |x: &int| *x < 0) == (~[], ~[1, 2, 3])); } #[test] fn test_partitioned() { - assert (~[]).partitioned(|x: &int| *x < 3) == (~[], ~[]); - assert (~[1, 2, 3]).partitioned(|x: &int| *x < 4) == - (~[1, 2, 3], ~[]); - assert (~[1, 2, 3]).partitioned(|x: &int| *x < 2) == - (~[1], ~[2, 3]); - assert (~[1, 2, 3]).partitioned(|x: &int| *x < 0) == - (~[], ~[1, 2, 3]); + fail_unless!((~[]).partitioned(|x: &int| *x < 3) == (~[], ~[])); + fail_unless!((~[1, 2, 3]).partitioned(|x: &int| *x < 4) == + (~[1, 2, 3], ~[])); + fail_unless!((~[1, 2, 3]).partitioned(|x: &int| *x < 2) == + (~[1], ~[2, 3])); + fail_unless!((~[1, 2, 3]).partitioned(|x: &int| *x < 0) == + (~[], ~[1, 2, 3])); } #[test] fn test_concat() { - assert concat(~[~[1], ~[2,3]]) == ~[1, 2, 3]; + fail_unless!(concat(~[~[1], ~[2,3]]) == ~[1, 2, 3]); } #[test] fn test_connect() { - assert connect(~[], &0) == ~[]; - assert connect(~[~[1], ~[2, 3]], &0) == ~[1, 0, 2, 3]; - assert connect(~[~[1], ~[2], ~[3]], &0) == ~[1, 0, 2, 0, 3]; + fail_unless!(connect(~[], &0) == ~[]); + fail_unless!(connect(~[~[1], ~[2, 3]], &0) == ~[1, 0, 2, 3]); + fail_unless!(connect(~[~[1], ~[2], ~[3]], &0) == ~[1, 0, 2, 0, 3]); } #[test] fn test_windowed () { - assert ~[~[1u,2u,3u],~[2u,3u,4u],~[3u,4u,5u],~[4u,5u,6u]] - == windowed (3u, ~[1u,2u,3u,4u,5u,6u]); + fail_unless!(~[~[1u,2u,3u],~[2u,3u,4u],~[3u,4u,5u],~[4u,5u,6u]] + == windowed (3u, ~[1u,2u,3u,4u,5u,6u])); - assert ~[~[1u,2u,3u,4u],~[2u,3u,4u,5u],~[3u,4u,5u,6u]] - == windowed (4u, ~[1u,2u,3u,4u,5u,6u]); + fail_unless!(~[~[1u,2u,3u,4u],~[2u,3u,4u,5u],~[3u,4u,5u,6u]] + == windowed (4u, ~[1u,2u,3u,4u,5u,6u])); - assert ~[] == windowed (7u, ~[1u,2u,3u,4u,5u,6u]); + fail_unless!(~[] == windowed (7u, ~[1u,2u,3u,4u,5u,6u])); } #[test] @@ -3477,26 +3477,26 @@ mod tests { fn test_unshift() { let mut x = ~[1, 2, 3]; x.unshift(0); - assert x == ~[0, 1, 2, 3]; + fail_unless!(x == ~[0, 1, 2, 3]); } #[test] fn test_insert() { let mut a = ~[1, 2, 4]; a.insert(2, 3); - assert a == ~[1, 2, 3, 4]; + fail_unless!(a == ~[1, 2, 3, 4]); let mut a = ~[1, 2, 3]; a.insert(0, 0); - assert a == ~[0, 1, 2, 3]; + fail_unless!(a == ~[0, 1, 2, 3]); let mut a = ~[1, 2, 3]; a.insert(3, 4); - assert a == ~[1, 2, 3, 4]; + fail_unless!(a == ~[1, 2, 3, 4]); let mut a = ~[]; a.insert(0, 1); - assert a == ~[1]; + fail_unless!(a == ~[1]); } #[test] @@ -3511,15 +3511,15 @@ mod tests { fn test_remove() { let mut a = ~[1, 2, 3, 4]; a.remove(2); - assert a == ~[1, 2, 4]; + fail_unless!(a == ~[1, 2, 4]); let mut a = ~[1, 2, 3]; a.remove(0); - assert a == ~[2, 3]; + fail_unless!(a == ~[2, 3]); let mut a = ~[1]; a.remove(0); - assert a == ~[]; + fail_unless!(a == ~[]); } #[test] @@ -3534,19 +3534,19 @@ mod tests { fn test_capacity() { let mut v = ~[0u64]; reserve(&mut v, 10u); - assert capacity(&v) == 10u; + fail_unless!(capacity(&v) == 10u); let mut v = ~[0u32]; reserve(&mut v, 10u); - assert capacity(&v) == 10u; + fail_unless!(capacity(&v) == 10u); } #[test] fn test_view() { let v = ~[1, 2, 3, 4, 5]; let v = v.view(1u, 3u); - assert(len(v) == 2u); - assert(v[0] == 2); - assert(v[1] == 3); + fail_unless!((len(v) == 2u)); + fail_unless!((v[0] == 2)); + fail_unless!((v[1] == 3)); } diff --git a/src/libfuzzer/ast_match.rs b/src/libfuzzer/ast_match.rs index afbe0c930cc..81048a69ca9 100644 --- a/src/libfuzzer/ast_match.rs +++ b/src/libfuzzer/ast_match.rs @@ -29,13 +29,13 @@ pure fn builtin_equal(&&a: T, &&b: T) -> bool { return a == b; } pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { return a == b; } fn main() { - assert (builtin_equal(5, 5)); - assert (!builtin_equal(5, 4)); - assert (!vec_equal(~[5, 5], ~[5], bind builtin_equal(_, _))); - assert (!vec_equal(~[5, 5], ~[5], builtin_equal_int)); - assert (!vec_equal(~[5, 5], ~[5, 4], builtin_equal_int)); - assert (!vec_equal(~[5, 5], ~[4, 5], builtin_equal_int)); - assert (vec_equal(~[5, 5], ~[5, 5], builtin_equal_int)); + fail_unless!((builtin_equal(5, 5))); + fail_unless!((!builtin_equal(5, 4))); + fail_unless!((!vec_equal(~[5, 5], ~[5], bind builtin_equal(_, _)))); + fail_unless!((!vec_equal(~[5, 5], ~[5], builtin_equal_int))); + fail_unless!((!vec_equal(~[5, 5], ~[5, 4], builtin_equal_int))); + fail_unless!((!vec_equal(~[5, 5], ~[4, 5], builtin_equal_int))); + fail_unless!((vec_equal(~[5, 5], ~[5, 5], builtin_equal_int))); error!("Pass"); } diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index fb4c6400434..7ea74b36940 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -14,12 +14,12 @@ use uint::range; // random uint less than n fn under(r : rand::rng, n : uint) -> uint { - assert n != 0u; r.next() as uint % n + fail_unless!(n != 0u); r.next() as uint % n } // random choice from a vec fn choice(r : rand::rng, v : ~[const T]) -> T { - assert vec::len(v) != 0u; v[under(r, vec::len(v))] + fail_unless!(vec::len(v) != 0u); v[under(r, vec::len(v))] } // k in n chance of being true diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 1eb4ff98a6e..8257af5760f 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -371,13 +371,13 @@ pub fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path, pub fn removeIfExists(filename: &Path) { // So sketchy! - assert !contains(filename.to_str(), ~" "); + fail_unless!(!contains(filename.to_str(), ~" ")); run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]); } pub fn removeDirIfExists(filename: &Path) { // So sketchy! - assert !contains(filename.to_str(), ~" "); + fail_unless!(!contains(filename.to_str(), ~" ")); run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]); } diff --git a/src/libfuzzer/rand_util.rs b/src/libfuzzer/rand_util.rs index 507d0666da0..25b1669d86f 100644 --- a/src/libfuzzer/rand_util.rs +++ b/src/libfuzzer/rand_util.rs @@ -13,12 +13,12 @@ use std::rand; // random uint less than n fn under(r : rand::rng, n : uint) -> uint { - assert n != 0u; r.next() as uint % n + fail_unless!(n != 0u); r.next() as uint % n } // random choice from a vec fn choice(r : rand::rng, v : ~[T]) -> T { - assert vec::len(v) != 0u; v[under(r, vec::len(v))] + fail_unless!(vec::len(v) != 0u); v[under(r, vec::len(v))] } // 1 in n chance of being true @@ -49,12 +49,12 @@ fn shuffled(r : rand::rng, v : ~[T]) -> ~[T] { // * weighted_vec is O(total weight) space type weighted = { weight: uint, item: T }; fn weighted_choice(r : rand::rng, v : ~[weighted]) -> T { - assert vec::len(v) != 0u; + fail_unless!(vec::len(v) != 0u); let total = 0u; for {weight: weight, item: _} in v { total += weight; } - assert total >= 0u; + fail_unless!(total >= 0u); let chosen = under(r, total); let so_far = 0u; for {weight: weight, item: item} in v { diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index ce51bb9229e..2d98a84aee9 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -118,7 +118,7 @@ pub fn get_rpath_relative_to_output(os: session::os, -> Path { use core::os; - assert not_win32(os); + fail_unless!(not_win32(os)); // Mac doesn't appear to support $ORIGIN let prefix = match os { @@ -134,8 +134,8 @@ pub fn get_rpath_relative_to_output(os: session::os, // Find the relative path from one file to another pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { - assert abs1.is_absolute; - assert abs2.is_absolute; + fail_unless!(abs1.is_absolute); + fail_unless!(abs2.is_absolute); let abs1 = abs1.normalize(); let abs2 = abs2.normalize(); debug!("finding relative path from %s to %s", @@ -144,8 +144,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { let split2 = /*bad*/copy abs2.components; let len1 = vec::len(split1); let len2 = vec::len(split2); - assert len1 > 0; - assert len2 > 0; + fail_unless!(len1 > 0); + fail_unless!(len2 > 0); let max_common_path = uint::min(len1, len2) - 1; let mut start_idx = 0; @@ -215,7 +215,7 @@ mod test { pub fn test_rpaths_to_flags() { let flags = rpaths_to_flags(~[Path("path1"), Path("path2")]); - assert flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]; + fail_unless!(flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]); } #[test] @@ -226,13 +226,13 @@ mod test { debug!("test_prefix_path: %s vs. %s", res.to_str(), d.to_str()); - assert str::ends_with(res.to_str(), d.to_str()); + fail_unless!(str::ends_with(res.to_str(), d.to_str())); } #[test] pub fn test_prefix_rpath_abs() { let res = get_install_prefix_rpath("triple"); - assert res.is_absolute; + fail_unless!(res.is_absolute); } #[test] @@ -240,7 +240,7 @@ mod test { let res = minimize_rpaths([Path("rpath1"), Path("rpath2"), Path("rpath1")]); - assert res == ~[Path("rpath1"), Path("rpath2")]; + fail_unless!(res == ~[Path("rpath1"), Path("rpath2")]); } #[test] @@ -249,7 +249,7 @@ mod test { Path("1a"), Path("4a"),Path("1a"), Path("2"), Path("3"), Path("4a"), Path("3")]); - assert res == ~[Path("1a"), Path("2"), Path("4a"), Path("3")]; + fail_unless!(res == ~[Path("1a"), Path("2"), Path("4a"), Path("3")]); } #[test] @@ -257,7 +257,7 @@ mod test { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/lib/mylib"); let res = get_relative_to(&p1, &p2); - assert res == Path("../lib"); + fail_unless!(res == Path("../lib")); } #[test] @@ -265,7 +265,7 @@ mod test { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/bin/../lib/mylib"); let res = get_relative_to(&p1, &p2); - assert res == Path("../lib"); + fail_unless!(res == Path("../lib")); } #[test] @@ -273,7 +273,7 @@ mod test { let p1 = Path("/usr/bin/whatever/rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); - assert res == Path("../../lib/whatever"); + fail_unless!(res == Path("../../lib/whatever")); } #[test] @@ -281,7 +281,7 @@ mod test { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); - assert res == Path("../lib/whatever"); + fail_unless!(res == Path("../lib/whatever")); } #[test] @@ -289,7 +289,7 @@ mod test { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/../mylib"); let res = get_relative_to(&p1, &p2); - assert res == Path("../lib"); + fail_unless!(res == Path("../lib")); } #[test] @@ -297,7 +297,7 @@ mod test { let p1 = Path("/1"); let p2 = Path("/2/3"); let res = get_relative_to(&p1, &p2); - assert res == Path("2"); + fail_unless!(res == Path("2")); } #[test] @@ -305,7 +305,7 @@ mod test { let p1 = Path("/1/2"); let p2 = Path("/3"); let res = get_relative_to(&p1, &p2); - assert res == Path(".."); + fail_unless!(res == Path("..")); } #[test] @@ -318,7 +318,7 @@ mod test { debug!("test_relative_tu8: %s vs. %s", res.to_str(), Path(".").to_str()); - assert res == Path("."); + fail_unless!(res == Path(".")); } #[test] @@ -328,7 +328,7 @@ mod test { let o = session::os_linux; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); - assert res.to_str() == ~"$ORIGIN/../lib"; + fail_unless!(res.to_str() == ~"$ORIGIN/../lib"); } #[test] @@ -337,7 +337,7 @@ mod test { let o = session::os_freebsd; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); - assert res.to_str() == ~"$ORIGIN/../lib"; + fail_unless!(res.to_str() == ~"$ORIGIN/../lib"); } #[test] @@ -348,7 +348,7 @@ mod test { let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); - assert res.to_str() == ~"@executable_path/../lib"; + fail_unless!(res.to_str() == ~"@executable_path/../lib"); } #[test] @@ -358,6 +358,6 @@ mod test { res.to_str(), os::make_absolute(&Path("lib")).to_str()); - assert res == os::make_absolute(&Path("lib")); + fail_unless!(res == os::make_absolute(&Path("lib"))); } } diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index b655744e17c..e7e29ec6c72 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -902,7 +902,7 @@ pub mod test { ~"rustc", matches, diagnostic::emit); let sess = build_session(sessopts, diagnostic::emit); let cfg = build_configuration(sess, ~"whatever", str_input(~"")); - 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 @@ -922,7 +922,7 @@ pub mod test { let sess = build_session(sessopts, diagnostic::emit); let cfg = build_configuration(sess, ~"whatever", str_input(~"")); let test_items = attr::find_meta_items_by_name(cfg, ~"test"); - assert (vec::len(test_items) == 1u); + fail_unless!((vec::len(test_items) == 1u)); } } diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 61b42a7becc..52426401d79 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -378,43 +378,43 @@ pub mod test { #[test] pub fn bin_crate_type_attr_results_in_bin_output() { let crate = make_crate(true, false); - assert !building_library(unknown_crate, crate, false); + fail_unless!(!building_library(unknown_crate, crate, false)); } #[test] pub fn lib_crate_type_attr_results_in_lib_output() { let crate = make_crate(false, true); - assert building_library(unknown_crate, crate, false); + fail_unless!(building_library(unknown_crate, crate, false)); } #[test] pub fn bin_option_overrides_lib_crate_type() { let crate = make_crate(false, true); - assert !building_library(bin_crate, crate, false); + fail_unless!(!building_library(bin_crate, crate, false)); } #[test] pub fn lib_option_overrides_bin_crate_type() { let crate = make_crate(true, false); - assert building_library(lib_crate, crate, false); + fail_unless!(building_library(lib_crate, crate, false)); } #[test] pub fn bin_crate_type_is_default() { let crate = make_crate(false, false); - assert !building_library(unknown_crate, crate, false); + fail_unless!(!building_library(unknown_crate, crate, false)); } #[test] pub fn test_option_overrides_lib_crate_type() { let crate = make_crate(false, true); - assert !building_library(unknown_crate, crate, true); + fail_unless!(!building_library(unknown_crate, crate, true)); } #[test] pub fn test_option_does_not_override_requested_lib_type() { let crate = make_crate(false, false); - assert building_library(lib_crate, crate, true); + fail_unless!(building_library(lib_crate, crate, true)); } } diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index f985ea03c71..4cb018ebdd1 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1460,8 +1460,8 @@ pub struct TypeNames { } pub fn associate_type(tn: @TypeNames, s: @str, t: TypeRef) { - assert tn.type_names.insert(t, s); - assert tn.named_types.insert(s, t); + fail_unless!(tn.type_names.insert(t, s)); + fail_unless!(tn.named_types.insert(s, t)); } pub fn type_has_name(tn: @TypeNames, t: TypeRef) -> Option<@str> { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index ff26000af97..890a58243a1 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -95,7 +95,7 @@ fn warn_if_multiple_versions(e: @mut Env, } })); - 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 3ef63b70aea..2f82d99420c 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -106,7 +106,7 @@ pub fn get_used_crate_files(cstore: @mut CStore) -> ~[Path] { } pub fn add_used_library(cstore: @mut CStore, lib: @~str) -> bool { - assert *lib != ~""; + fail_unless!(*lib != ~""); if cstore.used_libraries.contains(&*lib) { return false; } cstore.used_libraries.push(/*bad*/ copy *lib); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 3ffcd583816..8554f40b4b1 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1000,7 +1000,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 (vec::len(meta_items) == 1u); + fail_unless!((vec::len(meta_items) == 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 67d25637093..9a90b5f364c 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1064,7 +1064,7 @@ fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], ebml_w.start_tag(tag_index_buckets_bucket); for vec::each(**bucket) |elt| { ebml_w.start_tag(tag_index_buckets_bucket_elt); - assert elt.pos < 0xffff_ffff; + fail_unless!(elt.pos < 0xffff_ffff); writer.write_be_u32(elt.pos as u32); write_fn(writer, elt.val); ebml_w.end_tag(); @@ -1074,7 +1074,7 @@ fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], ebml_w.end_tag(); ebml_w.start_tag(tag_index_table); for bucket_locs.each |pos| { - assert *pos < 0xffff_ffff; + fail_unless!(*pos < 0xffff_ffff); writer.write_be_u32(*pos as u32); } ebml_w.end_tag(); @@ -1084,7 +1084,7 @@ fn encode_index(ebml_w: writer::Encoder, buckets: ~[@~[entry]], fn write_str(writer: io::Writer, &&s: ~str) { writer.write_str(s); } fn write_int(writer: io::Writer, &&n: int) { - assert n < 0x7fff_ffff; + fail_unless!(n < 0x7fff_ffff); writer.write_be_u32(n as u32); } @@ -1145,8 +1145,8 @@ fn synthesize_crate_attrs(ecx: @EncodeContext, fn synthesize_link_attr(ecx: @EncodeContext, +items: ~[@meta_item]) -> attribute { - assert !ecx.link_meta.name.is_empty(); - assert !ecx.link_meta.vers.is_empty(); + fail_unless!(!ecx.link_meta.name.is_empty()); + fail_unless!(!ecx.link_meta.vers.is_empty()); let name_item = attr::mk_name_value_item_str(@~"name", @@ -1212,7 +1212,7 @@ fn encode_crate_deps(ecx: @EncodeContext, // Sanity-check the crate numbers let mut expected_cnum = 1; for deps.each |n| { - assert (n.cnum == expected_cnum); + fail_unless!((n.cnum == expected_cnum)); expected_cnum += 1; } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 33a5aa65143..08b9facf486 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -140,12 +140,12 @@ fn parse_sigil(st: @mut PState) -> ast::Sigil { } fn parse_vstore(st: @mut PState) -> ty::vstore { - assert next(st) == '/'; + fail_unless!(next(st) == '/'); let c = peek(st); if '0' <= c && c <= '9' { let n = parse_int(st) as uint; - assert next(st) == '|'; + fail_unless!(next(st) == '|'); return ty::vstore_fixed(n); } @@ -162,7 +162,7 @@ fn parse_substs(st: @mut PState, conv: conv_did) -> ty::substs { let self_ty = parse_opt(st, || parse_ty(st, conv) ); - assert next(st) == '['; + fail_unless!(next(st) == '['); let mut params: ~[ty::t] = ~[]; while peek(st) != ']' { params.push(parse_ty(st, conv)); } st.pos = st.pos + 1u; @@ -179,13 +179,13 @@ fn parse_bound_region(st: @mut PState) -> ty::bound_region { 's' => ty::br_self, 'a' => { let id = parse_int(st) as uint; - assert next(st) == '|'; + fail_unless!(next(st) == '|'); ty::br_anon(id) } '[' => ty::br_named(st.tcx.sess.ident_of(parse_str(st, ']'))), 'c' => { let id = parse_int(st); - assert next(st) == '|'; + fail_unless!(next(st) == '|'); ty::br_cap_avoid(id, @parse_bound_region(st)) }, _ => fail!(~"parse_bound_region: bad input") @@ -198,16 +198,16 @@ fn parse_region(st: @mut PState) -> ty::Region { ty::re_bound(parse_bound_region(st)) } 'f' => { - assert next(st) == '['; + fail_unless!(next(st) == '['); let id = parse_int(st); - assert next(st) == '|'; + fail_unless!(next(st) == '|'); let br = parse_bound_region(st); - assert next(st) == ']'; + fail_unless!(next(st) == ']'); ty::re_free(id, br) } 's' => { let id = parse_int(st); - assert next(st) == '|'; + fail_unless!(next(st) == '|'); ty::re_scope(id) } 't' => { @@ -259,18 +259,18 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { } 'c' => return ty::mk_char(st.tcx), 't' => { - assert (next(st) == '['); + fail_unless!((next(st) == '[')); let def = parse_def(st, NominalType, conv); let substs = parse_substs(st, conv); - assert next(st) == ']'; + fail_unless!(next(st) == ']'); return ty::mk_enum(st.tcx, def, substs); } 'x' => { - assert next(st) == '['; + fail_unless!(next(st) == '['); let def = parse_def(st, NominalType, conv); let substs = parse_substs(st, conv); let vstore = parse_vstore(st); - assert next(st) == ']'; + fail_unless!(next(st) == ']'); return ty::mk_trait(st.tcx, def, substs, vstore); } 'p' => { @@ -300,7 +300,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { return ty::mk_estr(st.tcx, v); } 'T' => { - assert (next(st) == '['); + fail_unless!((next(st) == '[')); let mut params = ~[]; while peek(st) != ']' { params.push(parse_ty(st, conv)); } st.pos = st.pos + 1u; @@ -319,9 +319,9 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { } '#' => { let pos = parse_hex(st); - assert (next(st) == ':'); + fail_unless!((next(st) == ':')); let len = parse_hex(st); - assert (next(st) == '#'); + fail_unless!((next(st) == '#')); let key = ty::creader_cache_key {cnum: st.crate, pos: pos, len: len }; @@ -342,10 +342,10 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t { } 'B' => ty::mk_opaque_box(st.tcx), 'a' => { - assert (next(st) == '['); + fail_unless!((next(st) == '[')); let did = parse_def(st, NominalType, conv); let substs = parse_substs(st, conv); - assert (next(st) == ']'); + fail_unless!((next(st) == ']')); return ty::mk_struct(st.tcx, did, substs); } c => { error!("unexpected char in type string: %c", c); fail!();} @@ -460,7 +460,7 @@ 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 (next(st) == '['); + fail_unless!((next(st) == '[')); let mut inputs: ~[ty::arg] = ~[]; while peek(st) != ']' { let mode = parse_mode(st); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index e418aa35e1e..49a5be54684 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -176,7 +176,7 @@ pub impl ExtendedDecodeContext { */ // from_id_range should be non-empty - assert !ast_util::empty(self.from_id_range); + fail_unless!(!ast_util::empty(self.from_id_range)); (id - self.from_id_range.min + self.to_id_range.min) } fn tr_def_id(&self, did: ast::def_id) -> ast::def_id { @@ -213,7 +213,7 @@ pub impl ExtendedDecodeContext { * refer to the current crate and to the new, inlined node-id. */ - assert did.crate == ast::local_crate; + fail_unless!(did.crate == ast::local_crate); ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) } } fn tr_span(&self, _span: span) -> span { @@ -1231,7 +1231,7 @@ fn roundtrip(in_item: Option<@ast::item>) { debug!("expected string: %s", exp_str); debug!("actual string : %s", out_str); - assert exp_str == out_str; + fail_unless!(exp_str == out_str); } #[test] @@ -1278,8 +1278,10 @@ fn test_simplification() { ).get()); match (item_out, item_exp) { (ast::ii_item(item_out), ast::ii_item(item_exp)) => { - assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner) - == pprust::item_to_str(item_exp, ext_cx.parse_sess().interner); + fail_unless!(pprust::item_to_str(item_out, + ext_cx.parse_sess().interner) + == pprust::item_to_str(item_exp, + ext_cx.parse_sess().interner)); } _ => fail!() } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 07782c25284..a60b0332b8f 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -132,7 +132,7 @@ pub fn raw_pat(p: @pat) -> @pat { } pub 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/lint.rs b/src/librustc/middle/lint.rs index 7d0562e3901..2bd08f10981 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -872,7 +872,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) { fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool { let ident = cx.sess.str_of(ident); - assert !ident.is_empty(); + fail_unless!(!ident.is_empty()); let ident = ident_without_trailing_underscores(*ident); let ident = ident_without_leading_underscores(ident); char::is_uppercase(str::char_at(ident, 0)) && diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 3f054ec86a9..473fad5ee25 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -777,7 +777,7 @@ pub impl Liveness { fn live_on_entry(&self, ln: LiveNode, var: Variable) -> Option { - assert ln.is_valid(); + fail_unless!(ln.is_valid()); let reader = self.users[self.idx(ln, var)].reader; if reader.is_valid() {Some(self.ir.lnk(reader))} else {None} } @@ -792,14 +792,14 @@ pub impl Liveness { } fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool { - assert ln.is_valid(); + fail_unless!(ln.is_valid()); self.users[self.idx(ln, var)].used } fn assigned_on_entry(&self, ln: LiveNode, var: Variable) -> Option { - assert ln.is_valid(); + fail_unless!(ln.is_valid()); let writer = self.users[self.idx(ln, var)].writer; if writer.is_valid() {Some(self.ir.lnk(writer))} else {None} } @@ -1493,11 +1493,11 @@ pub 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, ln); + fail_unless!(cond_ln == self.propagate_through_opt_expr(cond, ln)); assert body_ln == self.with_loop_nodes(expr.id, succ, ln, || { self.propagate_through_block(body, cond_ln) - }); + })); } cond_ln diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 38a8a118e4e..866ec0ab515 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -463,7 +463,7 @@ pub impl DetermineRpCtxt { /// variance `variance`. If `id` was already parameterized, then /// the new variance is joined with the old variance. fn add_rp(&mut self, id: ast::node_id, variance: region_variance) { - assert id != 0; + fail_unless!(id != 0); let old_variance = self.region_paramd_items.find(&id); let joined_variance = match old_variance { None => variance, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 075d4673636..1ca3c045f57 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1411,7 +1411,7 @@ pub impl Resolver { match view_path.node { view_path_simple(_, full_path, _, _) => { let path_len = full_path.idents.len(); - assert path_len != 0; + fail_unless!(path_len != 0); for full_path.idents.eachi |i, ident| { if i != path_len - 1 { @@ -2107,7 +2107,7 @@ pub 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; } _ => { @@ -2123,7 +2123,7 @@ pub impl Resolver { if !resolution_result.indeterminate() { match *import_directive.subclass { GlobImport => { - assert module_.glob_count >= 1; + fail_unless!(module_.glob_count >= 1); module_.glob_count -= 1; } SingleImport(*) => { @@ -2258,7 +2258,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key(&target); + fail_unless!(module_.import_resolutions.contains_key(&target)); let import_resolution = module_.import_resolutions.get(&target); match value_result { @@ -2320,7 +2320,7 @@ pub impl Resolver { } } - assert import_resolution.outstanding_references >= 1; + fail_unless!(import_resolution.outstanding_references >= 1); import_resolution.outstanding_references -= 1; debug!("(resolving single import) successfully resolved import"); @@ -2417,7 +2417,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key(&target); + fail_unless!(module_.import_resolutions.contains_key(&target)); let import_resolution = module_.import_resolutions.get(&target); match module_result { @@ -2442,7 +2442,7 @@ pub impl Resolver { return Failed; } - assert import_resolution.outstanding_references >= 1; + fail_unless!(import_resolution.outstanding_references >= 1); import_resolution.outstanding_references -= 1; debug!("(resolving single module import) successfully resolved \ @@ -2476,7 +2476,7 @@ pub impl Resolver { return Indeterminate; } - assert containing_module.glob_count == 0; + fail_unless!(containing_module.glob_count == 0); // Add all resolved imports from the containing module. for containing_module.import_resolutions.each @@ -2664,7 +2664,7 @@ pub impl Resolver { span: span) -> ResolveResult<@mut Module> { 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 `%s` rooted at \ `%s`", @@ -3016,7 +3016,7 @@ pub impl Resolver { // If this is a search of all imports, we should be done with glob // resolution at this point. if name_search_type == SearchItemsAndAllImports { - assert module_.glob_count == 0; + fail_unless!(module_.glob_count == 0); } // Check the list of resolved imports. diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index d7254ffa660..072a52a96b8 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1219,7 +1219,7 @@ pub fn compile_submatch(bcx: block, /* For an empty match, a fall-through case must exist */ - assert(m.len() > 0u || chk.is_some()); + fail_unless!((m.len() > 0u || chk.is_some())); let _icx = bcx.insn_ctxt("match::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 445818be940..7af1fcc7e77 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -306,8 +306,8 @@ pub fn non_gc_box_cast(bcx: block, val: ValueRef) -> ValueRef { unsafe { debug!("non_gc_box_cast"); add_comment(bcx, ~"non_gc_box_cast"); - assert(llvm::LLVMGetPointerAddressSpace(val_ty(val)) == - gc_box_addrspace || bcx.unreachable); + fail_unless!(llvm::LLVMGetPointerAddressSpace(val_ty(val)) == + gc_box_addrspace || bcx.unreachable); let non_gc_t = T_ptr(llvm::LLVMGetElementType(val_ty(val))); PointerCast(bcx, val, non_gc_t) } @@ -479,7 +479,7 @@ pub fn get_res_dtor(ccx: @CrateContext, did: ast::def_id, let did = if did.crate != ast::local_crate { inline::maybe_instantiate_inline(ccx, did, true) } else { did }; - assert did.crate == ast::local_crate; + fail_unless!(did.crate == ast::local_crate); let (val, _) = monomorphize::monomorphic_fn(ccx, did, substs, None, None, None); @@ -1301,7 +1301,7 @@ pub fn cleanup_and_leave(bcx: block, } cur = match cur.parent { Some(next) => next, - None => { assert upto.is_none(); break; } + None => { fail_unless!(upto.is_none()); break; } }; } match leave { @@ -1488,7 +1488,7 @@ pub fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { let ccx = bcx.ccx(); let llty = type_of::type_of(ccx, t); if ty::type_has_params(t) { log(error, ty_to_str(ccx.tcx, t)); } - assert !ty::type_has_params(t); + fail_unless!(!ty::type_has_params(t)); let val = alloca(bcx, llty); return val; } @@ -2443,7 +2443,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { // Want parent_id and not id, because id is the dtor's type let class_ty = ty::lookup_item_type(tcx, parent_id).ty; // This code shouldn't be reached if the class is generic - assert !ty::type_has_params(class_ty); + fail_unless!(!ty::type_has_params(class_ty)); let lldty = unsafe { T_fn(~[ T_ptr(type_of(ccx, ty::mk_nil(tcx))), @@ -2463,7 +2463,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { let llfn; match /*bad*/copy (*v).node.kind { ast::tuple_variant_kind(args) => { - assert args.len() != 0u; + fail_unless!(args.len() != 0u); let pth = vec::append(/*bad*/copy *pth, ~[path_name(enm.ident), path_name((*v).node.name)]); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 897d898eae6..45104480b4c 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -814,7 +814,7 @@ pub fn Phi(cx: block, Ty: TypeRef, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef { unsafe { if cx.unreachable { return llvm::LLVMGetUndef(Ty); } - assert vals.len() == bbs.len(); + fail_unless!(vals.len() == bbs.len()); let phi = EmptyPhi(cx, Ty); count_insn(cx, "addincoming"); llvm::LLVMAddIncoming(phi, vec::raw::to_ptr(vals), @@ -1008,7 +1008,7 @@ pub fn Trap(cx: block) { let T: ValueRef = str::as_c_str(~"llvm.trap", |buf| { llvm::LLVMGetNamedFunction(M, buf) }); - assert (T as int != 0); + fail_unless!((T as int != 0)); let Args: ~[ValueRef] = ~[]; unsafe { count_insn(cx, "trap"); @@ -1022,7 +1022,7 @@ pub fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef, NumClauses: uint) -> ValueRef { unsafe { check_not_terminated(cx); - assert !cx.unreachable; + fail_unless!(!cx.unreachable); count_insn(cx, "landingpad"); return llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, NumClauses as c_uint, noname()); diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index b7ac909eee4..ba1c753729c 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -130,9 +130,9 @@ pub fn trans(bcx: block, expr: @ast::expr) -> Callee { } ast::def_variant(tid, vid) => { // nullary variants are not callable - assert ty::enum_variant_with_id(bcx.tcx(), - tid, - vid).args.len() > 0u; + 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)) } ast::def_struct(def_id) => { @@ -280,7 +280,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 def_id.crate == ast::local_crate; + fail_unless!(def_id.crate == ast::local_crate); let mut (val, must_cast) = monomorphize::monomorphic_fn(ccx, def_id, type_params, @@ -704,7 +704,7 @@ pub fn trans_arg_expr(bcx: block, // FIXME(#3548) use the adjustments table match autoref_arg { DoAutorefArg => { - assert !bcx.ccx().maps.moves_map.contains_key(&arg_expr.id); + fail_unless!(!bcx.ccx().maps.moves_map.contains_key(&arg_expr.id)); val = arg_datum.to_ref_llval(bcx); } DontAutorefArg => { @@ -722,8 +722,8 @@ pub fn trans_arg_expr(bcx: block, ast::by_val => { // NB: avoid running the take glue. - assert !bcx.ccx().maps.moves_map.contains_key( - &arg_expr.id); + fail_unless!(!bcx.ccx().maps.moves_map.contains_key( + &arg_expr.id)); val = arg_datum.to_value_llval(bcx); } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 25ce2a49919..b7a8e38dbb8 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -271,7 +271,7 @@ pub fn build_closure(bcx0: block, let datum = expr::trans_local_var(bcx, cap_var.def); match cap_var.mode { moves::CapRef => { - assert sigil == ast::BorrowedSigil; + fail_unless!(sigil == ast::BorrowedSigil); env_vals.push(EnvValue {action: EnvRef, datum: datum}); } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index a363a950f9b..c4b80c504da 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -1339,7 +1339,7 @@ pub fn monomorphize_type(bcx: block, t: ty::t) -> ty::t { Some(substs) => { ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t) } - _ => { assert !ty::type_has_params(t); t } + _ => { fail_unless!(!ty::type_has_params(t)); t } } } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 6390beb3097..8971d9f5669 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -70,7 +70,7 @@ pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit) pub fn const_ptrcast(cx: @CrateContext, a: ValueRef, t: TypeRef) -> ValueRef { unsafe { let b = llvm::LLVMConstPointerCast(a, T_ptr(t)); - assert cx.const_globals.insert(b as int, a); + fail_unless!(cx.const_globals.insert(b as int, a)); b } } @@ -100,7 +100,7 @@ pub fn const_deref(cx: @CrateContext, v: ValueRef) -> ValueRef { Some(v) => v, None => v }; - assert llvm::LLVMIsGlobalConstant(v) == True; + fail_unless!(llvm::LLVMIsGlobalConstant(v) == True); let v = llvm::LLVMGetInitializer(v); v } @@ -290,7 +290,7 @@ fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef { let len = llvm::LLVMConstIntGetZExtValue(len) as u64; let len = match ty::get(bt).sty { - ty::ty_estr(*) => {assert len > 0; len - 1}, + ty::ty_estr(*) => {fail_unless!(len > 0); len - 1}, _ => len }; if iv >= len { @@ -417,14 +417,14 @@ fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef { } } ast::expr_path(pth) => { - assert pth.types.len() == 0; + fail_unless!(pth.types.len() == 0); match cx.tcx.def_map.find(&e.id) { Some(ast::def_fn(def_id, _purity)) => { let f = if !ast_util::is_local(def_id) { let ty = csearch::get_type(cx.tcx, def_id).ty; base::trans_external_path(cx, def_id, ty) } else { - assert ast_util::is_local(def_id); + fail_unless!(ast_util::is_local(def_id)); base::get_item_val(cx, def_id.node) }; let ety = ty::expr_ty_adjusted(cx.tcx, e); diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 911cd347ed0..59c143ebce7 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -48,7 +48,7 @@ pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block { bcx = expr::trans_into(bcx, e, dest); } None => { - assert dest == expr::Ignore || bcx.unreachable; + fail_unless!(dest == expr::Ignore || bcx.unreachable); } } return bcx; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index ac150d44e39..556c15c446d 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -253,19 +253,19 @@ pub impl Datum { action: CopyAction, datum: Datum) -> block { debug!("store_to_datum(self=%s, action=%?, datum=%s)", self.to_str(bcx.ccx()), action, datum.to_str(bcx.ccx())); - assert datum.mode.is_by_ref(); + fail_unless!(datum.mode.is_by_ref()); self.store_to(bcx, id, action, datum.val) } fn move_to_datum(&self, bcx: block, action: CopyAction, datum: Datum) -> block { - assert datum.mode.is_by_ref(); + fail_unless!(datum.mode.is_by_ref()); self.move_to(bcx, action, datum.val) } fn copy_to_datum(&self, bcx: block, action: CopyAction, datum: Datum) -> block { - assert datum.mode.is_by_ref(); + fail_unless!(datum.mode.is_by_ref()); self.copy_to(bcx, action, datum.val) } @@ -378,7 +378,7 @@ pub impl Datum { * Schedules this datum for cleanup in `bcx`. The datum * must be an rvalue. */ - assert self.source == RevokeClean; + fail_unless!(self.source == RevokeClean); match self.mode { ByValue => { add_clean_temp_immediate(bcx, self.val, self.ty); @@ -399,7 +399,7 @@ pub impl Datum { // Lvalues which potentially need to be dropped // must be passed by ref, so that we can zero them // out. - assert self.mode.is_by_ref(); + fail_unless!(self.mode.is_by_ref()); zero_mem(bcx, self.val, self.ty); } } @@ -705,7 +705,7 @@ pub impl Datum { // changing the type, so I am putting this // code in place here to do the right // thing if this change ever goes through. - assert ty::type_is_immediate(ty); + fail_unless!(ty::type_is_immediate(ty)); (Some(Datum {ty: ty, ..*self}), bcx) } }; @@ -746,7 +746,7 @@ pub impl Datum { // except for changing the type, so I am putting this // code in place here to do the right thing if this // change ever goes through. - assert ty::type_is_immediate(ty); + fail_unless!(ty::type_is_immediate(ty)); (Some(Datum {ty: ty, ..*self}), bcx) } } @@ -806,7 +806,7 @@ pub impl Datum { // either we were asked to deref a specific number of times, // in which case we should have, or we asked to deref as many // times as we can - assert derefs == max || max == uint::max_value; + fail_unless!(derefs == max || max == uint::max_value); DatumBlock { bcx: bcx, datum: datum } } @@ -826,7 +826,7 @@ pub impl DatumBlock { } fn assert_by_ref(&self) -> DatumBlock { - assert self.datum.mode.is_by_ref(); + fail_unless!(self.datum.mode.is_by_ref()); *self } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 91454a91fe2..7f9ff2a244b 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -286,7 +286,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { debug!("add_env(closure_ty=%s)", ty_to_str(tcx, closure_ty)); let scratch = scratch_datum(bcx, closure_ty, false); let llfn = GEPi(bcx, scratch.val, [0u, abi::fn_field_code]); - assert datum.appropriate_mode() == ByValue; + fail_unless!(datum.appropriate_mode() == ByValue); Store(bcx, datum.to_appropriate_llval(bcx), llfn); let llenv = GEPi(bcx, scratch.val, [0u, abi::fn_field_box]); Store(bcx, base::null_env_ptr(bcx), llenv); @@ -465,7 +465,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } ast::expr_binary(op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key(&expr.id); + fail_unless!(!bcx.ccx().maps.method_map.contains_key(&expr.id)); return trans_binary(bcx, expr, op, lhs, rhs); } @@ -1318,10 +1318,10 @@ fn trans_unary_datum(bcx: block, let _icx = bcx.insn_ctxt("trans_unary_datum"); // if deref, would be LvalueExpr - assert op != ast::deref; + fail_unless!(op != ast::deref); // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key(&un_expr.id); + fail_unless!(!bcx.ccx().maps.method_map.contains_key(&un_expr.id)); let un_ty = expr_ty(bcx, un_expr); let sub_ty = expr_ty(bcx, sub_expr); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index b692ae67950..7f860bc0c85 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -398,7 +398,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; let ty_visitor_name = special_idents::ty_visitor; - assert bcx.ccx().tcx.intrinsic_defs.contains_key(&ty_visitor_name); + fail_unless!(bcx.ccx().tcx.intrinsic_defs.contains_key(&ty_visitor_name)); let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(&ty_visitor_name); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id); @@ -486,7 +486,7 @@ pub fn trans_struct_drop(bcx: block, // Class dtors have no explicit args, so the params should // just consist of the output pointer and the environment // (self) - assert(params.len() == 2); + fail_unless!((params.len() == 2)); // If we need to take a reference to the class (because it's using // the Drop trait), do so now. @@ -670,7 +670,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info { let _icx = ccx.insn_ctxt("declare_tydesc"); // If emit_tydescs already ran, then we shouldn't be creating any new // tydescs. - assert !*ccx.finished_tydescs; + fail_unless!(!*ccx.finished_tydescs); let llty = type_of(ccx, t); diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index ffc5d132c9f..f970d8f26b3 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -56,8 +56,8 @@ pub fn monomorphic_fn(ccx: @CrateContext, } }); - for real_substs.each() |s| { assert !ty::type_has_params(*s); } - for substs.each() |s| { assert !ty::type_has_params(*s); } + for real_substs.each() |s| { fail_unless!(!ty::type_has_params(*s)); } + for substs.each() |s| { fail_unless!(!ty::type_has_params(*s)); } let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len()); // XXX: Bad copy. let hash_id = make_mono_id(ccx, fn_id, copy substs, vtables, impl_did_opt, diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 4b9aad2558c..85c0bc80292 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -336,7 +336,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, -> block { use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, ~"final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc); + fail_unless!(bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc)); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc); let tydesc_ty = type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 8aabfdfa638..68eb0852445 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -70,7 +70,7 @@ pub fn type_of_fn_from_ty(cx: @CrateContext, fty: ty::t) -> TypeRef { } pub fn type_of_non_gc_box(cx: @CrateContext, t: ty::t) -> TypeRef { - assert !ty::type_needs_infer(t); + fail_unless!(!ty::type_needs_infer(t)); let t_norm = ty::normalize_ty(cx.tcx, t); if t != t_norm { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 802c9a8d20b..350c1526ce0 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1981,7 +1981,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 p.def_id.crate == ast::local_crate; + fail_unless!(p.def_id.crate == ast::local_crate); param_bounds_to_contents( cx, cx.ty_param_bounds.get(&p.def_id.node)) @@ -3519,7 +3519,7 @@ pub fn trait_supertraits(cx: ctxt, // 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 // InstantiatedTraitRef for each. @@ -3551,7 +3551,7 @@ pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { // If the lookup in trait_method_cache fails, assume that the trait // method we're trying to look up is in a different crate, and look // for it there. - assert id.crate != ast::local_crate; + fail_unless!(id.crate != ast::local_crate); let result = csearch::get_trait_methods(cx, id); // Store the trait method in the local trait_method_cache so that @@ -3872,7 +3872,7 @@ pub fn lookup_item_type(cx: ctxt, return tpt; } None => { - assert did.crate != ast::local_crate; + fail_unless!(did.crate != ast::local_crate); let tyt = csearch::get_type(cx, did); cx.tcache.insert(did, tyt); return tyt; diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 0c4f7a6d30f..65646cfcbb1 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1806,7 +1806,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, if check_completeness { // 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 field_types.each |class_field| { @@ -3175,8 +3175,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~"visit_tydesc" => { let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); - assert tcx.intrinsic_defs.contains_key(&tydesc_name); - assert ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name); + fail_unless!(tcx.intrinsic_defs.contains_key(&tydesc_name)); + fail_unless!(ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name)); let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name); let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 204991d50d3..392182bee3f 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -712,8 +712,8 @@ pub mod guarantor { ast::expr_copy(*) | ast::expr_repeat(*) | ast::expr_vec(*) => { - assert !ty::expr_is_lval( - rcx.fcx.tcx(), rcx.fcx.ccx.method_map, expr); + fail_unless!(!ty::expr_is_lval( + rcx.fcx.tcx(), rcx.fcx.ccx.method_map, expr)); None } } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index fa17c9438a2..7c9ca4ba85a 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -178,7 +178,7 @@ pub 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. @@ -355,7 +355,7 @@ pub fn lookup_vtable(vcx: &VtableContext, is_early) { Some(ref substs) => (/*bad*/copy *substs), None => { - assert is_early; + fail_unless!(is_early); // Bail out with a bogus answer return Some(vtable_param(0, 0)); } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index f08cdbe1d41..8abbb7a9909 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -811,7 +811,7 @@ pub impl CoherenceChecker { } fn span_of_impl(&self, implementation: @Impl) -> span { - assert implementation.did.crate == local_crate; + fail_unless!(implementation.did.crate == local_crate); match self.crate_context.tcx.items.find(&implementation.did.node) { Some(node_item(item, _)) => { return item.span; diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 3810b3070ba..9cb6c473d58 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -585,7 +585,7 @@ pub impl @mut InferCtxt { /// Execute `f` and commit the bindings if successful fn commit(f: fn() -> Result) -> Result { - assert !self.in_snapshot(); + fail_unless!(!self.in_snapshot()); debug!("commit()"); do indent { @@ -678,9 +678,9 @@ pub impl @mut InferCtxt { let region_var = self.next_region_var_nb(span); // add lb_region as a lower bound on the newly built variable - assert self.region_vars.make_subregion(span, - lb_region, - region_var).is_ok(); + fail_unless!(self.region_vars.make_subregion(span, + lb_region, + region_var).is_ok()); return region_var; } diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 7226872e12c..e9843c8a075 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -701,7 +701,7 @@ pub impl RegionVarBindings { match undo_item { Snapshot => {} AddVar(vid) => { - assert self.var_spans.len() == *vid + 1; + fail_unless!(self.var_spans.len() == *vid + 1); self.var_spans.pop(); } AddConstraint(ref constraint) => { @@ -758,7 +758,7 @@ pub impl RegionVarBindings { fn add_constraint(&mut self, +constraint: Constraint, span: span) { // cannot add constraints once regions are resolved - assert self.values.is_empty(); + fail_unless!(self.values.is_empty()); debug!("RegionVarBindings: add_constraint(%?)", constraint); @@ -774,7 +774,7 @@ pub impl RegionVarBindings { sub: Region, sup: Region) -> cres<()> { // cannot add constraints once regions are resolved - assert self.values.is_empty(); + fail_unless!(self.values.is_empty()); debug!("RegionVarBindings: make_subregion(%?, %?)", sub, sup); match (sub, sup) { @@ -816,7 +816,7 @@ pub impl RegionVarBindings { b: Region) -> cres { // cannot add constraints once regions are resolved - assert self.values.is_empty(); + fail_unless!(self.values.is_empty()); debug!("RegionVarBindings: lub_regions(%?, %?)", a, b); match (a, b) { @@ -842,7 +842,7 @@ pub impl RegionVarBindings { b: Region) -> cres { // cannot add constraints once regions are resolved - assert self.values.is_empty(); + fail_unless!(self.values.is_empty()); debug!("RegionVarBindings: glb_regions(%?, %?)", a, b); match (a, b) { @@ -1376,7 +1376,7 @@ pub impl RegionVarBindings { return match a_node.value { NoValue => { - assert a_node.classification == Contracting; + fail_unless!(a_node.classification == Contracting); a_node.value = Value(b_region); true // changed } @@ -1634,7 +1634,7 @@ pub impl RegionVarBindings { } ConstrainRegSubVar(region, _) => { - assert dir == Incoming; + fail_unless!(dir == Incoming); result.push(SpannedRegion { region: region, span: edge.span @@ -1642,7 +1642,7 @@ pub impl RegionVarBindings { } ConstrainVarSubReg(_, region) => { - assert dir == Outgoing; + fail_unless!(dir == Outgoing); result.push(SpannedRegion { region: region, span: edge.span diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 83ef61bbf49..bcbe08c2881 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -114,9 +114,9 @@ pub impl ResolveState { // n.b. This is a hokey mess because the current fold doesn't // allow us to pass back errors in any useful way. - assert vec::is_empty(self.v_seen); + fail_unless!(vec::is_empty(self.v_seen)); let rty = indent(|| self.resolve_type(typ) ); - assert vec::is_empty(self.v_seen); + fail_unless!(vec::is_empty(self.v_seen)); match self.err { None => { debug!("Resolved to %s + %s (modes=%x)", diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 9701e370ca8..867bcc30fa4 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -110,7 +110,7 @@ pub impl Env { m: &ast::_mod, idx: uint, names: &[~str]) -> Option { - assert idx < names.len(); + fail_unless!(idx < names.len()); for m.items.each |item| { if self.tcx.sess.str_of(item.ident) == names[idx] { return search(self, *item, idx+1, names); diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 3cf5b4f4ef0..d692a66f699 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -131,7 +131,7 @@ pub impl InferCtxt { } else { // If equal, redirect one to the other and increment the // other's rank. - assert node_a.rank == node_b.rank; + fail_unless!(node_a.rank == node_b.rank); self.set(node_b.root, Redirect(node_a.root)); (node_a.root, node_a.rank + 1) } diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 3c342e9986b..f0fc173101f 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -59,8 +59,8 @@ impl region_scope for MethodRscope { }) } fn self_region(&self, _span: span) -> Result { - assert self.region_parameterization.is_some() || - self.self_ty.is_borrowed(); + fail_unless!(self.region_parameterization.is_some() || + self.self_ty.is_borrowed()); result::Ok(ty::re_bound(ty::br_self)) } fn named_region(&self, span: span, id: ast::ident) @@ -94,7 +94,7 @@ impl region_scope for type_rscope { fn self_region(&self, _span: span) -> Result { // if the self region is used, region parameterization should // have inferred that this type is RP - assert self.is_some(); + fail_unless!(self.is_some()); result::Ok(ty::re_bound(ty::br_self)) } fn named_region(&self, span: span, id: ast::ident) diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 85d9dfe6fa6..b5793cc0abd 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -145,7 +145,7 @@ fn should_prune_unconfigured_items() { let source = ~"#[cfg(shut_up_and_leave_me_alone)]fn a() { }"; do from_str(source) |srv| { do exec(srv) |ctxt| { - assert vec::is_empty(ctxt.ast.node.module.items); + fail_unless!(vec::is_empty(ctxt.ast.node.module.items)); } } } @@ -155,7 +155,7 @@ fn srv_should_build_ast_map() { let source = ~"fn a() { }"; do from_str(source) |srv| { do exec(srv) |ctxt| { - assert !ctxt.ast_map.is_empty() + fail_unless!(!ctxt.ast_map.is_empty()) }; } } @@ -171,6 +171,6 @@ fn srv_should_return_request_result() { let source = ~"fn a() { }"; do from_str(source) |srv| { let result = exec(srv, |_ctxt| 1000 ); - assert result == 1000; + fail_unless!(result == 1000); } } diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs index 1d1a5209cae..32966156eb1 100644 --- a/src/librustdoc/attr_parser.rs +++ b/src/librustdoc/attr_parser.rs @@ -71,7 +71,7 @@ fn should_extract_crate_name_from_link_attribute() { let source = ~"#[link(name = \"snuggles\")]"; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); - assert attrs.name == Some(~"snuggles"); + fail_unless!(attrs.name == Some(~"snuggles")); } #[test] @@ -79,7 +79,7 @@ fn should_not_extract_crate_name_if_no_link_attribute() { let source = ~""; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); - assert attrs.name == None; + fail_unless!(attrs.name == None); } #[test] @@ -87,7 +87,7 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() { let source = ~"#[link(whatever)]"; let attrs = test::parse_attributes(source); let attrs = parse_crate(attrs); - assert attrs.name == None; + fail_unless!(attrs.name == None); } pub fn parse_desc(attrs: ~[ast::attribute]) -> Option<~str> { @@ -106,7 +106,7 @@ fn parse_desc_should_handle_undocumented_mods() { let source = ~""; let attrs = test::parse_attributes(source); let attrs = parse_desc(attrs); - assert attrs == None; + fail_unless!(attrs == None); } #[test] @@ -114,7 +114,7 @@ fn parse_desc_should_parse_simple_doc_attributes() { let source = ~"#[doc = \"basic\"]"; let attrs = test::parse_attributes(source); let attrs = parse_desc(attrs); - assert attrs == Some(~"basic"); + fail_unless!(attrs == Some(~"basic")); } pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool { @@ -133,28 +133,28 @@ pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool { fn should_parse_hidden_attribute() { let source = ~"#[doc(hidden)]"; let attrs = test::parse_attributes(source); - assert parse_hidden(attrs) == true; + fail_unless!(parse_hidden(attrs) == true); } #[test] fn should_parse_hidden_attribute_with_other_docs() { let source = ~"#[doc = \"foo\"] #[doc(hidden)] #[doc = \"foo\"]"; let attrs = test::parse_attributes(source); - assert parse_hidden(attrs) == true; + fail_unless!(parse_hidden(attrs) == true); } #[test] fn should_not_parse_non_hidden_attribute() { let source = ~"#[doc = \"\"]"; let attrs = test::parse_attributes(source); - assert parse_hidden(attrs) == false; + fail_unless!(parse_hidden(attrs) == false); } #[test] fn should_concatenate_multiple_doc_comments() { let source = ~"/// foo\n/// bar"; let desc = parse_desc(test::parse_attributes(source)); - assert desc == Some(~"foo\nbar"); + fail_unless!(desc == Some(~"foo\nbar")); } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 18696d6427b..5e3fdf19ad3 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -83,7 +83,7 @@ fn fold_crate( #[test] fn should_replace_top_module_name_with_crate_name() { let doc = test::mk_doc(~"#[link(name = \"bond\")];"); - assert doc.cratemod().name() == ~"bond"; + fail_unless!(doc.cratemod().name() == ~"bond"); } fn fold_item( @@ -126,25 +126,25 @@ fn parse_item_attrs( #[test] fn should_should_extract_mod_attributes() { let doc = test::mk_doc(~"#[doc = \"test\"] mod a { }"); - assert doc.cratemod().mods()[0].desc() == Some(~"test"); + fail_unless!(doc.cratemod().mods()[0].desc() == Some(~"test")); } #[test] fn should_extract_top_mod_attributes() { let doc = test::mk_doc(~"#[doc = \"test\"];"); - assert doc.cratemod().desc() == Some(~"test"); + fail_unless!(doc.cratemod().desc() == Some(~"test")); } #[test] fn should_extract_foreign_fn_attributes() { let doc = test::mk_doc(~"extern { #[doc = \"test\"] fn a(); }"); - assert doc.cratemod().nmods()[0].fns[0].desc() == Some(~"test"); + fail_unless!(doc.cratemod().nmods()[0].fns[0].desc() == Some(~"test")); } #[test] fn should_extract_fn_attributes() { let doc = test::mk_doc(~"#[doc = \"test\"] fn a() -> int { }"); - assert doc.cratemod().fns()[0].desc() == Some(~"test"); + fail_unless!(doc.cratemod().fns()[0].desc() == Some(~"test")); } fn fold_enum( @@ -196,13 +196,13 @@ fn fold_enum( fn should_extract_enum_docs() { let doc = test::mk_doc(~"#[doc = \"b\"]\ enum a { v }"); - assert doc.cratemod().enums()[0].desc() == Some(~"b"); + fail_unless!(doc.cratemod().enums()[0].desc() == Some(~"b")); } #[test] fn should_extract_variant_docs() { let doc = test::mk_doc(~"enum a { #[doc = \"c\"] v }"); - assert doc.cratemod().enums()[0].variants[0].desc == Some(~"c"); + fail_unless!(doc.cratemod().enums()[0].variants[0].desc == Some(~"c")); } fn fold_trait( @@ -255,7 +255,7 @@ fn merge_method_attrs( }; do vec::map2(docs, attrs) |doc, attrs| { - assert doc.name == attrs.first(); + fail_unless!(doc.name == attrs.first()); let desc = attrs.second(); doc::MethodDoc { @@ -268,7 +268,7 @@ fn merge_method_attrs( #[test] fn should_extract_trait_docs() { let doc = test::mk_doc(~"#[doc = \"whatever\"] trait i { fn a(); }"); - assert doc.cratemod().traits()[0].desc() == Some(~"whatever"); + fail_unless!(doc.cratemod().traits()[0].desc() == Some(~"whatever")); } #[test] @@ -278,7 +278,7 @@ fn should_extract_trait_method_docs() { #[doc = \"desc\"]\ fn f(a: bool) -> bool;\ }"); - assert doc.cratemod().traits()[0].methods[0].desc == Some(~"desc"); + fail_unless!(doc.cratemod().traits()[0].methods[0].desc == Some(~"desc")); } @@ -299,7 +299,7 @@ fn fold_impl( fn should_extract_impl_docs() { let doc = test::mk_doc( ~"#[doc = \"whatever\"] impl int { fn a() { } }"); - assert doc.cratemod().impls()[0].desc() == Some(~"whatever"); + fail_unless!(doc.cratemod().impls()[0].desc() == Some(~"whatever")); } #[test] @@ -309,7 +309,7 @@ fn should_extract_impl_method_docs() { #[doc = \"desc\"]\ fn f(a: bool) -> bool { }\ }"); - assert doc.cratemod().impls()[0].methods[0].desc == Some(~"desc"); + fail_unless!(doc.cratemod().impls()[0].methods[0].desc == Some(~"desc")); } #[cfg(test)] diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 83ef5a6f3a8..956d6ba2c5b 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -266,7 +266,7 @@ fn should_find_pandoc() { ProgramOutput { status: 0, out: ~"pandoc 1.8.2.1", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); - assert result == result::Ok(Some(~"pandoc")); + fail_unless!(result == result::Ok(Some(~"pandoc"))); } #[test] @@ -279,7 +279,7 @@ fn should_error_with_no_pandoc() { ProgramOutput { status: 1, out: ~"", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); - assert result == result::Err(~"couldn't find pandoc"); + fail_unless!(result == result::Err(~"couldn't find pandoc")); } #[cfg(test)] @@ -296,20 +296,20 @@ mod test { #[test] fn should_error_with_no_crates() { let config = test::parse_config(~[~"rustdoc"]); - assert config.get_err() == ~"no crates specified"; + fail_unless!(config.get_err() == ~"no crates specified"); } #[test] fn should_error_with_multiple_crates() { let config = test::parse_config(~[~"rustdoc", ~"crate1.rc", ~"crate2.rc"]); - assert config.get_err() == ~"multiple crates specified"; + fail_unless!(config.get_err() == ~"multiple crates specified"); } #[test] fn should_set_output_dir_to_cwd_if_not_provided() { let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); - assert config.get().output_dir == Path("."); + fail_unless!(config.get().output_dir == Path(".")); } #[test] @@ -317,13 +317,13 @@ fn should_set_output_dir_if_provided() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-dir", ~"snuggles" ]); - assert config.get().output_dir == Path("snuggles"); + fail_unless!(config.get().output_dir == Path("snuggles")); } #[test] fn should_set_output_format_to_pandoc_html_if_not_provided() { let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); - assert config.get().output_format == PandocHtml; + fail_unless!(config.get().output_format == PandocHtml); } #[test] @@ -331,7 +331,7 @@ fn should_set_output_format_to_markdown_if_requested() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-format", ~"markdown" ]); - assert config.get().output_format == Markdown; + fail_unless!(config.get().output_format == Markdown); } #[test] @@ -339,7 +339,7 @@ fn should_set_output_format_to_pandoc_html_if_requested() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-format", ~"html" ]); - assert config.get().output_format == PandocHtml; + fail_unless!(config.get().output_format == PandocHtml); } #[test] @@ -347,13 +347,13 @@ fn should_error_on_bogus_format() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-format", ~"bogus" ]); - assert config.get_err() == ~"unknown output format 'bogus'"; + fail_unless!(config.get_err() == ~"unknown output format 'bogus'"); } #[test] fn should_set_output_style_to_doc_per_mod_by_default() { let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); - assert config.get().output_style == DocPerMod; + fail_unless!(config.get().output_style == DocPerMod); } #[test] @@ -361,7 +361,7 @@ fn should_set_output_style_to_one_doc_if_requested() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-crate" ]); - assert config.get().output_style == DocPerCrate; + fail_unless!(config.get().output_style == DocPerCrate); } #[test] @@ -369,7 +369,7 @@ fn should_set_output_style_to_doc_per_mod_if_requested() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-style", ~"doc-per-mod" ]); - assert config.get().output_style == DocPerMod; + fail_unless!(config.get().output_style == DocPerMod); } #[test] @@ -377,7 +377,7 @@ fn should_error_on_bogus_output_style() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--output-style", ~"bogus" ]); - assert config.get_err() == ~"unknown output style 'bogus'"; + fail_unless!(config.get_err() == ~"unknown output style 'bogus'"); } #[test] @@ -385,11 +385,11 @@ fn should_set_pandoc_command_if_requested() { let config = test::parse_config(~[ ~"rustdoc", ~"crate.rc", ~"--pandoc-cmd", ~"panda-bear-doc" ]); - assert config.get().pandoc_cmd == Some(~"panda-bear-doc"); + fail_unless!(config.get().pandoc_cmd == Some(~"panda-bear-doc")); } #[test] fn should_set_pandoc_command_when_using_pandoc() { let config = test::parse_config(~[~"rustdoc", ~"crate.rc"]); - assert config.get().pandoc_cmd == Some(~"pandoc"); + fail_unless!(config.get().pandoc_cmd == Some(~"pandoc")); } diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index 3a4cd9e1379..a0733121b7c 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -84,20 +84,20 @@ fn fold_impl(fold: &fold::Fold<()>, doc: doc::ImplDoc) -> doc::ImplDoc { #[test] fn should_promote_desc() { let doc = test::mk_doc(~"#[doc = \"desc\"] mod m { }"); - assert doc.cratemod().mods()[0].brief() == Some(~"desc"); + fail_unless!(doc.cratemod().mods()[0].brief() == Some(~"desc")); } #[test] fn should_promote_trait_method_desc() { let doc = test::mk_doc(~"trait i { #[doc = \"desc\"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].brief == Some(~"desc"); + fail_unless!(doc.cratemod().traits()[0].methods[0].brief == Some(~"desc")); } #[test] fn should_promote_impl_method_desc() { let doc = test::mk_doc( ~"impl int { #[doc = \"desc\"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].brief == Some(~"desc"); + fail_unless!(doc.cratemod().impls()[0].methods[0].brief == Some(~"desc")); } #[cfg(test)] @@ -221,20 +221,20 @@ fn paragraphs(s: &str) -> ~[~str] { #[test] fn test_paragraphs_1() { let paras = paragraphs(~"1\n\n2"); - assert paras == ~[~"1", ~"2"]; + fail_unless!(paras == ~[~"1", ~"2"]); } #[test] fn test_paragraphs_2() { let paras = paragraphs(~"\n\n1\n1\n\n2\n\n"); - assert paras == ~[~"1\n1", ~"2"]; + fail_unless!(paras == ~[~"1\n1", ~"2"]); } #[test] fn should_promote_short_descs() { let desc = Some(~"desc"); let brief = extract(copy desc); - assert brief == desc; + fail_unless!(brief == desc); } #[test] @@ -248,7 +248,7 @@ Scotland in the mid 12th century, although it may have been built by King Henry II of England when he took control of England'snorthern counties."); let brief = extract(desc); - assert brief == None; + fail_unless!(brief == None); } #[test] @@ -262,8 +262,8 @@ Scotland in the mid 12th century, although it may have been built by King Henry II of England when he took control of England'snorthern counties."); let brief = extract(desc); - assert brief == Some( - ~"Warkworth Castle is a ruined medieval building in the town"); + fail_unless!(brief == Some( + ~"Warkworth Castle is a ruined medieval building in the town")); } #[test] @@ -277,8 +277,8 @@ Scotland in the mid 12th century, although it may have been built by King Henry II of England when he took control of England'snorthern counties."); let brief = extract(desc); - assert brief == Some( - ~"Warkworth..Castle is a ruined medieval building in the town"); + fail_unless!(brief == Some( + ~"Warkworth..Castle is a ruined medieval building in the town")); } #[test] @@ -292,6 +292,6 @@ Scotland in the mid 12th century, although it may have been built by King Henry II of England when he took control of England'snorthern counties."); let brief = extract(desc); - assert brief == Some( - ~"Warkworth... Castle is a ruined medieval building in the town"); + fail_unless!(brief == Some( + ~"Warkworth... Castle is a ruined medieval building in the town")); } diff --git a/src/librustdoc/escape_pass.rs b/src/librustdoc/escape_pass.rs index 3e14c6f92ce..1eb8c0e6eca 100644 --- a/src/librustdoc/escape_pass.rs +++ b/src/librustdoc/escape_pass.rs @@ -27,5 +27,5 @@ fn escape(s: &str) -> ~str { fn should_escape_backslashes() { let s = ~"\\n"; let r = escape(s); - assert r == ~"\\\\n"; + fail_unless!(r == ~"\\\\n"); } diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index 4e94c4cf68d..ba6e102785a 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -185,8 +185,8 @@ fn constdoc_from_const(itemdoc: doc::ItemDoc) -> doc::ConstDoc { #[test] fn should_extract_const_name_and_id() { let doc = test::mk_doc(~"const a: int = 0;"); - assert doc.cratemod().consts()[0].id() != 0; - assert doc.cratemod().consts()[0].name() == ~"a"; + fail_unless!(doc.cratemod().consts()[0].id() != 0); + fail_unless!(doc.cratemod().consts()[0].name() == ~"a"); } fn enumdoc_from_enum( @@ -216,14 +216,14 @@ fn variantdoc_from_variant(variant: &ast::variant) -> doc::VariantDoc { #[test] fn should_extract_enums() { let doc = test::mk_doc(~"enum e { v }"); - assert doc.cratemod().enums()[0].id() != 0; - assert doc.cratemod().enums()[0].name() == ~"e"; + fail_unless!(doc.cratemod().enums()[0].id() != 0); + fail_unless!(doc.cratemod().enums()[0].name() == ~"e"); } #[test] fn should_extract_enum_variants() { let doc = test::mk_doc(~"enum e { v }"); - assert doc.cratemod().enums()[0].variants[0].name == ~"v"; + fail_unless!(doc.cratemod().enums()[0].variants[0].name == ~"v"); } fn traitdoc_from_trait( @@ -262,13 +262,13 @@ fn traitdoc_from_trait( #[test] fn should_extract_traits() { let doc = test::mk_doc(~"trait i { fn f(); }"); - assert doc.cratemod().traits()[0].name() == ~"i"; + fail_unless!(doc.cratemod().traits()[0].name() == ~"i"); } #[test] fn should_extract_trait_methods() { let doc = test::mk_doc(~"trait i { fn f(); }"); - assert doc.cratemod().traits()[0].methods[0].name == ~"f"; + fail_unless!(doc.cratemod().traits()[0].methods[0].name == ~"f"); } fn impldoc_from_impl( @@ -295,7 +295,7 @@ fn impldoc_from_impl( #[test] fn should_extract_impl_methods() { let doc = test::mk_doc(~"impl int { fn f() { } }"); - assert doc.cratemod().impls()[0].methods[0].name == ~"f"; + fail_unless!(doc.cratemod().impls()[0].methods[0].name == ~"f"); } fn tydoc_from_ty( @@ -310,7 +310,7 @@ fn tydoc_from_ty( #[test] fn should_extract_tys() { let doc = test::mk_doc(~"type a = int;"); - assert doc.cratemod().types()[0].name() == ~"a"; + fail_unless!(doc.cratemod().types()[0].name() == ~"a"); } fn structdoc_from_struct( @@ -333,13 +333,13 @@ fn structdoc_from_struct( #[test] fn should_extract_structs() { let doc = test::mk_doc(~"struct Foo { field: () }"); - assert doc.cratemod().structs()[0].name() == ~"Foo"; + fail_unless!(doc.cratemod().structs()[0].name() == ~"Foo"); } #[test] fn should_extract_struct_fields() { let doc = test::mk_doc(~"struct Foo { field: () }"); - assert doc.cratemod().structs()[0].fields[0] == ~"field"; + fail_unless!(doc.cratemod().structs()[0].fields[0] == ~"field"); } #[cfg(test)] @@ -359,34 +359,34 @@ mod test { #[test] pub fn extract_empty_crate() { let doc = mk_doc(~""); - assert vec::is_empty(doc.cratemod().mods()); - assert vec::is_empty(doc.cratemod().fns()); + fail_unless!(vec::is_empty(doc.cratemod().mods())); + fail_unless!(vec::is_empty(doc.cratemod().fns())); } #[test] pub fn extract_mods() { let doc = mk_doc(~"mod a { mod b { } mod c { } }"); - assert doc.cratemod().mods()[0].name() == ~"a"; - assert doc.cratemod().mods()[0].mods()[0].name() == ~"b"; - assert doc.cratemod().mods()[0].mods()[1].name() == ~"c"; + fail_unless!(doc.cratemod().mods()[0].name() == ~"a"); + fail_unless!(doc.cratemod().mods()[0].mods()[0].name() == ~"b"); + fail_unless!(doc.cratemod().mods()[0].mods()[1].name() == ~"c"); } #[test] pub fn extract_fns_from_foreign_mods() { let doc = mk_doc(~"extern { fn a(); }"); - assert doc.cratemod().nmods()[0].fns[0].name() == ~"a"; + fail_unless!(doc.cratemod().nmods()[0].fns[0].name() == ~"a"); } #[test] pub fn extract_mods_deep() { let doc = mk_doc(~"mod a { mod b { mod c { } } }"); - assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c"; + fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c"); } #[test] pub fn extract_should_set_mod_ast_id() { let doc = mk_doc(~"mod a { }"); - assert doc.cratemod().mods()[0].id() != 0; + fail_unless!(doc.cratemod().mods()[0].id() != 0); } #[test] @@ -395,14 +395,14 @@ mod test { ~"fn a() { } \ mod b { fn c() { } }"); - assert doc.cratemod().fns()[0].name() == ~"a"; - assert doc.cratemod().mods()[0].fns()[0].name() == ~"c"; + fail_unless!(doc.cratemod().fns()[0].name() == ~"a"); + fail_unless!(doc.cratemod().mods()[0].fns()[0].name() == ~"c"); } #[test] pub fn extract_should_set_fn_ast_id() { let doc = mk_doc(~"fn a() { }"); - assert doc.cratemod().fns()[0].id() != 0; + fail_unless!(doc.cratemod().fns()[0].id() != 0); } #[test] @@ -410,7 +410,7 @@ mod test { let source = ~""; let ast = parse::from_str(source); let doc = extract(ast, ~"burp"); - assert doc.cratemod().name() == ~"burp"; + fail_unless!(doc.cratemod().name() == ~"burp"); } #[test] @@ -418,7 +418,7 @@ mod test { let source = ~""; do astsrv::from_str(source) |srv| { let doc = from_srv(srv, ~"name"); - assert doc.cratemod().name() == ~"name"; + fail_unless!(doc.cratemod().name() == ~"name"); } } } diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 4ea67c1bff6..e9d9732d51f 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -373,7 +373,7 @@ fn default_fold_should_produce_same_doc() { let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = (fld.fold_doc)(&fld, copy doc); - assert doc == folded; + fail_unless!(doc == folded); } #[test] @@ -383,7 +383,7 @@ fn default_fold_should_produce_same_consts() { let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = (fld.fold_doc)(&fld, copy doc); - assert doc == folded; + fail_unless!(doc == folded); } #[test] @@ -393,7 +393,7 @@ fn default_fold_should_produce_same_enums() { let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); let folded = (fld.fold_doc)(&fld, copy doc); - assert doc == folded; + fail_unless!(doc == folded); } #[test] @@ -403,5 +403,5 @@ fn default_parallel_fold_should_produce_same_doc() { let doc = extract::extract(ast, ~""); let fld = default_par_fold(()); let folded = (fld.fold_doc)(&fld, copy doc); - assert doc == folded; + fail_unless!(doc == folded); } diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index cfec1857df9..b18694d00db 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -160,15 +160,15 @@ fn pandoc_header_id(header: &str) -> ~str { #[test] fn should_remove_punctuation_from_headers() { - assert pandoc_header_id(~"impl foo of bar") == ~"impl-foo-of-bara"; - assert pandoc_header_id(~"impl of num::num for int") - == ~"impl-of-numnum-for-int"; - assert pandoc_header_id(~"impl of num::num for int/&") - == ~"impl-of-numnum-for-int"; - assert pandoc_header_id(~"impl of num::num for ^int") - == ~"impl-of-numnum-for-int"; - assert pandoc_header_id(~"impl for & condvar") - == ~"impl-for-condvar"; + fail_unless!(pandoc_header_id(~"impl foo of bar") == ~"impl-foo-of-bara"); + fail_unless!(pandoc_header_id(~"impl of num::num for int") + == ~"impl-of-numnum-for-int"); + fail_unless!(pandoc_header_id(~"impl of num::num for int/&") + == ~"impl-of-numnum-for-int"); + fail_unless!(pandoc_header_id(~"impl of num::num for ^int") + == ~"impl-of-numnum-for-int"); + fail_unless!(pandoc_header_id(~"impl for & condvar") + == ~"impl-for-condvar"); } #[test] @@ -177,18 +177,18 @@ fn should_index_mod_contents() { config::DocPerCrate, ~"mod a { } fn b() { }" ); - assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry { + fail_unless!((&doc.cratemod().index).get().entries[0] == doc::IndexEntry { kind: ~"Module", name: ~"a", brief: None, link: ~"#module-a" - }; - assert (&doc.cratemod().index).get().entries[1] == doc::IndexEntry { + }); + fail_unless!((&doc.cratemod().index).get().entries[1] == doc::IndexEntry { kind: ~"Function", name: ~"b", brief: None, link: ~"#function-b" - }; + }); } #[test] @@ -197,18 +197,18 @@ fn should_index_mod_contents_multi_page() { config::DocPerMod, ~"mod a { } fn b() { }" ); - assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry { + fail_unless!((&doc.cratemod().index).get().entries[0] == doc::IndexEntry { kind: ~"Module", name: ~"a", brief: None, link: ~"a.html" - }; - assert (&doc.cratemod().index).get().entries[1] == doc::IndexEntry { + }); + fail_unless!((&doc.cratemod().index).get().entries[1] == doc::IndexEntry { kind: ~"Function", name: ~"b", brief: None, link: ~"#function-b" - }; + }); } #[test] @@ -217,12 +217,12 @@ fn should_index_foreign_mod_pages() { config::DocPerMod, ~"extern mod a { }" ); - assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry { + fail_unless!((&doc.cratemod().index).get().entries[0] == doc::IndexEntry { kind: ~"Foreign module", name: ~"a", brief: None, link: ~"a.html" - }; + }); } #[test] @@ -231,8 +231,8 @@ fn should_add_brief_desc_to_index() { config::DocPerMod, ~"#[doc = \"test\"] mod a { }" ); - assert (&doc.cratemod().index).get().entries[0].brief - == Some(~"test"); + fail_unless!((&doc.cratemod().index).get().entries[0].brief + == Some(~"test")); } #[test] @@ -241,13 +241,13 @@ fn should_index_foreign_mod_contents() { config::DocPerCrate, ~"extern mod a { fn b(); }" ); - assert (&doc.cratemod().nmods()[0].index).get().entries[0] + fail_unless!((&doc.cratemod().nmods()[0].index).get().entries[0] == doc::IndexEntry { kind: ~"Function", name: ~"b", brief: None, link: ~"#function-b" - }; + }); } #[cfg(test)] diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index cb92e078fdd..888814f9e7b 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -91,9 +91,9 @@ fn should_write_modules_last() { let idx_c = str::find_str(markdown, ~"# Module `c`").get(); let idx_d = str::find_str(markdown, ~"## Function `d`").get(); - assert idx_b < idx_d; - assert idx_d < idx_a; - assert idx_a < idx_c; + fail_unless!(idx_b < idx_d); + fail_unless!(idx_d < idx_a); + fail_unless!(idx_a < idx_c); } struct Ctxt { @@ -175,10 +175,10 @@ fn should_write_title_for_each_page() { let (page, markdown) = po.recv(); match page { doc::CratePage(_) => { - assert str::contains(markdown, ~"% Crate core"); + fail_unless!(str::contains(markdown, ~"% Crate core")); } doc::ItemPage(_) => { - assert str::contains(markdown, ~"% Module a"); + fail_unless!(str::contains(markdown, ~"% Module a")); } } } @@ -248,7 +248,7 @@ pub fn header_name(doc: doc::ItemTag) -> ~str { fullpath } &doc::ImplTag(ref doc) => { - assert doc.self_ty.is_some(); + fail_unless!(doc.self_ty.is_some()); let self_ty = (&doc.self_ty).get(); let mut trait_part = ~""; for doc.trait_types.eachi |i, trait_type| { @@ -314,7 +314,7 @@ fn write_mod( #[test] fn should_write_full_path_to_mod() { let markdown = test::render(~"mod a { mod b { mod c { } } }"); - assert str::contains(markdown, ~"# Module `a::b::c`"); + fail_unless!(str::contains(markdown, ~"# Module `a::b::c`")); } fn write_common( @@ -359,7 +359,7 @@ fn should_write_sections() { Body\"]\ mod a { }"); - assert str::contains(markdown, ~"#### Header\n\nBody\n\n"); + fail_unless!(str::contains(markdown, ~"#### Header\n\nBody\n\n")); } fn write_mod_contents( @@ -416,7 +416,7 @@ fn item_header_lvl(doc: &doc::ItemTag) -> Hlvl { #[test] fn should_write_crate_description() { let markdown = test::render(~"#[doc = \"this is the crate\"];"); - assert str::contains(markdown, ~"this is the crate"); + fail_unless!(str::contains(markdown, ~"this is the crate")); } fn write_index(ctxt: &Ctxt, index: doc::Index) { @@ -440,32 +440,32 @@ fn write_index(ctxt: &Ctxt, index: doc::Index) { #[test] fn should_write_index() { let markdown = test::render(~"mod a { } mod b { }"); - assert str::contains( + fail_unless!(str::contains( markdown, ~"\n\n* [Module `a`](#module-a)\n\ * [Module `b`](#module-b)\n\n" - ); + )); } #[test] fn should_write_index_brief() { let markdown = test::render(~"#[doc = \"test\"] mod a { }"); - assert str::contains(markdown, ~"(#module-a) - test\n"); + fail_unless!(str::contains(markdown, ~"(#module-a) - test\n")); } #[test] fn should_not_write_index_if_no_entries() { let markdown = test::render(~""); - assert !str::contains(markdown, ~"\n\n\n"); + fail_unless!(!str::contains(markdown, ~"\n\n\n")); } #[test] fn should_write_index_for_foreign_mods() { let markdown = test::render(~"extern mod a { fn a(); }"); - assert str::contains( + fail_unless!(str::contains( markdown, ~"\n\n* [Function `a`](#function-a)\n\n" - ); + )); } fn write_nmod(ctxt: &Ctxt, doc: doc::NmodDoc) { @@ -483,22 +483,22 @@ fn write_nmod(ctxt: &Ctxt, doc: doc::NmodDoc) { #[test] fn should_write_foreign_mods() { let markdown = test::render(~"#[doc = \"test\"] extern mod a { }"); - assert str::contains(markdown, ~"Foreign module `a`"); - assert str::contains(markdown, ~"test"); + fail_unless!(str::contains(markdown, ~"Foreign module `a`")); + fail_unless!(str::contains(markdown, ~"test")); } #[test] fn should_write_foreign_fns() { let markdown = test::render( ~"extern mod a { #[doc = \"test\"] fn a(); }"); - assert str::contains(markdown, ~"test"); + fail_unless!(str::contains(markdown, ~"test")); } #[test] fn should_write_foreign_fn_headers() { let markdown = test::render( ~"extern mod a { #[doc = \"test\"] fn a(); }"); - assert str::contains(markdown, ~"## Function `a`"); + fail_unless!(str::contains(markdown, ~"## Function `a`")); } fn write_fn( @@ -542,19 +542,19 @@ fn code_block_indent(s: ~str) -> ~str { #[test] fn write_markdown_should_write_function_header() { let markdown = test::render(~"fn func() { }"); - assert str::contains(markdown, ~"## Function `func`"); + fail_unless!(str::contains(markdown, ~"## Function `func`")); } #[test] fn should_write_the_function_signature() { let markdown = test::render(~"#[doc = \"f\"] fn a() { }"); - assert str::contains(markdown, ~"\n fn a()\n"); + fail_unless!(str::contains(markdown, ~"\n fn a()\n")); } #[test] fn should_insert_blank_line_after_fn_signature() { let markdown = test::render(~"#[doc = \"f\"] fn a() { }"); - assert str::contains(markdown, ~"fn a()\n\n"); + fail_unless!(str::contains(markdown, ~"fn a()\n\n")); } #[test] @@ -575,13 +575,13 @@ fn should_correctly_indent_fn_signature() { ] }; let markdown = test::write_markdown_str(doc); - assert str::contains(markdown, ~" line 1\n line 2"); + fail_unless!(str::contains(markdown, ~" line 1\n line 2")); } #[test] fn should_leave_blank_line_between_fn_header_and_sig() { let markdown = test::render(~"fn a() { }"); - assert str::contains(markdown, ~"Function `a`\n\n fn a()"); + fail_unless!(str::contains(markdown, ~"Function `a`\n\n fn a()")); } fn write_const( @@ -595,7 +595,7 @@ fn write_const( #[test] fn should_write_const_header() { let markdown = test::render(~"const a: bool = true;"); - assert str::contains(markdown, ~"## Const `a`\n\n"); + fail_unless!(str::contains(markdown, ~"## Const `a`\n\n")); } #[test] @@ -603,7 +603,7 @@ fn should_write_const_description() { let markdown = test::render( ~"#[doc = \"b\"]\ const a: bool = true;"); - assert str::contains(markdown, ~"\n\nb\n\n"); + fail_unless!(str::contains(markdown, ~"\n\nb\n\n")); } fn write_enum( @@ -617,14 +617,14 @@ fn write_enum( #[test] fn should_write_enum_header() { let markdown = test::render(~"enum a { b }"); - assert str::contains(markdown, ~"## Enum `a`\n\n"); + fail_unless!(str::contains(markdown, ~"## Enum `a`\n\n")); } #[test] fn should_write_enum_description() { let markdown = test::render( ~"#[doc = \"b\"] enum a { b }"); - assert str::contains(markdown, ~"\n\nb\n\n"); + fail_unless!(str::contains(markdown, ~"\n\nb\n\n")); } fn write_variants( @@ -645,7 +645,7 @@ fn write_variants( } fn write_variant(ctxt: &Ctxt, doc: doc::VariantDoc) { - assert doc.sig.is_some(); + fail_unless!(doc.sig.is_some()); let sig = (&doc.sig).get(); match copy doc.desc { Some(desc) => { @@ -663,31 +663,31 @@ fn should_write_variant_list() { ~"enum a { \ #[doc = \"test\"] b, \ #[doc = \"test\"] c }"); - assert str::contains( + fail_unless!(str::contains( markdown, ~"\n\n#### Variants\n\ \n* `b` - test\ - \n* `c` - test\n\n"); + \n* `c` - test\n\n")); } #[test] fn should_write_variant_list_without_descs() { let markdown = test::render(~"enum a { b, c }"); - assert str::contains( + fail_unless!(str::contains( markdown, ~"\n\n#### Variants\n\ \n* `b`\ - \n* `c`\n\n"); + \n* `c`\n\n")); } #[test] fn should_write_variant_list_with_signatures() { let markdown = test::render(~"enum a { b(int), #[doc = \"a\"] c(int) }"); - assert str::contains( + fail_unless!(str::contains( markdown, ~"\n\n#### Variants\n\ \n* `b(int)`\ - \n* `c(int)` - a\n\n"); + \n* `c(int)` - a\n\n")); } fn write_trait(ctxt: &Ctxt, doc: doc::TraitDoc) { @@ -714,28 +714,28 @@ fn write_method(ctxt: &Ctxt, doc: doc::MethodDoc) { #[test] fn should_write_trait_header() { let markdown = test::render(~"trait i { fn a(); }"); - assert str::contains(markdown, ~"## Trait `i`"); + fail_unless!(str::contains(markdown, ~"## Trait `i`")); } #[test] fn should_write_trait_desc() { let markdown = test::render( ~"#[doc = \"desc\"] trait i { fn a(); }"); - assert str::contains(markdown, ~"desc"); + fail_unless!(str::contains(markdown, ~"desc")); } #[test] fn should_write_trait_method_header() { let markdown = test::render( ~"trait i { fn a(); }"); - assert str::contains(markdown, ~"### Method `a`"); + fail_unless!(str::contains(markdown, ~"### Method `a`")); } #[test] fn should_write_trait_method_signature() { let markdown = test::render( ~"trait i { fn a(); }"); - assert str::contains(markdown, ~"\n fn a()"); + fail_unless!(str::contains(markdown, ~"\n fn a()")); } fn write_impl(ctxt: &Ctxt, doc: doc::ImplDoc) { @@ -746,34 +746,34 @@ fn write_impl(ctxt: &Ctxt, doc: doc::ImplDoc) { #[test] fn should_write_impl_header() { let markdown = test::render(~"impl int { fn a() { } }"); - assert str::contains(markdown, ~"## Implementation for `int`"); + fail_unless!(str::contains(markdown, ~"## Implementation for `int`")); } #[test] fn should_write_impl_header_with_trait() { let markdown = test::render(~"impl j for int { fn a() { } }"); - assert str::contains(markdown, ~"## Implementation of `j` for `int`"); + fail_unless!(str::contains(markdown, ~"## Implementation of `j` for `int`")); } #[test] fn should_write_impl_desc() { let markdown = test::render( ~"#[doc = \"desc\"] impl int { fn a() { } }"); - assert str::contains(markdown, ~"desc"); + fail_unless!(str::contains(markdown, ~"desc")); } #[test] fn should_write_impl_method_header() { let markdown = test::render( ~"impl int { fn a() { } }"); - assert str::contains(markdown, ~"### Method `a`"); + fail_unless!(str::contains(markdown, ~"### Method `a`")); } #[test] fn should_write_impl_method_signature() { let markdown = test::render( ~"impl int { fn a() { } }"); - assert str::contains(markdown, ~"\n fn a()"); + fail_unless!(str::contains(markdown, ~"\n fn a()")); } fn write_type( @@ -787,20 +787,20 @@ fn write_type( #[test] fn should_write_type_header() { let markdown = test::render(~"type t = int;"); - assert str::contains(markdown, ~"## Type `t`"); + fail_unless!(str::contains(markdown, ~"## Type `t`")); } #[test] fn should_write_type_desc() { let markdown = test::render( ~"#[doc = \"desc\"] type t = int;"); - assert str::contains(markdown, ~"\n\ndesc\n\n"); + fail_unless!(str::contains(markdown, ~"\n\ndesc\n\n")); } #[test] fn should_write_type_signature() { let markdown = test::render(~"type t = int;"); - assert str::contains(markdown, ~"\n\n type t = int\n\n"); + fail_unless!(str::contains(markdown, ~"\n\n type t = int\n\n")); } fn write_struct( @@ -814,7 +814,7 @@ fn write_struct( #[test] fn should_write_struct_header() { let markdown = test::render(~"struct S { field: () }"); - assert str::contains(markdown, ~"## Struct `S`\n\n"); + fail_unless!(str::contains(markdown, ~"## Struct `S`\n\n")); } #[cfg(test)] @@ -901,12 +901,12 @@ mod test { #[test] pub fn write_markdown_should_write_mod_headers() { let markdown = render(~"mod moo { }"); - assert str::contains(markdown, ~"# Module `moo`"); + fail_unless!(str::contains(markdown, ~"# Module `moo`")); } #[test] pub fn should_leave_blank_line_after_header() { let markdown = render(~"mod morp { }"); - assert str::contains(markdown, ~"Module `morp`\n\n"); + fail_unless!(str::contains(markdown, ~"Module `morp`\n\n")); } } diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index acd456e77be..45fef5b80b8 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -92,7 +92,7 @@ fn pandoc_writer( config: config::Config, page: doc::Page ) -> Writer { - assert config.pandoc_cmd.is_some(); + fail_unless!(config.pandoc_cmd.is_some()); let pandoc_cmd = (&config.pandoc_cmd).get(); let filename = make_local_filename(config, page); @@ -201,7 +201,7 @@ pub fn make_filename( config.output_style == config::DocPerMod { ~"index" } else { - assert doc.topmod.name() != ~""; + fail_unless!(doc.topmod.name() != ~""); doc.topmod.name() } } @@ -229,7 +229,7 @@ fn should_use_markdown_file_name_based_off_crate() { let doc = test::mk_doc(~"test", ~""); let page = doc::CratePage(doc.CrateDoc()); let filename = make_local_filename(config, page); - assert filename.to_str() == ~"output/dir/test.md"; + fail_unless!(filename.to_str() == ~"output/dir/test.md"); } #[test] @@ -243,7 +243,7 @@ fn should_name_html_crate_file_name_index_html_when_doc_per_mod() { let doc = test::mk_doc(~"", ~""); let page = doc::CratePage(doc.CrateDoc()); let filename = make_local_filename(config, page); - assert filename.to_str() == ~"output/dir/index.html"; + fail_unless!(filename.to_str() == ~"output/dir/index.html"); } #[test] @@ -258,7 +258,7 @@ fn should_name_mod_file_names_by_path() { let modb = copy doc.cratemod().mods()[0].mods()[0]; let page = doc::ItemPage(doc::ModTag(modb)); let filename = make_local_filename(config, page); - assert filename == Path("output/dir/a_b.html"); + fail_unless!(filename == Path("output/dir/a_b.html")); } #[cfg(test)] diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs index 6e2f764de71..d5e877de712 100644 --- a/src/librustdoc/page_pass.rs +++ b/src/librustdoc/page_pass.rs @@ -154,19 +154,19 @@ fn should_not_split_the_doc_into_pages_for_doc_per_crate() { config::DocPerCrate, ~"mod a { } mod b { mod c { } }" ); - assert doc.pages.len() == 1u; + fail_unless!(doc.pages.len() == 1u); } #[test] fn should_make_a_page_for_every_mod() { let doc = test::mk_doc(~"mod a { }"); - assert doc.pages.mods()[0].name() == ~"a"; + fail_unless!(doc.pages.mods()[0].name() == ~"a"); } #[test] fn should_remove_mods_from_containing_mods() { let doc = test::mk_doc(~"mod a { }"); - assert vec::is_empty(doc.cratemod().mods()); + fail_unless!(vec::is_empty(doc.cratemod().mods())); } #[cfg(test)] diff --git a/src/librustdoc/pass.rs b/src/librustdoc/pass.rs index b4d0cfe7c93..7b80b0b4ae8 100644 --- a/src/librustdoc/pass.rs +++ b/src/librustdoc/pass.rs @@ -93,6 +93,6 @@ fn test_run_passes() { ]; let doc = extract::from_srv(srv.clone(), ~"one"); let doc = run_passes(srv, doc, passes); - assert doc.cratemod().name() == ~"onetwothree"; + fail_unless!(doc.cratemod().name() == ~"onetwothree"); } } diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index 4b41021beb7..58b25446dc1 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -98,10 +98,10 @@ fn should_record_mod_paths() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = run(srv.clone(), doc); - assert doc.cratemod().mods()[0].mods()[0].mods()[0].path() - == ~[~"a", ~"b"]; - assert doc.cratemod().mods()[0].mods()[1].mods()[0].path() - == ~[~"a", ~"d"]; + fail_unless!(doc.cratemod().mods()[0].mods()[0].mods()[0].path() + == ~[~"a", ~"b"]); + fail_unless!(doc.cratemod().mods()[0].mods()[1].mods()[0].path() + == ~[~"a", ~"d"]); } } @@ -111,7 +111,7 @@ fn should_record_fn_paths() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = run(srv.clone(), doc); - assert doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]; + fail_unless!(doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]); } } diff --git a/src/librustdoc/prune_hidden_pass.rs b/src/librustdoc/prune_hidden_pass.rs index 3755fd706c0..bbd975dd55a 100644 --- a/src/librustdoc/prune_hidden_pass.rs +++ b/src/librustdoc/prune_hidden_pass.rs @@ -66,7 +66,7 @@ fn should_prune_hidden_items() { use core::vec; let doc = test::mk_doc(~"#[doc(hidden)] mod a { }"); - assert vec::is_empty(doc.cratemod().mods()) + fail_unless!(vec::is_empty(doc.cratemod().mods())) } #[cfg(test)] diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index 85f25901ad1..17f11de8aeb 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -69,7 +69,7 @@ fn is_visible(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool { #[test] fn should_prune_items_without_pub_modifier() { let doc = test::mk_doc(~"mod a { }"); - assert vec::is_empty(doc.cratemod().mods()); + fail_unless!(vec::is_empty(doc.cratemod().mods())); } #[cfg(test)] diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 91f352a2eac..e64d4ccf69e 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -168,9 +168,9 @@ fn should_create_section_headers() { Body\"]\ mod a { }"); - assert str::contains( + fail_unless!(str::contains( doc.cratemod().mods()[0].item.sections[0].header, - ~"Header"); + ~"Header")); } #[test] @@ -181,9 +181,9 @@ fn should_create_section_bodies() { Body\"]\ mod a { }"); - assert str::contains( + fail_unless!(str::contains( doc.cratemod().mods()[0].item.sections[0].body, - ~"Body"); + ~"Body")); } #[test] @@ -194,7 +194,7 @@ fn should_not_create_sections_from_indented_headers() { Body\"]\ mod a { }"); - assert vec::is_empty(doc.cratemod().mods()[0].item.sections); + fail_unless!(vec::is_empty(doc.cratemod().mods()[0].item.sections)); } #[test] @@ -206,12 +206,12 @@ fn should_remove_section_text_from_main_desc() { Body\"]\ mod a { }"); - assert !str::contains( + fail_unless!(!str::contains( doc.cratemod().mods()[0].desc().get(), - ~"Header"); - assert !str::contains( + ~"Header")); + fail_unless!(!str::contains( doc.cratemod().mods()[0].desc().get(), - ~"Body"); + ~"Body")); } #[test] @@ -222,7 +222,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() { Body\"]\ mod a { }"); - assert doc.cratemod().mods()[0].desc() == None; + fail_unless!(doc.cratemod().mods()[0].desc() == None); } #[test] @@ -233,7 +233,7 @@ fn should_sectionalize_trait_methods() { # Header\n\ Body\"]\ fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].sections.len() == 1u; + fail_unless!(doc.cratemod().traits()[0].methods[0].sections.len() == 1u); } #[test] @@ -244,7 +244,7 @@ fn should_sectionalize_impl_methods() { # Header\n\ Body\"]\ fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].sections.len() == 1u; + fail_unless!(doc.cratemod().impls()[0].methods[0].sections.len() == 1u); } #[cfg(test)] diff --git a/src/librustdoc/sort_item_name_pass.rs b/src/librustdoc/sort_item_name_pass.rs index b20faf44fa4..0e6d83fa45f 100644 --- a/src/librustdoc/sort_item_name_pass.rs +++ b/src/librustdoc/sort_item_name_pass.rs @@ -31,7 +31,7 @@ fn test() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = (mk_pass().f)(srv.clone(), doc); - assert doc.cratemod().items[0].name() == ~"y"; - assert doc.cratemod().items[1].name() == ~"z"; + fail_unless!(doc.cratemod().items[0].name() == ~"y"); + fail_unless!(doc.cratemod().items[1].name() == ~"z"); } } diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index 8b39dcb1f8f..cddd5068816 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -55,14 +55,14 @@ fn test() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = (mk_pass().f)(srv.clone(), doc); - assert doc.cratemod().items[0].name() == ~"iconst"; - assert doc.cratemod().items[1].name() == ~"itype"; - assert doc.cratemod().items[2].name() == ~"ienum"; - assert doc.cratemod().items[3].name() == ~"istruct"; - assert doc.cratemod().items[4].name() == ~"itrait"; - assert doc.cratemod().items[5].name() == ~"__extensions__"; - assert doc.cratemod().items[6].name() == ~"ifn"; - assert doc.cratemod().items[7].name() == ~"imod"; - assert doc.cratemod().items[8].name() == ~"inmod"; + fail_unless!(doc.cratemod().items[0].name() == ~"iconst"); + fail_unless!(doc.cratemod().items[1].name() == ~"itype"); + fail_unless!(doc.cratemod().items[2].name() == ~"ienum"); + fail_unless!(doc.cratemod().items[3].name() == ~"istruct"); + fail_unless!(doc.cratemod().items[4].name() == ~"itrait"); + fail_unless!(doc.cratemod().items[5].name() == ~"__extensions__"); + fail_unless!(doc.cratemod().items[6].name() == ~"ifn"); + fail_unless!(doc.cratemod().items[7].name() == ~"imod"); + fail_unless!(doc.cratemod().items[8].name() == ~"inmod"); } } diff --git a/src/librustdoc/sort_pass.rs b/src/librustdoc/sort_pass.rs index c1e58f30c7a..4f4c5ea65d4 100644 --- a/src/librustdoc/sort_pass.rs +++ b/src/librustdoc/sort_pass.rs @@ -67,10 +67,10 @@ fn test() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = (mk_pass(~"", name_lteq).f)(srv.clone(), doc); - assert doc.cratemod().mods()[0].name() == ~"w"; - assert doc.cratemod().mods()[1].items[0].name() == ~"x"; - assert doc.cratemod().mods()[1].items[1].name() == ~"y"; - assert doc.cratemod().mods()[1].name() == ~"z"; + fail_unless!(doc.cratemod().mods()[0].name() == ~"w"); + fail_unless!(doc.cratemod().mods()[1].items[0].name() == ~"x"); + fail_unless!(doc.cratemod().mods()[1].items[1].name() == ~"y"); + fail_unless!(doc.cratemod().mods()[1].name() == ~"z"); } } @@ -84,10 +84,10 @@ fn should_be_stable() { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc); - assert doc.cratemod().mods()[0].items[0].name() == ~"b"; - assert doc.cratemod().mods()[1].items[0].name() == ~"d"; + fail_unless!(doc.cratemod().mods()[0].items[0].name() == ~"b"); + fail_unless!(doc.cratemod().mods()[1].items[0].name() == ~"d"); let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc); - assert doc.cratemod().mods()[0].items[0].name() == ~"b"; - assert doc.cratemod().mods()[1].items[0].name() == ~"d"; + fail_unless!(doc.cratemod().mods()[0].items[0].name() == ~"b"); + fail_unless!(doc.cratemod().mods()[1].items[0].name() == ~"d"); } } diff --git a/src/librustdoc/text_pass.rs b/src/librustdoc/text_pass.rs index 22bdc08a50e..1bd83375607 100644 --- a/src/librustdoc/text_pass.rs +++ b/src/librustdoc/text_pass.rs @@ -140,89 +140,89 @@ fn fold_impl( #[test] fn should_execute_op_on_enum_brief() { let doc = test::mk_doc(~"#[doc = \" a \"] enum a { b }"); - assert doc.cratemod().enums()[0].brief() == Some(~"a"); + fail_unless!(doc.cratemod().enums()[0].brief() == Some(~"a")); } #[test] fn should_execute_op_on_enum_desc() { let doc = test::mk_doc(~"#[doc = \" a \"] enum a { b }"); - assert doc.cratemod().enums()[0].desc() == Some(~"a"); + fail_unless!(doc.cratemod().enums()[0].desc() == Some(~"a")); } #[test] fn should_execute_op_on_variant_desc() { let doc = test::mk_doc(~"enum a { #[doc = \" a \"] b }"); - assert doc.cratemod().enums()[0].variants[0].desc == Some(~"a"); + fail_unless!(doc.cratemod().enums()[0].variants[0].desc == Some(~"a")); } #[test] fn should_execute_op_on_trait_brief() { let doc = test::mk_doc( ~"#[doc = \" a \"] trait i { fn a(); }"); - assert doc.cratemod().traits()[0].brief() == Some(~"a"); + fail_unless!(doc.cratemod().traits()[0].brief() == Some(~"a")); } #[test] fn should_execute_op_on_trait_desc() { let doc = test::mk_doc( ~"#[doc = \" a \"] trait i { fn a(); }"); - assert doc.cratemod().traits()[0].desc() == Some(~"a"); + fail_unless!(doc.cratemod().traits()[0].desc() == Some(~"a")); } #[test] fn should_execute_op_on_trait_method_brief() { let doc = test::mk_doc( ~"trait i { #[doc = \" a \"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].brief == Some(~"a"); + fail_unless!(doc.cratemod().traits()[0].methods[0].brief == Some(~"a")); } #[test] fn should_execute_op_on_trait_method_desc() { let doc = test::mk_doc( ~"trait i { #[doc = \" a \"] fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].desc == Some(~"a"); + fail_unless!(doc.cratemod().traits()[0].methods[0].desc == Some(~"a")); } #[test] fn should_execute_op_on_impl_brief() { let doc = test::mk_doc( ~"#[doc = \" a \"] impl int { fn a() { } }"); - assert doc.cratemod().impls()[0].brief() == Some(~"a"); + fail_unless!(doc.cratemod().impls()[0].brief() == Some(~"a")); } #[test] fn should_execute_op_on_impl_desc() { let doc = test::mk_doc( ~"#[doc = \" a \"] impl int { fn a() { } }"); - assert doc.cratemod().impls()[0].desc() == Some(~"a"); + fail_unless!(doc.cratemod().impls()[0].desc() == Some(~"a")); } #[test] fn should_execute_op_on_impl_method_brief() { let doc = test::mk_doc( ~"impl int { #[doc = \" a \"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].brief == Some(~"a"); + fail_unless!(doc.cratemod().impls()[0].methods[0].brief == Some(~"a")); } #[test] fn should_execute_op_on_impl_method_desc() { let doc = test::mk_doc( ~"impl int { #[doc = \" a \"] fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].desc == Some(~"a"); + fail_unless!(doc.cratemod().impls()[0].methods[0].desc == Some(~"a")); } #[test] fn should_execute_op_on_type_brief() { let doc = test::mk_doc( ~"#[doc = \" a \"] type t = int;"); - assert doc.cratemod().types()[0].brief() == Some(~"a"); + fail_unless!(doc.cratemod().types()[0].brief() == Some(~"a")); } #[test] fn should_execute_op_on_type_desc() { let doc = test::mk_doc( ~"#[doc = \" a \"] type t = int;"); - assert doc.cratemod().types()[0].desc() == Some(~"a"); + fail_unless!(doc.cratemod().types()[0].desc() == Some(~"a")); } #[test] @@ -232,7 +232,7 @@ fn should_execute_on_item_section_headers() { # Header \n\ Body\"]\ fn a() { }"); - assert doc.cratemod().fns()[0].sections()[0].header == ~"Header"; + fail_unless!(doc.cratemod().fns()[0].sections()[0].header == ~"Header"); } #[test] @@ -242,7 +242,7 @@ fn should_execute_on_item_section_bodies() { # Header\n\ Body \"]\ fn a() { }"); - assert doc.cratemod().fns()[0].sections()[0].body == ~"Body"; + fail_unless!(doc.cratemod().fns()[0].sections()[0].body == ~"Body"); } #[test] @@ -253,8 +253,8 @@ fn should_execute_on_trait_method_section_headers() { # Header \n\ Body\"]\ fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].sections[0].header - == ~"Header"; + fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].header + == ~"Header"); } #[test] @@ -265,7 +265,7 @@ fn should_execute_on_trait_method_section_bodies() { # Header\n\ Body \"]\ fn a(); }"); - assert doc.cratemod().traits()[0].methods[0].sections[0].body == ~"Body"; + fail_unless!(doc.cratemod().traits()[0].methods[0].sections[0].body == ~"Body"); } #[test] @@ -276,8 +276,8 @@ fn should_execute_on_impl_method_section_headers() { # Header \n\ Body\"]\ fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].sections[0].header - == ~"Header"; + fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].header + == ~"Header"); } #[test] @@ -288,7 +288,7 @@ fn should_execute_on_impl_method_section_bodies() { # Header\n\ Body \"]\ fn a() { } }"); - assert doc.cratemod().impls()[0].methods[0].sections[0].body == ~"Body"; + fail_unless!(doc.cratemod().impls()[0].methods[0].sections[0].body == ~"Body"); } #[cfg(test)] diff --git a/src/librustdoc/trim_pass.rs b/src/librustdoc/trim_pass.rs index eb63d9a52d0..58d629163e2 100644 --- a/src/librustdoc/trim_pass.rs +++ b/src/librustdoc/trim_pass.rs @@ -31,7 +31,7 @@ fn should_trim_text() { let doc = test::mk_doc(~"#[doc = \" desc \"] \ mod m { }"); - assert doc.cratemod().mods()[0].desc() == Some(~"desc"); + fail_unless!(doc.cratemod().mods()[0].desc() == Some(~"desc")); } #[cfg(test)] diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index c1e7675fd0e..2765a844f30 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -86,13 +86,13 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> { #[test] fn should_add_fn_sig() { let doc = test::mk_doc(~"fn a() -> int { }"); - assert doc.cratemod().fns()[0].sig == Some(~"fn a() -> int"); + fail_unless!(doc.cratemod().fns()[0].sig == Some(~"fn a() -> int")); } #[test] fn should_add_foreign_fn_sig() { let doc = test::mk_doc(~"extern mod a { fn a() -> int; }"); - assert doc.cratemod().nmods()[0].fns[0].sig == Some(~"fn a() -> int"); + fail_unless!(doc.cratemod().nmods()[0].fns[0].sig == Some(~"fn a() -> int")); } fn fold_const( @@ -121,7 +121,7 @@ fn fold_const( #[test] fn should_add_const_types() { let doc = test::mk_doc(~"const a: bool = true;"); - assert doc.cratemod().consts()[0].sig == Some(~"bool"); + fail_unless!(doc.cratemod().consts()[0].sig == Some(~"bool")); } fn fold_enum( @@ -165,7 +165,7 @@ fn fold_enum( #[test] fn should_add_variant_sigs() { let doc = test::mk_doc(~"enum a { b(int) }"); - assert doc.cratemod().enums()[0].variants[0].sig == Some(~"b(int)"); + fail_unless!(doc.cratemod().enums()[0].variants[0].sig == Some(~"b(int)")); } fn fold_trait( @@ -255,8 +255,8 @@ fn get_method_sig( #[test] fn should_add_trait_method_sigs() { let doc = test::mk_doc(~"trait i { fn a() -> int; }"); - assert doc.cratemod().traits()[0].methods[0].sig - == Some(~"fn a() -> int"); + fail_unless!(doc.cratemod().traits()[0].methods[0].sig + == Some(~"fn a() -> int")); } fn fold_impl( @@ -296,26 +296,26 @@ fn fold_impl( #[test] fn should_add_impl_trait_types() { let doc = test::mk_doc(~"impl j for int { fn a() { } }"); - assert doc.cratemod().impls()[0].trait_types[0] == ~"j"; + fail_unless!(doc.cratemod().impls()[0].trait_types[0] == ~"j"); } #[test] fn should_not_add_impl_trait_types_if_none() { let doc = test::mk_doc(~"impl int { fn a() { } }"); - assert vec::len(doc.cratemod().impls()[0].trait_types) == 0; + fail_unless!(vec::len(doc.cratemod().impls()[0].trait_types) == 0); } #[test] fn should_add_impl_self_ty() { let doc = test::mk_doc(~"impl int { fn a() { } }"); - assert doc.cratemod().impls()[0].self_ty == Some(~"int"); + fail_unless!(doc.cratemod().impls()[0].self_ty == Some(~"int")); } #[test] fn should_add_impl_method_sigs() { let doc = test::mk_doc(~"impl int { fn a() -> int { fail!() } }"); - assert doc.cratemod().impls()[0].methods[0].sig - == Some(~"fn a() -> int"); + fail_unless!(doc.cratemod().impls()[0].methods[0].sig + == Some(~"fn a() -> int")); } fn fold_type( @@ -354,7 +354,7 @@ fn fold_type( #[test] fn should_add_type_signatures() { let doc = test::mk_doc(~"type t = int;"); - assert doc.cratemod().types()[0].sig == Some(~"type t = int"); + fail_unless!(doc.cratemod().types()[0].sig == Some(~"type t = int")); } fn fold_struct( @@ -407,21 +407,21 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item { #[test] fn should_add_struct_defs() { let doc = test::mk_doc(~"struct S { field: () }"); - assert (&doc.cratemod().structs()[0].sig).get().contains("struct S {"); + fail_unless!((&doc.cratemod().structs()[0].sig).get().contains("struct S {")); } #[test] fn should_not_serialize_struct_drop_blocks() { // All we care about are the fields let doc = test::mk_doc(~"struct S { field: (), drop { } }"); - assert !(&doc.cratemod().structs()[0].sig).get().contains("drop"); + fail_unless!(!(&doc.cratemod().structs()[0].sig).get().contains("drop")); } #[test] fn should_not_serialize_struct_attrs() { // All we care about are the fields let doc = test::mk_doc(~"#[wut] struct S { field: () }"); - assert !(&doc.cratemod().structs()[0].sig).get().contains("wut"); + fail_unless!(!(&doc.cratemod().structs()[0].sig).get().contains("wut")); } #[cfg(test)] diff --git a/src/librustdoc/unindent_pass.rs b/src/librustdoc/unindent_pass.rs index 06595a23d96..6edf53785cb 100644 --- a/src/librustdoc/unindent_pass.rs +++ b/src/librustdoc/unindent_pass.rs @@ -83,7 +83,7 @@ fn unindent(s: &str) -> ~str { if str::is_whitespace(*line) { copy *line } else { - assert str::len(*line) >= min_indent; + fail_unless!(str::len(*line) >= min_indent); str::slice(*line, min_indent, str::len(*line)) } }; @@ -97,14 +97,14 @@ fn unindent(s: &str) -> ~str { fn should_unindent() { let s = ~" line1\n line2"; let r = unindent(s); - assert r == ~"line1\nline2"; + fail_unless!(r == ~"line1\nline2"); } #[test] fn should_unindent_multiple_paragraphs() { let s = ~" line1\n\n line2"; let r = unindent(s); - assert r == ~"line1\n\nline2"; + fail_unless!(r == ~"line1\n\nline2"); } #[test] @@ -113,7 +113,7 @@ fn should_leave_multiple_indent_levels() { // base indentation and should be preserved let s = ~" line1\n\n line2"; let r = unindent(s); - assert r == ~"line1\n\n line2"; + fail_unless!(r == ~"line1\n\n line2"); } #[test] @@ -125,12 +125,12 @@ fn should_ignore_first_line_indent() { // and continue here"] let s = ~"line1\n line2"; let r = unindent(s); - assert r == ~"line1\nline2"; + fail_unless!(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 r == ~"line1\n\n line2"; + fail_unless!(r == ~"line1\n\n line2"); } diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 8cfb216d2a2..b63a0a92e6c 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -787,19 +787,19 @@ pub fn link_exe(src: &Path, dest: &Path) -> bool { #[test] fn test_is_cmd() { - assert is_cmd(~"build"); - assert is_cmd(~"clean"); - assert is_cmd(~"do"); - assert is_cmd(~"info"); - assert is_cmd(~"install"); - assert is_cmd(~"prefer"); - assert is_cmd(~"test"); - assert is_cmd(~"uninstall"); - assert is_cmd(~"unprefer"); + fail_unless!(is_cmd(~"build")); + fail_unless!(is_cmd(~"clean")); + fail_unless!(is_cmd(~"do")); + fail_unless!(is_cmd(~"info")); + fail_unless!(is_cmd(~"install")); + fail_unless!(is_cmd(~"prefer")); + fail_unless!(is_cmd(~"test")); + fail_unless!(is_cmd(~"uninstall")); + fail_unless!(is_cmd(~"unprefer")); } #[test] fn test_parse_name() { - assert parse_name(~"org.mozilla.servo").get() == ~"servo"; - assert parse_name(~"org. mozilla.servo 2131").is_err(); + fail_unless!(parse_name(~"org.mozilla.servo").get() == ~"servo"); + fail_unless!(parse_name(~"org. mozilla.servo 2131").is_err()); } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index b07e6cdaa80..84b24efac96 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -44,7 +44,7 @@ pub impl Condvar/&self { */ #[inline(always)] 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); @@ -60,7 +60,7 @@ pub impl Condvar/&self { */ #[inline(always)] fn signal_on(&self, condvar_id: uint) -> bool { - assert !*self.failed; + fail_unless!(!*self.failed); self.cond.signal_on(condvar_id) } @@ -74,7 +74,7 @@ pub impl Condvar/&self { */ #[inline(always)] fn broadcast_on(&self, condvar_id: uint) -> uint { - assert !*self.failed; + fail_unless!(!*self.failed); self.cond.broadcast_on(condvar_id) } } @@ -230,7 +230,7 @@ struct PoisonOnFail { impl Drop for PoisonOnFail { fn finalize(&self) { unsafe { - /* assert !*self.failed; + /* fail_unless!(!*self.failed); -- might be false in case of cond.wait() */ if task::failing() { *self.failed = true; @@ -384,7 +384,7 @@ pub impl RWARC { // of this cast is removing the mutability.) let new_data = unsafe { cast::transmute_immut(data) }; // Downgrade ensured the token belonged to us. Just a sanity check. - assert ptr::ref_eq(&state.data, new_data); + fail_unless!(ptr::ref_eq(&state.data, new_data)); // Produce new token RWReadMode((new_data, new_token)) } @@ -476,13 +476,13 @@ mod tests { let arc_v = p.recv(); let v = *arc::get::<~[int]>(&arc_v); - assert v[3] == 4; + fail_unless!(v[3] == 4); }; let c = p.recv(); c.send(arc::clone(&arc_v)); - assert (*arc::get(&arc_v))[2] == 3; + fail_unless!((*arc::get(&arc_v))[2] == 3); log(info, arc_v); } @@ -503,7 +503,7 @@ mod tests { } do arc.access_cond |state, cond| { comm::send_one(c.take(), ()); - assert !*state; + fail_unless!(!*state); while !*state { cond.wait(); } @@ -519,7 +519,7 @@ mod tests { let _ = p.recv(); do arc2.access_cond |one, cond| { cond.signal(); - assert *one == 0; // Parent should fail when it wakes up. + fail_unless!(*one == 0); // Parent should fail when it wakes up. } } @@ -536,11 +536,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.access |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do arc.access |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -549,11 +549,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.write |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do arc.read |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -562,11 +562,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.write |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do arc.write |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -576,12 +576,12 @@ mod tests { do task::try || { do arc2.write_downgrade |write_mode| { do (&write_mode).write |one| { - assert *one == 2; + fail_unless!(*one == 2); } } }; do arc.write |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -590,11 +590,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.read |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do arc.read |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -603,11 +603,11 @@ mod tests { let arc2 = ~arc.clone(); do task::try || { do arc2.read |one| { - assert *one == 2; + fail_unless!(*one == 2); } }; do arc.write |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] #[ignore(cfg(windows))] @@ -618,12 +618,12 @@ mod tests { do arc2.write_downgrade |write_mode| { let read_mode = arc2.downgrade(write_mode); do (&read_mode).read |one| { - assert *one == 2; + fail_unless!(*one == 2); } } }; do arc.write |one| { - assert *one == 1; + fail_unless!(*one == 1); } } #[test] @@ -651,7 +651,7 @@ mod tests { do task::task().future_result(|+r| children.push(r)).spawn || { do arc3.read |num| { - assert *num >= 0; + fail_unless!(*num >= 0); } } } @@ -661,7 +661,7 @@ mod tests { // Wait for writer to finish p.recv(); - do arc.read |num| { assert *num == 10; } + do arc.read |num| { fail_unless!(*num == 10); } } #[test] pub fn test_rw_downgrade() { @@ -682,7 +682,7 @@ mod tests { do task::spawn || { rp1.recv(); // wait for downgrader to give go-ahead do arcn.read |state| { - assert *state == 31337; + fail_unless!(*state == 31337); rc2.send(()); } } @@ -694,7 +694,7 @@ mod tests { do task::spawn || { wp1.recv(); do arc2.write_cond |state, cond| { - assert *state == 0; + fail_unless!(*state == 0); *state = 42; cond.signal(); } @@ -702,7 +702,7 @@ mod tests { do arc2.write |state| { // This shouldn't happen until after the downgrade read // section, and all other readers, finish. - assert *state == 31337; + fail_unless!(*state == 31337); *state = 42; } wc2.send(()); @@ -715,7 +715,7 @@ mod tests { while *state == 0 { cond.wait(); } - assert *state == 42; + fail_unless!(*state == 42); *state = 31337; // send to other readers for vec::each(reader_convos) |x| { @@ -733,7 +733,7 @@ mod tests { } } wc1.send(()); // tell writer to try again - assert *state == 31337; + fail_unless!(*state == 31337); } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index d8fc6a5b9ee..0bd9e1eac51 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -153,23 +153,23 @@ mod tests { #[test] pub fn test_to_base64() { - assert (~"").to_base64() == ~""; - assert (~"f").to_base64() == ~"Zg=="; - assert (~"fo").to_base64() == ~"Zm8="; - assert (~"foo").to_base64() == ~"Zm9v"; - assert (~"foob").to_base64() == ~"Zm9vYg=="; - assert (~"fooba").to_base64() == ~"Zm9vYmE="; - assert (~"foobar").to_base64() == ~"Zm9vYmFy"; + fail_unless!((~"").to_base64() == ~""); + fail_unless!((~"f").to_base64() == ~"Zg=="); + fail_unless!((~"fo").to_base64() == ~"Zm8="); + fail_unless!((~"foo").to_base64() == ~"Zm9v"); + fail_unless!((~"foob").to_base64() == ~"Zm9vYg=="); + fail_unless!((~"fooba").to_base64() == ~"Zm9vYmE="); + fail_unless!((~"foobar").to_base64() == ~"Zm9vYmFy"); } #[test] pub fn test_from_base64() { - assert (~"").from_base64() == str::to_bytes(~""); - assert (~"Zg==").from_base64() == str::to_bytes(~"f"); - assert (~"Zm8=").from_base64() == str::to_bytes(~"fo"); - assert (~"Zm9v").from_base64() == str::to_bytes(~"foo"); - assert (~"Zm9vYg==").from_base64() == str::to_bytes(~"foob"); - assert (~"Zm9vYmE=").from_base64() == str::to_bytes(~"fooba"); - assert (~"Zm9vYmFy").from_base64() == str::to_bytes(~"foobar"); + fail_unless!((~"").from_base64() == str::to_bytes(~"")); + fail_unless!((~"Zg==").from_base64() == str::to_bytes(~"f")); + fail_unless!((~"Zm8=").from_base64() == str::to_bytes(~"fo")); + fail_unless!((~"Zm9v").from_base64() == str::to_bytes(~"foo")); + fail_unless!((~"Zm9vYg==").from_base64() == str::to_bytes(~"foob")); + fail_unless!((~"Zm9vYmE=").from_base64() == str::to_bytes(~"fooba")); + fail_unless!((~"Zm9vYmFy").from_base64() == str::to_bytes(~"foobar")); } } diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index a3109c00c01..5c3f37faca7 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -162,7 +162,7 @@ impl Sub for BigUint { lo }; - assert borrow == 0; // <=> assert (self >= other); + fail_unless!(borrow == 0); // <=> fail_unless!((self >= other)); return BigUint::new(diff); } } @@ -351,7 +351,7 @@ pub impl BigUint { n <<= 1; shift += 1; } - assert shift < BigDigit::bits; + fail_unless!(shift < BigDigit::bits); let (d, m) = divmod_inner(self << shift, other << shift); return (d, m >> shift); @@ -390,7 +390,7 @@ pub impl BigUint { for vec::rev_each(an) |elt| { 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; } @@ -434,7 +434,7 @@ pub impl BigUint { } pure 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) @@ -509,7 +509,7 @@ pub impl BigUint { #[cfg(target_arch = "x86_64")] priv pure 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), @@ -534,7 +534,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) { #[cfg(target_arch = "x86")] #[cfg(target_arch = "mips")] priv pure 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), @@ -787,7 +787,7 @@ pub impl BigInt { if ss < os { return -1; } if ss > os { return 1; } - assert ss == os; + fail_unless!(ss == os); match ss { Zero => 0, Plus => self.data.cmp(&other.data), @@ -874,7 +874,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], ~[]); @@ -892,30 +892,30 @@ mod biguint_tests { for vec::slice(data, i, data.len()).eachi |j0, nj| { let j = j0 + i; if i == j { - assert ni.cmp(nj) == 0; - assert nj.cmp(ni) == 0; - assert ni == nj; - assert !(ni != nj); - assert ni <= nj; - assert ni >= nj; - assert !(ni < nj); - assert !(ni > nj); + fail_unless!(ni.cmp(nj) == 0); + fail_unless!(nj.cmp(ni) == 0); + fail_unless!(ni == nj); + fail_unless!(!(ni != nj)); + fail_unless!(ni <= nj); + fail_unless!(ni >= nj); + fail_unless!(!(ni < nj)); + fail_unless!(!(ni > nj)); } else { - assert ni.cmp(nj) < 0; - assert nj.cmp(ni) > 0; + fail_unless!(ni.cmp(nj) < 0); + fail_unless!(nj.cmp(ni) > 0); - 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); } } } @@ -924,7 +924,7 @@ mod biguint_tests { #[test] fn test_shl() { fn check(v: ~[BigDigit], shift: uint, ans: ~[BigDigit]) { - assert BigUint::new(v) << shift == BigUint::new(ans); + fail_unless!(BigUint::new(v) << shift == BigUint::new(ans)); } check(~[], 3, ~[]); @@ -969,7 +969,7 @@ mod biguint_tests { #[ignore(cfg(target_arch = "mips"))] fn test_shr() { fn check(v: ~[BigDigit], shift: uint, ans: ~[BigDigit]) { - assert BigUint::new(v) >> shift == BigUint::new(ans); + fail_unless!(BigUint::new(v) >> shift == BigUint::new(ans)); } check(~[], 3, ~[]); @@ -1011,8 +1011,8 @@ mod biguint_tests { fn test_convert_int() { fn check(v: ~[BigDigit], i: int) { let b = BigUint::new(v); - assert b == IntConvertible::from_int(i); - assert b.to_int() == i; + fail_unless!(b == IntConvertible::from_int(i)); + fail_unless!(b.to_int() == i); } check(~[], 0); @@ -1021,17 +1021,17 @@ mod biguint_tests { check(~[ 0, 1], ((uint::max_value >> BigDigit::bits) + 1) as int); check(~[-1, -1 >> 1], int::max_value); - assert BigUint::new(~[0, -1]).to_int() == int::max_value; - assert BigUint::new(~[0, 0, 1]).to_int() == int::max_value; - assert BigUint::new(~[0, 0, -1]).to_int() == int::max_value; + fail_unless!(BigUint::new(~[0, -1]).to_int() == int::max_value); + fail_unless!(BigUint::new(~[0, 0, 1]).to_int() == int::max_value); + fail_unless!(BigUint::new(~[0, 0, -1]).to_int() == int::max_value); } #[test] fn test_convert_uint() { fn check(v: ~[BigDigit], u: uint) { let b = BigUint::new(v); - assert b == BigUint::from_uint(u); - assert b.to_uint() == u; + fail_unless!(b == BigUint::from_uint(u)); + fail_unless!(b.to_uint() == u); } check(~[], 0); @@ -1041,8 +1041,8 @@ mod biguint_tests { check(~[ 0, -1], uint::max_value << BigDigit::bits); check(~[-1, -1], uint::max_value); - assert BigUint::new(~[0, 0, 1]).to_uint() == uint::max_value; - assert BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value; + fail_unless!(BigUint::new(~[0, 0, 1]).to_uint() == uint::max_value); + fail_unless!(BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value); } const sum_triples: &static/[(&static/[BigDigit], @@ -1067,8 +1067,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); } } @@ -1080,8 +1080,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); } } @@ -1131,8 +1131,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 divmod_quadruples.each |elm| { @@ -1142,8 +1142,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); } } @@ -1156,10 +1156,10 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); if a.is_not_zero() { - assert c.divmod(&a) == (b, Zero::zero()); + fail_unless!(c.divmod(&a) == (b, Zero::zero())); } if b.is_not_zero() { - assert c.divmod(&b) == (a, Zero::zero()); + fail_unless!(c.divmod(&b) == (a, Zero::zero())); } } @@ -1170,7 +1170,7 @@ mod biguint_tests { let c = BigUint::from_slice(cVec); let d = BigUint::from_slice(dVec); - if b.is_not_zero() { assert a.divmod(&b) == (c, d); } + if b.is_not_zero() { fail_unless!(a.divmod(&b) == (c, d)); } } } @@ -1237,7 +1237,7 @@ mod biguint_tests { let &(n, rs) = num_pair; for rs.each |str_pair| { let &(radix, str) = str_pair; - assert n.to_str_radix(radix) == str; + fail_unless!(n.to_str_radix(radix) == str); } } } @@ -1248,13 +1248,13 @@ mod biguint_tests { let &(n, rs) = num_pair; for rs.each |str_pair| { let &(radix, str) = str_pair; - assert Some(n) == BigUint::from_str_radix(str, radix); + fail_unless!(Some(n) == BigUint::from_str_radix(str, radix)); } } - assert BigUint::from_str_radix(~"Z", 10) == None; - assert BigUint::from_str_radix(~"_", 2) == None; - assert BigUint::from_str_radix(~"-1", 10) == None; + fail_unless!(BigUint::from_str_radix(~"Z", 10) == None); + fail_unless!(BigUint::from_str_radix(~"_", 2) == None); + fail_unless!(BigUint::from_str_radix(~"-1", 10) == None); } #[test] @@ -1272,7 +1272,7 @@ mod biguint_tests { let ans = match BigUint::from_str_radix(s, 10) { Some(x) => x, None => fail!() }; - assert n == ans; + fail_unless!(n == ans); } check(3, "6"); @@ -1294,7 +1294,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, BigUint::from_uint(inp_n)); let ans = BigInt { sign: ans_s, data: BigUint::from_uint(ans_n)}; - assert inp == ans; + fail_unless!(inp == ans); } check(Plus, 1, Plus, 1); check(Plus, 0, Zero, 0); @@ -1314,30 +1314,30 @@ mod bigint_tests { for vec::slice(nums, i, nums.len()).eachi |j0, nj| { let j = i + j0; if i == j { - assert ni.cmp(nj) == 0; - assert nj.cmp(ni) == 0; - assert ni == nj; - assert !(ni != nj); - assert ni <= nj; - assert ni >= nj; - assert !(ni < nj); - assert !(ni > nj); + fail_unless!(ni.cmp(nj) == 0); + fail_unless!(nj.cmp(ni) == 0); + fail_unless!(ni == nj); + fail_unless!(!(ni != nj)); + fail_unless!(ni <= nj); + fail_unless!(ni >= nj); + fail_unless!(!(ni < nj)); + fail_unless!(!(ni > nj)); } else { - assert ni.cmp(nj) < 0; - assert nj.cmp(ni) > 0; + fail_unless!(ni.cmp(nj) < 0); + fail_unless!(nj.cmp(ni) > 0); - 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); } } } @@ -1346,8 +1346,8 @@ mod bigint_tests { #[test] fn test_convert_int() { fn check(b: BigInt, i: int) { - assert b == IntConvertible::from_int(i); - assert b.to_int() == i; + fail_unless!(b == IntConvertible::from_int(i)); + fail_unless!(b.to_int() == i); } check(Zero::zero(), 0); @@ -1356,29 +1356,29 @@ mod bigint_tests { Plus, BigUint::from_uint(int::max_value as uint) ), int::max_value); - assert BigInt::from_biguint( + fail_unless!(BigInt::from_biguint( Plus, BigUint::from_uint(int::max_value as uint + 1) - ).to_int() == int::max_value; - assert BigInt::from_biguint( + ).to_int() == int::max_value); + fail_unless!(BigInt::from_biguint( Plus, BigUint::new(~[1, 2, 3]) - ).to_int() == int::max_value; + ).to_int() == int::max_value); check(BigInt::from_biguint( Minus, BigUint::from_uint(-int::min_value as uint) ), int::min_value); - assert BigInt::from_biguint( + fail_unless!(BigInt::from_biguint( Minus, BigUint::from_uint(-int::min_value as uint + 1) - ).to_int() == int::min_value; - assert BigInt::from_biguint( + ).to_int() == int::min_value); + fail_unless!(BigInt::from_biguint( Minus, BigUint::new(~[1, 2, 3]) - ).to_int() == int::min_value; + ).to_int() == int::min_value); } #[test] fn test_convert_uint() { fn check(b: BigInt, u: uint) { - assert b == BigInt::from_uint(u); - assert b.to_uint() == u; + fail_unless!(b == BigInt::from_uint(u)); + fail_unless!(b.to_uint() == u); } check(Zero::zero(), 0); @@ -1387,16 +1387,16 @@ mod bigint_tests { check( BigInt::from_biguint(Plus, BigUint::from_uint(uint::max_value)), uint::max_value); - assert BigInt::from_biguint( + fail_unless!(BigInt::from_biguint( Plus, BigUint::new(~[1, 2, 3]) - ).to_uint() == uint::max_value; + ).to_uint() == uint::max_value); - assert BigInt::from_biguint( + fail_unless!(BigInt::from_biguint( Minus, BigUint::from_uint(uint::max_value) - ).to_uint() == 0; - assert BigInt::from_biguint( + ).to_uint() == 0); + fail_unless!(BigInt::from_biguint( Minus, BigUint::new(~[1, 2, 3]) - ).to_uint() == 0; + ).to_uint() == 0); } const sum_triples: &static/[(&static/[BigDigit], @@ -1421,14 +1421,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()); } } @@ -1440,14 +1440,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()); } } @@ -1497,11 +1497,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 divmod_quadruples.each |elm| { @@ -1511,8 +1511,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); } } @@ -1521,12 +1521,12 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_d: &BigInt, ans_m: &BigInt) { let (d, m) = a.divmod(b); if m.is_not_zero() { - assert m.sign == b.sign; + fail_unless!(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) { @@ -1572,12 +1572,12 @@ mod bigint_tests { fn check_sub(a: &BigInt, b: &BigInt, ans_q: &BigInt, ans_r: &BigInt) { let (q, r) = a.quotrem(b); if r.is_not_zero() { - assert r.sign == a.sign; + fail_unless!(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) { @@ -1612,8 +1612,8 @@ mod bigint_tests { #[test] fn test_to_str_radix() { fn check(n: int, ans: &str) { - assert ans == IntConvertible::from_int::( - n).to_str_radix(10); + fail_unless!(ans == IntConvertible::from_int::( + n).to_str_radix(10)); } check(10, "10"); check(1, "1"); @@ -1627,7 +1627,7 @@ mod bigint_tests { fn test_from_str_radix() { fn check(s: &str, ans: Option) { let ans = ans.map(|&n| IntConvertible::from_int(n)); - assert BigInt::from_str_radix(s, 10) == ans; + fail_unless!(BigInt::from_str_radix(s, 10) == ans); } check("10", Some(10)); check("1", Some(1)); @@ -1640,11 +1640,11 @@ mod bigint_tests { #[test] fn test_neg() { - assert -BigInt::new(Plus, ~[1, 1, 1]) == - BigInt::new(Minus, ~[1, 1, 1]); - assert -BigInt::new(Minus, ~[1, 1, 1]) == - BigInt::new(Plus, ~[1, 1, 1]); - assert -Zero::zero::() == Zero::zero::(); + fail_unless!(-BigInt::new(Plus, ~[1, 1, 1]) == + BigInt::new(Minus, ~[1, 1, 1])); + fail_unless!(-BigInt::new(Minus, ~[1, 1, 1]) == + BigInt::new(Plus, ~[1, 1, 1])); + fail_unless!(-Zero::zero::() == Zero::zero::()); } } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 939f6960bf9..b54c50da35c 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -132,7 +132,7 @@ pub impl BigBitv { fn process(&mut self, b: &BigBitv, nbits: uint, op: fn(uint, uint) -> uint) -> bool { let len = b.storage.len(); - assert (self.storage.len() == len); + fail_unless!((self.storage.len() == len)); let mut changed = false; for uint::range(0, len) |i| { let mask = big_mask(nbits, i); @@ -300,7 +300,7 @@ pub impl Bitv { /// Retrieve the value at index `i` #[inline(always)] pure 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) @@ -314,7 +314,7 @@ pub impl Bitv { */ #[inline(always)] 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) @@ -482,7 +482,7 @@ pub impl Bitv { * the bitvector and vector must have the same length */ fn eq_vec(&self, v: ~[uint]) -> bool { - assert self.nbits == v.len(); + fail_unless!(self.nbits == v.len()); let mut i = 0; while i < self.nbits { let w0 = self.get(i); @@ -723,7 +723,7 @@ impl Set for BitvSet { let nbits = self.capacity(); if value >= nbits { let newsize = uint::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; @@ -882,10 +882,10 @@ mod tests { #[test] pub fn test_to_str() { let zerolen = Bitv::new(0u, false); - assert zerolen.to_str() == ~""; + fail_unless!(zerolen.to_str() == ~""); let eightbits = Bitv::new(8u, false); - assert eightbits.to_str() == ~"00000000"; + fail_unless!(eightbits.to_str() == ~"00000000"); } #[test] @@ -894,16 +894,16 @@ mod tests { let mut exp; act = Bitv::new(0u, false); exp = vec::from_elem::(0u, 0u); - assert act.eq_vec(exp); + fail_unless!(act.eq_vec(exp)); } #[test] pub fn test_1_element() { let mut act; act = Bitv::new(1u, false); - assert act.eq_vec(~[0u]); + fail_unless!(act.eq_vec(~[0u])); act = Bitv::new(1u, true); - assert act.eq_vec(~[1u]); + fail_unless!(act.eq_vec(~[1u])); } #[test] @@ -911,7 +911,7 @@ mod tests { let mut b = bitv::Bitv::new(2, false); b.set(0, true); b.set(1, false); - assert b.to_str() == ~"10"; + fail_unless!(b.to_str() == ~"10"); } #[test] @@ -920,11 +920,11 @@ mod tests { // all 0 act = Bitv::new(10u, false); - assert (act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); + fail_unless!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]))); // all 1 act = Bitv::new(10u, true); - assert (act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); + fail_unless!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]))); // mixed act = Bitv::new(10u, false); @@ -933,7 +933,7 @@ mod tests { act.set(2u, true); act.set(3u, true); act.set(4u, true); - assert (act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u])); + fail_unless!((act.eq_vec(~[1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]))); // mixed act = Bitv::new(10u, false); @@ -942,7 +942,7 @@ mod tests { act.set(7u, true); act.set(8u, true); act.set(9u, true); - assert (act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u])); + fail_unless!((act.eq_vec(~[0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]))); // mixed act = Bitv::new(10u, false); @@ -950,7 +950,7 @@ mod tests { act.set(3u, true); act.set(6u, true); act.set(9u, true); - assert (act.eq_vec(~[1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u])); + fail_unless!((act.eq_vec(~[1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]))); } #[test] @@ -959,14 +959,14 @@ mod tests { // all 0 act = Bitv::new(31u, false); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(31u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -981,7 +981,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -996,7 +996,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1010,7 +1010,7 @@ mod tests { act.set(28u, true); act.set(29u, true); act.set(30u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1020,7 +1020,7 @@ mod tests { act.set(3u, true); act.set(17u, true); act.set(30u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u])); @@ -1032,14 +1032,14 @@ mod tests { // all 0 act = Bitv::new(32u, false); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(32u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1054,7 +1054,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1069,7 +1069,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1084,7 +1084,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1095,7 +1095,7 @@ mod tests { act.set(17u, true); act.set(30u, true); act.set(31u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u])); @@ -1107,14 +1107,14 @@ mod tests { // all 0 act = Bitv::new(33u, false); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); // all 1 act = Bitv::new(33u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); @@ -1129,7 +1129,7 @@ mod tests { act.set(5u, true); act.set(6u, true); act.set(7u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1144,7 +1144,7 @@ mod tests { act.set(21u, true); act.set(22u, true); act.set(23u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); @@ -1159,7 +1159,7 @@ mod tests { act.set(29u, true); act.set(30u, true); act.set(31u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u])); @@ -1171,7 +1171,7 @@ mod tests { act.set(30u, true); act.set(31u, true); act.set(32u, true); - assert (act.eq_vec( + fail_unless!(act.eq_vec( ~[0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u])); @@ -1181,14 +1181,14 @@ mod tests { pub 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] pub 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] @@ -1199,7 +1199,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] @@ -1214,37 +1214,37 @@ mod tests { b.set(i, true); } - assert a.equal(&b); + fail_unless!(a.equal(&b)); } #[test] pub fn test_from_bytes() { let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); let str = ~"10110110" + ~"00000000" + ~"11111111"; - assert bitv.to_str() == str; + fail_unless!(bitv.to_str() == str); } #[test] pub fn test_to_bytes() { let mut bv = Bitv::new(3, true); bv.set(1, false); - assert bv.to_bytes() == ~[0b10100000]; + fail_unless!(bv.to_bytes() == ~[0b10100000]); let mut bv = Bitv::new(9, false); bv.set(2, true); bv.set(8, true); - assert bv.to_bytes() == ~[0b00100000, 0b10000000]; + fail_unless!(bv.to_bytes() == ~[0b00100000, 0b10000000]); } #[test] pub fn test_from_bools() { - assert from_bools([true, false, true, true]).to_str() == ~"1011"; + fail_unless!(from_bools([true, false, true, true]).to_str() == ~"1011"); } #[test] pub fn test_to_bools() { let bools = ~[false, false, true, false, false, true, true, false]; - assert from_bytes([0b00100110]).to_bools() == bools; + fail_unless!(from_bytes([0b00100110]).to_bools() == bools); } #[test] @@ -1255,10 +1255,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] @@ -1269,10 +1269,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] @@ -1296,13 +1296,13 @@ mod tests { #[test] pub 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); - assert b.len() == 2; + 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)); + fail_unless!(b.len() == 2); } #[test] @@ -1310,26 +1310,26 @@ 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]; for a.intersection(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -1337,22 +1337,22 @@ 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]; for a.difference(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -1360,67 +1360,67 @@ 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]; for a.symmetric_difference(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] pub 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); + 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)); - assert b.insert(1); - assert b.insert(5); - assert b.insert(9); - assert b.insert(13); - assert b.insert(19); + 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]; for a.union(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] pub 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); - assert a.capacity() == uint::bits; + fail_unless!(a.insert(1000)); + fail_unless!(a.remove(&1000)); + fail_unless!(a.capacity() == uint::bits); } fn rng() -> rand::Rng { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index e0336be5986..8e75f694fa3 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -119,7 +119,7 @@ pub unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: @fn()) * Fails if `ofs` is greater or equal to the length of the vector */ pub fn get(t: CVec, ofs: uint) -> T { - assert ofs < len(t); + fail_unless!(ofs < len(t)); return unsafe { *ptr::mut_offset(t.base, ofs) }; } @@ -129,7 +129,7 @@ pub fn get(t: CVec, ofs: uint) -> T { * Fails if `ofs` is greater or equal to the length of the vector */ pub fn set(t: CVec, ofs: uint, v: T) { - assert ofs < len(t); + fail_unless!(ofs < len(t)); unsafe { *ptr::mut_offset(t.base, ofs) = v }; } @@ -156,7 +156,7 @@ mod tests { unsafe { let mem = libc::malloc(n); - assert mem as int != 0; + fail_unless!(mem as int != 0); return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, || unsafe { free(mem) }) }; @@ -169,9 +169,9 @@ mod tests { set(cv, 3u, 8u8); set(cv, 4u, 9u8); - assert get(cv, 3u) == 8u8; - assert get(cv, 4u) == 9u8; - assert len(cv) == 16u; + fail_unless!(get(cv, 3u) == 8u8); + fail_unless!(get(cv, 4u) == 9u8); + fail_unless!(len(cv) == 16u); } #[test] @@ -199,7 +199,7 @@ mod tests { set(cv, 0u, 32u8); set(cv, 1u, 33u8); - assert unsafe { *p } == 32u8; + fail_unless!(unsafe { *p } == 32u8); set(cv, 2u, 34u8); /* safety */ } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index a73b5f2a706..b6362f83f44 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -53,15 +53,15 @@ impl FuzzyEq for f64 { #[test] fn test_fuzzy_equals() { - assert (&1.0f).fuzzy_eq(&1.0); - assert (&1.0f32).fuzzy_eq(&1.0f32); - assert (&1.0f64).fuzzy_eq(&1.0f64); + fail_unless!((&1.0f).fuzzy_eq(&1.0)); + fail_unless!((&1.0f32).fuzzy_eq(&1.0f32)); + fail_unless!((&1.0f64).fuzzy_eq(&1.0f64)); } #[test] fn test_fuzzy_eq_eps() { - assert (&1.2f).fuzzy_eq_eps(&0.9, &0.5); - assert !(&1.5f).fuzzy_eq_eps(&0.9, &0.5); + fail_unless!((&1.2f).fuzzy_eq_eps(&0.9, &0.5)); + fail_unless!(!(&1.5f).fuzzy_eq_eps(&0.9, &0.5)); } #[test] @@ -87,16 +87,16 @@ mod test_complex{ let a = Complex {r: 0.9, i: 0.9}; let b = Complex {r: 0.9, i: 0.9}; - assert (a.fuzzy_eq(&b)); + fail_unless!((a.fuzzy_eq(&b))); } #[test] fn test_fuzzy_eq_eps() { let other = Complex {r: 0.9, i: 0.9}; - assert (&Complex {r: 0.9, i: 1.2}).fuzzy_eq_eps(&other, &0.5); - assert (&Complex {r: 1.2, i: 0.9}).fuzzy_eq_eps(&other, &0.5); - assert !(&Complex {r: 0.9, i: 1.5}).fuzzy_eq_eps(&other, &0.5); - assert !(&Complex {r: 1.5, i: 0.9}).fuzzy_eq_eps(&other, &0.5); + fail_unless!((&Complex {r: 0.9, i: 1.2}).fuzzy_eq_eps(&other, &0.5)); + fail_unless!((&Complex {r: 1.2, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); + fail_unless!(!(&Complex {r: 0.9, i: 1.5}).fuzzy_eq_eps(&other, &0.5)); + fail_unless!(!(&Complex {r: 1.5, i: 0.9}).fuzzy_eq_eps(&other, &0.5)); } } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 4189b37c2a4..99f6fa4c8cf 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -107,7 +107,7 @@ 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"); } } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index b203a53058d..33b0fd4eb68 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -95,7 +95,7 @@ pub impl Deque { /// Grow is only called on full elts, so nelts is also len(elts), unlike /// elsewhere. fn grow(nelts: uint, lo: uint, elts: &mut [Option]) -> ~[Option] { - assert nelts == elts.len(); + fail_unless!(nelts == elts.len()); let mut rv = ~[]; do rv.grow_fn(nelts + 1) |i| { @@ -121,46 +121,46 @@ mod tests { #[test] fn test_simple() { let mut d = Deque::new(); - assert d.len() == 0u; + fail_unless!(d.len() == 0u); d.add_front(17); d.add_front(42); d.add_back(137); - assert d.len() == 3u; + fail_unless!(d.len() == 3u); d.add_back(137); - assert d.len() == 4u; + fail_unless!(d.len() == 4u); log(debug, d.peek_front()); - assert *d.peek_front() == 42; + fail_unless!(*d.peek_front() == 42); log(debug, d.peek_back()); - assert *d.peek_back() == 137; + fail_unless!(*d.peek_back() == 137); let mut i: int = d.pop_front(); log(debug, i); - assert i == 42; + fail_unless!(i == 42); i = d.pop_back(); log(debug, i); - assert i == 137; + fail_unless!(i == 137); i = d.pop_back(); log(debug, i); - assert i == 137; + fail_unless!(i == 137); i = d.pop_back(); log(debug, i); - assert i == 17; - assert d.len() == 0u; + fail_unless!(i == 17); + fail_unless!(d.len() == 0u); d.add_back(3); - assert d.len() == 1u; + fail_unless!(d.len() == 1u); d.add_front(2); - assert d.len() == 2u; + fail_unless!(d.len() == 2u); d.add_back(4); - assert d.len() == 3u; + fail_unless!(d.len() == 3u); d.add_front(1); - assert d.len() == 4u; + fail_unless!(d.len() == 4u); log(debug, d.get(0)); log(debug, d.get(1)); log(debug, d.get(2)); log(debug, d.get(3)); - assert *d.get(0) == 1; - assert *d.get(1) == 2; - assert *d.get(2) == 3; - assert *d.get(3) == 4; + fail_unless!(*d.get(0) == 1); + fail_unless!(*d.get(1) == 2); + fail_unless!(*d.get(2) == 3); + fail_unless!(*d.get(3) == 4); } #[test] @@ -171,62 +171,62 @@ mod tests { let d: @int = @175; let mut deq = Deque::new(); - assert deq.len() == 0; + fail_unless!(deq.len() == 0); deq.add_front(a); deq.add_front(b); deq.add_back(c); - assert deq.len() == 3; + fail_unless!(deq.len() == 3); deq.add_back(d); - assert deq.len() == 4; - assert *deq.peek_front() == b; - assert *deq.peek_back() == d; - assert deq.pop_front() == b; - assert deq.pop_back() == d; - assert deq.pop_back() == c; - assert deq.pop_back() == a; - assert deq.len() == 0; + fail_unless!(deq.len() == 4); + fail_unless!(*deq.peek_front() == b); + fail_unless!(*deq.peek_back() == d); + fail_unless!(deq.pop_front() == b); + fail_unless!(deq.pop_back() == d); + fail_unless!(deq.pop_back() == c); + fail_unless!(deq.pop_back() == a); + fail_unless!(deq.len() == 0); deq.add_back(c); - assert deq.len() == 1; + fail_unless!(deq.len() == 1); deq.add_front(b); - assert deq.len() == 2; + fail_unless!(deq.len() == 2); deq.add_back(d); - assert deq.len() == 3; + fail_unless!(deq.len() == 3); deq.add_front(a); - assert deq.len() == 4; - assert *deq.get(0) == a; - assert *deq.get(1) == b; - assert *deq.get(2) == c; - assert *deq.get(3) == d; + fail_unless!(deq.len() == 4); + fail_unless!(*deq.get(0) == a); + fail_unless!(*deq.get(1) == b); + fail_unless!(*deq.get(2) == c); + fail_unless!(*deq.get(3) == d); } fn test_parameterized(a: T, b: T, c: T, d: T) { let mut deq = Deque::new(); - assert deq.len() == 0; + fail_unless!(deq.len() == 0); deq.add_front(a); deq.add_front(b); deq.add_back(c); - assert deq.len() == 3; + fail_unless!(deq.len() == 3); deq.add_back(d); - assert deq.len() == 4; - assert *deq.peek_front() == b; - assert *deq.peek_back() == d; - assert deq.pop_front() == b; - assert deq.pop_back() == d; - assert deq.pop_back() == c; - assert deq.pop_back() == a; - assert deq.len() == 0; + fail_unless!(deq.len() == 4); + fail_unless!(*deq.peek_front() == b); + fail_unless!(*deq.peek_back() == d); + fail_unless!(deq.pop_front() == b); + fail_unless!(deq.pop_back() == d); + fail_unless!(deq.pop_back() == c); + fail_unless!(deq.pop_back() == a); + fail_unless!(deq.len() == 0); deq.add_back(c); - assert deq.len() == 1; + fail_unless!(deq.len() == 1); deq.add_front(b); - assert deq.len() == 2; + fail_unless!(deq.len() == 2); deq.add_back(d); - assert deq.len() == 3; + fail_unless!(deq.len() == 3); deq.add_front(a); - assert deq.len() == 4; - assert *deq.get(0) == a; - assert *deq.get(1) == b; - assert *deq.get(2) == c; - assert *deq.get(3) == d; + fail_unless!(deq.len() == 4); + fail_unless!(*deq.get(0) == a); + fail_unless!(*deq.get(1) == b); + fail_unless!(*deq.get(2) == c); + fail_unless!(*deq.get(3) == d); } #[deriving_eq] diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index bbf3fc8c072..44461ae06ff 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -182,22 +182,22 @@ pub mod reader { pub fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) } pub fn doc_as_u8(d: Doc) -> u8 { - assert d.end == d.start + 1u; + fail_unless!(d.end == d.start + 1u); (*d.data)[d.start] } pub fn doc_as_u16(d: Doc) -> u16 { - assert d.end == d.start + 2u; + fail_unless!(d.end == d.start + 2u); io::u64_from_be_bytes(*d.data, d.start, 2u) as u16 } pub fn doc_as_u32(d: Doc) -> u32 { - assert d.end == d.start + 4u; + fail_unless!(d.end == d.start + 4u); io::u64_from_be_bytes(*d.data, d.start, 4u) as u32 } pub fn doc_as_u64(d: Doc) -> u64 { - assert d.end == d.start + 8u; + fail_unless!(d.end == d.start + 8u); io::u64_from_be_bytes(*d.data, d.start, 8u) } @@ -550,7 +550,7 @@ pub mod writer { priv impl Encoder { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&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); } @@ -694,7 +694,7 @@ mod tests { let deser = reader::Decoder(ebml_doc); let v1 = serialize::Decodable::decode(&deser); debug!("v1 == %?", v1); - assert v == v1; + fail_unless!(v == v1); } test_v(Some(22)); diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 798c5ae57c7..734e6e83581 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -358,8 +358,8 @@ pub mod flatteners { impl Unflattener for PodUnflattener { fn unflatten(&self, buf: ~[u8]) -> T { - assert size_of::() != 0; - assert size_of::() == buf.len(); + fail_unless!(size_of::() != 0); + fail_unless!(size_of::() == buf.len()); let addr_of_init: &u8 = unsafe { &*vec::raw::to_ptr(buf) }; let addr_of_value: &T = unsafe { cast::transmute(addr_of_init) }; copy *addr_of_value @@ -368,7 +368,7 @@ pub mod flatteners { impl Flattener for PodFlattener { fn flatten(&self, val: T) -> ~[u8] { - assert size_of::() != 0; + fail_unless!(size_of::() != 0); let val: *T = ptr::to_unsafe_ptr(&val); let byte_value = val as *u8; unsafe { vec::from_buf(byte_value, size_of::()) } @@ -521,11 +521,11 @@ pub mod bytepipes { let mut left = count; let mut bytes = ~[]; while !self.reader.eof() && left > 0 { - assert left <= count; - assert left > 0; + fail_unless!(left <= count); + fail_unless!(left > 0); let new_bytes = self.reader.read_bytes(left); bytes.push_all(new_bytes); - assert new_bytes.len() <= left; + fail_unless!(new_bytes.len() <= left); left -= new_bytes.len(); } @@ -578,7 +578,7 @@ pub mod bytepipes { return Some(bytes); } else if self.buf.len() > 0 { let mut bytes = ::core::util::replace(&mut self.buf, ~[]); - assert count > bytes.len(); + fail_unless!(count > bytes.len()); match self.try_recv(count - bytes.len()) { Some(rest) => { bytes.push_all(rest); @@ -589,7 +589,7 @@ pub mod bytepipes { } else if self.buf.is_empty() { match self.port.try_recv() { Some(buf) => { - assert !buf.is_empty(); + fail_unless!(!buf.is_empty()); self.buf = buf; return self.try_recv(count); } @@ -657,7 +657,7 @@ mod test { let port = serial::reader_port(reader); let res: int = port.recv(); - assert res == 10i; + fail_unless!(res == 10i); } #[test] @@ -671,7 +671,7 @@ mod test { } for int::range(0, 10) |i| { - assert i == port.recv() + fail_unless!(i == port.recv()) } } @@ -686,7 +686,7 @@ mod test { } for int::range(0, 10) |i| { - assert @i == port.recv() + fail_unless!(@i == port.recv()) } } @@ -703,7 +703,7 @@ mod test { let port = pod::reader_port(reader); let res: int = port.recv(); - assert res == 10; + fail_unless!(res == 10); } #[test] @@ -717,7 +717,7 @@ mod test { } for int::range(0, 10) |i| { - assert i == port.recv() + fail_unless!(i == port.recv()) } } @@ -801,7 +801,7 @@ mod test { kill_ch.send(None) }; - assert listen_res.is_ok(); + fail_unless!(listen_res.is_ok()); } // Client task @@ -814,7 +814,7 @@ mod test { debug!("connecting"); let iotask = &uv::global_loop::get(); let connect_result = tcp::connect(copy addr, port, iotask); - assert connect_result.is_ok(); + fail_unless!(connect_result.is_ok()); let sock = result::unwrap(connect_result); let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(sock); @@ -835,7 +835,7 @@ mod test { debug!("accepting connection"); let accept_result = tcp::accept(conn); debug!("accepted"); - assert accept_result.is_ok(); + fail_unless!(accept_result.is_ok()); let sock = result::unwrap(accept_result); res_chan.send(()); @@ -847,7 +847,7 @@ mod test { for int::range(0, 10) |i| { let j = port.recv(); debug!("receieved %?", j); - assert i == j; + fail_unless!(i == j); } // The test is over! @@ -893,7 +893,7 @@ mod test { let bytes = ~[]; let port = loader(bytes); let res: Option = port.try_recv(); - assert res.is_none(); + fail_unless!(res.is_none()); } #[test] @@ -910,7 +910,7 @@ mod test { let bytes = ~[0]; let port = loader(bytes); let res: Option = port.try_recv(); - assert res.is_none(); + fail_unless!(res.is_none()); } #[test] @@ -928,7 +928,7 @@ mod test { let bytes = CONTINUE.to_vec() + ~[0]; let port = loader(bytes); let res: Option = port.try_recv(); - assert res.is_none(); + fail_unless!(res.is_none()); } #[test] @@ -941,7 +941,7 @@ mod test { } fn test_try_recv_none4(+loader: PortLoader

) { - assert do task::try || { + fail_unless!(do task::try || { const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by a valid length, // then undeserializable garbage @@ -954,7 +954,7 @@ mod test { let port = loader(bytes); let _res: Option = port.try_recv(); - }.is_err(); + }.is_err()); } #[test] diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 68a9ce75593..5dc264cb878 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -154,7 +154,7 @@ pub mod test { #[test] pub fn test_from_value() { let f = from_value(~"snail"); - assert f.get() == ~"snail"; + fail_unless!(f.get() == ~"snail"); } #[test] @@ -162,31 +162,31 @@ pub mod test { let (ch, po) = oneshot::init(); send_one(ch, ~"whale"); let f = from_port(po); - assert f.get() == ~"whale"; + fail_unless!(f.get() == ~"whale"); } #[test] pub fn test_from_fn() { let f = from_fn(|| ~"brail"); - assert f.get() == ~"brail"; + fail_unless!(f.get() == ~"brail"); } #[test] pub fn test_interface_get() { let f = from_value(~"fail"); - assert f.get() == ~"fail"; + fail_unless!(f.get() == ~"fail"); } #[test] pub fn test_get_ref_method() { let f = from_value(22); - assert *f.get_ref() == 22; + fail_unless!(*f.get_ref() == 22); } #[test] pub fn test_spawn() { let f = spawn(|| ~"bale"); - assert f.get() == ~"bale"; + fail_unless!(f.get() == ~"bale"); } #[test] @@ -203,7 +203,7 @@ pub mod test { let f = do spawn { copy expected }; do task::spawn || { let actual = f.get(); - assert actual == expected; + fail_unless!(actual == expected); } } } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 4e851005de5..2090a3728db 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -480,7 +480,7 @@ pub mod groups { 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); return OptGroup { short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -493,7 +493,7 @@ pub mod groups { 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); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -506,7 +506,7 @@ pub mod groups { 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); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: ~"", @@ -519,7 +519,7 @@ pub mod groups { 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); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -535,7 +535,7 @@ pub mod groups { 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); return OptGroup {short_name: str::from_slice(short_name), long_name: str::from_slice(long_name), hint: str::from_slice(hint), @@ -647,11 +647,11 @@ mod tests { pub 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_) } } @@ -664,8 +664,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"test")); - assert (opt_str(m, ~"test") == ~"20"); + fail_unless!((opt_present(m, ~"test"))); + fail_unless!((opt_str(m, ~"test") == ~"20")); } _ => { fail!(~"test_reqopt_long failed"); } } @@ -711,8 +711,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"t")); - assert (opt_str(m, ~"t") == ~"20"); + fail_unless!((opt_present(m, ~"t"))); + fail_unless!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -760,8 +760,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"test")); - assert (opt_str(m, ~"test") == ~"20"); + fail_unless!((opt_present(m, ~"test"))); + fail_unless!((opt_str(m, ~"test") == ~"20")); } _ => fail!() } @@ -773,7 +773,7 @@ mod tests { let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"test")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), _ => fail!() } } @@ -807,8 +807,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"t")); - assert (opt_str(m, ~"t") == ~"20"); + fail_unless!((opt_present(m, ~"t"))); + fail_unless!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -820,7 +820,7 @@ mod tests { let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"t")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), _ => fail!() } } @@ -855,7 +855,7 @@ mod tests { let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (opt_present(m, ~"test")), + Ok(ref m) => fail_unless!(opt_present(m, ~"test")), _ => fail!() } } @@ -866,7 +866,7 @@ mod tests { let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"test")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), _ => fail!() } } @@ -902,7 +902,7 @@ mod tests { let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (opt_present(m, ~"t")), + Ok(ref m) => fail_unless!(opt_present(m, ~"t")), _ => fail!() } } @@ -913,7 +913,7 @@ mod tests { let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"t")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), _ => fail!() } } @@ -927,7 +927,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!() } @@ -952,7 +952,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_count(m, ~"v") == 1); + fail_unless!((opt_count(m, ~"v") == 1)); } _ => fail!() } @@ -965,7 +965,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_count(m, ~"v") == 2); + fail_unless!((opt_count(m, ~"v") == 2)); } _ => fail!() } @@ -978,7 +978,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_count(m, ~"v") == 2); + fail_unless!((opt_count(m, ~"v") == 2)); } _ => fail!() } @@ -991,7 +991,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_count(m, ~"verbose") == 1); + fail_unless!((opt_count(m, ~"verbose") == 1)); } _ => fail!() } @@ -1004,7 +1004,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_count(m, ~"verbose") == 2); + fail_unless!((opt_count(m, ~"verbose") == 2)); } _ => fail!() } @@ -1018,8 +1018,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"test")); - assert (opt_str(m, ~"test") == ~"20"); + fail_unless!((opt_present(m, ~"test"))); + fail_unless!((opt_str(m, ~"test") == ~"20")); } _ => fail!() } @@ -1031,7 +1031,7 @@ mod tests { let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"test")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"test")), _ => fail!() } } @@ -1054,11 +1054,11 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"test")); - assert (opt_str(m, ~"test") == ~"20"); + fail_unless!((opt_present(m, ~"test"))); + fail_unless!((opt_str(m, ~"test") == ~"20")); let pair = opt_strs(m, ~"test"); - assert (pair[0] == ~"20"); - assert (pair[1] == ~"30"); + fail_unless!((pair[0] == ~"20")); + fail_unless!((pair[1] == ~"30")); } _ => fail!() } @@ -1071,8 +1071,8 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"t")); - assert (opt_str(m, ~"t") == ~"20"); + fail_unless!((opt_present(m, ~"t"))); + fail_unless!((opt_str(m, ~"t") == ~"20")); } _ => fail!() } @@ -1084,7 +1084,7 @@ mod tests { let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert (!opt_present(m, ~"t")), + Ok(ref m) => fail_unless!(!opt_present(m, ~"t")), _ => fail!() } } @@ -1107,11 +1107,11 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (opt_present(m, ~"t")); - assert (opt_str(m, ~"t") == ~"20"); + fail_unless!((opt_present(m, ~"t"))); + fail_unless!((opt_str(m, ~"t") == ~"20")); let pair = opt_strs(m, ~"t"); - assert (pair[0] == ~"20"); - assert (pair[1] == ~"30"); + fail_unless!((pair[0] == ~"20")); + fail_unless!((pair[1] == ~"30")); } _ => fail!() } @@ -1152,20 +1152,20 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert (m.free[0] == ~"prog"); - assert (m.free[1] == ~"free1"); - assert (opt_str(m, ~"s") == ~"20"); - assert (m.free[2] == ~"free2"); - assert (opt_present(m, ~"flag")); - assert (opt_str(m, ~"long") == ~"30"); - assert (opt_present(m, ~"f")); + fail_unless!((m.free[0] == ~"prog")); + fail_unless!((m.free[1] == ~"free1")); + fail_unless!((opt_str(m, ~"s") == ~"20")); + fail_unless!((m.free[2] == ~"free2")); + fail_unless!((opt_present(m, ~"flag"))); + fail_unless!((opt_str(m, ~"long") == ~"30")); + fail_unless!((opt_present(m, ~"f"))); let pair = opt_strs(m, ~"m"); - assert (pair[0] == ~"40"); - assert (pair[1] == ~"50"); + fail_unless!((pair[0] == ~"40")); + fail_unless!((pair[1] == ~"50")); let pair = opt_strs(m, ~"n"); - assert (pair[0] == ~"-A B"); - assert (pair[1] == ~"-60 70"); - assert (!opt_present(m, ~"notpresent")); + fail_unless!((pair[0] == ~"-A B")); + fail_unless!((pair[1] == ~"-60 70")); + fail_unless!((!opt_present(m, ~"notpresent"))); } _ => fail!() } @@ -1179,17 +1179,17 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - assert opts_present(matches, ~[~"e"]); - assert opts_present(matches, ~[~"encrypt"]); - assert opts_present(matches, ~[~"encrypt", ~"e"]); - assert opts_present(matches, ~[~"e", ~"encrypt"]); - assert !opts_present(matches, ~[~"thing"]); - assert !opts_present(matches, ~[]); + fail_unless!(opts_present(matches, ~[~"e"])); + fail_unless!(opts_present(matches, ~[~"encrypt"])); + fail_unless!(opts_present(matches, ~[~"encrypt", ~"e"])); + fail_unless!(opts_present(matches, ~[~"e", ~"encrypt"])); + fail_unless!(!opts_present(matches, ~[~"thing"])); + fail_unless!(!opts_present(matches, ~[])); - assert opts_str(matches, ~[~"e"]) == ~"foo"; - assert opts_str(matches, ~[~"encrypt"]) == ~"foo"; - assert opts_str(matches, ~[~"e", ~"encrypt"]) == ~"foo"; - assert opts_str(matches, ~[~"encrypt", ~"e"]) == ~"foo"; + fail_unless!(opts_str(matches, ~[~"e"]) == ~"foo"); + fail_unless!(opts_str(matches, ~[~"encrypt"]) == ~"foo"); + fail_unless!(opts_str(matches, ~[~"e", ~"encrypt"]) == ~"foo"); + fail_unless!(opts_str(matches, ~[~"encrypt", ~"e"]) == ~"foo"); } #[test] @@ -1200,68 +1200,68 @@ mod tests { result::Ok(m) => m, result::Err(_) => fail!() }; - assert opts_present(matches, ~[~"L"]); - assert opts_str(matches, ~[~"L"]) == ~"foo"; - assert opts_present(matches, ~[~"M"]); - assert opts_str(matches, ~[~"M"]) == ~"."; + fail_unless!(opts_present(matches, ~[~"L"])); + fail_unless!(opts_str(matches, ~[~"L"]) == ~"foo"); + fail_unless!(opts_present(matches, ~[~"M"])); + fail_unless!(opts_str(matches, ~[~"M"]) == ~"."); } #[test] pub fn test_groups_reqopt() { let opt = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); - assert opt == OptGroup { short_name: ~"b", + fail_unless!(opt == OptGroup { short_name: ~"b", long_name: ~"banana", hint: ~"VAL", desc: ~"some bananas", hasarg: Yes, - occur: Req } + occur: Req }) } #[test] pub fn test_groups_optopt() { let opt = groups::optopt(~"a", ~"apple", ~"some apples", ~"VAL"); - assert opt == OptGroup { short_name: ~"a", + fail_unless!(opt == OptGroup { short_name: ~"a", long_name: ~"apple", hint: ~"VAL", desc: ~"some apples", hasarg: Yes, - occur: Optional } + occur: Optional }) } #[test] pub fn test_groups_optflag() { let opt = groups::optflag(~"k", ~"kiwi", ~"some kiwis"); - assert opt == OptGroup { short_name: ~"k", + fail_unless!(opt == OptGroup { short_name: ~"k", long_name: ~"kiwi", hint: ~"", desc: ~"some kiwis", hasarg: No, - occur: Optional } + occur: Optional }) } #[test] pub fn test_groups_optflagopt() { let opt = groups::optflagopt(~"p", ~"pineapple", ~"some pineapples", ~"VAL"); - assert opt == OptGroup { short_name: ~"p", + fail_unless!(opt == OptGroup { short_name: ~"p", long_name: ~"pineapple", hint: ~"VAL", desc: ~"some pineapples", hasarg: Maybe, - occur: Optional } + occur: Optional }) } #[test] pub fn test_groups_optmulti() { let opt = groups::optmulti(~"l", ~"lime", ~"some limes", ~"VAL"); - assert opt == OptGroup { short_name: ~"l", + fail_unless!(opt == OptGroup { short_name: ~"l", long_name: ~"lime", hint: ~"VAL", desc: ~"some limes", hasarg: Yes, - occur: Multi } + occur: Multi }) } #[test] @@ -1270,7 +1270,7 @@ mod tests { let verbose = groups::reqopt(~"b", ~"banana", ~"some bananas", ~"VAL"); - assert groups::long_to_short(&verbose) == short; + fail_unless!(groups::long_to_short(&verbose) == short); } #[test] @@ -1295,8 +1295,8 @@ mod tests { ~"-p", ~"16", ~"l", ~"35"]; // FIXME #4681: sort options here? - assert getopts(sample_args, short) - == groups::getopts(sample_args, verbose); + fail_unless!(getopts(sample_args, short) + == groups::getopts(sample_args, verbose)); } #[test] @@ -1327,7 +1327,7 @@ Options: debug!("expected: <<%s>>", expected); debug!("generated: <<%s>>", generated_usage); - assert generated_usage == expected; + fail_unless!(generated_usage == expected); } #[test] @@ -1356,7 +1356,7 @@ Options: debug!("expected: <<%s>>", expected); debug!("generated: <<%s>>", usage); - assert usage == expected + fail_unless!(usage == expected) } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 4ebd151eb2e..01e0b58f77e 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1229,45 +1229,45 @@ mod tests { #[test] fn test_write_null() { - assert to_str(&Null) == ~"null"; + fail_unless!(to_str(&Null) == ~"null"); } #[test] fn test_write_number() { - assert to_str(&Number(3f)) == ~"3"; - assert to_str(&Number(3.1f)) == ~"3.1"; - assert to_str(&Number(-1.5f)) == ~"-1.5"; - assert to_str(&Number(0.5f)) == ~"0.5"; + fail_unless!(to_str(&Number(3f)) == ~"3"); + fail_unless!(to_str(&Number(3.1f)) == ~"3.1"); + fail_unless!(to_str(&Number(-1.5f)) == ~"-1.5"); + fail_unless!(to_str(&Number(0.5f)) == ~"0.5"); } #[test] fn test_write_str() { - assert to_str(&String(~"")) == ~"\"\""; - assert to_str(&String(~"foo")) == ~"\"foo\""; + fail_unless!(to_str(&String(~"")) == ~"\"\""); + fail_unless!(to_str(&String(~"foo")) == ~"\"foo\""); } #[test] fn test_write_bool() { - assert to_str(&Boolean(true)) == ~"true"; - assert to_str(&Boolean(false)) == ~"false"; + fail_unless!(to_str(&Boolean(true)) == ~"true"); + fail_unless!(to_str(&Boolean(false)) == ~"false"); } #[test] fn test_write_list() { - assert to_str(&List(~[])) == ~"[]"; - assert to_str(&List(~[Boolean(true)])) == ~"[true]"; - assert to_str(&List(~[ + fail_unless!(to_str(&List(~[])) == ~"[]"); + fail_unless!(to_str(&List(~[Boolean(true)])) == ~"[true]"); + fail_unless!(to_str(&List(~[ Boolean(false), Null, List(~[String(~"foo\nbar"), Number(3.5f)]) - ])) == ~"[false,null,[\"foo\\nbar\",3.5]]"; + ])) == ~"[false,null,[\"foo\\nbar\",3.5]]"); } #[test] fn test_write_object() { - assert to_str(&mk_object(~[])) == ~"{}"; - assert to_str(&mk_object(~[(~"a", Boolean(true))])) - == ~"{\"a\":true}"; + fail_unless!(to_str(&mk_object(~[])) == ~"{}"); + fail_unless!(to_str(&mk_object(~[(~"a", Boolean(true))])) + == ~"{\"a\":true}"); let a = mk_object(~[ (~"a", Boolean(true)), (~"b", List(~[ @@ -1278,7 +1278,7 @@ mod tests { // We can't compare the strings directly because the object fields be // printed in a different order. let b = result::unwrap(from_str(to_str(&a))); - assert a == b; + fail_unless!(a == b); } // two fns copied from libsyntax/util/testing.rs. @@ -1347,165 +1347,195 @@ mod tests { #[test] fn test_trailing_characters() { - assert from_str(~"nulla") == - Err(Error {line: 1u, col: 5u, msg: @~"trailing characters"}); - assert from_str(~"truea") == - Err(Error {line: 1u, col: 5u, msg: @~"trailing characters"}); - assert from_str(~"falsea") == - Err(Error {line: 1u, col: 6u, msg: @~"trailing characters"}); - assert from_str(~"1a") == - Err(Error {line: 1u, col: 2u, msg: @~"trailing characters"}); - assert from_str(~"[]a") == - Err(Error {line: 1u, col: 3u, msg: @~"trailing characters"}); - assert from_str(~"{}a") == - Err(Error {line: 1u, col: 3u, msg: @~"trailing characters"}); + fail_unless!(from_str(~"nulla") == + Err(Error {line: 1u, col: 5u, msg: @~"trailing characters"})); + fail_unless!(from_str(~"truea") == + Err(Error {line: 1u, col: 5u, msg: @~"trailing characters"})); + fail_unless!(from_str(~"falsea") == + Err(Error {line: 1u, col: 6u, msg: @~"trailing characters"})); + fail_unless!(from_str(~"1a") == + Err(Error {line: 1u, col: 2u, msg: @~"trailing characters"})); + fail_unless!(from_str(~"[]a") == + Err(Error {line: 1u, col: 3u, msg: @~"trailing characters"})); + fail_unless!(from_str(~"{}a") == + Err(Error {line: 1u, col: 3u, msg: @~"trailing characters"})); } #[test] fn test_read_identifiers() { - assert from_str(~"n") == - Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"}); - assert from_str(~"nul") == - Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"}); + fail_unless!(from_str(~"n") == + Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"})); + fail_unless!(from_str(~"nul") == + Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"})); - assert from_str(~"t") == - Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"}); - assert from_str(~"truz") == - Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"}); + fail_unless!(from_str(~"t") == + Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"})); + fail_unless!(from_str(~"truz") == + Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"})); - assert from_str(~"f") == - Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"}); - assert from_str(~"faz") == - Err(Error {line: 1u, col: 3u, msg: @~"invalid syntax"}); + fail_unless!(from_str(~"f") == + Err(Error {line: 1u, col: 2u, msg: @~"invalid syntax"})); + fail_unless!(from_str(~"faz") == + Err(Error {line: 1u, col: 3u, msg: @~"invalid syntax"})); - assert from_str(~"null") == Ok(Null); - assert from_str(~"true") == Ok(Boolean(true)); - assert from_str(~"false") == Ok(Boolean(false)); - assert from_str(~" null ") == Ok(Null); - assert from_str(~" true ") == Ok(Boolean(true)); - assert from_str(~" false ") == Ok(Boolean(false)); + fail_unless!(from_str(~"null") == Ok(Null)); + fail_unless!(from_str(~"true") == Ok(Boolean(true))); + fail_unless!(from_str(~"false") == Ok(Boolean(false))); + fail_unless!(from_str(~" null ") == Ok(Null)); + fail_unless!(from_str(~" true ") == Ok(Boolean(true))); + fail_unless!(from_str(~" false ") == Ok(Boolean(false))); } #[test] fn test_read_number() { - assert from_str(~"+") == - Err(Error {line: 1u, col: 1u, msg: @~"invalid syntax"}); - assert from_str(~".") == - Err(Error {line: 1u, col: 1u, msg: @~"invalid syntax"}); + fail_unless!(from_str(~"+") == + Err(Error {line: 1u, col: 1u, msg: @~"invalid syntax"})); + fail_unless!(from_str(~".") == + Err(Error {line: 1u, col: 1u, msg: @~"invalid syntax"})); - assert from_str(~"-") == - Err(Error {line: 1u, col: 2u, msg: @~"invalid number"}); - assert from_str(~"00") == - Err(Error {line: 1u, col: 2u, msg: @~"invalid number"}); - assert from_str(~"1.") == - Err(Error {line: 1u, col: 3u, msg: @~"invalid number"}); - assert from_str(~"1e") == - Err(Error {line: 1u, col: 3u, msg: @~"invalid number"}); - assert from_str(~"1e+") == - Err(Error {line: 1u, col: 4u, msg: @~"invalid number"}); + fail_unless!(from_str(~"-") == + Err(Error {line: 1u, col: 2u, msg: @~"invalid number"})); + fail_unless!(from_str(~"00") == + Err(Error {line: 1u, col: 2u, msg: @~"invalid number"})); + fail_unless!(from_str(~"1.") == + Err(Error {line: 1u, col: 3u, msg: @~"invalid number"})); + fail_unless!(from_str(~"1e") == + Err(Error {line: 1u, col: 3u, msg: @~"invalid number"})); + fail_unless!(from_str(~"1e+") == + Err(Error {line: 1u, col: 4u, msg: @~"invalid number"})); - assert from_str(~"3") == Ok(Number(3f)); - assert from_str(~"3.1") == Ok(Number(3.1f)); - assert from_str(~"-1.2") == Ok(Number(-1.2f)); - assert from_str(~"0.4") == Ok(Number(0.4f)); - assert from_str(~"0.4e5") == Ok(Number(0.4e5f)); - assert from_str(~"0.4e+15") == Ok(Number(0.4e15f)); - assert from_str(~"0.4e-01") == Ok(Number(0.4e-01f)); - assert from_str(~" 3 ") == Ok(Number(3f)); + fail_unless!(from_str(~"3") == Ok(Number(3f))); + fail_unless!(from_str(~"3.1") == Ok(Number(3.1f))); + fail_unless!(from_str(~"-1.2") == Ok(Number(-1.2f))); + fail_unless!(from_str(~"0.4") == Ok(Number(0.4f))); + fail_unless!(from_str(~"0.4e5") == Ok(Number(0.4e5f))); + fail_unless!(from_str(~"0.4e+15") == Ok(Number(0.4e15f))); + fail_unless!(from_str(~"0.4e-01") == Ok(Number(0.4e-01f))); + fail_unless!(from_str(~" 3 ") == Ok(Number(3f))); } #[test] fn test_read_str() { - assert from_str(~"\"") == - Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing string"}); - assert from_str(~"\"lol") == - Err(Error {line: 1u, col: 5u, msg: @~"EOF while parsing string"}); + fail_unless!(from_str(~"\"") == + Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing string" + })); + fail_unless!(from_str(~"\"lol") == + Err(Error {line: 1u, col: 5u, msg: @~"EOF while parsing string" + })); - assert from_str(~"\"\"") == Ok(String(~"")); - assert from_str(~"\"foo\"") == Ok(String(~"foo")); - assert from_str(~"\"\\\"\"") == Ok(String(~"\"")); - assert from_str(~"\"\\b\"") == Ok(String(~"\x08")); - assert from_str(~"\"\\n\"") == Ok(String(~"\n")); - assert from_str(~"\"\\r\"") == Ok(String(~"\r")); - assert from_str(~"\"\\t\"") == Ok(String(~"\t")); - assert from_str(~" \"foo\" ") == Ok(String(~"foo")); + fail_unless!(from_str(~"\"\"") == Ok(String(~""))); + fail_unless!(from_str(~"\"foo\"") == Ok(String(~"foo"))); + fail_unless!(from_str(~"\"\\\"\"") == Ok(String(~"\""))); + fail_unless!(from_str(~"\"\\b\"") == Ok(String(~"\x08"))); + fail_unless!(from_str(~"\"\\n\"") == Ok(String(~"\n"))); + fail_unless!(from_str(~"\"\\r\"") == Ok(String(~"\r"))); + fail_unless!(from_str(~"\"\\t\"") == Ok(String(~"\t"))); + fail_unless!(from_str(~" \"foo\" ") == Ok(String(~"foo"))); } #[test] fn test_unicode_hex_escapes_in_str() { - assert from_str(~"\"\\u12ab\"") == Ok(String(~"\u12ab")); - assert from_str(~"\"\\uAB12\"") == Ok(String(~"\uAB12")); + fail_unless!(from_str(~"\"\\u12ab\"") == Ok(String(~"\u12ab"))); + fail_unless!(from_str(~"\"\\uAB12\"") == Ok(String(~"\uAB12"))); } #[test] fn test_read_list() { - assert from_str(~"[") == - Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing value"}); - assert from_str(~"[1") == - Err(Error {line: 1u, col: 3u, msg: @~"EOF while parsing list"}); - assert from_str(~"[1,") == - Err(Error {line: 1u, col: 4u, msg: @~"EOF while parsing value"}); - assert from_str(~"[1,]") == - Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"}); - assert from_str(~"[6 7]") == - Err(Error {line: 1u, col: 4u, msg: @~"expected `,` or `]`"}); + fail_unless!(from_str(~"[") == + Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing value"})); + fail_unless!(from_str(~"[1") == + Err(Error {line: 1u, col: 3u, msg: @~"EOF while parsing list"})); + fail_unless!(from_str(~"[1,") == + Err(Error {line: 1u, col: 4u, msg: @~"EOF while parsing value"})); + fail_unless!(from_str(~"[1,]") == + Err(Error {line: 1u, col: 4u, msg: @~"invalid syntax"})); + fail_unless!(from_str(~"[6 7]") == + Err(Error {line: 1u, col: 4u, msg: @~"expected `,` or `]`"})); - assert from_str(~"[]") == Ok(List(~[])); - assert from_str(~"[ ]") == Ok(List(~[])); - assert from_str(~"[true]") == Ok(List(~[Boolean(true)])); - assert from_str(~"[ false ]") == Ok(List(~[Boolean(false)])); - assert from_str(~"[null]") == Ok(List(~[Null])); - assert from_str(~"[3, 1]") == Ok(List(~[Number(3f), Number(1f)])); - assert from_str(~"\n[3, 2]\n") == Ok(List(~[Number(3f), Number(2f)])); - assert from_str(~"[2, [4, 1]]") == - Ok(List(~[Number(2f), List(~[Number(4f), Number(1f)])])); + fail_unless!(from_str(~"[]") == Ok(List(~[]))); + fail_unless!(from_str(~"[ ]") == Ok(List(~[]))); + fail_unless!(from_str(~"[true]") == Ok(List(~[Boolean(true)]))); + fail_unless!(from_str(~"[ false ]") == Ok(List(~[Boolean(false)]))); + fail_unless!(from_str(~"[null]") == Ok(List(~[Null]))); + fail_unless!(from_str(~"[3, 1]") == + Ok(List(~[Number(3f), Number(1f)]))); + fail_unless!(from_str(~"\n[3, 2]\n") == + Ok(List(~[Number(3f), Number(2f)]))); + fail_unless!(from_str(~"[2, [4, 1]]") == + Ok(List(~[Number(2f), List(~[Number(4f), Number(1f)])]))); } #[test] fn test_read_object() { - assert from_str(~"{") == - Err(Error {line: 1u, col: 2u, msg: @~"EOF while parsing object"}); - assert from_str(~"{ ") == - Err(Error {line: 1u, col: 3u, msg: @~"EOF while parsing object"}); - assert from_str(~"{1") == - Err(Error {line: 1u, col: 2u, msg: @~"key must be a string"}); - assert from_str(~"{ \"a\"") == - Err(Error {line: 1u, col: 6u, msg: @~"EOF while parsing object"}); - assert from_str(~"{\"a\"") == - Err(Error {line: 1u, col: 5u, msg: @~"EOF while parsing object"}); - assert from_str(~"{\"a\" ") == - Err(Error {line: 1u, col: 6u, msg: @~"EOF while parsing object"}); + fail_unless!(from_str(~"{") == + Err(Error { + line: 1u, + col: 2u, + msg: @~"EOF while parsing object"})); + fail_unless!(from_str(~"{ ") == + Err(Error { + line: 1u, + col: 3u, + msg: @~"EOF while parsing object"})); + fail_unless!(from_str(~"{1") == + Err(Error { + line: 1u, + col: 2u, + msg: @~"key must be a string"})); + fail_unless!(from_str(~"{ \"a\"") == + Err(Error { + line: 1u, + col: 6u, + msg: @~"EOF while parsing object"})); + fail_unless!(from_str(~"{\"a\"") == + Err(Error { + line: 1u, + col: 5u, + msg: @~"EOF while parsing object"})); + fail_unless!(from_str(~"{\"a\" ") == + Err(Error { + line: 1u, + col: 6u, + msg: @~"EOF while parsing object"})); - assert from_str(~"{\"a\" 1") == - Err(Error {line: 1u, col: 6u, msg: @~"expected `:`"}); - assert from_str(~"{\"a\":") == - Err(Error {line: 1u, col: 6u, msg: @~"EOF while parsing value"}); - assert from_str(~"{\"a\":1") == - Err(Error {line: 1u, col: 7u, msg: @~"EOF while parsing object"}); - assert from_str(~"{\"a\":1 1") == - Err(Error {line: 1u, col: 8u, msg: @~"expected `,` or `}`"}); - assert from_str(~"{\"a\":1,") == - Err(Error {line: 1u, col: 8u, msg: @~"EOF while parsing object"}); + fail_unless!(from_str(~"{\"a\" 1") == + Err(Error {line: 1u, col: 6u, msg: @~"expected `:`"})); + fail_unless!(from_str(~"{\"a\":") == + Err(Error {line: 1u, col: 6u, msg: @~"EOF while parsing value"})); + fail_unless!(from_str(~"{\"a\":1") == + Err(Error { + line: 1u, + col: 7u, + msg: @~"EOF while parsing object"})); + fail_unless!(from_str(~"{\"a\":1 1") == + Err(Error {line: 1u, col: 8u, msg: @~"expected `,` or `}`"})); + fail_unless!(from_str(~"{\"a\":1,") == + Err(Error { + line: 1u, + col: 8u, + msg: @~"EOF while parsing object"})); - assert result::unwrap(from_str(~"{}")) == mk_object(~[]); - assert result::unwrap(from_str(~"{\"a\": 3}")) == - mk_object(~[(~"a", Number(3.0f))]); + fail_unless!(result::unwrap(from_str(~"{}")) == mk_object(~[])); + fail_unless!(result::unwrap(from_str(~"{\"a\": 3}")) == + mk_object(~[(~"a", Number(3.0f))])); - assert result::unwrap(from_str(~"{ \"a\": null, \"b\" : true }")) == + fail_unless!(result::unwrap(from_str( + ~"{ \"a\": null, \"b\" : true }")) == mk_object(~[ (~"a", Null), - (~"b", Boolean(true))]); - assert result::unwrap( + (~"b", Boolean(true))])); + fail_unless!(result::unwrap( from_str(~"\n{ \"a\": null, \"b\" : true }\n")) == mk_object(~[ (~"a", Null), - (~"b", Boolean(true))]); - assert result::unwrap(from_str(~"{\"a\" : 1.0 ,\"b\": [ true ]}")) == + (~"b", Boolean(true))])); + fail_unless!(result::unwrap(from_str( + ~"{\"a\" : 1.0 ,\"b\": [ true ]}")) == mk_object(~[ (~"a", Number(1.0)), (~"b", List(~[Boolean(true)])) - ]); - assert result::unwrap(from_str( + ])); + fail_unless!(result::unwrap(from_str( ~"{" + ~"\"a\": 1.0, " + ~"\"b\": [" + @@ -1523,12 +1553,15 @@ mod tests { (~"c", mk_object(~[(~"d", Null)])) ]) ])) - ]); + ])); } #[test] fn test_multiline_errors() { - assert from_str(~"{\n \"foo\":\n \"bar\"") == - Err(Error {line: 3u, col: 8u, msg: @~"EOF while parsing object"}); + fail_unless!(from_str(~"{\n \"foo\":\n \"bar\"") == + Err(Error { + line: 3u, + col: 8u, + msg: @~"EOF while parsing object"})); } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 043e0cafe61..5ab1722ae83 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -165,28 +165,28 @@ 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] pub fn test_from_vec() { let l = from_vec(~[0, 1, 2]); - assert (head(l) == 0); + fail_unless!((head(l) == 0)); let tail_l = tail(l); - assert (head(tail_l) == 1); + fail_unless!((head(tail_l) == 1)); let tail_tail_l = tail(tail_l); - assert (head(tail_tail_l) == 2); + fail_unless!((head(tail_tail_l) == 2)); } #[test] pub fn test_from_vec_empty() { let empty : @list::List = from_vec(~[]); - assert (empty == @list::Nil::); + fail_unless!((empty == @list::Nil::)); } #[test] @@ -194,8 +194,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 (list::foldl(0u, l, add) == 10u); - assert (list::foldl(0u, empty, add) == 0u); + fail_unless!((list::foldl(0u, l, add) == 10u)); + fail_unless!((list::foldl(0u, empty, add) == 0u)); } #[test] @@ -204,14 +204,14 @@ mod tests { *a - *b } let l = from_vec(~[1, 2, 3, 4]); - assert (list::foldl(0, l, sub) == -10); + fail_unless!((list::foldl(0, l, sub) == -10)); } #[test] pub fn test_find_success() { fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec(~[0, 1, 2]); - assert (list::find(l, match_) == option::Some(2)); + fail_unless!((list::find(l, match_) == option::Some(2))); } #[test] @@ -219,32 +219,32 @@ mod tests { fn match_(_i: &int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::; - assert (list::find(l, match_) == option::None::); - assert (list::find(empty, match_) == option::None::); + fail_unless!((list::find(l, match_) == option::None::)); + fail_unless!((list::find(empty, match_) == option::None::)); } #[test] pub 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] pub fn test_len() { let l = from_vec(~[0, 1, 2]); let empty = @list::Nil::; - assert (list::len(l) == 3u); - assert (list::len(empty) == 0u); + fail_unless!((list::len(l) == 3u)); + fail_unless!((list::len(empty) == 0u)); } #[test] pub fn test_append() { - assert from_vec(~[1,2,3,4]) - == list::append(list::from_vec(~[1,2]), list::from_vec(~[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/libstd/md4.rs b/src/libstd/md4.rs index 6fe82d554de..3dc669da571 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -125,15 +125,16 @@ pub pure fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } #[test] fn test_md4() { - assert md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0"; - assert md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24"; - assert md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d"; - assert md4_text(~"message digest") == ~"d9130a8164549fe818874806e1c7014b"; - assert md4_text(~"abcdefghijklmnopqrstuvwxyz") == - ~"d79e1c308aa5bbcdeea8ed63df412da9"; - assert md4_text(~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ - 0123456789") == ~"043f8582f241db351ce627e153e7f0e4"; - assert md4_text(~"1234567890123456789012345678901234567890123456789\ + fail_unless!(md4_text(~"") == ~"31d6cfe0d16ae931b73c59d7e0c089c0"); + fail_unless!(md4_text(~"a") == ~"bde52cb31de33e46245e05fbdbd6fb24"); + fail_unless!(md4_text(~"abc") == ~"a448017aaf21d8525fc10ae87aa6729d"); + fail_unless!(md4_text(~"message digest") == ~"d9130a8164549fe818874806e1c7014b"); + fail_unless!(md4_text(~"abcdefghijklmnopqrstuvwxyz") == + ~"d79e1c308aa5bbcdeea8ed63df412da9"); + fail_unless!(md4_text( + ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ + 0123456789") == ~"043f8582f241db351ce627e153e7f0e4"); + fail_unless!(md4_text(~"1234567890123456789012345678901234567890123456789\ 0123456789012345678901234567890") == - ~"e33b4ddc9c38f2199c3e7b164fcc0536"; + ~"e33b4ddc9c38f2199c3e7b164fcc0536"); } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 7a5c40f403f..8021162188f 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -377,7 +377,7 @@ mod test { #[test] fn test_ip_ipv4_parse_and_format_ip() { let localhost_str = ~"127.0.0.1"; - assert (format_addr(&v4::parse_addr(localhost_str)) + fail_unless!(format_addr(&v4::parse_addr(localhost_str)) == localhost_str) } #[test] @@ -386,14 +386,14 @@ mod test { let format_result = format_addr(&v6::parse_addr(localhost_str)); log(debug, fmt!("results: expected: '%s' actual: '%s'", localhost_str, format_result)); - assert format_result == localhost_str; + fail_unless!(format_result == localhost_str); } #[test] fn test_ip_ipv4_bad_parse() { match v4::try_parse_addr(~"b4df00d") { result::Err(ref err_info) => { log(debug, fmt!("got error as expected %?", err_info)); - assert true; + fail_unless!(true); } result::Ok(ref addr) => { fail!(fmt!("Expected failure, but got addr %?", addr)); @@ -406,7 +406,7 @@ mod test { match v6::try_parse_addr(~"::,~2234k;") { result::Err(ref err_info) => { log(debug, fmt!("got error as expected %?", err_info)); - assert true; + fail_unless!(true); } result::Ok(ref addr) => { fail!(fmt!("Expected failure, but got addr %?", addr)); @@ -437,7 +437,7 @@ mod test { } // at least one result.. this is going to vary from system // to system, based on stuff like the contents of /etc/hosts - assert !results.is_empty(); + fail_unless!(!results.is_empty()); } #[test] #[ignore(reason = "valgrind says it's leaky")] @@ -445,6 +445,6 @@ mod test { let localhost_name = ~"sjkl234m,./sdf"; let iotask = &uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); - assert result::is_err(&ga_result); + fail_unless!(result::is_err(&ga_result)); } } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 67e10b58617..5328975f82a 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -875,7 +875,7 @@ impl io::Reader for TcpSocketBuf { let mut count: uint = 0; loop { - assert count < len; + fail_unless!(count < len); // If possible, copy up to `len` bytes from the internal // `data.buf` into `buf` @@ -895,7 +895,7 @@ impl io::Reader for TcpSocketBuf { } } - assert count <= len; + fail_unless!(count <= len); if count == len { break; } @@ -1587,15 +1587,15 @@ pub mod test { server_port, expected_req, hl_loop); - assert actual_resp_result.is_ok(); + fail_unless!(actual_resp_result.is_ok()); let actual_resp = actual_resp_result.get(); let actual_req = server_result_po.recv(); debug!("REQ: expected: '%s' actual: '%s'", expected_req, actual_req); debug!("RESP: expected: '%s' actual: '%s'", expected_resp, actual_resp); - assert str::contains(actual_req, expected_req); - assert str::contains(actual_resp, expected_resp); + fail_unless!(str::contains(actual_req, expected_req)); + fail_unless!(str::contains(actual_resp, expected_resp)); } pub fn impl_gl_tcp_ipv4_get_peer_addr() { let hl_loop = &uv::global_loop::get(); @@ -1628,9 +1628,9 @@ pub mod test { debug!("testing peer address"); // This is what we are actually testing! - assert net::ip::format_addr(&sock.get_peer_addr()) == - ~"127.0.0.1"; - assert net::ip::get_port(&sock.get_peer_addr()) == 8887; + fail_unless!(net::ip::format_addr(&sock.get_peer_addr()) == + ~"127.0.0.1"); + fail_unless!(net::ip::get_port(&sock.get_peer_addr()) == 8887); // Fulfill the protocol the test server expects let resp_bytes = str::to_bytes(~"ping"); @@ -1691,7 +1691,7 @@ pub mod test { hl_loop); match listen_err { AddressInUse => { - assert true; + fail_unless!(true); } _ => { fail!(~"expected address_in_use listen error,"+ @@ -1710,7 +1710,7 @@ pub mod test { hl_loop); match listen_err { AccessDenied => { - assert true; + fail_unless!(true); } _ => { fail!(~"expected address_in_use listen error,"+ @@ -1747,7 +1747,7 @@ pub mod test { let server_addr = ip::v4::parse_addr(server_ip); let conn_result = connect(server_addr, server_port, iotask); if result::is_err(&conn_result) { - assert false; + fail_unless!(false); } let sock_buf = @socket_buf(result::unwrap(conn_result)); buf_write(sock_buf, expected_req); @@ -1762,8 +1762,8 @@ pub mod test { expected_req, actual_req)); log(debug, fmt!("RESP: expected: '%s' actual: '%s'", expected_resp, actual_resp)); - assert str::contains(actual_req, expected_req); - assert str::contains(actual_resp, expected_resp); + fail_unless!(str::contains(actual_req, expected_req)); + fail_unless!(str::contains(actual_resp, expected_resp)); } pub fn impl_tcp_socket_impl_reader_handles_eof() { @@ -1794,7 +1794,7 @@ pub mod test { let server_addr = ip::v4::parse_addr(server_ip); let conn_result = connect(server_addr, server_port, hl_loop); if result::is_err(&conn_result) { - assert false; + fail_unless!(false); } let sock_buf = @socket_buf(result::unwrap(conn_result)); buf_write(sock_buf, expected_req); @@ -1802,7 +1802,7 @@ pub mod test { let buf_reader = sock_buf as Reader; let actual_response = str::from_bytes(buf_reader.read_whole_stream()); debug!("Actual response: %s", actual_response); - assert expected_resp == actual_response; + fail_unless!(expected_resp == actual_response); } fn buf_write(w: &W, val: &str) { diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 18f38e074c7..0739f624882 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -733,83 +733,83 @@ impl to_bytes::IterBytes for Url { #[test] fn test_split_char_first() { let (u,v) = split_char_first(~"hello, sweet world", ','); - assert u == ~"hello"; - assert v == ~" sweet world"; + fail_unless!(u == ~"hello"); + fail_unless!(v == ~" sweet world"); let (u,v) = split_char_first(~"hello sweet world", ','); - assert u == ~"hello sweet world"; - assert v == ~""; + fail_unless!(u == ~"hello sweet world"); + fail_unless!(v == ~""); } #[test] fn test_get_authority() { let (u, h, p, r) = get_authority( "//user:pass@rust-lang.org/something").unwrap(); - assert u == Some(UserInfo::new(~"user", Some(~"pass"))); - assert h == ~"rust-lang.org"; - assert p.is_none(); - assert r == ~"/something"; + fail_unless!(u == Some(UserInfo::new(~"user", Some(~"pass")))); + fail_unless!(h == ~"rust-lang.org"); + fail_unless!(p.is_none()); + fail_unless!(r == ~"/something"); let (u, h, p, r) = get_authority( "//rust-lang.org:8000?something").unwrap(); - assert u.is_none(); - assert h == ~"rust-lang.org"; - assert p == Some(~"8000"); - assert r == ~"?something"; + fail_unless!(u.is_none()); + fail_unless!(h == ~"rust-lang.org"); + fail_unless!(p == Some(~"8000")); + fail_unless!(r == ~"?something"); let (u, h, p, r) = get_authority( "//rust-lang.org#blah").unwrap(); - assert u.is_none(); - assert h == ~"rust-lang.org"; - assert p.is_none(); - assert r == ~"#blah"; + fail_unless!(u.is_none()); + fail_unless!(h == ~"rust-lang.org"); + fail_unless!(p.is_none()); + fail_unless!(r == ~"#blah"); // ipv6 tests let (_, h, _, _) = get_authority( "//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap(); - assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; + fail_unless!(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 h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; - assert p == Some(~"8000"); + fail_unless!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + fail_unless!(p == Some(~"8000")); let (u, h, p, _) = get_authority( "//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah" ).unwrap(); - assert u == Some(UserInfo::new(~"us", Some(~"p"))); - assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"; - assert p == Some(~"8000"); + fail_unless!(u == Some(UserInfo::new(~"us", Some(~"p")))); + fail_unless!(h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334"); + fail_unless!(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( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err(); - assert get_authority( - "//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err(); + 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()); + 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 '//' let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap(); - assert h == ~""; + fail_unless!(h == ~""); let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap(); - assert h == ~""; + fail_unless!(h == ~""); } #[test] fn test_get_path() { let (p, r) = get_path("/something+%20orother", true).unwrap(); - assert p == ~"/something+ orother"; - assert r == ~""; + fail_unless!(p == ~"/something+ orother"); + fail_unless!(r == ~""); let (p, r) = get_path("test@email.com#fragment", false).unwrap(); - assert p == ~"test@email.com"; - assert r == ~"#fragment"; + fail_unless!(p == ~"test@email.com"); + fail_unless!(r == ~"#fragment"); let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap(); - assert p == ~"/gen/:addr="; - assert r == ~"?q=v"; + fail_unless!(p == ~"/gen/:addr="); + fail_unless!(r == ~"?q=v"); //failure cases - assert get_path(~"something?q", true).is_err(); + fail_unless!(get_path(~"something?q", true).is_err()); } #[cfg(test)] @@ -826,246 +826,246 @@ mod tests { let up = from_str(url); let u = up.unwrap(); - assert u.scheme == ~"http"; + fail_unless!(u.scheme == ~"http"); let userinfo = u.user.get_ref(); - assert userinfo.user == ~"user"; - assert userinfo.pass.get_ref() == &~"pass"; - assert u.host == ~"rust-lang.org"; - assert u.path == ~"/doc"; - assert u.query == ~[(~"s", ~"v")]; - assert u.fragment.get_ref() == &~"something"; + fail_unless!(userinfo.user == ~"user"); + fail_unless!(userinfo.pass.get_ref() == &~"pass"); + fail_unless!(u.host == ~"rust-lang.org"); + fail_unless!(u.path == ~"/doc"); + fail_unless!(u.query == ~[(~"s", ~"v")]); + fail_unless!(u.fragment.get_ref() == &~"something"); } #[test] pub 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] pub 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] pub 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] pub fn test_no_scheme() { - assert get_scheme("noschemehere.html").is_err(); + fail_unless!(get_scheme("noschemehere.html").is_err()); } #[test] pub 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] pub fn test_full_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?s=v#something"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_userless_url_parse_and_format() { let url = ~"http://rust-lang.org/doc?s=v#something"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_queryless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc#something"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub 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 from_str(url).unwrap().to_str() == should_be; + fail_unless!(from_str(url).unwrap().to_str() == should_be); } #[test] pub fn test_fragmentless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org/doc?q=v"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_minimal_url_parse_and_format() { let url = ~"http://rust-lang.org/doc"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_scheme_host_only_url_parse_and_format() { let url = ~"http://rust-lang.org"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_pathless_url_parse_and_format() { let url = ~"http://user:pass@rust-lang.org?q=v#something"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_scheme_host_fragment_only_url_parse_and_format() { let url = ~"http://rust-lang.org#something"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub 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] pub fn test_url_without_authority() { let url = ~"mailto:test@email.com"; - assert from_str(url).unwrap().to_str() == url; + fail_unless!(from_str(url).unwrap().to_str() == url); } #[test] pub fn test_encode() { - assert encode("") == ~""; - assert encode("http://example.com") == ~"http://example.com"; - assert encode("foo bar% baz") == ~"foo%20bar%25%20baz"; - assert encode(" ") == ~"%20"; - assert encode("!") == ~"!"; - assert encode("\"") == ~"\""; - assert encode("#") == ~"#"; - assert encode("$") == ~"$"; - assert encode("%") == ~"%25"; - assert encode("&") == ~"&"; - assert encode("'") == ~"%27"; - assert encode("(") == ~"("; - assert encode(")") == ~")"; - assert encode("*") == ~"*"; - assert encode("+") == ~"+"; - assert encode(",") == ~","; - assert encode("/") == ~"/"; - assert encode(":") == ~":"; - assert encode(";") == ~";"; - assert encode("=") == ~"="; - assert encode("?") == ~"?"; - assert encode("@") == ~"@"; - assert encode("[") == ~"["; - assert encode("]") == ~"]"; + fail_unless!(encode("") == ~""); + fail_unless!(encode("http://example.com") == ~"http://example.com"); + fail_unless!(encode("foo bar% baz") == ~"foo%20bar%25%20baz"); + fail_unless!(encode(" ") == ~"%20"); + fail_unless!(encode("!") == ~"!"); + fail_unless!(encode("\"") == ~"\""); + fail_unless!(encode("#") == ~"#"); + fail_unless!(encode("$") == ~"$"); + fail_unless!(encode("%") == ~"%25"); + fail_unless!(encode("&") == ~"&"); + fail_unless!(encode("'") == ~"%27"); + fail_unless!(encode("(") == ~"("); + fail_unless!(encode(")") == ~")"); + fail_unless!(encode("*") == ~"*"); + fail_unless!(encode("+") == ~"+"); + fail_unless!(encode(",") == ~","); + fail_unless!(encode("/") == ~"/"); + fail_unless!(encode(":") == ~":"); + fail_unless!(encode(";") == ~";"); + fail_unless!(encode("=") == ~"="); + fail_unless!(encode("?") == ~"?"); + fail_unless!(encode("@") == ~"@"); + fail_unless!(encode("[") == ~"["); + fail_unless!(encode("]") == ~"]"); } #[test] pub fn test_encode_component() { - assert encode_component("") == ~""; - assert encode_component("http://example.com") == - ~"http%3A%2F%2Fexample.com"; - assert encode_component("foo bar% baz") == ~"foo%20bar%25%20baz"; - assert encode_component(" ") == ~"%20"; - assert encode_component("!") == ~"%21"; - assert encode_component("#") == ~"%23"; - assert encode_component("$") == ~"%24"; - assert encode_component("%") == ~"%25"; - assert encode_component("&") == ~"%26"; - assert encode_component("'") == ~"%27"; - assert encode_component("(") == ~"%28"; - assert encode_component(")") == ~"%29"; - assert encode_component("*") == ~"%2A"; - assert encode_component("+") == ~"%2B"; - assert encode_component(",") == ~"%2C"; - assert encode_component("/") == ~"%2F"; - assert encode_component(":") == ~"%3A"; - assert encode_component(";") == ~"%3B"; - assert encode_component("=") == ~"%3D"; - assert encode_component("?") == ~"%3F"; - assert encode_component("@") == ~"%40"; - assert encode_component("[") == ~"%5B"; - assert encode_component("]") == ~"%5D"; + fail_unless!(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"); + fail_unless!(encode_component(" ") == ~"%20"); + fail_unless!(encode_component("!") == ~"%21"); + fail_unless!(encode_component("#") == ~"%23"); + fail_unless!(encode_component("$") == ~"%24"); + fail_unless!(encode_component("%") == ~"%25"); + fail_unless!(encode_component("&") == ~"%26"); + fail_unless!(encode_component("'") == ~"%27"); + fail_unless!(encode_component("(") == ~"%28"); + fail_unless!(encode_component(")") == ~"%29"); + fail_unless!(encode_component("*") == ~"%2A"); + fail_unless!(encode_component("+") == ~"%2B"); + fail_unless!(encode_component(",") == ~"%2C"); + fail_unless!(encode_component("/") == ~"%2F"); + fail_unless!(encode_component(":") == ~"%3A"); + fail_unless!(encode_component(";") == ~"%3B"); + fail_unless!(encode_component("=") == ~"%3D"); + fail_unless!(encode_component("?") == ~"%3F"); + fail_unless!(encode_component("@") == ~"%40"); + fail_unless!(encode_component("[") == ~"%5B"); + fail_unless!(encode_component("]") == ~"%5D"); } #[test] pub fn test_decode() { - assert decode("") == ~""; - assert decode("abc/def 123") == ~"abc/def 123"; - assert decode("abc%2Fdef%20123") == ~"abc%2Fdef 123"; - assert decode("%20") == ~" "; - assert decode("%21") == ~"%21"; - assert decode("%22") == ~"%22"; - assert decode("%23") == ~"%23"; - assert decode("%24") == ~"%24"; - assert decode("%25") == ~"%"; - assert decode("%26") == ~"%26"; - assert decode("%27") == ~"'"; - assert decode("%28") == ~"%28"; - assert decode("%29") == ~"%29"; - assert decode("%2A") == ~"%2A"; - assert decode("%2B") == ~"%2B"; - assert decode("%2C") == ~"%2C"; - assert decode("%2F") == ~"%2F"; - assert decode("%3A") == ~"%3A"; - assert decode("%3B") == ~"%3B"; - assert decode("%3D") == ~"%3D"; - assert decode("%3F") == ~"%3F"; - assert decode("%40") == ~"%40"; - assert decode("%5B") == ~"%5B"; - assert decode("%5D") == ~"%5D"; + fail_unless!(decode("") == ~""); + fail_unless!(decode("abc/def 123") == ~"abc/def 123"); + fail_unless!(decode("abc%2Fdef%20123") == ~"abc%2Fdef 123"); + fail_unless!(decode("%20") == ~" "); + fail_unless!(decode("%21") == ~"%21"); + fail_unless!(decode("%22") == ~"%22"); + fail_unless!(decode("%23") == ~"%23"); + fail_unless!(decode("%24") == ~"%24"); + fail_unless!(decode("%25") == ~"%"); + fail_unless!(decode("%26") == ~"%26"); + fail_unless!(decode("%27") == ~"'"); + fail_unless!(decode("%28") == ~"%28"); + fail_unless!(decode("%29") == ~"%29"); + fail_unless!(decode("%2A") == ~"%2A"); + fail_unless!(decode("%2B") == ~"%2B"); + fail_unless!(decode("%2C") == ~"%2C"); + fail_unless!(decode("%2F") == ~"%2F"); + fail_unless!(decode("%3A") == ~"%3A"); + fail_unless!(decode("%3B") == ~"%3B"); + fail_unless!(decode("%3D") == ~"%3D"); + fail_unless!(decode("%3F") == ~"%3F"); + fail_unless!(decode("%40") == ~"%40"); + fail_unless!(decode("%5B") == ~"%5B"); + fail_unless!(decode("%5D") == ~"%5D"); } #[test] pub fn test_decode_component() { - assert decode_component("") == ~""; - assert decode_component("abc/def 123") == ~"abc/def 123"; - assert decode_component("abc%2Fdef%20123") == ~"abc/def 123"; - assert decode_component("%20") == ~" "; - assert decode_component("%21") == ~"!"; - assert decode_component("%22") == ~"\""; - assert decode_component("%23") == ~"#"; - assert decode_component("%24") == ~"$"; - assert decode_component("%25") == ~"%"; - assert decode_component("%26") == ~"&"; - assert decode_component("%27") == ~"'"; - assert decode_component("%28") == ~"("; - assert decode_component("%29") == ~")"; - assert decode_component("%2A") == ~"*"; - assert decode_component("%2B") == ~"+"; - assert decode_component("%2C") == ~","; - assert decode_component("%2F") == ~"/"; - assert decode_component("%3A") == ~":"; - assert decode_component("%3B") == ~";"; - assert decode_component("%3D") == ~"="; - assert decode_component("%3F") == ~"?"; - assert decode_component("%40") == ~"@"; - assert decode_component("%5B") == ~"["; - assert decode_component("%5D") == ~"]"; + fail_unless!(decode_component("") == ~""); + fail_unless!(decode_component("abc/def 123") == ~"abc/def 123"); + fail_unless!(decode_component("abc%2Fdef%20123") == ~"abc/def 123"); + fail_unless!(decode_component("%20") == ~" "); + fail_unless!(decode_component("%21") == ~"!"); + fail_unless!(decode_component("%22") == ~"\""); + fail_unless!(decode_component("%23") == ~"#"); + fail_unless!(decode_component("%24") == ~"$"); + fail_unless!(decode_component("%25") == ~"%"); + fail_unless!(decode_component("%26") == ~"&"); + fail_unless!(decode_component("%27") == ~"'"); + fail_unless!(decode_component("%28") == ~"("); + fail_unless!(decode_component("%29") == ~")"); + fail_unless!(decode_component("%2A") == ~"*"); + fail_unless!(decode_component("%2B") == ~"+"); + fail_unless!(decode_component("%2C") == ~","); + fail_unless!(decode_component("%2F") == ~"/"); + fail_unless!(decode_component("%3A") == ~":"); + fail_unless!(decode_component("%3B") == ~";"); + fail_unless!(decode_component("%3D") == ~"="); + fail_unless!(decode_component("%3F") == ~"?"); + fail_unless!(decode_component("%40") == ~"@"); + fail_unless!(decode_component("%5B") == ~"["); + fail_unless!(decode_component("%5D") == ~"]"); } #[test] pub fn test_encode_form_urlencoded() { let mut m = LinearMap::new(); - assert encode_form_urlencoded(&m) == ~""; + fail_unless!(encode_form_urlencoded(&m) == ~""); m.insert(~"", ~[]); m.insert(~"foo", ~[]); - assert encode_form_urlencoded(&m) == ~""; + fail_unless!(encode_form_urlencoded(&m) == ~""); let mut m = LinearMap::new(); m.insert(~"foo", ~[~"bar", ~"123"]); - assert encode_form_urlencoded(&m) == ~"foo=bar&foo=123"; + fail_unless!(encode_form_urlencoded(&m) == ~"foo=bar&foo=123"); let mut m = LinearMap::new(); m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]); - assert encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34"; + fail_unless!(encode_form_urlencoded(&m) == ~"foo+bar=abc&foo+bar=12+%3D+34"); } #[test] @@ -1073,13 +1073,13 @@ mod tests { // FIXME #4449: Commented out because this causes an ICE, but only // on FreeBSD /* - assert decode_form_urlencoded(~[]).len() == 0; + fail_unless!(decode_form_urlencoded(~[]).len() == 0); let s = str::to_bytes("a=1&foo+bar=abc&foo+bar=12+%3D+34"); let form = decode_form_urlencoded(s); - assert form.len() == 2; - assert form.get_ref(&~"a") == &~[~"1"]; - assert form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"]; + fail_unless!(form.len() == 2); + fail_unless!(form.get_ref(&~"a") == &~[~"1"]); + fail_unless!(form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"]); */ } } diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index eb5ad2b6d73..0f6434f1b2b 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -427,59 +427,59 @@ mod tests { debug!("uint -> uint"); let hm_uu: HashMap = HashMap::(); - assert (hm_uu.insert(10u, 12u)); - assert (hm_uu.insert(11u, 13u)); - assert (hm_uu.insert(12u, 14u)); - assert (hm_uu.get(&11) == 13u); - assert (hm_uu.get(&12) == 14u); - assert (hm_uu.get(&10) == 12u); - assert (!hm_uu.insert(12u, 14u)); - assert (hm_uu.get(&12) == 14u); - assert (!hm_uu.insert(12u, 12u)); - assert (hm_uu.get(&12) == 12u); + fail_unless!((hm_uu.insert(10u, 12u))); + fail_unless!((hm_uu.insert(11u, 13u))); + fail_unless!((hm_uu.insert(12u, 14u))); + fail_unless!((hm_uu.get(&11) == 13u)); + fail_unless!((hm_uu.get(&12) == 14u)); + fail_unless!((hm_uu.get(&10) == 12u)); + fail_unless!((!hm_uu.insert(12u, 14u))); + fail_unless!((hm_uu.get(&12) == 14u)); + fail_unless!((!hm_uu.insert(12u, 12u))); + fail_unless!((hm_uu.get(&12) == 12u)); let ten: ~str = ~"ten"; let eleven: ~str = ~"eleven"; let twelve: ~str = ~"twelve"; debug!("str -> uint"); let hm_su: HashMap<~str, uint> = HashMap::<~str, uint>(); - assert (hm_su.insert(~"ten", 12u)); - assert (hm_su.insert(eleven, 13u)); - assert (hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(&eleven) == 13u); - assert (hm_su.get(&~"eleven") == 13u); - assert (hm_su.get(&~"twelve") == 14u); - assert (hm_su.get(&~"ten") == 12u); - assert (!hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(&~"twelve") == 14u); - assert (!hm_su.insert(~"twelve", 12u)); - assert (hm_su.get(&~"twelve") == 12u); + fail_unless!((hm_su.insert(~"ten", 12u))); + fail_unless!((hm_su.insert(eleven, 13u))); + fail_unless!((hm_su.insert(~"twelve", 14u))); + fail_unless!((hm_su.get(&eleven) == 13u)); + fail_unless!((hm_su.get(&~"eleven") == 13u)); + fail_unless!((hm_su.get(&~"twelve") == 14u)); + fail_unless!((hm_su.get(&~"ten") == 12u)); + fail_unless!((!hm_su.insert(~"twelve", 14u))); + fail_unless!((hm_su.get(&~"twelve") == 14u)); + fail_unless!((!hm_su.insert(~"twelve", 12u))); + fail_unless!((hm_su.get(&~"twelve") == 12u)); debug!("uint -> str"); let hm_us: HashMap = HashMap::(); - assert (hm_us.insert(10u, ~"twelve")); - assert (hm_us.insert(11u, ~"thirteen")); - assert (hm_us.insert(12u, ~"fourteen")); - assert hm_us.get(&11) == ~"thirteen"; - assert hm_us.get(&12) == ~"fourteen"; - assert hm_us.get(&10) == ~"twelve"; - assert (!hm_us.insert(12u, ~"fourteen")); - assert hm_us.get(&12) == ~"fourteen"; - assert (!hm_us.insert(12u, ~"twelve")); - assert hm_us.get(&12) == ~"twelve"; + fail_unless!((hm_us.insert(10u, ~"twelve"))); + fail_unless!((hm_us.insert(11u, ~"thirteen"))); + fail_unless!((hm_us.insert(12u, ~"fourteen"))); + fail_unless!(hm_us.get(&11) == ~"thirteen"); + fail_unless!(hm_us.get(&12) == ~"fourteen"); + fail_unless!(hm_us.get(&10) == ~"twelve"); + fail_unless!((!hm_us.insert(12u, ~"fourteen"))); + fail_unless!(hm_us.get(&12) == ~"fourteen"); + fail_unless!((!hm_us.insert(12u, ~"twelve"))); + fail_unless!(hm_us.get(&12) == ~"twelve"); debug!("str -> str"); let hm_ss: HashMap<~str, ~str> = HashMap::<~str, ~str>(); - assert (hm_ss.insert(ten, ~"twelve")); - assert (hm_ss.insert(eleven, ~"thirteen")); - assert (hm_ss.insert(twelve, ~"fourteen")); - assert hm_ss.get(&~"eleven") == ~"thirteen"; - assert hm_ss.get(&~"twelve") == ~"fourteen"; - assert hm_ss.get(&~"ten") == ~"twelve"; - assert (!hm_ss.insert(~"twelve", ~"fourteen")); - assert hm_ss.get(&~"twelve") == ~"fourteen"; - assert (!hm_ss.insert(~"twelve", ~"twelve")); - assert hm_ss.get(&~"twelve") == ~"twelve"; + fail_unless!((hm_ss.insert(ten, ~"twelve"))); + fail_unless!((hm_ss.insert(eleven, ~"thirteen"))); + fail_unless!((hm_ss.insert(twelve, ~"fourteen"))); + fail_unless!(hm_ss.get(&~"eleven") == ~"thirteen"); + fail_unless!(hm_ss.get(&~"twelve") == ~"fourteen"); + fail_unless!(hm_ss.get(&~"ten") == ~"twelve"); + fail_unless!((!hm_ss.insert(~"twelve", ~"fourteen"))); + fail_unless!(hm_ss.get(&~"twelve") == ~"fourteen"); + fail_unless!((!hm_ss.insert(~"twelve", ~"twelve"))); + fail_unless!(hm_ss.get(&~"twelve") == ~"twelve"); debug!("*** finished test_simple"); } @@ -498,7 +498,7 @@ mod tests { HashMap::(); let mut i: uint = 0u; while i < num_to_insert { - assert (hm_uu.insert(i, i * i)); + fail_unless!((hm_uu.insert(i, i * i))); debug!("inserting %u -> %u", i, i*i); i += 1u; } @@ -506,16 +506,16 @@ mod tests { i = 0u; while i < num_to_insert { debug!("get(%u) = %u", i, hm_uu.get(&i)); - assert (hm_uu.get(&i) == i * i); + fail_unless!((hm_uu.get(&i) == i * i)); i += 1u; } - assert (hm_uu.insert(num_to_insert, 17u)); - assert (hm_uu.get(&num_to_insert) == 17u); + fail_unless!((hm_uu.insert(num_to_insert, 17u))); + fail_unless!((hm_uu.get(&num_to_insert) == 17u)); debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(%u) = %u", i, hm_uu.get(&i)); - assert (hm_uu.get(&i) == i * i); + fail_unless!((hm_uu.get(&i) == i * i)); i += 1u; } debug!("str -> str"); @@ -523,8 +523,8 @@ mod tests { HashMap::<~str, ~str>(); i = 0u; while i < num_to_insert { - assert hm_ss.insert(uint::to_str_radix(i, 2u), - uint::to_str_radix(i * i, 2u)); + fail_unless!(hm_ss.insert(uint::to_str_radix(i, 2u), + uint::to_str_radix(i * i, 2u))); debug!("inserting \"%s\" -> \"%s\"", uint::to_str_radix(i, 2u), uint::to_str_radix(i*i, 2u)); @@ -536,22 +536,22 @@ mod tests { debug!("get(\"%s\") = \"%s\"", uint::to_str_radix(i, 2u), hm_ss.get(&uint::to_str_radix(i, 2u))); - assert hm_ss.get(&uint::to_str_radix(i, 2u)) == - uint::to_str_radix(i * i, 2u); + fail_unless!(hm_ss.get(&uint::to_str_radix(i, 2u)) == + uint::to_str_radix(i * i, 2u)); i += 1u; } - assert (hm_ss.insert(uint::to_str_radix(num_to_insert, 2u), + fail_unless!(hm_ss.insert(uint::to_str_radix(num_to_insert, 2u), uint::to_str_radix(17u, 2u))); - assert hm_ss.get(&uint::to_str_radix(num_to_insert, 2u)) == - uint::to_str_radix(17u, 2u); + fail_unless!(hm_ss.get(&uint::to_str_radix(num_to_insert, 2u)) == + uint::to_str_radix(17u, 2u)); debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(\"%s\") = \"%s\"", uint::to_str_radix(i, 2u), hm_ss.get(&uint::to_str_radix(i, 2u))); - assert hm_ss.get(&uint::to_str_radix(i, 2u)) == - uint::to_str_radix(i * i, 2u); + fail_unless!(hm_ss.get(&uint::to_str_radix(i, 2u)) == + uint::to_str_radix(i * i, 2u)); i += 1u; } debug!("*** finished test_growth"); @@ -565,55 +565,55 @@ mod tests { HashMap::(); let mut i: uint = 0u; while i < num_to_insert { - assert (hm.insert(i, i * i)); + fail_unless!((hm.insert(i, i * i))); debug!("inserting %u -> %u", i, i*i); i += 1u; } - assert (hm.len() == num_to_insert); + fail_unless!((hm.len() == num_to_insert)); debug!("-----"); debug!("removing evens"); i = 0u; while i < num_to_insert { let v = hm.remove(&i); - assert v; + fail_unless!(v); i += 2u; } - assert (hm.len() == num_to_insert / 2u); + fail_unless!((hm.len() == num_to_insert / 2u)); debug!("-----"); i = 1u; while i < num_to_insert { debug!("get(%u) = %u", i, hm.get(&i)); - assert (hm.get(&i) == i * i); + fail_unless!((hm.get(&i) == i * i)); i += 2u; } debug!("-----"); i = 1u; while i < num_to_insert { debug!("get(%u) = %u", i, hm.get(&i)); - assert (hm.get(&i) == i * i); + fail_unless!((hm.get(&i) == i * i)); i += 2u; } debug!("-----"); i = 0u; while i < num_to_insert { - assert (hm.insert(i, i * i)); + fail_unless!((hm.insert(i, i * i))); debug!("inserting %u -> %u", i, i*i); i += 2u; } - assert (hm.len() == num_to_insert); + fail_unless!((hm.len() == num_to_insert)); debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(%u) = %u", i, hm.get(&i)); - assert (hm.get(&i) == i * i); + fail_unless!((hm.get(&i) == i * i)); i += 1u; } debug!("-----"); - assert (hm.len() == num_to_insert); + fail_unless!((hm.len() == num_to_insert)); i = 0u; while i < num_to_insert { debug!("get(%u) = %u", i, hm.get(&i)); - assert (hm.get(&i) == i * i); + fail_unless!((hm.get(&i) == i * i)); i += 1u; } debug!("*** finished test_removal"); @@ -623,18 +623,18 @@ mod tests { fn test_contains_key() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert (!map.contains_key(&key)); + fail_unless!((!map.contains_key(&key))); map.insert(key, ~"val"); - assert (map.contains_key(&key)); + fail_unless!((map.contains_key(&key))); } #[test] fn test_find() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert map.find(&key).is_none(); + fail_unless!(map.find(&key).is_none()); map.insert(key, ~"val"); - assert map.find(&key).get() == ~"val"; + fail_unless!(map.find(&key).get() == ~"val"); } #[test] @@ -642,11 +642,11 @@ mod tests { let key = ~"k"; let mut map = HashMap::<~str, ~str>(); map.insert(key, ~"val"); - assert (map.len() == 1); - assert (map.contains_key(&key)); + fail_unless!((map.len() == 1)); + fail_unless!((map.contains_key(&key))); map.clear(); - assert (map.len() == 0); - assert (!map.contains_key(&key)); + fail_unless!((map.len() == 0)); + fail_unless!((!map.contains_key(&key))); } #[test] @@ -656,10 +656,10 @@ mod tests { (~"b", 2), (~"c", 3) ]); - assert map.len() == 3u; - assert map.get(&~"a") == 1; - assert map.get(&~"b") == 2; - assert map.get(&~"c") == 3; + fail_unless!(map.len() == 3u); + fail_unless!(map.get(&~"a") == 1); + fail_unless!(map.get(&~"b") == 2); + fail_unless!(map.get(&~"c") == 3); } #[test] @@ -685,11 +685,11 @@ mod tests { map.update_with_key(~"cat", 2, addMoreToCount); // check the total counts - assert map.find(&~"cat").get() == 10; - assert map.find(&~"ferret").get() == 3; - assert map.find(&~"mongoose").get() == 1; + fail_unless!(map.find(&~"cat").get() == 10); + fail_unless!(map.find(&~"ferret").get() == 3); + fail_unless!(map.find(&~"mongoose").get() == 1); // sadly, no mythical animals were counted! - assert map.find(&~"unicorn").is_none(); + fail_unless!(map.find(&~"unicorn").is_none()); } } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index d65921f910c..a33effba8e0 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -68,7 +68,7 @@ fn map_slices( cast::reinterpret_cast(&slice); log(info, fmt!("slice: %?", (base, vec::len(slice), end - base))); - assert(vec::len(slice) == end - base); + fail_unless!((vec::len(slice) == end - base)); f(base, slice) } }; @@ -79,12 +79,12 @@ fn map_slices( log(info, ~"tasks spawned"); log(info, fmt!("num_tasks: %?", (num_tasks, futures.len()))); - assert(num_tasks == futures.len()); + fail_unless!((num_tasks == futures.len())); let r = do futures.map() |ys| { ys.get() }; - assert(r.len() == futures.len()); + fail_unless!((r.len() == futures.len())); r } } @@ -115,7 +115,7 @@ pub fn mapi( }); let r = vec::concat(slices); log(info, (r.len(), xs.len())); - assert(r.len() == xs.len()); + fail_unless!((r.len() == xs.len())); r } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 2a2c655cca9..676bc68e4e5 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -197,87 +197,87 @@ mod tests { let mut sorted = merge_sort(data, le); let mut heap = from_vec(data); while !heap.is_empty() { - assert heap.top() == sorted.last(); - assert heap.pop() == sorted.pop(); + fail_unless!(heap.top() == sorted.last()); + fail_unless!(heap.pop() == sorted.pop()); } } #[test] fn test_push() { let mut heap = from_vec(~[2, 4, 9]); - assert heap.len() == 3; - assert *heap.top() == 9; + fail_unless!(heap.len() == 3); + fail_unless!(*heap.top() == 9); heap.push(11); - assert heap.len() == 4; - assert *heap.top() == 11; + fail_unless!(heap.len() == 4); + fail_unless!(*heap.top() == 11); heap.push(5); - assert heap.len() == 5; - assert *heap.top() == 11; + fail_unless!(heap.len() == 5); + fail_unless!(*heap.top() == 11); heap.push(27); - assert heap.len() == 6; - assert *heap.top() == 27; + fail_unless!(heap.len() == 6); + fail_unless!(*heap.top() == 27); heap.push(3); - assert heap.len() == 7; - assert *heap.top() == 27; + fail_unless!(heap.len() == 7); + fail_unless!(*heap.top() == 27); heap.push(103); - assert heap.len() == 8; - assert *heap.top() == 103; + fail_unless!(heap.len() == 8); + fail_unless!(*heap.top() == 103); } #[test] fn test_push_unique() { let mut heap = from_vec(~[~2, ~4, ~9]); - assert heap.len() == 3; - assert *heap.top() == ~9; + fail_unless!(heap.len() == 3); + fail_unless!(*heap.top() == ~9); heap.push(~11); - assert heap.len() == 4; - assert *heap.top() == ~11; + fail_unless!(heap.len() == 4); + fail_unless!(*heap.top() == ~11); heap.push(~5); - assert heap.len() == 5; - assert *heap.top() == ~11; + fail_unless!(heap.len() == 5); + fail_unless!(*heap.top() == ~11); heap.push(~27); - assert heap.len() == 6; - assert *heap.top() == ~27; + fail_unless!(heap.len() == 6); + fail_unless!(*heap.top() == ~27); heap.push(~3); - assert heap.len() == 7; - assert *heap.top() == ~27; + fail_unless!(heap.len() == 7); + fail_unless!(*heap.top() == ~27); heap.push(~103); - assert heap.len() == 8; - assert *heap.top() == ~103; + fail_unless!(heap.len() == 8); + fail_unless!(*heap.top() == ~103); } #[test] fn test_push_pop() { let mut heap = from_vec(~[5, 5, 2, 1, 3]); - assert heap.len() == 5; - assert heap.push_pop(6) == 6; - assert heap.len() == 5; - assert heap.push_pop(0) == 5; - assert heap.len() == 5; - assert heap.push_pop(4) == 5; - assert heap.len() == 5; - assert heap.push_pop(1) == 4; - assert heap.len() == 5; + fail_unless!(heap.len() == 5); + fail_unless!(heap.push_pop(6) == 6); + fail_unless!(heap.len() == 5); + fail_unless!(heap.push_pop(0) == 5); + fail_unless!(heap.len() == 5); + fail_unless!(heap.push_pop(4) == 5); + fail_unless!(heap.len() == 5); + fail_unless!(heap.push_pop(1) == 4); + fail_unless!(heap.len() == 5); } #[test] fn test_replace() { let mut heap = from_vec(~[5, 5, 2, 1, 3]); - assert heap.len() == 5; - assert heap.replace(6) == 5; - assert heap.len() == 5; - assert heap.replace(0) == 6; - assert heap.len() == 5; - assert heap.replace(4) == 5; - assert heap.len() == 5; - assert heap.replace(1) == 4; - assert heap.len() == 5; + fail_unless!(heap.len() == 5); + fail_unless!(heap.replace(6) == 5); + fail_unless!(heap.len() == 5); + fail_unless!(heap.replace(0) == 6); + fail_unless!(heap.len() == 5); + fail_unless!(heap.replace(4) == 5); + fail_unless!(heap.len() == 5); + fail_unless!(heap.replace(1) == 4); + fail_unless!(heap.len() == 5); } fn check_to_vec(data: ~[int]) { let heap = from_vec(data); - assert merge_sort(heap.to_vec(), le) == merge_sort(data, le); - assert heap.to_sorted_vec() == merge_sort(data, le); + fail_unless!(merge_sort(heap.to_vec(), le) == merge_sort(data, le)); + fail_unless!(heap.to_sorted_vec() == merge_sort(data, le)); } #[test] @@ -305,7 +305,7 @@ mod tests { #[test] fn test_empty_maybe_pop() { let mut heap = new::(); - assert heap.maybe_pop().is_none(); + fail_unless!(heap.maybe_pop().is_none()); } #[test] @@ -316,7 +316,7 @@ mod tests { #[test] fn test_empty_maybe_top() { let empty = new::(); - assert empty.maybe_top().is_none(); + fail_unless!(empty.maybe_top().is_none()); } #[test] diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index ba107b340bc..d511ac9744e 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -704,7 +704,7 @@ pub mod node { */ pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, char_len: uint) -> @Node { - assert(byte_start + byte_len <= str::len(*str)); + fail_unless!((byte_start + byte_len <= str::len(*str))); let candidate = @Leaf(Leaf { byte_offset: byte_start, byte_len: byte_len, @@ -1313,8 +1313,8 @@ mod tests { #[test] fn trivial() { - assert char_len(empty()) == 0u; - assert byte_len(empty()) == 0u; + fail_unless!(char_len(empty()) == 0u); + fail_unless!(byte_len(empty()) == 0u); } #[test] @@ -1322,8 +1322,8 @@ mod tests { let sample = @~"0123456789ABCDE"; let r = of_str(sample); - assert char_len(r) == str::char_len(*sample); - assert rope_to_string(r) == *sample; + fail_unless!(char_len(r) == str::char_len(*sample)); + fail_unless!(rope_to_string(r) == *sample); } #[test] @@ -1338,8 +1338,8 @@ mod tests { } let sample = @*buf; let r = of_str(sample); - assert char_len(r) == str::char_len(*sample); - assert rope_to_string(r) == *sample; + fail_unless!(char_len(r) == str::char_len(*sample)); + fail_unless!(rope_to_string(r) == *sample); let mut string_iter = 0u; let string_len = str::len(*sample); @@ -1359,7 +1359,7 @@ mod tests { } } - assert equal; + fail_unless!(equal); } #[test] @@ -1384,7 +1384,7 @@ mod tests { } } - assert len == str::char_len(*sample); + fail_unless!(len == str::char_len(*sample)); } #[test] @@ -1405,11 +1405,11 @@ mod tests { while i < 8 { r2 = append_rope(r2, r2); i+= 1;} - assert eq(r1, r2); + fail_unless!(eq(r1, r2)); let r3 = bal(r2); - assert char_len(r1) == char_len(r3); + fail_unless!(char_len(r1) == char_len(r3)); - assert eq(r1, r3); + fail_unless!(eq(r1, r3)); } #[test] @@ -1426,23 +1426,23 @@ mod tests { for uint::range(0u, char_len(r)) |i| { r2 = append_char(r2, char_at(r, i)); } - assert eq(r, r2); + fail_unless!(eq(r, r2)); let mut r3 = empty(); for uint::range(0u, char_len(r)) |i| { r3 = prepend_char(r3, char_at(r, char_len(r) - i - 1u)); } - assert eq(r, r3); + fail_unless!(eq(r, r3)); //Additional sanity checks let balr = bal(r); let bal2 = bal(r2); let bal3 = bal(r3); - assert eq(r, balr); - assert eq(r, bal2); - assert eq(r, bal3); - assert eq(r2, r3); - assert eq(bal2, bal3); + fail_unless!(eq(r, balr)); + fail_unless!(eq(r, bal2)); + fail_unless!(eq(r, bal3)); + fail_unless!(eq(r2, r3)); + fail_unless!(eq(bal2, bal3)); } #[test] @@ -1457,6 +1457,6 @@ mod tests { //Same rope, obtained with rope::concat let r2 = concat(vec::from_elem(10u, chunk)); - assert eq(r, r2); + fail_unless!(eq(r, r2)); } } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 7c7f3390f2e..bf4091e1e90 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -240,74 +240,74 @@ pub fn parse(s: &str) -> Option { #[test] fn test_parse() { - assert parse("") == None; - assert parse(" ") == None; - assert parse("1") == None; - assert parse("1.2") == None; - assert parse("1.2") == None; - assert parse("1") == None; - assert parse("1.2") == None; - assert parse("1.2.3-") == None; - assert parse("a.b.c") == None; - assert parse("1.2.3 abc") == None; + fail_unless!(parse("") == None); + fail_unless!(parse(" ") == None); + fail_unless!(parse("1") == None); + fail_unless!(parse("1.2") == None); + fail_unless!(parse("1.2") == None); + fail_unless!(parse("1") == None); + fail_unless!(parse("1.2") == None); + fail_unless!(parse("1.2.3-") == None); + fail_unless!(parse("a.b.c") == None); + fail_unless!(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, @@ -315,60 +315,60 @@ fn test_parse() { build: ~[AlphaNumeric(~"build5"), Numeric(7), AlphaNumeric(~"3aedf")] - }); + })); } #[test] fn test_eq() { - assert parse("1.2.3") == parse("1.2.3"); - assert parse("1.2.3-alpha1") == parse("1.2.3-alpha1"); + fail_unless!(parse("1.2.3") == parse("1.2.3")); + fail_unless!(parse("1.2.3-alpha1") == parse("1.2.3-alpha1")); } #[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"); + 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")); } #[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")); + 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"))); } #[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"); + 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")); } #[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")); + 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"))); } #[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"); + 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")); } #[test] @@ -389,7 +389,7 @@ fn test_spec_order() { while i < vs.len() { let a = parse(vs[i-1]).get(); let b = parse(vs[i]).get(); - assert a < b; + fail_unless!(a < b); i += 1; } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index e8c1413e90a..b1ef0233d97 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -74,7 +74,7 @@ pub fn sha1() -> @Sha1 { work_buf: @mut ~[u32]}; fn add_input(st: &mut Sha1State, msg: &[const u8]) { - assert (!st.computed); + fail_unless!((!st.computed)); for vec::each_const(msg) |element| { st.msg_block[st.msg_block_idx] = *element; st.msg_block_idx += 1u; @@ -90,8 +90,8 @@ pub fn sha1() -> @Sha1 { } } fn process_msg_block(st: &mut Sha1State) { - assert (vec::len(st.h) == digest_buf_len); - assert (vec::len(*st.work_buf) == work_buf_len); + fail_unless!((vec::len(st.h) == digest_buf_len)); + fail_unless!((vec::len(*st.work_buf) == work_buf_len)); let mut t: int; // Loop counter let mut w = st.work_buf; @@ -192,7 +192,7 @@ pub fn sha1() -> @Sha1 { * can be assumed that the message digest has been computed. */ fn pad_msg(st: &mut Sha1State) { - assert (vec::len((*st).msg_block) == msg_block_len); + fail_unless!((vec::len((*st).msg_block) == msg_block_len)); /* * Check to see if the current message block is too small to hold @@ -230,7 +230,7 @@ pub fn sha1() -> @Sha1 { impl Sha1 for Sha1State { fn reset(&mut self) { - assert (vec::len(self.h) == digest_buf_len); + fail_unless!((vec::len(self.h) == digest_buf_len)); self.len_low = 0u32; self.len_high = 0u32; self.msg_block_idx = 0u; @@ -366,13 +366,13 @@ mod tests { ]; let tests = fips_180_1_tests + wikipedia_tests; fn check_vec_eq(v0: ~[u8], v1: ~[u8]) { - assert (vec::len::(v0) == vec::len::(v1)); + fail_unless!((vec::len::(v0) == vec::len::(v1))); let len = vec::len::(v0); let mut i = 0u; while i < len { let a = v0[i]; let b = v1[i]; - assert (a == b); + fail_unless!((a == b)); i += 1u; } } @@ -385,8 +385,8 @@ mod tests { check_vec_eq(t.output, out); let out_str = sh.result_str(); - assert(out_str.len() == 40); - assert(out_str == t.output_str); + fail_unless!((out_str.len() == 40)); + fail_unless!((out_str == t.output_str)); sh.reset(); } @@ -406,8 +406,8 @@ mod tests { check_vec_eq(t.output, out); let out_str = sh.result_str(); - assert(out_str.len() == 40); - assert(out_str == t.output_str); + fail_unless!((out_str.len() == 40)); + fail_unless!((out_str == t.output_str)); sh.reset(); } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index aad8fab834f..84600ac74ee 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -153,30 +153,30 @@ mod tests { #[test] fn test_len() { let mut map = SmallIntMap::new(); - assert map.len() == 0; - assert map.is_empty(); - assert map.insert(5, 20); - assert map.len() == 1; - assert !map.is_empty(); - assert map.insert(11, 12); - assert map.len() == 2; - assert !map.is_empty(); - assert map.insert(14, 22); - assert map.len() == 3; - assert !map.is_empty(); + fail_unless!(map.len() == 0); + fail_unless!(map.is_empty()); + fail_unless!(map.insert(5, 20)); + fail_unless!(map.len() == 1); + fail_unless!(!map.is_empty()); + fail_unless!(map.insert(11, 12)); + fail_unless!(map.len() == 2); + fail_unless!(!map.is_empty()); + fail_unless!(map.insert(14, 22)); + fail_unless!(map.len() == 3); + 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] @@ -201,11 +201,11 @@ mod tests { map.update_with_key(3, 2, addMoreToCount); // check the total counts - assert map.find(&3).get() == &10; - assert map.find(&5).get() == &3; - assert map.find(&9).get() == &1; + fail_unless!(map.find(&3).get() == &10); + fail_unless!(map.find(&5).get() == &3); + fail_unless!(map.find(&9).get() == &1); // sadly, no sevens were counted - assert map.find(&7).is_none(); + fail_unless!(map.find(&7).is_none()); } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 5c037b5bac5..37be1c86e91 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -219,7 +219,7 @@ pub fn tim_sort(array: &mut [T]) { fn binarysort(array: &mut [T], start: uint) { let size = array.len(); let mut start = start; - assert start <= size; + fail_unless!(start <= size); if start == 0 { start += 1; } @@ -227,7 +227,7 @@ fn binarysort(array: &mut [T], start: uint) { let pivot = array[start]; let mut left = 0; let mut right = start; - assert left <= right; + fail_unless!(left <= right); while left < right { let mid = (left + right) >> 1; @@ -237,7 +237,7 @@ fn binarysort(array: &mut [T], start: uint) { left = mid+1; } } - assert left == right; + fail_unless!(left == right); let mut n = start-left; copy_vec(array, left+1, array, left, n); @@ -268,7 +268,7 @@ pure fn min_run_length(n: uint) -> uint { fn count_run_ascending(array: &mut [T]) -> uint { let size = array.len(); - assert size > 0; + fail_unless!(size > 0); if size == 1 { return 1; } let mut run = 2; @@ -289,7 +289,7 @@ fn count_run_ascending(array: &mut [T]) -> uint { pure fn gallop_left(key: &const T, array: &[const T], hint: uint) -> uint { let size = array.len(); - assert size != 0 && hint < size; + fail_unless!(size != 0 && hint < size); let mut last_ofs = 0; let mut ofs = 1; @@ -320,7 +320,7 @@ pure fn gallop_left(key: &const T, array: &[const T], last_ofs = hint - ofs; ofs = hint - tmp; } - assert (last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size; + fail_unless!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); last_ofs += 1; while last_ofs < ofs { @@ -331,14 +331,14 @@ pure fn gallop_left(key: &const T, array: &[const T], ofs = m; } } - assert last_ofs == ofs; + fail_unless!(last_ofs == ofs); return ofs; } pure fn gallop_right(key: &const T, array: &[const T], hint: uint) -> uint { let size = array.len(); - assert size != 0 && hint < size; + fail_unless!(size != 0 && hint < size); let mut last_ofs = 0; let mut ofs = 1; @@ -370,7 +370,7 @@ pure fn gallop_right(key: &const T, array: &[const T], ofs = hint - tmp; } - assert (last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size; + fail_unless!((last_ofs < ofs || last_ofs+1 < ofs+1) && ofs <= size); last_ofs += 1; while last_ofs < ofs { @@ -382,7 +382,7 @@ pure fn gallop_right(key: &const T, array: &[const T], ofs = m; } } - assert last_ofs == ofs; + fail_unless!(last_ofs == ofs); return ofs; } @@ -412,8 +412,8 @@ pub impl MergeState { fn merge_at(&self, n: uint, array: &mut [T]) { let mut size = self.runs.len(); - assert size >= 2; - assert n == size-2 || n == size-3; + fail_unless!(size >= 2); + fail_unless!(n == size-2 || n == size-3); do self.runs.borrow_mut |arr| { @@ -422,8 +422,8 @@ pub impl MergeState { let b2 = arr[n+1].base; let l2 = arr[n+1].len; - assert l1 > 0 && l2 > 0; - assert b1 + l1 == b2; + fail_unless!(l1 > 0 && l2 > 0); + fail_unless!(b1 + l1 == b2); arr[n].len = l1 + l2; if n == size-3 { @@ -453,7 +453,7 @@ pub impl MergeState { fn merge_lo(&self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { - assert len1 != 0 && len2 != 0 && base1+len1 == base2; + fail_unless!(len1 != 0 && len2 != 0 && base1+len1 == base2); let mut tmp = vec::slice(array, base1, base1+len1).to_vec(); @@ -483,7 +483,7 @@ pub impl MergeState { let mut break_outer = false; loop { - assert len1 > 1 && len2 != 0; + fail_unless!(len1 > 1 && len2 != 0); if array[c2] < tmp[c1] { array[dest] <-> array[c2]; dest += 1; c2 += 1; len2 -= 1; @@ -507,7 +507,7 @@ pub impl MergeState { // Start to gallop loop { - assert len1 > 1 && len2 != 0; + fail_unless!(len1 > 1 && len2 != 0); let tmp_view = vec::const_slice(tmp, c1, c1+len1); count1 = gallop_right(&const array[c2], tmp_view, 0); @@ -542,21 +542,21 @@ pub impl MergeState { self.min_gallop = if min_gallop < 1 { 1 } else { min_gallop }; if len1 == 1 { - assert len2 > 0; + fail_unless!(len2 > 0); copy_vec(array, dest, array, c2, len2); array[dest+len2] <-> tmp[c1]; } else if len1 == 0 { fail!(~"Comparison violates its contract!"); } else { - assert len2 == 0; - assert len1 > 1; + fail_unless!(len2 == 0); + fail_unless!(len1 > 1); copy_vec(array, dest, tmp, c1, len1); } } fn merge_hi(&self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { - assert len1 != 1 && len2 != 0 && base1 + len1 == base2; + fail_unless!(len1 != 1 && len2 != 0 && base1 + len1 == base2); let mut tmp = vec::slice(array, base2, base2+len2).to_vec(); @@ -588,7 +588,7 @@ pub impl MergeState { let mut break_outer = false; loop { - assert len1 != 0 && len2 > 1; + fail_unless!(len1 != 0 && len2 > 1); if tmp[c2] < array[c1] { array[dest] <-> array[c1]; dest -= 1; c1 -= 1; len1 -= 1; @@ -612,7 +612,7 @@ pub impl MergeState { // Start to gallop loop { - assert len2 > 1 && len1 != 0; + fail_unless!(len2 > 1 && len1 != 0); let tmp_view = vec::mut_slice(array, base1, base1+len1); count1 = len1 - gallop_right( @@ -658,7 +658,7 @@ pub impl MergeState { self.min_gallop = if min_gallop < 1 { 1 } else { min_gallop }; if len2 == 1 { - assert len1 > 0; + fail_unless!(len1 > 0); dest -= len1; c1 -= len1; copy_vec(array, dest+1, array, c1+1, len1); @@ -666,8 +666,8 @@ pub impl MergeState { } else if len2 == 0 { fail!(~"Comparison violates its contract!"); } else { - assert len1 == 0; - assert len2 != 0; + fail_unless!(len1 == 0); + fail_unless!(len2 != 0); copy_vec(array, dest-(len2-1), tmp, 0, len2); } } @@ -708,7 +708,7 @@ pub impl MergeState { #[inline(always)] fn copy_vec(dest: &mut [T], s1: uint, from: &[const T], s2: uint, len: uint) { - assert s1+len <= dest.len() && s2+len <= from.len(); + fail_unless!(s1+len <= dest.len() && s2+len <= from.len()); let slice = vec::slice(from, s2, s2+len).to_vec(); for slice.eachi |i, v| { @@ -730,7 +730,7 @@ mod test_qsort3 { let mut i = 0; while i < len { log(debug, v2[i]); - assert (v2[i] == v1[i]); + fail_unless!((v2[i] == v1[i])); i += 1; } } @@ -777,7 +777,7 @@ mod test_qsort { let mut i = 0u; while i < len { log(debug, v2[i]); - assert (v2[i] == v1[i]); + fail_unless!((v2[i] == v1[i])); i += 1; } } @@ -822,7 +822,7 @@ mod test_qsort { for vec::each(pairs) |p| { let (a, b) = *p; debug!("%d %d", a, b); - assert (a == b); + fail_unless!((a == b)); } } } @@ -843,7 +843,7 @@ mod tests { let mut i = 0u; while i < len { log(debug, v3[i]); - assert (v3[i] == v2[i]); + fail_unless!((v3[i] == v2[i])); i += 1; } } @@ -870,7 +870,7 @@ mod tests { pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } let mut v1 = ~[3, 2, 1]; let v2 = merge_sort(v1, le); - assert v2 == ~[1, 2, 3]; + fail_unless!(v2 == ~[1, 2, 3]); } #[test] @@ -891,7 +891,7 @@ mod tests { let names2 = ~["Alex Andy", "Jack Brown", "joe bob", "Joe Bob", "JOE Bob", "JOE BOB", "Sally Mae"]; let names3 = merge_sort(names1, ile); - assert names3 == names2; + fail_unless!(names3 == names2); } } @@ -927,7 +927,7 @@ mod test_tim_sort { let mut i = 0u; while i < len { log(debug, v2[i]); - assert (v2[i] == v1[i]); + fail_unless!((v2[i] == v1[i])); i += 1u; } } diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs index b786699351e..2a62ebadd2b 100644 --- a/src/libstd/stats.rs +++ b/src/libstd/stats.rs @@ -36,22 +36,22 @@ impl Stats for &self/[f64] { } fn min(self) -> f64 { - assert self.len() != 0; + fail_unless!(self.len() != 0); vec::foldl(self[0], self, |p,q| cmp::min(p, *q)) } fn max(self) -> f64 { - assert self.len() != 0; + fail_unless!(self.len() != 0); vec::foldl(self[0], self, |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) } fn median(self) -> f64 { - assert self.len() != 0; + fail_unless!(self.len() != 0); let mut tmp = vec::from_slice(self); sort::tim_sort(tmp); if tmp.len() & 1 == 0 { diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 6c8d719e5f5..d143c665d83 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -588,7 +588,7 @@ pub impl RWlock { do task::unkillable { let mut first_reader = false; do self.state.with |state| { - assert !state.read_mode; + fail_unless!(!state.read_mode); state.read_mode = true; first_reader = (state.read_count == 0); state.read_count += 1; @@ -618,8 +618,8 @@ impl Drop for RWlockReleaseRead/&self { do task::unkillable { let mut last_reader = false; do self.lock.state.with |state| { - assert state.read_mode; - assert state.read_count > 0; + fail_unless!(state.read_mode); + fail_unless!(state.read_count > 0); state.read_count -= 1; if state.read_count == 0 { last_reader = true; @@ -653,7 +653,7 @@ impl Drop for RWlockReleaseDowngrade/&self { let mut writer_or_last_reader = false; do self.lock.state.with |state| { if state.read_mode { - assert state.read_count > 0; + fail_unless!(state.read_count > 0); state.read_count -= 1; if state.read_count == 0 { // Case 1: Writer downgraded & was the last reader @@ -839,7 +839,7 @@ mod tests { access_shared(sharedstate, m, 10); let _ = p.recv(); - assert *sharedstate == 20; + fail_unless!(*sharedstate == 20); fn access_shared(sharedstate: &mut int, m: &Mutex, n: uint) { for n.times { @@ -861,7 +861,7 @@ mod tests { do task::spawn || { do m2.lock_cond |cond| { let woken = cond.signal(); - assert woken; + fail_unless!(woken); } } cond.wait(); @@ -879,7 +879,7 @@ mod tests { let _ = port.recv(); // Wait until child gets in the mutex do m.lock_cond |cond| { let woken = cond.signal(); - assert woken; + fail_unless!(woken); } let _ = port.recv(); // Wait until child wakes up } @@ -905,7 +905,7 @@ mod tests { for ports.each |port| { let _ = port.recv(); } do m.lock_cond |cond| { let num_woken = cond.broadcast(); - assert num_woken == num_waiters; + fail_unless!(num_woken == num_waiters); } // wait until all children wake up for ports.each |port| { let _ = port.recv(); } @@ -926,7 +926,7 @@ mod tests { do m.lock_cond |_x| { } }; do m2.lock_cond |cond| { - assert !cond.signal(); + fail_unless!(!cond.signal()); } } #[test] #[ignore(cfg(windows))] @@ -940,7 +940,7 @@ mod tests { fail!(); } }; - assert result.is_err(); + fail_unless!(result.is_err()); // child task must have finished by the time try returns do m.lock { } } @@ -963,11 +963,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 do m.lock_cond |cond| { let woken = cond.signal(); - assert !woken; + fail_unless!(!woken); } } #[test] #[ignore(cfg(windows))] @@ -1000,12 +1000,12 @@ 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 for vec::each(p.recv()) |p| { p.recv(); } // wait on all its siblings do m.lock_cond |cond| { let woken = cond.broadcast(); - assert woken == 0; + fail_unless!(woken == 0); } struct SendOnFailure { c: comm::Chan<()>, @@ -1056,7 +1056,7 @@ mod tests { } } }; - assert result.is_err(); + fail_unless!(result.is_err()); } #[test] #[ignore(cfg(windows))] pub fn test_mutex_no_condvars() { @@ -1064,17 +1064,17 @@ mod tests { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.wait(); } }; - assert result.is_err(); + fail_unless!(result.is_err()); let result = do task::try { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.signal(); } }; - assert result.is_err(); + fail_unless!(result.is_err()); let result = do task::try { let m = ~mutex_with_condvars(0); do m.lock_cond |cond| { cond.broadcast(); } }; - assert result.is_err(); + fail_unless!(result.is_err()); } /************************************************************************ * Reader/writer lock tests @@ -1116,7 +1116,7 @@ mod tests { access_shared(sharedstate, x, mode2, 10); let _ = p.recv(); - assert *sharedstate == 20; + fail_unless!(*sharedstate == 20); fn access_shared(sharedstate: &mut int, x: &RWlock, mode: RWlockMode, n: uint) { @@ -1210,7 +1210,7 @@ mod tests { do task::spawn || { do x2.write_cond |cond| { let woken = cond.signal(); - assert woken; + fail_unless!(woken); } } cond.wait(); @@ -1229,7 +1229,7 @@ mod tests { do x.read { } // Must be able to get in as a reader in the meantime do 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 do x.read { } // Just for good measure @@ -1268,7 +1268,7 @@ mod tests { for ports.each |port| { let _ = port.recv(); } do lock_cond(x, dg2) |cond| { let num_woken = cond.broadcast(); - assert num_woken == num_waiters; + fail_unless!(num_woken == num_waiters); } // wait until all children wake up for ports.each |port| { let _ = port.recv(); } @@ -1295,7 +1295,7 @@ mod tests { fail!(); } }; - assert result.is_err(); + fail_unless!(result.is_err()); // child task must have finished by the time try returns do lock_rwlock_in_mode(x, mode2) { } } diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index c3b4435bc8f..09cab72ab21 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -45,7 +45,7 @@ pub impl TaskPool { static fn new(n_tasks: uint, opt_sched_mode: Option, init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool { - assert n_tasks >= 1; + fail_unless!(n_tasks >= 1); let channels = do vec::from_fn(n_tasks) |i| { let (port, chan) = comm::stream::>(); diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 1e95f1aafa5..cd023962c88 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -29,5 +29,5 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { fn test_mkdtemp() { let p = mkdtemp(&Path("."), "foobar").unwrap(); os::remove_dir(&p); - assert str::ends_with(p.to_str(), "foobar"); + fail_unless!(str::ends_with(p.to_str(), "foobar")); } diff --git a/src/libstd/term.rs b/src/libstd/term.rs index af826af9397..fb63755a572 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -60,7 +60,7 @@ pub fn color_supported() -> bool { } pub fn set_color(writer: io::Writer, first_char: u8, color: u8) { - assert (color < 16u8); + fail_unless!((color < 16u8)); esc(writer); let mut color = color; if color >= 8u8 { writer.write(~['1' as u8, ';' as u8]); color -= 8u8; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 3d2d5a0b371..b43389b9da2 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -283,8 +283,8 @@ pub fn run_tests_console(opts: &TestOpts, run_tests(opts, tests, |x| callback(&x, st)); - assert (st.passed + st.failed + - st.ignored + st.benchmarked == st.total); + fail_unless!(st.passed + st.failed + + st.ignored + st.benchmarked == st.total); let success = st.failed == 0u; if !success { @@ -397,7 +397,7 @@ fn should_sort_failures_before_printing_them() { let apos = str::find_str(s, ~"a").get(); let bpos = str::find_str(s, ~"b").get(); - assert apos < bpos; + fail_unless!(apos < bpos); } fn use_color() -> bool { return get_concurrency() == 1; } @@ -791,7 +791,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - assert res != TrOk; + fail_unless!(res != TrOk); } #[test] @@ -809,7 +809,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - assert res == TrIgnored; + fail_unless!(res == TrIgnored); } #[test] @@ -828,7 +828,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - assert res == TrOk; + fail_unless!(res == TrOk); } #[test] @@ -846,7 +846,7 @@ mod tests { let ch = SharedChan(ch); run_test(false, desc, ch); let (_, res) = p.recv(); - assert res == TrFailed; + fail_unless!(res == TrFailed); } #[test] @@ -856,7 +856,7 @@ mod tests { either::Left(copy o) => o, _ => fail!(~"Malformed arg in first_free_arg_should_be_a_filter") }; - assert ~"filter" == opts.filter.get(); + fail_unless!(~"filter" == opts.filter.get()); } #[test] @@ -866,7 +866,7 @@ mod tests { either::Left(copy o) => o, _ => fail!(~"Malformed arg in parse_ignored_flag") }; - assert (opts.run_ignored); + fail_unless!((opts.run_ignored)); } #[test] @@ -906,9 +906,9 @@ mod tests { ]; let filtered = filter_tests(&opts, tests); - assert (vec::len(filtered) == 1); - assert (filtered[0].desc.name.to_str() == ~"1"); - assert (filtered[0].desc.ignore == false); + fail_unless!((vec::len(filtered) == 1)); + fail_unless!((filtered[0].desc.name.to_str() == ~"1")); + fail_unless!((filtered[0].desc.ignore == false)); } #[test] @@ -962,7 +962,7 @@ mod tests { for vec::each(pairs) |p| { match *p { - (ref a, ref b) => { assert (*a == b.desc.name.to_str()); } + (ref a, ref b) => { fail_unless!((*a == b.desc.name.to_str())); } } } } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 525f9284cc3..d008ad15006 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -56,7 +56,7 @@ pub struct Timespec { sec: i64, nsec: i32 } */ pub impl Timespec { static pure 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 } } } @@ -910,17 +910,17 @@ 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); } } @@ -929,16 +929,16 @@ mod tests { let ns1 = precise_time_ns(); debug!("s0=%s sec", float::to_str_digits(s0, 9u)); - assert s0 > 0.; + fail_unless!(s0 > 0.); let ns0 = (s0 * 1000000000.) as u64; debug!("ns0=%? ns", ns0); debug!("ns1=%? ns", ns0); - assert ns1 >= ns0; + fail_unless!(ns1 >= ns0); let ns2 = precise_time_ns(); debug!("ns2=%? ns", ns0); - assert ns2 >= ns1; + fail_unless!(ns2 >= ns1); } pub fn test_at_utc() { @@ -948,18 +948,18 @@ mod tests { let time = ::time::Timespec::new(1234567890, 54321); let utc = at_utc(time); - assert utc.tm_sec == 30_i32; - assert utc.tm_min == 31_i32; - assert utc.tm_hour == 23_i32; - assert utc.tm_mday == 13_i32; - assert utc.tm_mon == 1_i32; - assert utc.tm_year == 109_i32; - assert utc.tm_wday == 5_i32; - assert utc.tm_yday == 43_i32; - assert utc.tm_isdst == 0_i32; - assert utc.tm_gmtoff == 0_i32; - assert utc.tm_zone == ~"UTC"; - assert utc.tm_nsec == 54321_i32; + fail_unless!(utc.tm_sec == 30_i32); + fail_unless!(utc.tm_min == 31_i32); + fail_unless!(utc.tm_hour == 23_i32); + fail_unless!(utc.tm_mday == 13_i32); + fail_unless!(utc.tm_mon == 1_i32); + fail_unless!(utc.tm_year == 109_i32); + fail_unless!(utc.tm_wday == 5_i32); + fail_unless!(utc.tm_yday == 43_i32); + fail_unless!(utc.tm_isdst == 0_i32); + fail_unless!(utc.tm_gmtoff == 0_i32); + fail_unless!(utc.tm_zone == ~"UTC"); + fail_unless!(utc.tm_nsec == 54321_i32); } pub fn test_at() { @@ -971,23 +971,23 @@ mod tests { error!("time_at: %?", local); - assert local.tm_sec == 30_i32; - assert local.tm_min == 31_i32; - assert local.tm_hour == 15_i32; - assert local.tm_mday == 13_i32; - assert local.tm_mon == 1_i32; - assert local.tm_year == 109_i32; - assert local.tm_wday == 5_i32; - assert local.tm_yday == 43_i32; - assert local.tm_isdst == 0_i32; - assert local.tm_gmtoff == -28800_i32; + fail_unless!(local.tm_sec == 30_i32); + fail_unless!(local.tm_min == 31_i32); + fail_unless!(local.tm_hour == 15_i32); + fail_unless!(local.tm_mday == 13_i32); + fail_unless!(local.tm_mon == 1_i32); + fail_unless!(local.tm_year == 109_i32); + fail_unless!(local.tm_wday == 5_i32); + fail_unless!(local.tm_yday == 43_i32); + fail_unless!(local.tm_isdst == 0_i32); + fail_unless!(local.tm_gmtoff == -28800_i32); // 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 local.tm_nsec == 54321_i32; + fail_unless!(local.tm_nsec == 54321_i32); } pub fn test_to_timespec() { @@ -997,8 +997,8 @@ mod tests { let time = ::time::Timespec::new(1234567890, 54321); let utc = at_utc(time); - assert utc.to_timespec() == time; - assert utc.to_local().to_timespec() == time; + fail_unless!(utc.to_timespec() == time); + fail_unless!(utc.to_local().to_timespec() == time); } pub fn test_conversions() { @@ -1009,12 +1009,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); } pub fn test_strptime() { @@ -1023,41 +1023,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 %Y"; - assert strptime(~"", format) == Err(~"Invalid time"); - assert strptime(~"Fri Feb 13 15:31:30", format) - == Err(~"Invalid time"); + fail_unless!(strptime(~"", format) == Err(~"Invalid time")); + fail_unless!(strptime(~"Fri Feb 13 15:31:30", format) + == Err(~"Invalid time")); match strptime(~"Fri Feb 13 15:31:30 2009", format) { Err(copy 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 == 0_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 == 0_i32); } } @@ -1077,7 +1077,7 @@ mod tests { ~"Friday", ~"Saturday" ]) |day| { - assert test(*day, ~"%A"); + fail_unless!(test(*day, ~"%A")); } for vec::each([ @@ -1089,7 +1089,7 @@ mod tests { ~"Fri", ~"Sat" ]) |day| { - assert test(*day, ~"%a"); + fail_unless!(test(*day, ~"%a")); } for vec::each([ @@ -1106,7 +1106,7 @@ mod tests { ~"November", ~"December" ]) |day| { - assert test(*day, ~"%B"); + fail_unless!(test(*day, ~"%B")); } for vec::each([ @@ -1123,52 +1123,52 @@ mod tests { ~"Nov", ~"Dec" ]) |day| { - 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 result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone == ~"UTC"; - assert result::unwrap(strptime(~"PST", ~"%Z")).tm_zone == ~""; - assert result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff == 0; - assert result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff == 0; - assert test(~"%", ~"%%"); + 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!(result::unwrap(strptime(~"UTC", ~"%Z")).tm_zone == ~"UTC"); + fail_unless!(result::unwrap(strptime(~"PST", ~"%Z")).tm_zone == ~""); + fail_unless!(result::unwrap(strptime(~"-0000", ~"%z")).tm_gmtoff == 0); + fail_unless!(result::unwrap(strptime(~"-0800", ~"%z")).tm_gmtoff == 0); + fail_unless!(test(~"%", ~"%%")); } pub fn test_ctime() { @@ -1181,8 +1181,8 @@ mod tests { error!("test_ctime: %? %?", utc.ctime(), local.ctime()); - assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009"; - assert local.ctime() == ~"Fri Feb 13 15:31:30 2009"; + fail_unless!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); + fail_unless!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); } pub fn test_strftime() { @@ -1193,69 +1193,69 @@ mod tests { let utc = at_utc(time); let local = at(time); - assert local.strftime(~"") == ~""; - assert local.strftime(~"%A") == ~"Friday"; - assert local.strftime(~"%a") == ~"Fri"; - assert local.strftime(~"%B") == ~"February"; - assert local.strftime(~"%b") == ~"Feb"; - assert local.strftime(~"%C") == ~"20"; - assert local.strftime(~"%c") == ~"Fri Feb 13 15:31:30 2009"; - assert local.strftime(~"%D") == ~"02/13/09"; - assert local.strftime(~"%d") == ~"13"; - assert local.strftime(~"%e") == ~"13"; - assert local.strftime(~"%F") == ~"2009-02-13"; - // assert local.strftime("%G") == "2009"; - // assert local.strftime("%g") == "09"; - assert local.strftime(~"%H") == ~"15"; - assert local.strftime(~"%I") == ~"03"; - assert local.strftime(~"%j") == ~"044"; - assert local.strftime(~"%k") == ~"15"; - assert local.strftime(~"%l") == ~" 3"; - assert local.strftime(~"%M") == ~"31"; - assert local.strftime(~"%m") == ~"02"; - assert local.strftime(~"%n") == ~"\n"; - assert local.strftime(~"%P") == ~"pm"; - assert local.strftime(~"%p") == ~"PM"; - assert local.strftime(~"%R") == ~"15:31"; - assert local.strftime(~"%r") == ~"03:31:30 PM"; - assert local.strftime(~"%S") == ~"30"; - assert local.strftime(~"%s") == ~"1234567890"; - assert local.strftime(~"%T") == ~"15:31:30"; - assert local.strftime(~"%t") == ~"\t"; - // assert local.strftime("%U") == "06"; - assert local.strftime(~"%u") == ~"5"; - // assert local.strftime("%V") == "07"; - assert local.strftime(~"%v") == ~"13-Feb-2009"; - // assert local.strftime("%W") == "06"; - assert local.strftime(~"%w") == ~"5"; + fail_unless!(local.strftime(~"") == ~""); + fail_unless!(local.strftime(~"%A") == ~"Friday"); + fail_unless!(local.strftime(~"%a") == ~"Fri"); + fail_unless!(local.strftime(~"%B") == ~"February"); + fail_unless!(local.strftime(~"%b") == ~"Feb"); + fail_unless!(local.strftime(~"%C") == ~"20"); + fail_unless!(local.strftime(~"%c") == ~"Fri Feb 13 15:31:30 2009"); + fail_unless!(local.strftime(~"%D") == ~"02/13/09"); + fail_unless!(local.strftime(~"%d") == ~"13"); + fail_unless!(local.strftime(~"%e") == ~"13"); + fail_unless!(local.strftime(~"%F") == ~"2009-02-13"); + // fail_unless!(local.strftime("%G") == "2009"); + // fail_unless!(local.strftime("%g") == "09"); + fail_unless!(local.strftime(~"%H") == ~"15"); + fail_unless!(local.strftime(~"%I") == ~"03"); + fail_unless!(local.strftime(~"%j") == ~"044"); + fail_unless!(local.strftime(~"%k") == ~"15"); + fail_unless!(local.strftime(~"%l") == ~" 3"); + fail_unless!(local.strftime(~"%M") == ~"31"); + fail_unless!(local.strftime(~"%m") == ~"02"); + fail_unless!(local.strftime(~"%n") == ~"\n"); + fail_unless!(local.strftime(~"%P") == ~"pm"); + fail_unless!(local.strftime(~"%p") == ~"PM"); + fail_unless!(local.strftime(~"%R") == ~"15:31"); + fail_unless!(local.strftime(~"%r") == ~"03:31:30 PM"); + fail_unless!(local.strftime(~"%S") == ~"30"); + fail_unless!(local.strftime(~"%s") == ~"1234567890"); + fail_unless!(local.strftime(~"%T") == ~"15:31:30"); + fail_unless!(local.strftime(~"%t") == ~"\t"); + // fail_unless!(local.strftime("%U") == "06"); + fail_unless!(local.strftime(~"%u") == ~"5"); + // fail_unless!(local.strftime("%V") == "07"); + fail_unless!(local.strftime(~"%v") == ~"13-Feb-2009"); + // fail_unless!(local.strftime("%W") == "06"); + fail_unless!(local.strftime(~"%w") == ~"5"); // handle "%X" // handle "%x" - assert local.strftime(~"%Y") == ~"2009"; - assert local.strftime(~"%y") == ~"09"; + fail_unless!(local.strftime(~"%Y") == ~"2009"); + fail_unless!(local.strftime(~"%y") == ~"09"); // 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 local.strftime(~"%z") == ~"-0800"; - assert local.strftime(~"%%") == ~"%"; + fail_unless!(local.strftime(~"%z") == ~"-0800"); + fail_unless!(local.strftime(~"%%") == ~"%"); // FIXME (#2350): We should probably standardize on the timezone // 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 local.ctime() == ~"Fri Feb 13 15:31:30 2009"; - assert local.rfc822z() == ~"Fri, 13 Feb 2009 15:31:30 -0800"; - assert local.rfc3339() == ~"2009-02-13T15:31:30-08:00"; + fail_unless!(local.ctime() == ~"Fri Feb 13 15:31:30 2009"); + fail_unless!(local.rfc822z() == ~"Fri, 13 Feb 2009 15:31:30 -0800"); + fail_unless!(local.rfc3339() == ~"2009-02-13T15:31:30-08:00"); - assert utc.ctime() == ~"Fri Feb 13 23:31:30 2009"; - assert utc.rfc822() == ~"Fri, 13 Feb 2009 23:31:30 GMT"; - assert utc.rfc822z() == ~"Fri, 13 Feb 2009 23:31:30 -0000"; - assert utc.rfc3339() == ~"2009-02-13T23:31:30Z"; + fail_unless!(utc.ctime() == ~"Fri Feb 13 23:31:30 2009"); + fail_unless!(utc.rfc822() == ~"Fri, 13 Feb 2009 23:31:30 GMT"); + fail_unless!(utc.rfc822z() == ~"Fri, 13 Feb 2009 23:31:30 -0000"); + fail_unless!(utc.rfc3339() == ~"2009-02-13T23:31:30Z"); } pub fn test_timespec_eq_ord() { @@ -1267,28 +1267,28 @@ mod tests { let d = &Timespec::new(2, 1); let e = &Timespec::new(2, 1); - assert eq(d, e); - assert ne(c, e); + fail_unless!(eq(d, e)); + fail_unless!(ne(c, e)); - assert lt(a, b); - assert lt(b, c); - assert lt(c, d); + fail_unless!(lt(a, b)); + fail_unless!(lt(b, c)); + fail_unless!(lt(c, d)); - assert le(a, b); - assert le(b, c); - assert le(c, d); - assert le(d, e); - assert le(e, d); + fail_unless!(le(a, b)); + fail_unless!(le(b, c)); + fail_unless!(le(c, d)); + fail_unless!(le(d, e)); + fail_unless!(le(e, d)); - assert ge(b, a); - assert ge(c, b); - assert ge(d, c); - assert ge(e, d); - assert ge(d, e); + fail_unless!(ge(b, a)); + fail_unless!(ge(c, b)); + fail_unless!(ge(d, c)); + fail_unless!(ge(e, d)); + fail_unless!(ge(d, e)); - assert gt(b, a); - assert gt(c, b); - assert gt(d, c); + fail_unless!(gt(b, a)); + fail_unless!(gt(c, b)); + fail_unless!(gt(d, c)); } #[test] diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index f0898e22400..60469d0b0f2 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -260,14 +260,14 @@ mod test { match recv_timeout(hl_loop, 10u, &test_po) { Some(val) => { - assert val == expected; + fail_unless!(val == expected); successes += 1; } _ => failures += 1 }; } - assert successes > times / 2; + fail_unless!(successes > times / 2); } #[test] @@ -291,6 +291,6 @@ mod test { }; } - assert successes > times / 2; + fail_unless!(successes > times / 2); } } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index d1fe1d4c67a..878696a9a90 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -697,39 +697,39 @@ mod test_treemap { #[test] fn find_empty() { - let m = TreeMap::new::(); assert m.find(&5) == None; + let m = TreeMap::new::(); 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); - assert m.find(&2) == None; + fail_unless!(m.insert(1, 2)); + fail_unless!(m.insert(5, 3)); + fail_unless!(m.insert(9, 3)); + fail_unless!(m.find(&2) == None); } #[test] fn insert_replace() { let mut m = TreeMap::new(); - assert m.insert(5, 2); - assert m.insert(2, 9); - assert !m.insert(2, 11); - assert m.find(&2).unwrap() == &11; + fail_unless!(m.insert(5, 2)); + fail_unless!(m.insert(2, 9)); + fail_unless!(!m.insert(2, 11)); + fail_unless!(m.find(&2).unwrap() == &11); } #[test] 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] @@ -744,28 +744,28 @@ mod test_treemap { m.insert(copy k1, copy v1); m.insert(copy k2, copy v2); - assert m.find(&k2) == Some(&v2); - assert m.find(&k1) == Some(&v1); + fail_unless!(m.find(&k2) == Some(&v2)); + fail_unless!(m.find(&k1) == Some(&v1)); } fn check_equal(ctrl: &[(K, V)], map: &TreeMap) { - assert ctrl.is_empty() == map.is_empty(); + fail_unless!(ctrl.is_empty() == map.is_empty()); for ctrl.each |x| { let &(k, v) = x; - assert map.find(&k).unwrap() == &v + fail_unless!(map.find(&k).unwrap() == &v) } for map.each |&(map_k, map_v)| { let mut found = false; for ctrl.each |x| { let &(ctrl_k, 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); } } @@ -773,12 +773,12 @@ mod test_treemap { parent: &~TreeNode) { match *node { Some(ref r) => { - assert r.key.cmp(&parent.key) == Less; - assert r.level == parent.level - 1; // left is black + fail_unless!(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); } - None => assert parent.level == 1 // parent is leaf + None => fail_unless!(parent.level == 1) // parent is leaf } } @@ -787,14 +787,14 @@ mod test_treemap { parent_red: bool) { match *node { Some(ref r) => { - assert r.key.cmp(&parent.key) == Greater; + fail_unless!(r.key.cmp(&parent.key) == Greater); let red = r.level == parent.level; - if parent_red { assert !red } // no dual horizontal links - assert red || r.level == parent.level - 1; // right red or black + if parent_red { fail_unless!(!red) } // no dual horizontal links + fail_unless!(red || r.level == parent.level - 1); // right red or black 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 } } @@ -814,7 +814,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 rng = rand::seeded_rng(&[42]); @@ -823,7 +823,7 @@ mod test_treemap { let k = rng.gen_int(); let v = rng.gen_int(); if !ctrl.contains(&(k, v)) { - assert map.insert(k, v); + fail_unless!(map.insert(k, v)); ctrl.push((k, v)); check_structure(&map); check_equal(ctrl, &map); @@ -833,7 +833,7 @@ mod test_treemap { for 30.times { let r = rng.gen_uint_range(0, ctrl.len()); let (key, _) = vec::remove(&mut ctrl, r); - assert map.remove(&key); + fail_unless!(map.remove(&key)); check_structure(&map); check_equal(ctrl, &map); } @@ -843,36 +843,36 @@ mod test_treemap { #[test] fn test_len() { let mut m = TreeMap::new(); - assert m.insert(3, 6); - assert m.len() == 1; - assert m.insert(0, 0); - assert m.len() == 2; - assert m.insert(4, 8); - assert m.len() == 3; - assert m.remove(&3); - assert m.len() == 2; - assert !m.remove(&5); - assert m.len() == 2; - assert m.insert(2, 4); - assert m.len() == 3; - assert m.insert(1, 2); - assert m.len() == 4; + fail_unless!(m.insert(3, 6)); + fail_unless!(m.len() == 1); + fail_unless!(m.insert(0, 0)); + fail_unless!(m.len() == 2); + fail_unless!(m.insert(4, 8)); + fail_unless!(m.len() == 3); + fail_unless!(m.remove(&3)); + fail_unless!(m.len() == 2); + fail_unless!(!m.remove(&5)); + fail_unless!(m.len() == 2); + fail_unless!(m.insert(2, 4)); + fail_unless!(m.len() == 3); + fail_unless!(m.insert(1, 2)); + fail_unless!(m.len() == 4); } #[test] fn test_each() { 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 m.each |&(k, v)| { - assert *k == n; - assert *v == n * 2; + fail_unless!(*k == n); + fail_unless!(*v == n * 2); n += 1; } } @@ -881,16 +881,16 @@ mod test_treemap { fn test_each_reverse() { 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 m.each_reverse |&(k, v)| { - assert *k == n; - assert *v == n * 2; + fail_unless!(*k == n); + fail_unless!(*v == n * 2); n -= 1; } } @@ -900,17 +900,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] @@ -918,17 +918,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] @@ -936,13 +936,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] @@ -954,24 +954,24 @@ 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(); // FIXME: #4492 (ICE): iter.get() == Some((&x1, &y1)) - assert map_next(&mut a).unwrap() == (&x1, &y1); - assert map_next(&mut a).unwrap() == (&x2, &y2); - assert map_next(&mut a).unwrap() == (&x3, &y3); - assert map_next(&mut a).unwrap() == (&x4, &y4); - assert map_next(&mut a).unwrap() == (&x5, &y5); + fail_unless!(map_next(&mut a).unwrap() == (&x1, &y1)); + fail_unless!(map_next(&mut a).unwrap() == (&x2, &y2)); + fail_unless!(map_next(&mut a).unwrap() == (&x3, &y3)); + fail_unless!(map_next(&mut a).unwrap() == (&x4, &y4)); + fail_unless!(map_next(&mut a).unwrap() == (&x5, &y5)); - assert map_next(&mut a).is_none(); + fail_unless!(map_next(&mut a).is_none()); let mut b = m.iter(); @@ -980,7 +980,7 @@ mod test_treemap { let mut i = 0; for map_advance(&mut b) |x| { - assert expected[i] == x; + fail_unless!(expected[i] == x); i += 1; if i == 2 { @@ -989,7 +989,7 @@ mod test_treemap { } for map_advance(&mut b) |x| { - assert expected[i] == x; + fail_unless!(expected[i] == x); i += 1; } } @@ -1003,80 +1003,80 @@ 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_each() { 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 m.each |x| { - assert *x == n; + fail_unless!(*x == n); n += 1 } } @@ -1085,15 +1085,15 @@ mod test_set { fn test_each_reverse() { 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 m.each_reverse |x| { - assert *x == n; + fail_unless!(*x == n); n -= 1 } } @@ -1103,29 +1103,29 @@ mod test_set { let mut a = TreeSet::new(); let mut b = TreeSet::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); + 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)); - 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!(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 a.intersection(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -1133,22 +1133,22 @@ mod test_set { let mut a = TreeSet::new(); let mut b = TreeSet::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 a.difference(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -1156,25 +1156,25 @@ mod test_set { let mut a = TreeSet::new(); let mut b = TreeSet::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 a.symmetric_difference(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } #[test] @@ -1182,28 +1182,28 @@ mod test_set { let mut a = TreeSet::new(); let mut b = TreeSet::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); + 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)); - 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!(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 a.union(&b) |x| { - assert *x == expected[i]; + fail_unless!(*x == expected[i]); i += 1 } - assert i == expected.len(); + fail_unless!(i == expected.len()); } } diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index acafc4035f8..b3581e2690c 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -224,25 +224,25 @@ mod tests { #[test] fn test_is_digit() { - assert (unicode::icu::is_digit('0')); - assert (!unicode::icu::is_digit('m')); + fail_unless!((unicode::icu::is_digit('0'))); + fail_unless!((!unicode::icu::is_digit('m'))); } #[test] fn test_is_lower() { - assert (unicode::icu::is_lower('m')); - assert (!unicode::icu::is_lower('M')); + fail_unless!((unicode::icu::is_lower('m'))); + fail_unless!((!unicode::icu::is_lower('M'))); } #[test] fn test_is_space() { - assert (unicode::icu::is_space(' ')); - assert (!unicode::icu::is_space('m')); + fail_unless!((unicode::icu::is_space(' '))); + fail_unless!((!unicode::icu::is_space('m'))); } #[test] fn test_is_upper() { - assert (unicode::icu::is_upper('M')); - assert (!unicode::icu::is_upper('m')); + fail_unless!((unicode::icu::is_upper('M'))); + fail_unless!((!unicode::icu::is_upper('m'))); } } diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 2414b1f9bfa..522a613f02d 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -188,7 +188,7 @@ extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) { // pretty much, if we still have an active handle and it is *not* // the async handle that facilities global loop communication, we // want to barf out and fail - assert handle == arg; + fail_unless!(handle == arg); } extern fn tear_down_close_cb(handle: *ll::uv_async_t) { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 0f58da54745..a48dd7b4f86 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -1339,7 +1339,7 @@ pub mod test { stream as *libc::c_void); let err_msg = get_last_err_info(test_loop); log(debug, err_msg); - assert false; + fail_unless!(false); } log(debug, ~"finishing on_connect_cb"); } @@ -1411,12 +1411,12 @@ pub mod test { } else { log(debug, ~"tcp_connect() failure"); - assert false; + fail_unless!(false); } } else { log(debug, ~"tcp_init() failure"); - assert false; + fail_unless!(false); } loop_delete(test_loop); } @@ -1493,7 +1493,7 @@ pub mod test { log(debug, get_last_err_info( get_loop_for_uv_handle(client_stream_ptr as *libc::c_void))); - assert false; + fail_unless!(false); } } else { @@ -1553,19 +1553,19 @@ pub mod test { else { log(debug, fmt!("server_connection_cb: bad read:%d", read_result as int)); - assert false; + fail_unless!(false); } } else { log(debug, fmt!("server_connection_cb: bad accept: %d", accept_result as int)); - assert false; + fail_unless!(false); } } else { log(debug, fmt!("server_connection_cb: bad client init: %d", client_init_result as int)); - assert false; + fail_unless!(false); } } } @@ -1684,25 +1684,25 @@ pub mod test { else { log(debug, fmt!("uv_async_init failure: %d", async_result as int)); - assert false; + fail_unless!(false); } } else { log(debug, fmt!("non-zero result on uv_listen: %d", listen_result as int)); - assert false; + fail_unless!(false); } } else { log(debug, fmt!("non-zero result on uv_tcp_bind: %d", bind_result as int)); - assert false; + fail_unless!(false); } } else { log(debug, fmt!("non-zero result on uv_tcp_init: %d", tcp_init_result as int)); - assert false; + fail_unless!(false); } loop_delete(test_loop); } @@ -1747,8 +1747,8 @@ pub mod test { let msg_from_client = server_port.recv(); let msg_from_server = client_port.recv(); - assert str::contains(msg_from_client, kill_server_msg); - assert str::contains(msg_from_server, server_resp_msg); + fail_unless!(str::contains(msg_from_client, kill_server_msg)); + fail_unless!(str::contains(msg_from_server, server_resp_msg)); } } @@ -1794,7 +1794,7 @@ pub mod test { t_name, rust_size, foreign_size as uint); log(debug, output); } - assert sizes_match; + fail_unless!(sizes_match); } } @@ -1859,7 +1859,7 @@ pub mod test { // .. can't get the uv::ll::sockaddr_in6 to == 28 :/ // .. so the type always appears to be 32 in size.. which is // good, i guess.. better too big than too little - assert (4u+foreign_handle_size as uint) == rust_handle_size; + fail_unless!((4u+foreign_handle_size as uint) == rust_handle_size); } } #[test] @@ -1873,7 +1873,7 @@ pub mod test { foreign_handle_size as uint, rust_handle_size); log(debug, output); // FIXME #1645 .. see note above about struct padding - assert (4u+foreign_handle_size as uint) == rust_handle_size; + fail_unless!((4u+foreign_handle_size as uint) == rust_handle_size); } } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 1038982d353..a525c0df5fa 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -253,7 +253,7 @@ pub impl FileMap { // about what ends a line between this file and parse.rs fn next_line(&self, +pos: BytePos) { // the new charpos must be > the last one (or it's the first one). - assert ((self.lines.len() == 0) + fail_unless!((self.lines.len() == 0) || (self.lines[self.lines.len() - 1] < pos)); self.lines.push(pos); } @@ -272,7 +272,7 @@ pub 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, @@ -393,7 +393,7 @@ pub impl CodeMap { pub fn span_to_snippet(&self, sp: span) -> ~str { let begin = self.lookup_byte_offset(sp.lo); let end = self.lookup_byte_offset(sp.hi); - assert begin.fm.start_pos == end.fm.start_pos; + fail_unless!(begin.fm.start_pos == end.fm.start_pos); return str::slice(*begin.fm.src, begin.pos.to_uint(), end.pos.to_uint()); } @@ -453,7 +453,7 @@ priv 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, @@ -492,8 +492,8 @@ priv impl CodeMap { total_extra_bytes += mbc.bytes; // We should never see a byte position in the middle of a // character - assert bpos == mbc.pos - || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes; + fail_unless!(bpos == mbc.pos + || bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes); } else { break; } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 7b4f92ab3ca..f76f10f3de1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -430,7 +430,7 @@ pub fn core_macros() -> ~str { macro_rules! fail_unless( ($cond:expr) => { if !$cond { - fail!(~\"assertion failed: \" + stringify!($cond)) + ::core::sys::fail_assert(stringify!($cond), file!(), line!()) } } ) diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 5ea9257d583..eafe871a288 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -54,7 +54,7 @@ impl gen_send for message { message(ref _id, span, ref tys, this, Some(ref next_state)) => { debug!("pipec: next state exists"); let next = this.proto.get_state(next_state.state); - assert next_state.tys.len() == next.generics.ty_params.len(); + fail_unless!(next_state.tys.len() == next.generics.ty_params.len()); let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str())); let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t)); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 0e63ea3278e..c66e726bbf7 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -410,7 +410,7 @@ pub fn parse( } } - assert cur_eis.len() > 0u; + fail_unless!(cur_eis.len() > 0u); } } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index ca5c4564dd9..494ef3a81a0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -57,7 +57,7 @@ pub fn is_doc_comment(s: &str) -> bool { } pub fn doc_comment_style(comment: &str) -> ast::attr_style { - assert is_doc_comment(comment); + fail_unless!(is_doc_comment(comment)); if comment.starts_with(~"//!") || comment.starts_with(~"/*!") { ast::attr_inner } else { @@ -136,8 +136,8 @@ fn read_to_eol(rdr: @mut StringReader) -> ~str { fn read_one_line_comment(rdr: @mut StringReader) -> ~str { let val = read_to_eol(rdr); - assert ((val[0] == '/' as u8 && val[1] == '/' as u8) || - (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; } @@ -249,7 +249,7 @@ fn read_block_comment(rdr: @mut 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 524f9b48dd5..ab57d177112 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -187,7 +187,7 @@ pub fn bump(rdr: @mut StringReader) { rdr.last_pos = rdr.pos; let current_byte_offset = byte_offset(rdr).to_uint();; if current_byte_offset < (*rdr.src).len() { - assert rdr.curr != -1 as char; + fail_unless!(rdr.curr != -1 as char); let last_char = rdr.curr; let next = str::char_range_at(*rdr.src, current_byte_offset); let byte_offset_diff = next.next - current_byte_offset; @@ -314,7 +314,7 @@ fn consume_any_line_comment(rdr: @mut StringReader) } pub pure fn is_block_non_doc_comment(s: &str) -> bool { - assert s.len() >= 1u; + fail_unless!(s.len() >= 1u); str::all_between(s, 1u, s.len() - 1u, |ch| ch == '*') } @@ -872,21 +872,21 @@ pub mod test { let env = setup(~"'a'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT('a' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT('a' as i64, ast::ty_char)); } #[test] fn character_space() { let env = setup(~"' '"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT(' ' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT(' ' as i64, ast::ty_char)); } #[test] fn character_escaped() { let env = setup(~"'\n'"); let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); - assert tok == token::LIT_INT('\n' as i64, ast::ty_char); + fail_unless!(tok == token::LIT_INT('\n' as i64, ast::ty_char)); } #[test] fn lifetime_name() { @@ -894,7 +894,7 @@ pub mod test { let TokenAndSpan {tok, sp: _} = env.string_reader.next_token(); let id = env.interner.intern(@~"abc"); - assert tok == token::LIFETIME(id); + fail_unless!(tok == token::LIFETIME(id)); } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 96a8f780934..48d3fbe8889 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -197,7 +197,7 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id { let rv = sess.next_id; sess.next_id += 1; // ID 0 is reserved for the crate and doesn't actually exist in the AST - assert rv != 0; + fail_unless!(rv != 0); return rv; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2a113c44612..0dba2bd45e1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2499,7 +2499,7 @@ pub impl Parser { fn parse_block(&self) -> blk { let (attrs, blk) = self.parse_inner_attrs_and_block(false); - assert vec::is_empty(attrs); + fail_unless!(vec::is_empty(attrs)); return blk; } @@ -3846,7 +3846,7 @@ pub impl Parser { foreign_items_allowed: bool, macros_allowed: bool ) -> item_or_view_item { - assert items_allowed != foreign_items_allowed; + fail_unless!(items_allowed != foreign_items_allowed); maybe_whole!(iovi self, nt_item); let lo = self.span.lo; @@ -4215,11 +4215,11 @@ pub impl Parser { view_items.push(view_item); } iovi_item(item) => { - assert items_allowed; + fail_unless!(items_allowed); items.push(item) } iovi_foreign_item(foreign_item) => { - assert foreign_items_allowed; + fail_unless!(foreign_items_allowed); foreign_items.push(foreign_item); } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 60e6e4dc87e..df658b96d7b 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -117,7 +117,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 = vec::len(toks); - assert (n == vec::len(szs)); + fail_unless!((n == vec::len(szs))); let mut i = left; let mut L = lim; let mut s = ~"["; @@ -369,12 +369,12 @@ pub 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; } 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; @@ -382,11 +382,11 @@ pub impl Printer { return x; } fn scan_top(&mut self) -> uint { - assert (!self.scan_stack_empty); + fail_unless!((!self.scan_stack_empty)); return self.scan_stack[self.top]; } 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; @@ -396,7 +396,7 @@ pub impl Printer { fn advance_right(&mut self) { self.right += 1u; self.right %= self.buf_len; - assert (self.right != self.left); + fail_unless!((self.right != self.left)); } fn advance_left(&mut self, ++x: token, L: int) { debug!("advnce_left ~[%u,%u], sizeof(%u)=%d", self.left, self.right, @@ -405,7 +405,7 @@ pub impl Printer { self.print(x, L); match x { BREAK(b) => self.left_total += b.blank_space, - STRING(_, len) => { assert (len == L); self.left_total += len; } + STRING(_, len) => { fail_unless!((len == L)); self.left_total += len; } _ => () } if self.left != self.right { @@ -494,7 +494,7 @@ pub impl Printer { } END => { debug!("print END -> pop END"); - assert (self.print_stack.len() != 0u); + fail_unless!((self.print_stack.len() != 0u)); self.print_stack.pop(); } BREAK(b) => { @@ -528,8 +528,8 @@ pub impl Printer { } STRING(s, len) => { debug!("print STRING(%s)", *s); - assert (L == len); - // assert L <= space; + fail_unless!((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 c0ce8ec45aa..d87238c720e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1327,8 +1327,8 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { print_fn_block_args(s, decl); space(s.s); // } - assert body.node.stmts.is_empty(); - assert body.node.expr.is_some(); + fail_unless!(body.node.stmts.is_empty()); + fail_unless!(body.node.expr.is_some()); // we extract the block, so as not to create another set of boxes match body.node.expr.get().node { ast::expr_block(ref blk) => { @@ -1460,7 +1460,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) { // if any are mut, all are mut if vec::any(locs, |l| l.node.is_mutbl) { - assert vec::all(locs, |l| l.node.is_mutbl); + fail_unless!(vec::all(locs, |l| l.node.is_mutbl)); word_nbsp(s, ~"mut"); } @@ -2086,7 +2086,7 @@ pub fn maybe_print_comment(s: @ps, pos: BytePos) { pub fn print_comment(s: @ps, cmnt: comments::cmnt) { match cmnt.style { comments::mixed => { - assert (vec::len(cmnt.lines) == 1u); + fail_unless!((vec::len(cmnt.lines) == 1u)); zerobreak(s.s); word(s.s, cmnt.lines[0]); zerobreak(s.s); diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 5fc93412c50..2c852084aa7 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -74,32 +74,32 @@ pub fn i1 () { pub fn i2 () { let i : Interner<@~str> = Interner::new(); // first one is zero: - assert i.intern (@~"dog") == 0; + fail_unless!(i.intern (@~"dog") == 0); // re-use gets the same entry: - assert i.intern (@~"dog") == 0; + fail_unless!(i.intern (@~"dog") == 0); // different string gets a different #: - assert i.intern (@~"cat") == 1; - assert i.intern (@~"cat") == 1; + fail_unless!(i.intern (@~"cat") == 1); + fail_unless!(i.intern (@~"cat") == 1); // dog is still at zero - assert i.intern (@~"dog") == 0; + fail_unless!(i.intern (@~"dog") == 0); // gensym gets 3 - assert i.gensym (@~"zebra" ) == 2; + fail_unless!(i.gensym (@~"zebra" ) == 2); // gensym of same string gets new number : - assert i.gensym (@~"zebra" ) == 3; + fail_unless!(i.gensym (@~"zebra" ) == 3); // gensym of *existing* string gets new number: - assert i.gensym (@~"dog") == 4; - assert i.get(0) == @~"dog"; - assert i.get(1) == @~"cat"; - assert i.get(2) == @~"zebra"; - assert i.get(3) == @~"zebra"; - assert i.get(4) == @~"dog"; + fail_unless!(i.gensym (@~"dog") == 4); + fail_unless!(i.get(0) == @~"dog"); + fail_unless!(i.get(1) == @~"cat"); + fail_unless!(i.get(2) == @~"zebra"); + fail_unless!(i.get(3) == @~"zebra"); + fail_unless!(i.get(4) == @~"dog"); } #[test] pub fn i3 () { let i : Interner<@~str> = Interner::prefill([@~"Alan",@~"Bob",@~"Carol"]); - assert i.get(0) == @~"Alan"; - assert i.get(1) == @~"Bob"; - assert i.get(2) == @~"Carol"; - assert i.intern(@~"Bob") == 1; + fail_unless!(i.get(0) == @~"Alan"); + fail_unless!(i.get(1) == @~"Bob"); + fail_unless!(i.get(2) == @~"Carol"); + fail_unless!(i.intern(@~"Bob") == 1); } diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 92e91929f1a..a1896c660eb 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -42,7 +42,7 @@ fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } for uint::range(0, num_keys) |i| { - assert map.get(&i) == i+1; + fail_unless!(map.get(&i) == i+1); } } } @@ -64,7 +64,7 @@ fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { - assert map.remove(&i); + fail_unless!(map.remove(&i)); } } } @@ -81,7 +81,7 @@ fn old_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); - assert map.get(&s) == i; + fail_unless!(map.get(&s) == i); } } } @@ -103,7 +103,7 @@ fn old_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(&uint::to_str(i)); + fail_unless!(map.remove(&uint::to_str(i))); } } } @@ -118,7 +118,7 @@ fn linear_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) } for uint::range(0, num_keys) |i| { - assert map.find(&i).unwrap() == &(i+1); + fail_unless!(map.find(&i).unwrap() == &(i+1)); } } } @@ -140,7 +140,7 @@ fn linear_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { - assert map.remove(&i); + fail_unless!(map.remove(&i)); } } } @@ -157,7 +157,7 @@ fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) for uint::range(0, num_keys) |i| { let s = uint::to_str(i); - assert map.find(&s).unwrap() == &i; + fail_unless!(map.find(&s).unwrap() == &i); } } } @@ -179,7 +179,7 @@ fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(&uint::to_str(i)); + fail_unless!(map.remove(&uint::to_str(i))); } } } @@ -194,7 +194,7 @@ fn tree_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } for uint::range(0, num_keys) |i| { - assert map.find(&i).unwrap() == &(i+1); + fail_unless!(map.find(&i).unwrap() == &(i+1)); } } } @@ -216,7 +216,7 @@ fn tree_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { - assert map.remove(&i); + fail_unless!(map.remove(&i)); } } } @@ -233,7 +233,7 @@ fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); - assert map.find(&s).unwrap() == &i; + fail_unless!(map.find(&s).unwrap() == &i); } } } @@ -255,7 +255,7 @@ fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(&uint::to_str(i)); + fail_unless!(map.remove(&uint::to_str(i))); } } } diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index 5e73b286530..ab441277c62 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -42,7 +42,7 @@ pub impl Results { } for uint::range(0, num_keys) |i| { - assert set.contains(&i); + fail_unless!(set.contains(&i)); } } } @@ -64,7 +64,7 @@ pub impl Results { do timed(&mut self.delete_ints) { for uint::range(0, num_keys) |i| { - assert set.remove(&i); + fail_unless!(set.remove(&i)); } } } @@ -82,7 +82,7 @@ pub impl Results { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); - assert set.contains(&s); + fail_unless!(set.contains(&s)); } } } @@ -104,7 +104,7 @@ pub impl Results { } do timed(&mut self.delete_strings) { for uint::range(0, num_keys) |i| { - assert set.remove(&uint::to_str(i)); + fail_unless!(set.remove(&uint::to_str(i))); } } } diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index 7f1f4bd1834..4117add8926 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -47,10 +47,10 @@ fn main() { let end = std::time::precise_time_s(); // check each vector - assert raw_v.len() == max; - for raw_v.eachi |i, v| { assert i == *v; } - assert dvec_v.len() == max; - for dvec_v.eachi |i, v| { assert i == *v; } + fail_unless!(raw_v.len() == max); + for raw_v.eachi |i, v| { fail_unless!(i == *v); } + fail_unless!(dvec_v.len() == max); + for dvec_v.eachi |i, v| { fail_unless!(i == *v); } let raw = mid - start; let dvec = end - mid; diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 0b172011648..9efcc05e996 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -293,7 +293,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { }; result }; - assert(colors.len() == old_len); + fail_unless!((colors.len() == old_len)); } // Convert the results. @@ -461,7 +461,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert(validate(copy edges, *root, bfs_tree)); + fail_unless!((validate(copy edges, *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line( @@ -481,7 +481,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert(validate(copy edges, *root, bfs_tree)); + fail_unless!((validate(copy edges, *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line( @@ -501,7 +501,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert(validate(copy edges, *root, bfs_tree)); + fail_unless!((validate(copy edges, *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line(fmt!("Validation completed in %? seconds.", diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index fbd80d58130..5ae1f796304 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -95,7 +95,7 @@ fn run(args: &[~str]) { io::stdout().write_str(fmt!("Test took %? seconds\n", elapsed)); let thruput = ((size / workers * workers) as float) / (elapsed as float); io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput)); - assert result == num_bytes * size; + fail_unless!(result == num_bytes * size); } fn main() { diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 25135383745..db1aaf9bcdb 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -92,7 +92,7 @@ fn run(args: &[~str]) { io::stdout().write_str(fmt!("Test took %? seconds\n", elapsed)); let thruput = ((size / workers * workers) as float) / (elapsed as float); io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput)); - assert result == num_bytes * size; + fail_unless!(result == num_bytes * size); } fn main() { diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index e0d2fbb0513..77cd7890f29 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -73,7 +73,7 @@ fn stress_task(&&id: int) { let mut i = 0; loop { let n = 15; - assert (fib(n) == fib(n)); + fail_unless!((fib(n) == fib(n))); i += 1; error!("%d: Completed %d iterations", id, i); } diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index d54376a2532..930e3d8a608 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -22,7 +22,7 @@ fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap) { fn check_sequential(min: uint, max: uint, map: &SmallIntMap) { for uint::range(min, max) |i| { - assert *map.get(&i) == i + 22u; + fail_unless!(*map.get(&i) == i + 22u); } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index dc8136bc122..78234ca0dfa 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -40,7 +40,7 @@ pub enum grid_t { grid_ctor(grid), } // read a sudoku problem from file f pub fn read_grid(f: io::Reader) -> grid_t { - assert f.read_line() == ~"9,9"; /* assert first line is exactly "9,9" */ + fail_unless!(f.read_line() == ~"9,9"); /* assert first line is exactly "9,9" */ let mut g = vec::from_fn(10u, {|_i| vec::from_elem(10u, 0 as u8) diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 40390ceeee4..de58ae8ab0d 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -51,7 +51,7 @@ fn spawn_supervised_blocking(myname: &str, +f: ~fn()) { task::task().future_result(|+r| res = Some(r)).supervised().spawn(f); error!("%s group waiting", myname); let x = option::unwrap(res).recv(); - assert x == task::Success; + fail_unless!(x == task::Success); } fn main() { @@ -81,5 +81,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 a7d18ca637d..1e21af7b3f0 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 @@ -18,5 +18,5 @@ fn main() { //~^ ERROR cannot infer an appropriate lifetime } // Adding this line causes a method unification failure instead - // do (&option::unwrap(y)).read |state| { assert *state == 1; } + // do (&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 a5b97abf7ba..b1375cc7980 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 @@ -18,5 +18,5 @@ fn main() { y = Some(write_mode); } // Adding this line causes a method unification failure instead - // do (&option::unwrap(y)).write |state| { assert *state == 1; } + // do (&option::unwrap(y)).write |state| { fail_unless!(*state == 1); } } diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index cbbf484ad55..25ae0308732 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -23,10 +23,10 @@ fn main() { let b: clam = clam{x: @10, y: @20}; let z: int = a.x + b.y; log(debug, z); - assert (z == 21); + fail_unless!((z == 21)); let forty: fish = fish{a: @40}; let two: fish = fish{a: @2}; let answer: int = forty.a + two.a; log(debug, answer); - assert (answer == 42); + fail_unless!((answer == 42)); } 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 d428feb2a24..4a90d2f4b7f 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/block-arg-as-stmt-with-value.rs b/src/test/compile-fail/block-arg-as-stmt-with-value.rs index 056184da166..1ef5ae16079 100644 --- a/src/test/compile-fail/block-arg-as-stmt-with-value.rs +++ b/src/test/compile-fail/block-arg-as-stmt-with-value.rs @@ -19,5 +19,5 @@ fn compute1() -> float { fn main() { let x = compute1(); log(debug, x); - assert(x == -4f); + fail_unless!((x == -4f)); } 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 a15b7c8bdfd..e56a179e774 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -16,8 +16,8 @@ fn box_imm() { let mut v = ~3; do borrow(v) |w| { //~ NOTE loan of mutable local variable granted here v = ~4; //~ ERROR assigning to captured outer mutable variable in a stack closure prohibited due to outstanding loan - assert *v == 3; - assert *w == 4; + fail_unless!(*v == 3); + fail_unless!(*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 e8604d2c8ac..b5c8f509167 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 destructure(Some(22)) == 22; + fail_unless!(destructure(Some(22)) == 22); } diff --git a/src/test/compile-fail/cast-from-nil.rs b/src/test/compile-fail/cast-from-nil.rs index 262bf1030bc..1c2a3e17426 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 49cbb12cb19..b8c2274076c 100644 --- a/src/test/compile-fail/crateresolve5.rs +++ b/src/test/compile-fail/crateresolve5.rs @@ -18,5 +18,5 @@ extern mod cr5_2 (name = "crateresolve5", vers = "0.2"); fn main() { // Nominal types from two multiple versions of a crate are different types - assert cr5_1::nominal() == cr5_2::nominal(); + fail_unless!(cr5_1::nominal() == cr5_2::nominal()); } diff --git a/src/test/compile-fail/do2.rs b/src/test/compile-fail/do2.rs index 10311834915..89821f97513 100644 --- a/src/test/compile-fail/do2.rs +++ b/src/test/compile-fail/do2.rs @@ -11,6 +11,6 @@ fn f(f: @fn(int) -> bool) -> bool { f(10i) } fn main() { - assert do f() |i| { i == 10i } == 10i; + fail_unless!(do f() |i| { i == 10i } == 10i); //~^ ERROR: expected `bool` but found `int` } diff --git a/src/test/compile-fail/issue-1896-1.rs b/src/test/compile-fail/issue-1896-1.rs index 29544caed53..bf130addb6b 100644 --- a/src/test/compile-fail/issue-1896-1.rs +++ b/src/test/compile-fail/issue-1896-1.rs @@ -20,5 +20,5 @@ fn main () { let myInt: uint = (aFn.theFn)(); - assert myInt == 10; + fail_unless!(myInt == 10); } diff --git a/src/test/compile-fail/issue-2467.rs b/src/test/compile-fail/issue-2467.rs index 86453964f07..6d31deea3ff 100644 --- a/src/test/compile-fail/issue-2467.rs +++ b/src/test/compile-fail/issue-2467.rs @@ -12,5 +12,5 @@ enum test { thing = 3u } //~ ERROR mismatched types //~^ ERROR expected signed integer constant fn main() { log(error, thing as int); - assert(thing as int == 3); + fail_unless!((thing as int == 3)); } diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 951944e2485..83fdb86628b 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -35,8 +35,8 @@ fn main() { let mut v = ~[]; v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy` - assert (v.len() == 2); + fail_unless!((v.len() == 2)); } - assert *x == 1; + fail_unless!(*x == 1); } diff --git a/src/test/compile-fail/issue-2969.rs b/src/test/compile-fail/issue-2969.rs index 88c76fb31a1..5e6fa6e95f8 100644 --- a/src/test/compile-fail/issue-2969.rs +++ b/src/test/compile-fail/issue-2969.rs @@ -15,5 +15,5 @@ fn main() let mut x = [1, 2, 4]; let v : &int = &x[2]; x[2] = 6; - assert *v == 6; + fail_unless!(*v == 6); } diff --git a/src/test/compile-fail/issue-3888.rs b/src/test/compile-fail/issue-3888.rs index 4f9cd28738a..779265e5a29 100644 --- a/src/test/compile-fail/issue-3888.rs +++ b/src/test/compile-fail/issue-3888.rs @@ -25,17 +25,17 @@ fn vec_peek(v: &r/[T]) -> Option< (&r/T, &r/[T]) > { fn test_peek_empty_stack() { let v : &[int] = &[]; - assert (None == vec_peek(v)); + fail_unless!((None == vec_peek(v))); } fn test_peek_empty_unique() { let v : ~[int] = ~[]; - assert (None == vec_peek(v)); + fail_unless!((None == vec_peek(v))); } fn test_peek_empty_managed() { let v : @[int] = @[]; - assert (None == vec_peek(v)); + fail_unless!((None == vec_peek(v))); } diff --git a/src/test/compile-fail/issue-511.rs b/src/test/compile-fail/issue-511.rs index f337914da6d..632b15dadd4 100644 --- a/src/test/compile-fail/issue-511.rs +++ b/src/test/compile-fail/issue-511.rs @@ -12,7 +12,7 @@ extern mod std; use core::cmp::Eq; fn f(o: &mut Option) { - assert *o == option::None; + fail_unless!(*o == option::None); } fn main() { diff --git a/src/test/compile-fail/issue-818.rs b/src/test/compile-fail/issue-818.rs index 00f2df00385..0de7276fc8c 100644 --- a/src/test/compile-fail/issue-818.rs +++ b/src/test/compile-fail/issue-818.rs @@ -20,5 +20,5 @@ mod ctr { fn main() { let c = ctr::new(42); let c2 = ctr::inc(c); - assert *c2 == 5; //~ ERROR can only dereference enums with a single, public variant + fail_unless!(*c2 == 5); //~ ERROR can only dereference enums with a single, public variant } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index f369e765d69..e0651a68fa9 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 x: &blk/int = &3; repeater(@x) }; - assert 3 == *(y.get()); //~ ERROR reference is not valid + fail_unless!(3 == *(y.get())); //~ ERROR reference is not valid } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index a51f7d8efbe..fbbac6e0a64 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -27,7 +27,7 @@ fn to_foo(t: T) { let v = &3; struct F { f: T } let x = @F {f:t} as foo; - assert x.foo(v) == 3; + fail_unless!(x.foo(v) == 3); } fn to_foo_2(t: T) -> foo { diff --git a/src/test/compile-fail/mod_file_correct_spans.rs b/src/test/compile-fail/mod_file_correct_spans.rs index f2973fb0d5e..832e6d8a6a7 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/mod_file_not_exist.rs b/src/test/compile-fail/mod_file_not_exist.rs index 42a43ea358c..d742ad04d76 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 not_a_real_file.rs fn main() { - assert mod_file_aux::bar() == 10; + fail_unless!(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 56be5e5022a..2f71f4d22f9 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 m::foo() == 10; + fail_unless!(m::foo() == 10); } diff --git a/src/test/compile-fail/mode-inference-fail.rs b/src/test/compile-fail/mode-inference-fail.rs index 9c08d127962..fd15321e1d0 100644 --- a/src/test/compile-fail/mode-inference-fail.rs +++ b/src/test/compile-fail/mode-inference-fail.rs @@ -18,6 +18,6 @@ fn apply_int(f: fn(int) -> int, a: int) -> int { f(a) } fn main() { let f = {|i| i}; - assert apply_int(f, 2) == 2; - assert apply(f, 2) == 2; //~ ERROR expected argument mode && + fail_unless!(apply_int(f, 2) == 2); + fail_unless!(apply(f, 2) == 2); //~ ERROR expected argument mode && } diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index b374a03eaba..a0c1bf040e3 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -19,10 +19,10 @@ fn main() { do task::spawn() { let v = *arc::get(&arc_v); - assert v[3] == 4; + fail_unless!(v[3] == 4); }; - assert (*arc::get(&arc_v))[2] == 3; + fail_unless!((*arc::get(&arc_v))[2] == 3); log(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 8c33e026026..4cb78e7032b 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -17,10 +17,10 @@ fn main() { do task::spawn() { //~ NOTE `arc_v` moved into closure environment here let v = *arc::get(&arc_v); - assert v[3] == 4; + fail_unless!(v[3] == 4); }; - assert (*arc::get(&arc_v))[2] == 3; //~ ERROR use of moved value: `arc_v` + fail_unless!((*arc::get(&arc_v))[2] == 3); //~ ERROR use of moved value: `arc_v` log(info, arc_v); } diff --git a/src/test/compile-fail/noncopyable-match-pattern.rs b/src/test/compile-fail/noncopyable-match-pattern.rs index d90e2f372a8..0623f93a38b 100644 --- a/src/test/compile-fail/noncopyable-match-pattern.rs +++ b/src/test/compile-fail/noncopyable-match-pattern.rs @@ -12,7 +12,7 @@ fn main() { let x = Some(unstable::exclusive(false)); match x { Some(copy z) => { //~ ERROR copying a value of non-copyable type - do z.with |b| { assert !*b; } + do z.with |b| { fail_unless!(!*b); } } None => fail!() } diff --git a/src/test/compile-fail/omitted-arg-wrong-types.rs b/src/test/compile-fail/omitted-arg-wrong-types.rs index d432c5eac46..0ab53da0c4a 100644 --- a/src/test/compile-fail/omitted-arg-wrong-types.rs +++ b/src/test/compile-fail/omitted-arg-wrong-types.rs @@ -12,9 +12,9 @@ fn let_in(x: T, f: &fn(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/private-struct-field-cross-crate.rs b/src/test/compile-fail/private-struct-field-cross-crate.rs index 7cf4ef8df7b..1df102a751a 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::*; 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 48e0d85d2a7..86a14587006 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-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index 2732e495558..f5e304dbe72 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 updated_flag.desc == "My new flag"; + fail_unless!(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 4c069b0a958..063764eea0e 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 @@ -16,7 +16,7 @@ fn x_coord(p: &r/point) -> &r/int { fn foo(p: @point) -> &int { let xc = x_coord(p); //~ ERROR illegal borrow - assert *xc == 3; + fail_unless!(*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 72cca99b201..59329195b71 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 @@ -19,10 +19,10 @@ fn foo(cond: fn() -> bool, box: fn() -> @int) { // of this borrow is the fn body as a whole. y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough - assert *x == *y; + fail_unless!(*x == *y); if cond() { break; } } - assert *y != 0; + fail_unless!(*y != 0); } fn main() {} diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 8b81b311730..f4e41d951aa 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 get_v(@hc as get_ctxt) == 22u; + fail_unless!(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 48ef79a9984..cd395fe4dd1 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 illegal borrow: borrowed value does not live long enough - assert (*x == 3); + fail_unless!((*x == 3)); } } diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs index 4550d95aa5d..b13835a89d4 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/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index bd886f44ede..c825118fa98 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 call_it(x) == 22; + fail_unless!(call_it(x) == 22); } diff --git a/src/test/pretty/alt-naked-expr-long.rs b/src/test/pretty/alt-naked-expr-long.rs index a0ade868afd..73a5b864ea8 100644 --- a/src/test/pretty/alt-naked-expr-long.rs +++ b/src/test/pretty/alt-naked-expr-long.rs @@ -22,5 +22,5 @@ fn main() { + ~"very" + ~"very" + ~"long" + ~"string", None => ~"none" }; - assert y == ~"some(_)"; + fail_unless!(y == ~"some(_)"); } diff --git a/src/test/pretty/alt-naked-expr.rs b/src/test/pretty/alt-naked-expr.rs index 0ef5c8d16b0..3a92e3c28e7 100644 --- a/src/test/pretty/alt-naked-expr.rs +++ b/src/test/pretty/alt-naked-expr.rs @@ -13,5 +13,5 @@ fn main() { let x = Some(3); let y = match x { Some(_) => ~"some(_)", None => ~"none" }; - assert y == ~"some(_)"; + fail_unless!(y == ~"some(_)"); } diff --git a/src/test/pretty/record-trailing-comma.rs b/src/test/pretty/record-trailing-comma.rs index f026f217b99..fc80c75e532 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 sth.x + sth2.y == 9; + fail_unless!(sth.x + sth2.y == 9); } diff --git a/src/test/run-fail/fail.rs b/src/test/run-fail/fail.rs index 0aa3f36d29c..23207dcf437 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/linked-failure.rs b/src/test/run-fail/linked-failure.rs index e8bb075ac00..458ec11c674 100644 --- a/src/test/run-fail/linked-failure.rs +++ b/src/test/run-fail/linked-failure.rs @@ -13,7 +13,7 @@ // error-pattern:1 == 2 extern mod std; -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 97e4edc81bc..1955a29058f 100644 --- a/src/test/run-fail/linked-failure4.rs +++ b/src/test/run-fail/linked-failure4.rs @@ -11,7 +11,7 @@ // error-pattern:1 == 2 -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/str-overrun.rs b/src/test/run-fail/str-overrun.rs index 2465a77661d..f7ece96fd6e 100644 --- a/src/test/run-fail/str-overrun.rs +++ b/src/test/run-fail/str-overrun.rs @@ -15,5 +15,5 @@ fn main() { let s: ~str = ~"hello"; // Bounds-check failure. - assert (s[5] == 0x0 as u8); + fail_unless!((s[5] == 0x0 as u8)); } diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs index 47a99410e9e..17838348b82 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -17,5 +17,5 @@ fn main() { } fn startfn() { - assert str::is_empty(~"Ensure that the child task runs by failing"); + fail_unless!(str::is_empty(~"Ensure that the child task runs by failing")); } diff --git a/src/test/run-fail/unwind-alt.rs b/src/test/run-fail/unwind-alt.rs index 1b28dd0e8ef..035afa781de 100644 --- a/src/test/run-fail/unwind-alt.rs +++ b/src/test/run-fail/unwind-alt.rs @@ -16,7 +16,7 @@ fn test_box() { fn test_str() { let res = match false { true => { ~"happy" }, _ => fail!(~"non-exhaustive match failure") }; - assert res == ~"happy"; + fail_unless!(res == ~"happy"); } fn main() { test_box(); diff --git a/src/test/run-fail/unwind-assert.rs b/src/test/run-fail/unwind-assert.rs index 1efff172d7c..1d5397e7d38 100644 --- a/src/test/run-fail/unwind-assert.rs +++ b/src/test/run-fail/unwind-assert.rs @@ -12,5 +12,5 @@ fn main() { let a = @0; - assert false; + fail_unless!(false); } diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index fb47469adef..46176425249 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -14,8 +14,8 @@ fn main() { let v: ~[int] = ~[10]; let x: int = 0; - assert (v[x] == 10); + fail_unless!((v[x] == 10)); // Bounds-check failure. - assert (v[x + 2] == 20); + fail_unless!((v[x + 2] == 20)); } diff --git a/src/test/run-fail/vec-underrun.rs b/src/test/run-fail/vec-underrun.rs index cae2c2693f3..c01dbf03455 100644 --- a/src/test/run-fail/vec-underrun.rs +++ b/src/test/run-fail/vec-underrun.rs @@ -14,8 +14,8 @@ fn main() { let v: ~[int] = ~[10, 20]; let x: int = 0; - assert (v[x] == 10); + fail_unless!((v[x] == 10)); // Bounds-check failure. - assert (v[x - 1] == 20); + fail_unless!((v[x - 1] == 20)); } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 6f7276af798..311760b6aa5 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -15,7 +15,7 @@ extern mod std; use core::vec::{same_length, zip}; fn enum_chars(start: u8, end: u8) -> ~[char] { - assert start < end; + fail_unless!(start < end); let mut i = start; let mut r = ~[]; while i <= end { r.push(i as char); i += 1 as u8; } @@ -23,7 +23,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { } fn enum_uints(start: uint, end: uint) -> ~[uint] { - assert start < end; + fail_unless!(start < end); let mut i = start; let mut r = ~[]; while i <= end { r.push(i); i += 1; } @@ -35,7 +35,7 @@ fn main() { let chars = enum_chars(a, j); let ints = enum_uints(k, l); - assert same_length(chars, ints); + fail_unless!(same_length(chars, ints)); let ps = zip(chars, ints); fail!(~"the impossible happened"); } diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 57b45575b3e..92f80a9aa0d 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -84,7 +84,7 @@ fn check_pp(cx: fake_ext_ctxt, stdout().write_line(s); if expect != ~"" { error!("expect: '%s', got: '%s'", expect, s); - assert s == expect; + fail_unless!(s == expect); } } 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 d62c719edf1..4c99e6f1a09 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -20,6 +20,6 @@ fn f(a: A, b: u16) -> @fn() -> (A, u16) { pub fn main() { let (a, b) = f(22_u64, 44u16)(); debug!("a=%? b=%?", a, b); - assert a == 22u64; - assert b == 44u16; + fail_unless!(a == 22u64); + fail_unless!(b == 44u16); } diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 1de3fde58f2..5bf8051cc1a 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -35,6 +35,6 @@ pub fn main() { make_cycle(z); let (a, b) = z(); debug!("a=%u b=%u", *a as uint, b as uint); - assert *a == x; - assert b == y; + fail_unless!(*a == x); + fail_unless!(b == y); } diff --git a/src/test/run-pass/alt-implicit-copy-unique.rs b/src/test/run-pass/alt-implicit-copy-unique.rs index e73eb57d607..c00b185d131 100644 --- a/src/test/run-pass/alt-implicit-copy-unique.rs +++ b/src/test/run-pass/alt-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/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index 647be966df4..97b835f55be 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -25,7 +25,7 @@ fn foo(s: @int) { _ => { debug!("?"); fail!(); } } log(debug, ::core::sys::refcount(s)); - assert (::core::sys::refcount(s) == count + 1u); + fail_unless!((::core::sys::refcount(s) == count + 1u)); let _ = ::core::sys::refcount(s); // don't get bitten by last-use. } @@ -39,5 +39,5 @@ pub fn main() { log(debug, ::core::sys::refcount(s)); let count2 = ::core::sys::refcount(s); let _ = ::core::sys::refcount(s); // don't get bitten by last-use. - assert count == count2; + fail_unless!(count == count2); } diff --git a/src/test/run-pass/alt-pattern-lit.rs b/src/test/run-pass/alt-pattern-lit.rs index 22512a47fe0..37f924dd1be 100644 --- a/src/test/run-pass/alt-pattern-lit.rs +++ b/src/test/run-pass/alt-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/alt-ref-binding-in-guard-3256.rs b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs index d9c348cf993..ece2943a1c1 100644 --- a/src/test/run-pass/alt-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs @@ -12,7 +12,7 @@ pub fn main() { let x = Some(unstable::exclusive(true)); match x { Some(ref z) if z.with(|b| *b) => { - do z.with |b| { assert *b; } + do z.with |b| { fail_unless!(*b); } }, _ => fail!() } diff --git a/src/test/run-pass/alt-ref-binding-mut-option.rs b/src/test/run-pass/alt-ref-binding-mut-option.rs index 50bcd3644ed..f6c5e64b353 100644 --- a/src/test/run-pass/alt-ref-binding-mut-option.rs +++ b/src/test/run-pass/alt-ref-binding-mut-option.rs @@ -14,5 +14,5 @@ pub fn main() { None => {} Some(ref mut p) => { *p += 1; } } - assert v == Some(23); + fail_unless!(v == Some(23)); } diff --git a/src/test/run-pass/alt-ref-binding-mut.rs b/src/test/run-pass/alt-ref-binding-mut.rs index 9f062f7b001..c8b1822e5fa 100644 --- a/src/test/run-pass/alt-ref-binding-mut.rs +++ b/src/test/run-pass/alt-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 v.f == 23; + fail_unless!(v.f == 23); } diff --git a/src/test/run-pass/alt-ref-binding.rs b/src/test/run-pass/alt-ref-binding.rs index abb7aa30a01..8b25d329b9a 100644 --- a/src/test/run-pass/alt-ref-binding.rs +++ b/src/test/run-pass/alt-ref-binding.rs @@ -16,5 +16,5 @@ fn destructure(x: Option) -> int { } pub fn main() { - assert destructure(Some(22)) == 22; + fail_unless!(destructure(Some(22)) == 22); } diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index d98dc11801e..4a362ca8e87 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -24,7 +24,7 @@ pub fn main() { } let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() }; - assert (x == 1); + fail_unless!((x == 1)); match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() } diff --git a/src/test/run-pass/alt-tag.rs b/src/test/run-pass/alt-tag.rs index 624c57a614e..aff2d9ad564 100644 --- a/src/test/run-pass/alt-tag.rs +++ b/src/test/run-pass/alt-tag.rs @@ -32,7 +32,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 (process(gray) == 127); - assert (process(clear) == 0); - assert (process(red) == 255); + fail_unless!((process(gray) == 127)); + fail_unless!((process(clear) == 0)); + fail_unless!((process(red) == 255)); } diff --git a/src/test/run-pass/alt-unique-bind.rs b/src/test/run-pass/alt-unique-bind.rs index 902f95e7ef1..6412cc7ffd5 100644 --- a/src/test/run-pass/alt-unique-bind.rs +++ b/src/test/run-pass/alt-unique-bind.rs @@ -12,7 +12,7 @@ pub fn main() { match ~100 { ~x => { debug!("%?", x); - assert x == 100; + fail_unless!(x == 100); } } } diff --git a/src/test/run-pass/alt-with-ret-arm.rs b/src/test/run-pass/alt-with-ret-arm.rs index 29247e47fa5..ccdbc744ca3 100644 --- a/src/test/run-pass/alt-with-ret-arm.rs +++ b/src/test/run-pass/alt-with-ret-arm.rs @@ -16,6 +16,6 @@ pub fn main() { None => return (), Some(num) => num as u32 }; - assert f == 1234u32; + fail_unless!(f == 1234u32); log(error, f) } diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 95c23753c27..186fdb28494 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -23,9 +23,9 @@ fn f2(a: int, f: &fn(int)) -> int { f(1); return a; } pub fn main() { let mut a = X {x: 1}, b = 2, c = 3; - assert (f1(&mut a, &mut b, c) == 6); - assert (a.x == 0); - assert (b == 10); - assert (f2(a.x, |x| a.x = 50) == 0); - assert (a.x == 50); + fail_unless!((f1(&mut a, &mut b, c) == 6)); + fail_unless!((a.x == 0)); + fail_unless!((b == 10)); + fail_unless!((f2(a.x, |x| a.x = 50) == 0)); + fail_unless!((a.x == 50)); } diff --git a/src/test/run-pass/arith-0.rs b/src/test/run-pass/arith-0.rs index 6f5ef7837c3..0725ac2e174 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; log(debug, a); - assert (a * (a - 1) == 90); + fail_unless!((a * (a - 1) == 90)); } diff --git a/src/test/run-pass/arith-1.rs b/src/test/run-pass/arith-1.rs index 652f433e33d..3dc60d63bbe 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 (i32_a == 10); - assert (i32_a - 10 == 0); - assert (i32_a / 10 == 1); - assert (i32_a - 20 == -10); - assert (i32_a << 10 == 10240); - assert (i32_a << 16 == 655360); - assert (i32_a * 16 == 160); - assert (i32_a * i32_a * i32_a == 1000); - assert (i32_a * i32_a * i32_a * i32_a == 10000); - assert (i32_a * i32_a / i32_a * i32_a == 100); - assert (i32_a * (i32_a - 1) << 2 + i32_a == 368640); + fail_unless!((i32_a == 10)); + fail_unless!((i32_a - 10 == 0)); + fail_unless!((i32_a / 10 == 1)); + fail_unless!((i32_a - 20 == -10)); + fail_unless!((i32_a << 10 == 10240)); + fail_unless!((i32_a << 16 == 655360)); + fail_unless!((i32_a * 16 == 160)); + fail_unless!((i32_a * i32_a * i32_a == 1000)); + fail_unless!((i32_a * i32_a * i32_a * i32_a == 10000)); + fail_unless!((i32_a * i32_a / i32_a * i32_a == 100)); + fail_unless!((i32_a * (i32_a - 1) << 2 + i32_a == 368640)); let i32_b: int = 0x10101010; - assert (i32_b + 1 - 1 == i32_b); - assert (i32_b << 1 == i32_b << 1); - assert (i32_b >> 1 == i32_b >> 1); - assert (i32_b & i32_b << 1 == 0); + fail_unless!((i32_b + 1 - 1 == i32_b)); + fail_unless!((i32_b << 1 == i32_b << 1)); + fail_unless!((i32_b >> 1 == i32_b >> 1)); + fail_unless!((i32_b & i32_b << 1 == 0)); log(debug, i32_b | i32_b << 1); - assert (i32_b | i32_b << 1 == 0x30303030); + fail_unless!((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 651bf865eab..45bd35a68af 100644 --- a/src/test/run-pass/arith-unsigned.rs +++ b/src/test/run-pass/arith-unsigned.rs @@ -13,24 +13,24 @@ // Unsigned integer operations pub fn main() { - assert (0u8 < 255u8); - assert (0u8 <= 255u8); - assert (255u8 > 0u8); - assert (255u8 >= 0u8); - assert (250u8 / 10u8 == 25u8); - assert (255u8 % 10u8 == 5u8); - assert (0u16 < 60000u16); - assert (0u16 <= 60000u16); - assert (60000u16 > 0u16); - assert (60000u16 >= 0u16); - assert (60000u16 / 10u16 == 6000u16); - assert (60005u16 % 10u16 == 5u16); - assert (0u32 < 4000000000u32); - assert (0u32 <= 4000000000u32); - assert (4000000000u32 > 0u32); - assert (4000000000u32 >= 0u32); - assert (4000000000u32 / 10u32 == 400000000u32); - assert (4000000005u32 % 10u32 == 5u32); + fail_unless!((0u8 < 255u8)); + fail_unless!((0u8 <= 255u8)); + fail_unless!((255u8 > 0u8)); + fail_unless!((255u8 >= 0u8)); + fail_unless!((250u8 / 10u8 == 25u8)); + fail_unless!((255u8 % 10u8 == 5u8)); + fail_unless!((0u16 < 60000u16)); + fail_unless!((0u16 <= 60000u16)); + fail_unless!((60000u16 > 0u16)); + fail_unless!((60000u16 >= 0u16)); + fail_unless!((60000u16 / 10u16 == 6000u16)); + fail_unless!((60005u16 % 10u16 == 5u16)); + fail_unless!((0u32 < 4000000000u32)); + fail_unless!((0u32 <= 4000000000u32)); + fail_unless!((4000000000u32 > 0u32)); + fail_unless!((4000000000u32 >= 0u32)); + fail_unless!((4000000000u32 / 10u32 == 400000000u32)); + fail_unless!((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 3911c2c76be..e3159df8378 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/assign-assign.rs b/src/test/run-pass/assign-assign.rs index 3f73d61090a..f3a792d6cca 100644 --- a/src/test/run-pass/assign-assign.rs +++ b/src/test/run-pass/assign-assign.rs @@ -12,21 +12,21 @@ fn test_assign() { let mut x: int; let mut y: () = x = 10; - assert (x == 10); + fail_unless!((x == 10)); let mut z = x = 11; - assert (x == 11); + fail_unless!((x == 11)); z = x = 12; - assert (x == 12); + fail_unless!((x == 12)); } fn test_assign_op() { let mut x: int = 0; let mut y: () = x += 10; - assert (x == 10); + fail_unless!((x == 10)); let mut z = x += 11; - assert (x == 21); + fail_unless!((x == 21)); z = x += 12; - assert (x == 33); + fail_unless!((x == 33)); } 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 c537eb9997f..9f13147b276 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -41,17 +41,17 @@ fn length>(x: T) -> uint { pub fn main() { let x = ~[0,1,2,3]; // Call a method - for x.iterate() |y| { assert x[*y] == *y; } + for x.iterate() |y| { fail_unless!(x[*y] == *y); } // Call a parameterized function - assert length(copy x) == vec::len(x); + fail_unless!(length(copy x) == vec::len(x)); // Call a parameterized function, with type arguments that require // a borrow - assert length::(x) == vec::len(x); + fail_unless!(length::(x) == vec::len(x)); // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; // Call a method - for z.iterate() |y| { assert z[*y] == *y; } + for z.iterate() |y| { fail_unless!(z[*y] == *y); } // Call a parameterized function - assert length::(z) == vec::len(z); + fail_unless!(length::(z) == vec::len(z)); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 171e7a836be..f9e5ebf261c 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -34,7 +34,7 @@ fn test_prettyprint>( a.encode(&prettyprint::Serializer(w)) }; debug!("s == %?", s); - assert s == *expected; + fail_unless!(s == *expected); } fn test_ebml(x: ~[T]) -> T { return x[0]; } fn g(act: fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } pub fn main() { - assert (g(f) == 1); + fail_unless!((g(f) == 1)); let f1: fn(~[~str]) -> ~str = f; - assert (f1(~[~"x", ~"y", ~"z"]) == ~"x"); + fail_unless!((f1(~[~"x", ~"y", ~"z"]) == ~"x")); } diff --git a/src/test/run-pass/autoderef-method-newtype.rs b/src/test/run-pass/autoderef-method-newtype.rs index 5eb4d6dcaf3..9cd4093787d 100644 --- a/src/test/run-pass/autoderef-method-newtype.rs +++ b/src/test/run-pass/autoderef-method-newtype.rs @@ -20,5 +20,5 @@ enum foo = uint; pub fn main() { let x = foo(3u); - assert x.double() == 6u; + fail_unless!(x.double() == 6u); } diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 65a274d7764..3d64c5d0e42 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 x.double() == 6u; + fail_unless!(x.double() == 6u); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index be028a789c9..a3d4e28dec7 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -22,5 +22,5 @@ impl double for @uint { pub fn main() { let x = @3u; - assert x.double() == 6u; + fail_unless!(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 52f7a0ba72e..9a6469bbca8 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 x.double() == 6u; + fail_unless!(x.double() == 6u); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 1a8d550e9e7..c44ded77ec8 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 x.double() == 6u; + fail_unless!(x.double() == 6u); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 1e61f194354..e6b05989903 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 x.double() == 6u; + fail_unless!(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 8bc02eb2f9f..0b872569f19 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -26,5 +26,5 @@ impl Foo for uint { pub fn main() { let x = @3u; - assert x.foo() == ~"@3"; + fail_unless!(x.foo() == ~"@3"); } diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index 4a4f6c9bce7..03c6a60016d 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -9,11 +9,11 @@ // except according to those terms. pub fn main() { - assert 0xffffffffu32 == (-1 as u32); - assert 4294967295u32 == (-1 as u32); - assert 0xffffffffffffffffu64 == (-1 as u64); - assert 18446744073709551615u64 == (-1 as u64); + fail_unless!(0xffffffffu32 == (-1 as u32)); + fail_unless!(4294967295u32 == (-1 as u32)); + fail_unless!(0xffffffffffffffffu64 == (-1 as u64)); + fail_unless!(18446744073709551615u64 == (-1 as u64)); - assert -2147483648i32 - 1i32 == 2147483647i32; - assert -9223372036854775808i64 - 1i64 == 9223372036854775807i64; + fail_unless!(-2147483648i32 - 1i32 == 2147483647i32); + fail_unless!(-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 b7fa7915aa5..2153db5e40c 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 1-1 == 0; + fail_unless!(1-1 == 0); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index e8866f78430..bcc76cc3585 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -11,55 +11,55 @@ // Binop corner cases fn test_nil() { - assert (() == ()); - assert (!(() != ())); - assert (!(() < ())); - assert (() <= ()); - assert (!(() > ())); - assert (() >= ()); + fail_unless!((() == ())); + 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 (false & false == false); - assert (true & false == false); - assert (true & true == true); - assert (false | false == false); - assert (true | false == true); - assert (true | true == true); - assert (false ^ false == false); - assert (true ^ false == true); - assert (true ^ true == false); + fail_unless!((false & false == false)); + fail_unless!((true & false == false)); + fail_unless!((true & true == true)); + fail_unless!((false | false == false)); + fail_unless!((true | false == true)); + fail_unless!((true | true == true)); + fail_unless!((false ^ false == false)); + fail_unless!((true ^ false == true)); + fail_unless!((true ^ true == false)); } fn test_char() { let ch10 = 10 as char; let ch4 = 4 as char; let ch2 = 2 as char; - assert (ch10 + ch4 == 14 as char); - assert (ch10 - ch4 == 6 as char); - assert (ch10 * ch4 == 40 as char); - assert (ch10 / ch4 == ch2); - assert (ch10 % ch4 == ch2); - assert (ch10 >> ch2 == ch2); - assert (ch10 << ch4 == 160 as char); - assert (ch10 | ch4 == 14 as char); - assert (ch10 & ch2 == ch2); - assert (ch10 ^ ch2 == 8 as char); + fail_unless!((ch10 + ch4 == 14 as char)); + fail_unless!((ch10 - ch4 == 6 as char)); + fail_unless!((ch10 * ch4 == 40 as char)); + fail_unless!((ch10 / ch4 == ch2)); + fail_unless!((ch10 % ch4 == ch2)); + fail_unless!((ch10 >> ch2 == ch2)); + fail_unless!((ch10 << ch4 == 160 as char)); + fail_unless!((ch10 | ch4 == 14 as char)); + fail_unless!((ch10 & ch2 == ch2)); + fail_unless!((ch10 ^ ch2 == 8 as char)); } fn test_box() { - assert (@10 == @10); + fail_unless!((@10 == @10)); } fn test_ptr() { @@ -68,14 +68,14 @@ fn test_ptr() { let p2: *u8 = ::core::cast::reinterpret_cast(&0); let p3: *u8 = ::core::cast::reinterpret_cast(&1); - assert 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 == 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); } } @@ -110,11 +110,11 @@ fn test_class() { (::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))), (::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r)))); } - assert(q == r); + fail_unless!((q == r)); r.y = 17; - assert(r.y != q.y); - assert(r.y == 17); - assert(q != r); + fail_unless!((r.y != q.y)); + fail_unless!((r.y == 17)); + fail_unless!((q != r)); } pub fn main() { diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index 680ffb73855..a2caf5e97f5 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -12,12 +12,12 @@ #[cfg(target_arch = "x86")] fn target() { - assert (-1000 as uint >> 3u == 536870787u); + fail_unless!((-1000 as uint >> 3u == 536870787u)); } #[cfg(target_arch = "x86_64")] fn target() { - assert (-1000 as uint >> 3u == 2305843009213693827u); + fail_unless!((-1000 as uint >> 3u == 2305843009213693827u)); } fn general() { @@ -28,14 +28,14 @@ fn general() { a = a ^ b; log(debug, a); log(debug, b); - assert (b == 1); - assert (a == 2); - assert (!0xf0 & 0xff == 0xf); - assert (0xf0 | 0xf == 0xff); - assert (0xf << 4 == 0xf0); - assert (0xf0 >> 4 == 0xf); - assert (-16 >> 2 == -4); - assert (0b1010_1010 | 0b0101_0101 == 0xff); + fail_unless!((b == 1)); + fail_unless!((a == 2)); + fail_unless!((!0xf0 & 0xff == 0xf)); + fail_unless!((0xf0 | 0xf == 0xff)); + fail_unless!((0xf << 4 == 0xf0)); + fail_unless!((0xf0 >> 4 == 0xf)); + fail_unless!((-16 >> 2 == -4)); + fail_unless!((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 1549eb6fbc2..f0dafa0805e 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -24,9 +24,9 @@ fn asBlock( f : &fn()->uint ) -> uint { pub fn main() { let x = asSendfn(|| 22u); - assert(x == 22u); + fail_unless!((x == 22u)); let x = asLambda(|| 22u); - assert(x == 22u); + fail_unless!((x == 22u)); let x = asBlock(|| 22u); - assert(x == 22u); + fail_unless!((x == 22u)); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs index 09bfe1720f7..b46aad99845 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs @@ -14,5 +14,5 @@ pub fn main() { // Trailing expressions don't require parentheses: let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f; - assert y == 15f; + fail_unless!(y == 15f); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index f908bbf745a..94d568b7158 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -12,5 +12,5 @@ pub fn main() { fn f(i: fn() -> uint) -> uint { i() } let v = ~[-1f, 0f, 1f, 2f, 3f]; let z = do do vec::foldl(f, v) |x, _y| { x } { 22u }; - assert z == 22u; + fail_unless!(z == 22u); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-call.rs b/src/test/run-pass/block-arg-can-be-followed-by-call.rs index 9fd3c76bd34..bbdbfc74b0e 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-call.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-call.rs @@ -12,5 +12,5 @@ pub fn main() { fn f(i: uint) -> uint { i } let v = ~[-1f, 0f, 1f, 2f, 3f]; let z = do vec::foldl(f, v) |x, _y| { x } (22u); - assert z == 22u; + fail_unless!(z == 22u); } diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index 8eb0a8bef93..f74c531503f 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -28,9 +28,9 @@ fn w_ret(v: ~[int]) -> int { } pub fn main() { - assert w_semi(~[0, 1, 2, 3]) == -10; - assert w_paren1(~[0, 1, 2, 3]) == -4; - assert w_paren2(~[0, 1, 2, 3]) == -4; - assert w_ret(~[0, 1, 2, 3]) == -4; + fail_unless!(w_semi(~[0, 1, 2, 3]) == -10); + fail_unless!(w_paren1(~[0, 1, 2, 3]) == -4); + fail_unless!(w_paren2(~[0, 1, 2, 3]) == -4); + fail_unless!(w_ret(~[0, 1, 2, 3]) == -4); } diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index af2e6815e07..6d311a13828 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -14,5 +14,5 @@ fn call_any(f: fn() -> uint) -> uint { pub fn main() { let x_r = do call_any { 22u }; - assert x_r == 22u; + fail_unless!(x_r == 22u); } diff --git a/src/test/run-pass/block-arg-used-as-lambda.rs b/src/test/run-pass/block-arg-used-as-lambda.rs index 04adeb9c71b..6d26ede8e3a 100644 --- a/src/test/run-pass/block-arg-used-as-lambda.rs +++ b/src/test/run-pass/block-arg-used-as-lambda.rs @@ -19,6 +19,6 @@ pub fn main() { let x_r = x(22u); let y_r = y(x_r); - assert x_r == 44u; - assert y_r == 88u; + fail_unless!(x_r == 44u); + fail_unless!(y_r == 88u); } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index d85a51997e1..fa4a61549dc 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -19,20 +19,20 @@ pub fn main() { // Usable at all: let mut any_negative = do vec::any(v) |e| { float::is_negative(*e) }; - assert any_negative; + fail_unless!(any_negative); // Higher precedence than assignments: any_negative = do vec::any(v) |e| { float::is_negative(*e) }; - assert any_negative; + fail_unless!(any_negative); // Higher precedence than unary operations: let abs_v = do vec::map(v) |e| { float::abs(*e) }; - assert do vec::all(abs_v) |e| { float::is_nonnegative(*e) }; - assert !do vec::any(abs_v) |e| { float::is_negative(*e) }; + fail_unless!(do vec::all(abs_v) |e| { float::is_nonnegative(*e) }); + fail_unless!(!do vec::any(abs_v) |e| { float::is_negative(*e) }); // Usable in funny statement-like forms: if !do vec::any(v) |e| { float::is_positive(*e) } { - assert false; + fail_unless!(false); } match do vec::all(v) |e| { float::is_negative(*e) } { true => { fail!(~"incorrect answer."); } @@ -51,12 +51,12 @@ pub fn main() { let w = do vec::foldl(0f, v) |x, y| { x + *y } + 10f; let y = do vec::foldl(0f, v) |x, y| { x + *y } + 10f; let z = 10f + do vec::foldl(0f, v) |x, y| { x + *y }; - assert w == y; - assert y == z; + fail_unless!(w == y); + fail_unless!(y == z); // In the tail of a block let w = if true { do vec::any(abs_v) |e| { float::is_nonnegative(*e) } } else { false }; - assert w; + fail_unless!(w); } diff --git a/src/test/run-pass/block-expr-precedence.rs b/src/test/run-pass/block-expr-precedence.rs index 7d56a6a46ff..39e19cfec97 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 if (true) { 12 } else { 12 } - num == 0; - assert 12 - if (true) { 12 } else { 12 } == 0; + fail_unless!(if (true) { 12 } else { 12 } - num == 0); + fail_unless!(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 3cd5f36fcb6..4593934d523 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: fn() -> int) -> int { return f(); } pub fn main() { fn f() -> int { return 7; } - assert (force(f) == 7); + fail_unless!((force(f) == 7)); let g = {||force(f)}; - assert (g() == 7); + fail_unless!((g() == 7)); } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index b23ce112267..571e67b4e5b 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -23,5 +23,5 @@ pub fn main() { log(error, odds); }); log(error, odds); - assert (odds == 4); + fail_unless!((odds == 4)); } diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index df49fc6a4ef..1ec5c781807 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -22,5 +22,5 @@ pub fn main() { }); }); log(error, sum); - assert (sum == 225); + fail_unless!((sum == 225)); } diff --git a/src/test/run-pass/block-vec-map2.rs b/src/test/run-pass/block-vec-map2.rs index cfc18d29e78..24f990ef7cd 100644 --- a/src/test/run-pass/block-vec-map2.rs +++ b/src/test/run-pass/block-vec-map2.rs @@ -16,5 +16,5 @@ pub fn main() { ~[true, false, false, true, true], |i, b| if *b { -(*i) } else { *i } ); log(error, copy v); - assert (v == ~[-1, 2, 3, -4, -5]); + fail_unless!((v == ~[-1, 2, 3, -4, -5])); } diff --git a/src/test/run-pass/bool-not.rs b/src/test/run-pass/bool-not.rs index d79b6f73398..656abab0cc1 100644 --- a/src/test/run-pass/bool-not.rs +++ b/src/test/run-pass/bool-not.rs @@ -13,6 +13,6 @@ // -*- rust -*- 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-at-vec.rs b/src/test/run-pass/borrowck-borrow-from-at-vec.rs index 0b15adb82bf..6757f8655f1 100644 --- a/src/test/run-pass/borrowck-borrow-from-at-vec.rs +++ b/src/test/run-pass/borrowck-borrow-from-at-vec.rs @@ -16,5 +16,5 @@ fn sum_slice(x: &[int]) -> int { pub fn main() { let x = @[1, 2, 3]; - assert sum_slice(x) == 6; + fail_unless!(sum_slice(x) == 6); } 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 4196527728a..f2bde5a9f4b 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -15,8 +15,8 @@ fn borrow(x: &int, f: fn(x: &int)) { fn test1(x: @~int) { do borrow(copy *x) |p| { let x_a = ptr::addr_of(&(**x)); - assert (x_a as uint) != ptr::to_uint(p); - assert unsafe{*x_a} == *p; + fail_unless!((x_a as uint) != ptr::to_uint(p)); + fail_unless!(unsafe{*x_a} == *p); } } diff --git a/src/test/run-pass/borrowck-fixed-length-vecs.rs b/src/test/run-pass/borrowck-fixed-length-vecs.rs index 647c0b646cf..764f5510481 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 *y == 22; + fail_unless!(*y == 22); } 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 62e58412a73..a90381ad631 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 has_mut_vec(~[1, 2, 3]) == 6; + fail_unless!(has_mut_vec(~[1, 2, 3]) == 6); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-discr.rs b/src/test/run-pass/borrowck-preserve-box-in-discr.rs index c6fc92bd56d..ba1c6aec215 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-discr.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-discr.rs @@ -16,14 +16,14 @@ pub fn main() { let mut x = @F {f: ~3}; match x { @F {f: ref b_x} => { - assert **b_x == 3; - assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(**b_x)); + fail_unless!(**b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(**b_x))); x = @F {f: ~4}; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint); - assert **b_x == 3; - assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)); + fail_unless!(**b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x))); } } } 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 5cea4129857..0b84ba4ff59 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -14,7 +14,7 @@ fn borrow(x: &int, f: fn(x: &int)) { let before = *x; f(x); let after = *x; - assert before == after; + fail_unless!(before == after); } struct F { f: ~int } @@ -22,12 +22,12 @@ struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; do borrow(x.f) |b_x| { - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x))); x = @F {f: ~4}; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint); - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x))); } } diff --git a/src/test/run-pass/borrowck-preserve-box-in-pat.rs b/src/test/run-pass/borrowck-preserve-box-in-pat.rs index 29d94a0e8ea..374283ffb8a 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-pat.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-pat.rs @@ -16,14 +16,14 @@ pub fn main() { let mut x = @mut @F {f: ~3}; match x { @@F{f: ref b_x} => { - assert **b_x == 3; - assert ptr::addr_of(&(x.f)) == ptr::addr_of(b_x); + fail_unless!(**b_x == 3); + fail_unless!(ptr::addr_of(&(x.f)) == ptr::addr_of(b_x)); *x = @F {f: ~4}; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint); - assert **b_x == 3; - assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)); + fail_unless!(**b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x))); } } } 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 b11a5356f69..fedd8c42e8f 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -14,7 +14,7 @@ fn borrow(x: &int, f: fn(x: &int)) { let before = *x; f(x); let after = *x; - assert before == after; + fail_unless!(before == after); } struct F { f: ~int } @@ -22,12 +22,12 @@ struct F { f: ~int } pub fn main() { let mut x = ~@F{f: ~3}; do borrow(x.f) |b_x| { - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x))); *x = @F{f: ~4}; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint); - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x))); } } diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index 70f26d12dcd..ec9e82c7731 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -14,18 +14,18 @@ fn borrow(x: &int, f: fn(x: &int)) { let before = *x; f(x); let after = *x; - assert before == after; + fail_unless!(before == after); } pub fn main() { let mut x = @3; do borrow(x) |b_x| { - assert *b_x == 3; - assert ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x))); x = @22; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint); - assert *b_x == 3; - assert ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x))); } } diff --git a/src/test/run-pass/borrowck-preserve-cond-box.rs b/src/test/run-pass/borrowck-preserve-cond-box.rs index ca785558be3..808f333dbf1 100644 --- a/src/test/run-pass/borrowck-preserve-cond-box.rs +++ b/src/test/run-pass/borrowck-preserve-cond-box.rs @@ -25,13 +25,13 @@ fn testfn(cond: bool) { } debug!("*r = %d, exp = %d", *r, exp); - assert *r == exp; + fail_unless!(*r == exp); x = @5; y = @6; debug!("*r = %d, exp = %d", *r, exp); - assert *r == exp; + fail_unless!(*r == exp); } 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 8e16565bf53..fd64507daa1 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -14,7 +14,7 @@ fn borrow(x: &int, f: fn(x: &int)) { let before = *x; f(x); let after = *x; - assert before == after; + fail_unless!(before == after); } struct F { f: ~int } @@ -22,12 +22,12 @@ struct F { f: ~int } pub fn main() { let mut x = @F {f: ~3}; do borrow((*x).f) |b_x| { - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x))); x = @F {f: ~4}; debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint); - assert *b_x == 3; - assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)); + fail_unless!(*b_x == 3); + fail_unless!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x))); } } diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 530870191f5..e43bcecaa9f 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -25,5 +25,5 @@ pub fn main() { *x * b } }; - assert z == 18; + fail_unless!(z == 18); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-2.rs b/src/test/run-pass/borrowed-ptr-pattern-2.rs index 48af01c6f55..e1e5d685428 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 138b224e3cb..9043018b816 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(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/borrowed-ptr-pattern-infallible.rs b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs index e28b4e425eb..1f7464c3ad4 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs @@ -10,7 +10,7 @@ pub fn main() { let (&x, &y, &z) = (&3, &'a', &@"No pets!"); - assert x == 3; - assert y == 'a'; - assert z == @"No pets!"; + fail_unless!(x == 3); + fail_unless!(y == 'a'); + fail_unless!(z == @"No pets!"); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-option.rs b/src/test/run-pass/borrowed-ptr-pattern-option.rs index 5fcc2ca6b47..d0d276a8c8c 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(x: &r/Option, y: &r/Option) -> &r/Option { pub fn main() { let x = None; let y = Some(3); - assert select(&x, &y).get() == 3; + fail_unless!(select(&x, &y).get() == 3); } diff --git a/src/test/run-pass/borrowed-ptr-pattern.rs b/src/test/run-pass/borrowed-ptr-pattern.rs index b51481f1ea1..e092dea3d1c 100644 --- a/src/test/run-pass/borrowed-ptr-pattern.rs +++ b/src/test/run-pass/borrowed-ptr-pattern.rs @@ -15,7 +15,7 @@ fn foo(x: &T) -> T{ } pub fn main() { - assert foo(&3) == 3; - assert foo(&'a') == 'a'; - assert foo(&@"Dogs rule, cats drool") == @"Dogs rule, cats drool"; + fail_unless!(foo(&3) == 3); + fail_unless!(foo(&'a') == 'a'); + fail_unless!(foo(&@"Dogs rule, cats drool") == @"Dogs rule, cats drool"); } diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs index 4893040ff34..bceedcad4a8 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-unbox.rs b/src/test/run-pass/box-unbox.rs index 1efe12c1a3c..81ccfe5f4fa 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}; debug!("see what's in our box"); - assert (unbox::(bfoo) == foo); + fail_unless!((unbox::(bfoo) == foo)); } diff --git a/src/test/run-pass/box.rs b/src/test/run-pass/box.rs index 05b32150e2d..12276e4cfa6 100644 --- a/src/test/run-pass/box.rs +++ b/src/test/run-pass/box.rs @@ -10,4 +10,4 @@ -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 9d4b0dffdba..f65e8481562 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -13,21 +13,21 @@ pub fn main() { let mut i = 0; while i < 20 { i += 1; if i == 10 { break; } } - assert (i == 10); + fail_unless!((i == 10)); loop { i += 1; if i == 20 { break; } } - assert (i == 20); + fail_unless!((i == 20)); for vec::each(~[1, 2, 3, 4, 5, 6]) |x| { - 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 { loop; } assert (i % 2 != 0); } + while i < 10 { i += 1; if i % 2 == 0 { loop; } fail_unless!((i % 2 != 0)); } i = 0; loop { - i += 1; if i % 2 == 0 { loop; } assert (i % 2 != 0); + i += 1; if i % 2 == 0 { loop; } fail_unless!((i % 2 != 0)); if i >= 10 { break; } } for vec::each(~[1, 2, 3, 4, 5, 6]) |x| { if *x % 2 == 0 { loop; } - assert (*x % 2 != 0); + fail_unless!((*x % 2 != 0)); } } diff --git a/src/test/run-pass/by-val-and-by-move.rs b/src/test/run-pass/by-val-and-by-move.rs index d361b20e833..673c558f98c 100644 --- a/src/test/run-pass/by-val-and-by-move.rs +++ b/src/test/run-pass/by-val-and-by-move.rs @@ -22,5 +22,5 @@ fn free(-_t: T) { pub fn main() { let z = @3; - assert 3 == it_takes_two(z, z); + fail_unless!(3 == it_takes_two(z, z)); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index a16e45a1cf4..158c18868d6 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -29,7 +29,7 @@ fn atoll(s: ~str) -> i64 { pub fn main() { unsafe { - assert atol(~"1024") * 10 == atol(~"10240"); + fail_unless!(atol(~"1024") * 10 == atol(~"10240")); assert (atoll(~"11111111111111111") * 10i64) == 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 5abf499937a..9d2c6f23198 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 x = dvec::DVec::<@fn() -> int>(); x.push(foo); - assert (x[0])() == 22; + fail_unless!((x[0])() == 22); } diff --git a/src/test/run-pass/cap-clause-move.rs b/src/test/run-pass/cap-clause-move.rs index 7089e596619..44f9b3e990e 100644 --- a/src/test/run-pass/cap-clause-move.rs +++ b/src/test/run-pass/cap-clause-move.rs @@ -12,20 +12,20 @@ pub fn main() { let x = ~1; let y = ptr::addr_of(&(*x)) as uint; let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint; - assert lam_move() == y; + fail_unless!(lam_move() == y); let x = ~2; let y = ptr::addr_of(&(*x)) as uint; let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint; - assert lam_move() == y; + fail_unless!(lam_move() == y); let x = ~3; let y = ptr::addr_of(&(*x)) as uint; let snd_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint; - assert snd_move() == y; + fail_unless!(snd_move() == y); let x = ~4; let y = ptr::addr_of(&(*x)) as uint; let lam_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint; - assert lam_move() == y; + fail_unless!(lam_move() == y); } diff --git a/src/test/run-pass/cast.rs b/src/test/run-pass/cast.rs index b7d23c5176e..97400198167 100644 --- a/src/test/run-pass/cast.rs +++ b/src/test/run-pass/cast.rs @@ -14,13 +14,13 @@ // -*- rust -*- pub fn main() { let i: int = 'Q' as int; - assert (i == 0x51); + fail_unless!((i == 0x51)); let u: u32 = i as u32; - assert (u == 0x51 as u32); - assert (u == 'Q' as u32); - assert (i as u8 == 'Q' as u8); - assert (i as u8 as i8 == 'Q' as u8 as i8); - assert (0x51 as char == 'Q'); - assert (true == 1 as bool); - assert (0 as u32 == false as u32); + fail_unless!((u == 0x51 as u32)); + fail_unless!((u == 'Q' as u32)); + fail_unless!((i as u8 == 'Q' as u8)); + fail_unless!((i as u8 as i8 == 'Q' as u8 as i8)); + fail_unless!((0x51 as char == 'Q')); + fail_unless!((true == 1 as bool)); + fail_unless!((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 def739c1002..7e30910b169 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -18,5 +18,5 @@ pub fn main() { let p = @22u; let r = foo(p); debug!("r=%u", r); - assert r == 22u; + fail_unless!(r == 22u); } diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index 2897ad24fd4..2366582a4ed 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(); //debug!("%?", 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 01054ba44cf..55ecf317f85 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -20,6 +20,6 @@ pub fn main() { //debug!("%?", bt0); do cci_iter_lib::iter(~[1, 2, 3]) |i| { io::print(fmt!("%d", i)); - //assert bt0 == sys::rusti::frame_address(2u32); + //fail_unless!(bt0 == sys::rusti::frame_address(2u32)); } } diff --git a/src/test/run-pass/cci_nested_exe.rs b/src/test/run-pass/cci_nested_exe.rs index 26bfd1ad4dc..56b42759599 100644 --- a/src/test/run-pass/cci_nested_exe.rs +++ b/src/test/run-pass/cci_nested_exe.rs @@ -18,12 +18,12 @@ pub fn main() { let lst = new_int_alist(); alist_add(lst, 22, ~"hi"); alist_add(lst, 44, ~"ho"); - assert alist_get(lst, 22) == ~"hi"; - assert alist_get(lst, 44) == ~"ho"; + fail_unless!(alist_get(lst, 22) == ~"hi"); + fail_unless!(alist_get(lst, 44) == ~"ho"); let lst = new_int_alist_2(); alist_add(lst, 22, ~"hi"); alist_add(lst, 44, ~"ho"); - assert alist_get(lst, 22) == ~"hi"; - assert alist_get(lst, 44) == ~"ho"; + fail_unless!(alist_get(lst, 22) == ~"hi"); + fail_unless!(alist_get(lst, 44) == ~"ho"); } diff --git a/src/test/run-pass/cci_no_inline_exe.rs b/src/test/run-pass/cci_no_inline_exe.rs index f0adaca8242..f2e6eeb31ff 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(); //debug!("%?", bt1); - //assert bt0 != bt1; + //fail_unless!(bt0 != bt1); } } diff --git a/src/test/run-pass/char.rs b/src/test/run-pass/char.rs index 7900b2ffa7c..d1d1cc84d38 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 (c == 'x'); - assert ('x' == c); - assert (c == c); - assert (c == d); - assert (d == c); - assert (d == 'x'); - assert ('x' == d); + fail_unless!((c == 'x')); + fail_unless!(('x' == c)); + fail_unless!((c == c)); + fail_unless!((c == d)); + fail_unless!((d == c)); + fail_unless!((d == 'x')); + fail_unless!(('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 53c50d7fca0..5f3650d3aec 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::*; fn print_out(thing: @ToStr, expected: ~str) { let actual = thing.to_str(); debug!("%s", actual); - assert(actual == expected); + fail_unless!((actual == expected)); } pub fn main() { diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate.rs b/src/test/run-pass/class-cast-to-trait-cross-crate.rs index d21ff90e7fb..c3f5db0b100 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate.rs @@ -51,7 +51,7 @@ class cat : to_str { fn print_out(thing: T, expected: str) { let actual = thing.to_str(); debug!("%s", actual); - assert(actual == expected); + fail_unless!((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 39466bb8c16..50a3d5cc617 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 @@ -88,6 +88,6 @@ pub fn main() { let whitefang : dog = dog(); annoy_neighbors(@(copy nyan) as @noisy); annoy_neighbors(@(copy whitefang) as @noisy); - assert(nyan.meow_count() == 10u); - assert(*whitefang.volume == 1); + fail_unless!((nyan.meow_count() == 10u)); + fail_unless!((*whitefang.volume == 1)); } diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index f0044f8d17c..85cbbcc23a3 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(cat(~"Spreckles").get_name() == ~"Spreckles"); + fail_unless!((cat(~"Spreckles").get_name() == ~"Spreckles")); } diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 4b4eb1fc774..15972d4bcd0 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -78,6 +78,6 @@ pub fn main() { for uint::range(1u, 5u) |_i| { nyan.speak(); } // cat returns true if uint input is greater than // the number of meows so far - assert(nyan.get(1)); - assert(!nyan.get(10)); + fail_unless!((nyan.get(1))); + fail_unless!((!nyan.get(10))); } 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 34203b091fe..b6169377310 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -129,11 +129,11 @@ priv impl cat { pub fn main() { let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan"); for uint::range(1, 5) |_| { nyan.speak(); } - assert(*nyan.find(&1).unwrap() == ~"nyan"); - assert(nyan.find(&10) == None); + fail_unless!((*nyan.find(&1).unwrap() == ~"nyan")); + fail_unless!((nyan.find(&10) == None)); let mut spotty: cat = cat::new(2, 57, tuxedo); for uint::range(0, 6) |_| { spotty.speak(); } - assert(spotty.len() == 8); - assert(spotty.contains_key(&2)); - assert(spotty.get(&3) == &tuxedo); + fail_unless!((spotty.len() == 8)); + fail_unless!((spotty.contains_key(&2))); + fail_unless!((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 aa77dbb62c0..ed3e3e38c93 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 uint::range(1u, 10u) |_i| { 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 896b139110f..9e6637c9b17 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 uint::range(1u, 10u) |_i| { make_speak(nyan); }; - assert(nyan.eat()); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/class-implements-multiple-traits.rs b/src/test/run-pass/class-implements-multiple-traits.rs index 4b2c2d0d308..22519be0817 100644 --- a/src/test/run-pass/class-implements-multiple-traits.rs +++ b/src/test/run-pass/class-implements-multiple-traits.rs @@ -123,7 +123,7 @@ fn scratched_something(critter: T) -> bool { pub fn main() { let nyan : cat = cat(0u, 2, "nyan"); annoy_neighbors(nyan as noisy); - assert(nyan.meow_count() == 10u); - assert(bite_everything(nyan as bitey)); - assert(scratched_something(nyan as scratchy)); + fail_unless!((nyan.meow_count() == 10u)); + fail_unless!((bite_everything(nyan as bitey))); + fail_unless!((scratched_something(nyan as scratchy))); } diff --git a/src/test/run-pass/class-method-cross-crate.rs b/src/test/run-pass/class-method-cross-crate.rs index bfa61c2f264..cb266c1f9b4 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::*; pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((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 fc5191e522d..2664841e3e4 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::*; pub fn main() { let mut nyan : cat = cat(52u, 99); let mut kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((kitty.how_hungry == 2)); nyan.speak(); - assert(nyan.meow_count() == 53u); + fail_unless!((nyan.meow_count() == 53u)); } diff --git a/src/test/run-pass/class-methods.rs b/src/test/run-pass/class-methods.rs index f65bcf7be8e..0168db2b7b5 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 mut kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((kitty.how_hungry == 2)); nyan.speak(); - assert(nyan.meow_count() == 53u); + fail_unless!((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 a96a1920d92..e87cbc383bc 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::*; pub fn main() { let mut nyan : cat = cat::(52u, 99, ~['p']); let mut kitty = cat(1000u, 2, ~[~"tabby"]); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((kitty.how_hungry == 2)); nyan.speak(~[1u,2u,3u]); - assert(nyan.meow_count() == 55u); + fail_unless!((nyan.meow_count() == 55u)); kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); - assert(kitty.meow_count() == 1004u); + fail_unless!((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 654260d8399..88fe2be2bdb 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(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((kitty.how_hungry == 2)); nyan.speak(~[1,2,3]); - assert(nyan.meow_count() == 55u); + fail_unless!((nyan.meow_count() == 55u)); kitty.speak(~[~"meow", ~"mew", ~"purr", ~"chirp"]); - assert(kitty.meow_count() == 1004u); + fail_unless!((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 eb0d8de7eab..7cba1456ee7 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(); debug!("%s", actual); - assert(actual == expected); + fail_unless!((actual == expected)); } pub fn main() { diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index 5e39b18db73..294c7264c73 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -31,5 +31,5 @@ pub fn main() { let m = int_hash(); m.insert(1, 2); m.insert(3, 4); - assert iter::to_vec(keys(m)) == ~[1, 3]; + fail_unless!(iter::to_vec(keys(m)) == ~[1, 3]); } diff --git a/src/test/run-pass/classes-cross-crate.rs b/src/test/run-pass/classes-cross-crate.rs index 2ab6ce01b24..2999f38caec 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::*; pub fn main() { let mut nyan = cat(0u, 2, ~"nyan"); nyan.eat(); - assert(!nyan.eat()); + fail_unless!((!nyan.eat())); for uint::range(1u, 10u) |_i| { nyan.speak(); }; - assert(nyan.eat()); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/classes-simple-cross-crate.rs b/src/test/run-pass/classes-simple-cross-crate.rs index 74f4b0aac69..b1deb5b5e1a 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::*; pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((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 505537af7a1..bb2da08d5a1 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 mut kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((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 b17e81160e5..850e34db6d1 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 mut nyan : cat = cat(52u, 99); let mut kitty = cat(1000u, 2); - assert(nyan.how_hungry == 99); - assert(kitty.how_hungry == 2); + fail_unless!((nyan.how_hungry == 99)); + fail_unless!((kitty.how_hungry == 2)); } diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index 0d8d7fc37a9..136573fe05b 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 uint::range(1u, 10u) |_i| { nyan.speak(); }; - assert(nyan.eat()); + fail_unless!((nyan.eat())); } diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 9c8ca729a23..08ff8b1ab4f 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -13,8 +13,8 @@ extern mod std; fn f(x : @{a:int, b:int}) { - assert (x.a == 10); - assert (x.b == 12); + fail_unless!((x.a == 10)); + fail_unless!((x.b == 12)); } pub fn main() { 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 8c31b39ac28..7d8b5707d87 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 @@ -24,6 +24,6 @@ fn f(a: A, b: u16) -> @fn() -> (A, u16) { pub fn main() { let (a, b) = f(22_u64, 44u16)(); debug!("a=%? b=%?", a, b); - assert a == 22u64; - assert b == 44u16; + fail_unless!(a == 22u64); + fail_unless!(b == 44u16); } diff --git a/src/test/run-pass/closure-inference.rs b/src/test/run-pass/closure-inference.rs index 33202193acb..246450d2a07 100644 --- a/src/test/run-pass/closure-inference.rs +++ b/src/test/run-pass/closure-inference.rs @@ -16,5 +16,5 @@ fn apply(f: fn(A) -> A, v: A) -> A { f(v) } pub fn main() { let f = {|i| foo(i)}; - assert apply(f, 2) == 3; + fail_unless!(apply(f, 2) == 3); } diff --git a/src/test/run-pass/closure-inference2.rs b/src/test/run-pass/closure-inference2.rs index ed86326cb38..05926761897 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 f(2) == 2; - assert f(5) == 5; + fail_unless!(f(2) == 2); + fail_unless!(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 35f963d8fb9..8fab061b4de 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs @@ -12,5 +12,5 @@ fn foo(speaker: &const SpeechMaker) -> uint { pub fn main() { let mut lincoln = SpeechMaker {speeches: 22}; - assert foo(&const lincoln) == 55; + fail_unless!(foo(&const 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 7b01fe81c67..7ab63f43769 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -12,7 +12,7 @@ fn bip(v: &[uint]) -> ~[uint] { pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; - assert the_vec == foo(the_vec); - assert the_vec == bar(the_vec); - assert the_vec == bip(the_vec); + fail_unless!(the_vec == foo(the_vec)); + fail_unless!(the_vec == bar(the_vec)); + fail_unless!(the_vec == 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 0c31560e981..f89a59ff022 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -11,5 +11,5 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; bar(the_vec); - assert the_vec == ~[100, 3, 2, 1]; + fail_unless!(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 8f0a7a1a4db..2ca19b2299a 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 the_vec == ~[100, 3, 2, 1]; + fail_unless!(the_vec == ~[100, 3, 2, 1]); } diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index da467ae7ba5..c9c04562201 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -17,7 +17,7 @@ pub fn main() { let y = p.recv(); error!("received"); log(error, y); - assert (y == 10); + fail_unless!((y == 10)); } fn child(c: &Chan) { diff --git a/src/test/run-pass/compare-generic-enums.rs b/src/test/run-pass/compare-generic-enums.rs index 591d2666e25..9c91bad0df7 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 0e4c92085ed..0a579916e93 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -88,7 +88,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; @@ -104,7 +104,7 @@ fn test_in_fn_ctxt() { #[cfg(bogus)] const i: int = 0; const i: int = 1; - assert (i == 1); + fail_unless!((i == 1)); } mod test_foreign_items { diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index 6e75758ff77..aa8dffe8eab 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(d == 0x123456789abcdef0); - assert(h == 0x1234); + fail_unless!((d == 0x123456789abcdef0)); + fail_unless!((h == 0x1234)); } _ => fail!() } diff --git a/src/test/run-pass/const-const.rs b/src/test/run-pass/const-const.rs index c07b2e2671e..142bcb7f9a8 100644 --- a/src/test/run-pass/const-const.rs +++ b/src/test/run-pass/const-const.rs @@ -12,5 +12,5 @@ const a: int = 1; const b: int = a + 2; pub fn main() { - assert b == 3; + fail_unless!(b == 3); } diff --git a/src/test/run-pass/const-contents.rs b/src/test/run-pass/const-contents.rs index 512ecc6d351..72db11c64e8 100644 --- a/src/test/run-pass/const-contents.rs +++ b/src/test/run-pass/const-contents.rs @@ -18,10 +18,10 @@ const notb : bool = !true; const neg : int = -(1); pub fn main() { - assert(lsl == 4); - assert(add == 3); - assert(addf == 3.0f); - assert(not == -1); - assert(notb == false); - assert(neg == -1); + fail_unless!((lsl == 4)); + fail_unless!((add == 3)); + fail_unless!((addf == 3.0f)); + fail_unless!((not == -1)); + fail_unless!((notb == false)); + fail_unless!((neg == -1)); } diff --git a/src/test/run-pass/const-enum-newtype-align.rs b/src/test/run-pass/const-enum-newtype-align.rs index 9c9013ef860..5aa9aeafeed 100644 --- a/src/test/run-pass/const-enum-newtype-align.rs +++ b/src/test/run-pass/const-enum-newtype-align.rs @@ -13,5 +13,5 @@ struct S { a: u8, b: E } const C: S = S { a: 0xA5, b: E(0xDEADBEEF) }; pub fn main() { - assert C.b == 0xDEADBEEF; + fail_unless!(C.b == 0xDEADBEEF); } diff --git a/src/test/run-pass/const-enum-struct.rs b/src/test/run-pass/const-enum-struct.rs index f8fb407244b..8ab470461eb 100644 --- a/src/test/run-pass/const-enum-struct.rs +++ b/src/test/run-pass/const-enum-struct.rs @@ -14,6 +14,6 @@ const C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-enum-struct2.rs b/src/test/run-pass/const-enum-struct2.rs index 12bc06d5f06..49078b8efe2 100644 --- a/src/test/run-pass/const-enum-struct2.rs +++ b/src/test/run-pass/const-enum-struct2.rs @@ -14,6 +14,6 @@ const C: S = S { a: V0, b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-enum-tuple.rs b/src/test/run-pass/const-enum-tuple.rs index df41f5129ca..d46207ea812 100644 --- a/src/test/run-pass/const-enum-tuple.rs +++ b/src/test/run-pass/const-enum-tuple.rs @@ -13,6 +13,6 @@ const C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-enum-tuple2.rs b/src/test/run-pass/const-enum-tuple2.rs index ec585f1e0d8..08007b5b67d 100644 --- a/src/test/run-pass/const-enum-tuple2.rs +++ b/src/test/run-pass/const-enum-tuple2.rs @@ -13,6 +13,6 @@ const C: (E, u16, u16) = (V0, 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct.rs b/src/test/run-pass/const-enum-tuplestruct.rs index db2c637f10e..a88bbca7919 100644 --- a/src/test/run-pass/const-enum-tuplestruct.rs +++ b/src/test/run-pass/const-enum-tuplestruct.rs @@ -14,6 +14,6 @@ const C: S = S(V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-enum-tuplestruct2.rs b/src/test/run-pass/const-enum-tuplestruct2.rs index b07ac6cb28f..4bbadd40574 100644 --- a/src/test/run-pass/const-enum-tuplestruct2.rs +++ b/src/test/run-pass/const-enum-tuplestruct2.rs @@ -14,6 +14,6 @@ const C: S = S(V0, 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; - assert n != 0xBAD; - assert n == 0x600D; + fail_unless!(n != 0xBAD); + fail_unless!(n == 0x600D); } diff --git a/src/test/run-pass/const-extern-function.rs b/src/test/run-pass/const-extern-function.rs index 1fd2ebab83f..6b6a3e4d0a4 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 foopy == f; - assert f == s.f; + fail_unless!(foopy == f); + fail_unless!(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 c2c2792e0d2..c13215bb236 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -29,7 +29,7 @@ pub fn main() { io::println(fmt!("%?", p)); io::println(fmt!("%?", q)); io::println(fmt!("%?", t)); - assert p == 3; - assert q == 3; - assert t == 20; + fail_unless!(p == 3); + fail_unless!(q == 3); + fail_unless!(t == 20); } diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index 4e46d67cafe..c3d09a58b5b 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 { f: &'self fn() -> int } const b : Bar/&static = Bar { f: foo }; pub fn main() { - assert (b.f)() == 0xca7f000d; + fail_unless!((b.f)() == 0xca7f000d); } diff --git a/src/test/run-pass/const-negative.rs b/src/test/run-pass/const-negative.rs index 2b6817d4a08..a2550829331 100644 --- a/src/test/run-pass/const-negative.rs +++ b/src/test/run-pass/const-negative.rs @@ -13,5 +13,5 @@ const toplevel_mod: int = -1; pub fn main() { - assert toplevel_mod == -1; + fail_unless!(toplevel_mod == -1); } diff --git a/src/test/run-pass/const-newtype-enum.rs b/src/test/run-pass/const-newtype-enum.rs index 5e1bc7561d9..b96b0e957c9 100644 --- a/src/test/run-pass/const-newtype-enum.rs +++ b/src/test/run-pass/const-newtype-enum.rs @@ -13,8 +13,8 @@ enum Foo = u32; const X: Foo = Foo(17); pub fn main() { - assert(*X == 17); - assert(*Y == 23); + fail_unless!((*X == 17)); + fail_unless!((*Y == 23)); } const Y: Foo = Foo(23); diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index 2709d0d8a56..184a9da6fb7 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 { const X: Foo = Bar; pub fn main() { - assert((X as uint) == 0xDEADBEE); - assert((Y as uint) == 0xDEADBEE); + fail_unless!(((X as uint) == 0xDEADBEE)); + fail_unless!(((Y as uint) == 0xDEADBEE)); } const 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 04d1aa11478..f65d3ea5df7 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 @@ const y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, pub fn main() { let (p, _) = y.x; - assert p == 0xf0f0f0f0_f0f0f0f0; + fail_unless!(p == 0xf0f0f0f0_f0f0f0f0); io::println(fmt!("0x%x", p as uint)); } diff --git a/src/test/run-pass/const-region-ptrs.rs b/src/test/run-pass/const-region-ptrs.rs index c847b4ff0f1..dbb3abe7daf 100644 --- a/src/test/run-pass/const-region-ptrs.rs +++ b/src/test/run-pass/const-region-ptrs.rs @@ -18,6 +18,6 @@ const y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { io::println(fmt!("x = %?", *x)); io::println(fmt!("y = {a: %?, b: %?}", y.a, *(y.b))); - assert *x == 10; - assert *(y.b) == 10; + fail_unless!(*x == 10); + fail_unless!(*(y.b) == 10); } diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index e49488a66e8..b210b20458c 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -25,9 +25,9 @@ const y : foo = foo { b:2, c:3, a: 1 }; const z : &'static foo = &foo { a: 10, b: 22, c: 12 }; pub fn main() { - assert x.b == 2; - assert x == y; - assert z.b == 22; + fail_unless!(x.b == 2); + fail_unless!(x == y); + fail_unless!(z.b == 22); io::println(fmt!("0x%x", x.b as uint)); io::println(fmt!("0x%x", z.c as uint)); } diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index 9f8618d82ca..9a25a2eb1aa 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -15,8 +15,8 @@ const X: Bar = Bar(1, 2); pub fn main() { match X { Bar(x, y) => { - assert x == 1; - assert y == 2; + fail_unless!(x == 1); + fail_unless!(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 a719af7120e..1e86ff3515b 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 @@ const y : &'static [int] = &[1,2,3,4]; pub fn main() { io::println(fmt!("%?", x[1])); io::println(fmt!("%?", y[1])); - assert x[1] == 2; - assert x[3] == 4; - assert x[3] == y[3]; + fail_unless!(x[1] == 2); + fail_unless!(x[3] == 4); + fail_unless!(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 1356ff0a043..e6841495880 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -18,6 +18,6 @@ pub fn main() { BAR => 2, _ => 3 }; - assert y == 2; + fail_unless!(y == 2); } diff --git a/src/test/run-pass/crateresolve1.rs b/src/test/run-pass/crateresolve1.rs index 4b037919154..819e8d4901a 100644 --- a/src/test/run-pass/crateresolve1.rs +++ b/src/test/run-pass/crateresolve1.rs @@ -16,5 +16,5 @@ extern mod crateresolve1(vers = "0.2"); pub fn main() { - assert crateresolve1::f() == 20; + fail_unless!(crateresolve1::f() == 20); } diff --git a/src/test/run-pass/crateresolve2.rs b/src/test/run-pass/crateresolve2.rs index dd9f60687b3..9312c9c2a51 100644 --- a/src/test/run-pass/crateresolve2.rs +++ b/src/test/run-pass/crateresolve2.rs @@ -15,17 +15,17 @@ mod a { extern mod crateresolve2(vers = "0.1"); - pub fn f() { assert crateresolve2::f() == 10; } + pub fn f() { fail_unless!(crateresolve2::f() == 10); } } mod b { extern mod crateresolve2(vers = "0.2"); - pub fn f() { assert crateresolve2::f() == 20; } + pub fn f() { fail_unless!(crateresolve2::f() == 20); } } mod c { extern mod crateresolve2(vers = "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 71f0fa8adfa..51dde6cd9c3 100644 --- a/src/test/run-pass/crateresolve3.rs +++ b/src/test/run-pass/crateresolve3.rs @@ -17,12 +17,12 @@ mod a { extern mod crateresolve3(vers = "0.1"); - pub fn f() { assert crateresolve3::f() == 10; } + pub fn f() { fail_unless!(crateresolve3::f() == 10); } } mod b { extern mod crateresolve3(vers = "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 4e664c41aa3..ba35170b147 100644 --- a/src/test/run-pass/crateresolve4.rs +++ b/src/test/run-pass/crateresolve4.rs @@ -16,12 +16,12 @@ pub mod a { extern mod crateresolve4b(vers = "0.1"); - pub fn f() { assert crateresolve4b::f() == 20; } + pub fn f() { fail_unless!(crateresolve4b::f() == 20); } } pub mod b { extern mod crateresolve4b(vers = "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 d6a4ab210ed..b467da6802e 100644 --- a/src/test/run-pass/crateresolve5.rs +++ b/src/test/run-pass/crateresolve5.rs @@ -17,8 +17,8 @@ extern mod cr5_2 (name = "crateresolve5", vers = "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/crateresolve6.rs b/src/test/run-pass/crateresolve6.rs index cabc60a00ee..f273b12eae4 100644 --- a/src/test/run-pass/crateresolve6.rs +++ b/src/test/run-pass/crateresolve6.rs @@ -18,6 +18,6 @@ extern mod cr6_1 (name = "crateresolve_calories", vers = "0.1", calories="100"); extern mod cr6_2 (name = "crateresolve_calories", vers = "0.1", calories="200"); pub fn main() { - assert cr6_1::f() == 100; - assert cr6_2::f() == 200; + fail_unless!(cr6_1::f() == 100); + fail_unless!(cr6_2::f() == 200); } diff --git a/src/test/run-pass/crateresolve7.rs b/src/test/run-pass/crateresolve7.rs index f6dccdbfd70..49d8f27dbd6 100644 --- a/src/test/run-pass/crateresolve7.rs +++ b/src/test/run-pass/crateresolve7.rs @@ -16,6 +16,6 @@ extern mod crateresolve7x; pub fn main() { - assert crateresolve7x::a::f() == 100; - assert crateresolve7x::b::f() == 200; + fail_unless!(crateresolve7x::a::f() == 100); + fail_unless!(crateresolve7x::b::f() == 200); } diff --git a/src/test/run-pass/deep.rs b/src/test/run-pass/deep.rs index 2f51ec4a7dc..fceae82e68e 100644 --- a/src/test/run-pass/deep.rs +++ b/src/test/run-pass/deep.rs @@ -16,4 +16,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-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 22c12e7f795..9431e6b8343 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -18,9 +18,9 @@ enum Foo { pub fn main() { let a = Bar; let b = Bar; - assert a == b; - assert !(a != b); - assert a.eq(&b); - assert !a.ne(&b); + fail_unless!(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 22cee722bb3..35575285e7a 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -17,9 +17,9 @@ enum Foo { pub fn main() { let a = Bar(1, 2); let b = Bar(1, 2); - assert a == b; - assert !(a != b); - assert a.eq(&b); - assert !a.ne(&b); + fail_unless!(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 70a13f972b8..4c8c81d5312 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 Foo == Foo; - assert !(Foo != Foo); + fail_unless!(Foo == Foo); + fail_unless!(!(Foo != Foo)); } \ No newline at end of file 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 e2bb4c446e3..0f44f7b7cf9 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 @@ -6,7 +6,7 @@ enum S { pub fn main() { let x = X { x: 1, y: 2 }; - assert x == x; - assert !(x != x); + fail_unless!(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 3a4f373fed2..ab68d502491 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 a1 == a2; - assert !(a1 == b); + fail_unless!(a1 == a1); + fail_unless!(a1 == a2); + fail_unless!(!(a1 == b)); - assert a1 != b; - assert !(a1 != a1); - assert !(a1 != a2); + fail_unless!(a1 != b); + fail_unless!(!(a1 != a1)); + fail_unless!(!(a1 != a2)); } diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index cdd0f544626..f1d50e4e824 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -18,9 +18,9 @@ struct Foo { pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 }; - assert a == b; - assert !(a != b); - assert a.eq(&b); - assert !a.ne(&b); + fail_unless!(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 5040b08d003..07c09dc7fd4 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -21,9 +21,9 @@ 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 a == b; - assert !(a != b); - assert a.eq(&b); - assert !a.ne(&b); + fail_unless!(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 dfe8c3f9730..b7ade51e344 100644 --- a/src/test/run-pass/div-mod.rs +++ b/src/test/run-pass/div-mod.rs @@ -15,14 +15,14 @@ pub fn main() { let x: int = 15; let y: int = 5; - assert (x / 5 == 3); - assert (x / 4 == 3); - assert (x / 3 == 5); - assert (x / y == 3); - assert (15 / y == 3); - assert (x % 5 == 0); - assert (x % 4 == 3); - assert (x % 3 == 0); - assert (x % y == 0); - assert (15 % y == 0); + fail_unless!((x / 5 == 3)); + fail_unless!((x / 4 == 3)); + fail_unless!((x / 3 == 5)); + fail_unless!((x / y == 3)); + fail_unless!((15 / y == 3)); + fail_unless!((x % 5 == 0)); + fail_unless!((x % 4 == 3)); + fail_unless!((x % 3 == 0)); + fail_unless!((x % y == 0)); + fail_unless!((15 % y == 0)); } diff --git a/src/test/run-pass/do2.rs b/src/test/run-pass/do2.rs index d82331c6045..8995faaf8ba 100644 --- a/src/test/run-pass/do2.rs +++ b/src/test/run-pass/do2.rs @@ -11,5 +11,5 @@ fn f(f: @fn(int) -> int) -> int { f(10) } pub fn main() { - assert do f() |i| { i } == 10; + fail_unless!(do f() |i| { i } == 10); } diff --git a/src/test/run-pass/do3.rs b/src/test/run-pass/do3.rs index 09337d892a7..dee9bd77a91 100644 --- a/src/test/run-pass/do3.rs +++ b/src/test/run-pass/do3.rs @@ -11,5 +11,5 @@ fn f(f: @fn(int) -> int) -> int { f(10) } pub fn main() { - assert do f |i| { i } == 10; + fail_unless!(do f |i| { i } == 10); } diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs index cb8b1c5f25f..dff37af9a59 100644 --- a/src/test/run-pass/dvec-test.rs +++ b/src/test/run-pass/dvec-test.rs @@ -12,7 +12,7 @@ pub fn main() { let d = dvec::DVec(); d.push(3); d.push(4); - assert d.get() == ~[3, 4]; + fail_unless!(d.get() == ~[3, 4]); d.set(~[5]); d.push(6); d.push(7); @@ -23,14 +23,14 @@ pub fn main() { d.push_slice(~[11, 12, 13], 1u, 2u); let exp = ~[5, 6, 7, 8, 9, 10, 11, 12, 13, 12]; - assert d.get() == exp; - assert d.get() == exp; - assert d.len() == exp.len(); + fail_unless!(d.get() == exp); + fail_unless!(d.get() == exp); + fail_unless!(d.len() == exp.len()); for d.eachi |i, e| { - assert *e == exp[i]; + fail_unless!(*e == exp[i]); } let v = dvec::unwrap(d); - assert v == exp; + fail_unless!(v == exp); } diff --git a/src/test/run-pass/else-if.rs b/src/test/run-pass/else-if.rs index 6fc2b7d2a1b..15e68bccba8 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/empty-tag.rs b/src/test/run-pass/empty-tag.rs index 4c71e10c8e3..ca81489e0bd 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -18,7 +18,7 @@ impl cmp::Eq for chan { } fn wrapper3(i: chan) { - assert i == chan_t; + fail_unless!(i == chan_t); } pub fn main() { diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index 19045500cf2..aca9f72d265 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -20,7 +20,7 @@ pub fn main() { } fn test_color(color: color, val: int, name: ~str) { - assert color as int == val; - assert color as float == val as float; + fail_unless!(color as int == val); + fail_unless!(color as float == val as float); } diff --git a/src/test/run-pass/estr-slice.rs b/src/test/run-pass/estr-slice.rs index ca6928556fa..3e6b5fca0d2 100644 --- a/src/test/run-pass/estr-slice.rs +++ b/src/test/run-pass/estr-slice.rs @@ -17,12 +17,12 @@ pub fn main() { log(debug, x); log(debug, y); - assert x[0] == 'h' as u8; - assert x[4] == 'o' as u8; + fail_unless!(x[0] == 'h' as u8); + fail_unless!(x[4] == 'o' as u8); let z : &str = &"thing"; - assert v == x; - assert x != z; + fail_unless!(v == x); + fail_unless!(x != z); let a = &"aaaa"; let b = &"bbbb"; @@ -32,27 +32,27 @@ 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 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); log(debug, 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); log(debug, cc); } diff --git a/src/test/run-pass/estr-uniq.rs b/src/test/run-pass/estr-uniq.rs index c6b8cc9fab9..4720f29f891 100644 --- a/src/test/run-pass/estr-uniq.rs +++ b/src/test/run-pass/estr-uniq.rs @@ -13,6 +13,6 @@ pub fn main() { let _y : ~str = ~"there"; let mut z = ~"thing"; z = x; - assert z[0] == ('h' as u8); - assert z[4] == ('o' as u8); + fail_unless!(z[0] == ('h' as u8)); + fail_unless!(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 5357bcc6ab0..657a8810897 100644 --- a/src/test/run-pass/evec-internal-boxes.rs +++ b/src/test/run-pass/evec-internal-boxes.rs @@ -13,6 +13,6 @@ pub fn main() { let _y : [@int * 5] = [@1,@2,@3,@4,@5]; let mut z = [@1,@2,@3,@4,@5]; z = x; - assert *z[0] == 1; - assert *z[4] == 5; + fail_unless!(*z[0] == 1); + fail_unless!(*z[4] == 5); } diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index a97eacfee88..937912e7baf 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 z[0] == 1; - assert z[4] == 5; + fail_unless!(z[0] == 1); + fail_unless!(z[4] == 5); let a : [int * 5] = [1,1,1,1,1]; let b : [int * 5] = [2,2,2,2,2]; @@ -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; + 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); log(debug, c); diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index e8e4f64a9cd..0ca9af6c03a 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -12,8 +12,8 @@ pub fn main() { let x : &[int] = &[1,2,3,4,5]; let mut z = &[1,2,3,4,5]; z = x; - assert z[0] == 1; - assert z[4] == 5; + fail_unless!(z[0] == 1); + fail_unless!(z[4] == 5); let a : &[int] = &[1,1,1,1,1]; let b : &[int] = &[2,2,2,2,2]; @@ -22,33 +22,33 @@ 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; + 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); log(debug, 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); log(debug, cc); } diff --git a/src/test/run-pass/exec-env.rs b/src/test/run-pass/exec-env.rs index 67cc820ac5d..2478eed2f0c 100644 --- a/src/test/run-pass/exec-env.rs +++ b/src/test/run-pass/exec-env.rs @@ -12,5 +12,5 @@ // exec-env:TEST_EXEC_ENV=22 pub fn main() { - assert os::getenv(~"TEST_EXEC_ENV") == Some(~"22"); + fail_unless!(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 88c78e9e997..16c4986fc53 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -38,6 +38,6 @@ pub impl LinearMap { pub fn main() { let mut m = ~linear_map::<(),()>(); - assert m.len() == 0; + fail_unless!(m.len() == 0); } diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs index c18e263245a..6c981a93d7c 100644 --- a/src/test/run-pass/explicit-self-objects-box.rs +++ b/src/test/run-pass/explicit-self-objects-box.rs @@ -18,7 +18,7 @@ struct S { impl Foo for S { fn f(@self) { - assert self.x == 3; + fail_unless!(self.x == 3); } } diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs index 3b5c02672d6..1fa054a9060 100644 --- a/src/test/run-pass/explicit-self-objects-simple.rs +++ b/src/test/run-pass/explicit-self-objects-simple.rs @@ -18,7 +18,7 @@ struct S { impl Foo for S { fn f(&self) { - assert self.x == 3; + fail_unless!(self.x == 3); } } diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index 44f39e3ef0c..2361df4f457 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 self.x == 3; + fail_unless!(self.x == 3); } } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 885eb9837a7..44edbd44bd3 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -68,13 +68,13 @@ impl Nus for thing { fn f(&self) {} } pub fn main() { let x = @thing(A {a: @10}); - assert x.foo() == 10; - assert x.quux() == 10; + fail_unless!(x.foo() == 10); + fail_unless!(x.quux() == 10); let y = ~thing(A {a: @10}); - assert (copy y).bar() == 10; - assert y.quux() == 10; + fail_unless!((copy y).bar() == 10); + fail_unless!(y.quux() == 10); let z = thing(A {a: @11}); - assert z.spam() == 11; + fail_unless!(z.spam() == 11); } diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 1b33df0b328..36483f88377 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-alt-box.rs b/src/test/run-pass/expr-alt-box.rs index 004d101dd27..a5ad80a49e7 100644 --- a/src/test/run-pass/expr-alt-box.rs +++ b/src/test/run-pass/expr-alt-box.rs @@ -16,13 +16,13 @@ // Tests for match as expressions resulting in boxed types fn test_box() { let res = match true { true => { @100 } _ => fail!(~"wat") }; - assert (*res == 100); + fail_unless!((*res == 100)); } fn test_str() { let res = match true { true => { ~"happy" }, _ => fail!(~"not happy at all") }; - assert (res == ~"happy"); + fail_unless!((res == ~"happy")); } pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-alt-fail.rs b/src/test/run-pass/expr-alt-fail.rs index 7838ea70b42..a22afab485c 100644 --- a/src/test/run-pass/expr-alt-fail.rs +++ b/src/test/run-pass/expr-alt-fail.rs @@ -10,12 +10,12 @@ fn test_simple() { let r = match true { true => { true } false => { fail!() } }; - assert (r == true); + fail_unless!((r == true)); } fn test_box() { let r = match true { true => { ~[10] } false => { fail!() } }; - assert (r[0] == 10); + fail_unless!((r[0] == 10)); } pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index 7f477d3f103..5d9e317be38 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -16,7 +16,7 @@ type compare = @fn(@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-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index 5612cca639d..15bfd759059 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -15,7 +15,7 @@ type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; - assert (eq(expected, actual)); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index 3c1131455f1..b24ac9de009 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -18,7 +18,7 @@ fn test_generic(expected: ~T, eq: compare) { true => { copy expected }, _ => fail!(~"wat") }; - assert (eq(expected, actual)); + fail_unless!((eq(expected, actual))); } fn test_box() { diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index 2d45e6a7a3e..7bbd0bfc380 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -18,7 +18,7 @@ fn test_generic(expected: T, eq: compare) { true => copy expected, _ => fail!(~"wat") }; - assert (eq(expected, actual)); + fail_unless!((eq(expected, actual))); } fn test_vec() { diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index df7fbb8d5b2..1c7f907933e 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -15,7 +15,7 @@ type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; - assert (eq(expected, actual)); + fail_unless!((eq(expected, actual))); } fn test_bool() { diff --git a/src/test/run-pass/expr-alt-struct.rs b/src/test/run-pass/expr-alt-struct.rs index ed362edde40..564fb1a912c 100644 --- a/src/test/run-pass/expr-alt-struct.rs +++ b/src/test/run-pass/expr-alt-struct.rs @@ -18,7 +18,7 @@ struct R { i: int } fn test_rec() { let rs = match true { true => R {i: 100}, _ => fail!() }; - assert (rs.i == 100); + fail_unless!((rs.i == 100)); } enum mood { happy, sad, } @@ -32,7 +32,7 @@ impl cmp::Eq for mood { fn test_tag() { let rs = match true { true => { happy } false => { sad } }; - assert (rs == happy); + fail_unless!((rs == happy)); } pub fn main() { test_rec(); test_tag(); } diff --git a/src/test/run-pass/expr-alt-unique.rs b/src/test/run-pass/expr-alt-unique.rs index 2865da3dd1f..3fa9e84d4b3 100644 --- a/src/test/run-pass/expr-alt-unique.rs +++ b/src/test/run-pass/expr-alt-unique.rs @@ -16,7 +16,7 @@ // Tests for match as expressions resulting in boxed types fn test_box() { let res = match true { true => { ~100 }, _ => fail!() }; - assert (*res == 100); + fail_unless!((*res == 100)); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt.rs b/src/test/run-pass/expr-alt.rs index c10f922e880..de18290b7af 100644 --- a/src/test/run-pass/expr-alt.rs +++ b/src/test/run-pass/expr-alt.rs @@ -16,14 +16,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 mut rs = match true { true => { true } false => { false } }; - assert (rs); + fail_unless!((rs)); } fn test_alt_as_alt_head() { @@ -34,7 +34,7 @@ fn test_alt_as_alt_head() { true => { false } false => { true } }; - assert (rs); + fail_unless!((rs)); } fn test_alt_as_block_result() { @@ -43,7 +43,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/expr-block-box.rs b/src/test/run-pass/expr-block-box.rs index f1fa9d8e2d5..a3e55b739af 100644 --- a/src/test/run-pass/expr-block-box.rs +++ b/src/test/run-pass/expr-block-box.rs @@ -12,4 +12,4 @@ // -*- rust -*- -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 eb82a2a4445..9967281612b 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 = @fn() -> 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 737ff99440d..925c1b2cc4d 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -16,7 +16,7 @@ type compare = @fn(@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 eeda810b5c6..9f2018a12e9 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 = @fn(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_vec() { diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index a9074b6f97f..9600d36bbbb 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -15,7 +15,7 @@ type compare = @fn(~T, ~T) -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { copy expected }; - 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 6624e6ea015..3d5953494ae 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -16,7 +16,7 @@ type compare = @fn(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_vec() { diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 63187bee76f..c582a30fa25 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -17,7 +17,7 @@ type compare = @fn(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_bool() { diff --git a/src/test/run-pass/expr-block-slot.rs b/src/test/run-pass/expr-block-slot.rs index 1e3a91ae2ce..474f5a1bf51 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 (a.a == 3); + fail_unless!((a.a == 3)); let c = { let d = V {v: 3}; d }; - assert (c.v == 3); + fail_unless!((c.v == 3)); } diff --git a/src/test/run-pass/expr-block-unique.rs b/src/test/run-pass/expr-block-unique.rs index f6b31ee3733..8b9e77071ea 100644 --- a/src/test/run-pass/expr-block-unique.rs +++ b/src/test/run-pass/expr-block-unique.rs @@ -12,4 +12,4 @@ // -*- rust -*- -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 fb3d3efd650..faa36ffa09a 100644 --- a/src/test/run-pass/expr-block.rs +++ b/src/test/run-pass/expr-block.rs @@ -14,15 +14,15 @@ // -*- rust -*- // 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 }; - assert (rs == 10); + fail_unless!((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 2d370bada28..287f935eef8 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 x.a == 100; + fail_unless!(x.a == 100); x.a = 20; let mut y = copy x; f(&mut y); - assert x.a == 20; + fail_unless!(x.a == 20); } diff --git a/src/test/run-pass/expr-elseif-ref.rs b/src/test/run-pass/expr-elseif-ref.rs index ffcfe6448bc..2bacf914a70 100644 --- a/src/test/run-pass/expr-elseif-ref.rs +++ b/src/test/run-pass/expr-elseif-ref.rs @@ -13,5 +13,5 @@ pub fn main() { let y: @uint = @10u; let x = if false { y } else if true { y } else { y }; - assert (*y == 10u); + fail_unless!((*y == 10u)); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index 0db78f776c4..5695ea24d83 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 (f() == 10); + fail_unless!((f() == 10)); } fn test_vec() { fn f() -> ~[int] { ~[10, 11] } - assert (f()[1] == 11); + fail_unless!((f()[1] == 11)); } fn test_generic() { fn f(t: T) -> T { t } - assert (f(10) == 10); + fail_unless!((f(10) == 10)); } fn test_alt() { fn f() -> int { match true { false => { 10 } true => { 20 } } } - assert (f() == 20); + fail_unless!((f() == 20)); } fn test_if() { fn f() -> int { if true { 10 } else { 20 } } - assert (f() == 10); + fail_unless!((f() == 10)); } fn test_block() { fn f() -> int { { 10 } } - assert (f() == 10); + fail_unless!((f() == 10)); } fn test_ret() { @@ -43,14 +43,14 @@ fn test_ret() { return 10 // no semi } - assert (f() == 10); + fail_unless!((f() == 10)); } // From issue #372 fn test_372() { fn f() -> int { let x = { 3 }; x } - assert (f() == 3); + fail_unless!((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 7ca8c8f88c8..4a38f9986b8 100644 --- a/src/test/run-pass/expr-if-box.rs +++ b/src/test/run-pass/expr-if-box.rs @@ -16,12 +16,12 @@ // Tests for if as expressions returning boxed types fn test_box() { let rs = if true { @100 } else { @101 }; - assert (*rs == 100); + fail_unless!((*rs == 100)); } fn test_str() { let rs = if true { ~"happy" } else { ~"sad" }; - assert (rs == ~"happy"); + fail_unless!((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 61f118d1840..813ce4edbae 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -8,16 +8,16 @@ // 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!() }; - assert (x == 10); + fail_unless!((x == 10)); } fn test_elseif_fail() { let x = if false { 0 } else if false { fail!() } else { 10 }; - assert (x == 10); + fail_unless!((x == 10)); } pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index fd5e88da730..036b99b344a 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -16,7 +16,7 @@ type compare = @fn(@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 08809d03515..5868f45f3c8 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 = @fn(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_vec() { diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 18cc4048242..f4945a0fa21 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -16,7 +16,7 @@ type compare = @fn(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_bool() { diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index ea0bd768438..d37a67d922e 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -19,7 +19,7 @@ struct I { i: int } fn test_rec() { let rs = if true { I {i: 100} } else { I {i: 101} }; - assert (rs.i == 100); + fail_unless!((rs.i == 100)); } enum mood { happy, sad, } @@ -33,7 +33,7 @@ impl cmp::Eq for mood { fn test_tag() { let rs = if true { happy } else { sad }; - assert (rs == happy); + fail_unless!((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 4cf99f83039..1b635431ba6 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -16,7 +16,7 @@ // Tests for if as expressions returning boxed types fn test_box() { let rs = if true { ~100 } else { ~101 }; - assert (*rs == 100); + fail_unless!((*rs == 100)); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if.rs b/src/test/run-pass/expr-if.rs index b75c633671b..55958f88ced 100644 --- a/src/test/run-pass/expr-if.rs +++ b/src/test/run-pass/expr-if.rs @@ -14,43 +14,43 @@ // -*- rust -*- // 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/exterior.rs b/src/test/run-pass/exterior.rs index 2ce67f16c06..c5d52830686 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -14,13 +14,13 @@ // -*- rust -*- struct Point {x: int, y: int, z: int} -fn f(p: @mut Point) { assert (p.z == 12); p.z = 13; assert (p.z == 13); } +fn f(p: @mut Point) { fail_unless!((p.z == 12)); p.z = 13; fail_unless!((p.z == 13)); } pub fn main() { let a: Point = Point {x: 10, y: 11, z: 12}; let b: @mut Point = @mut copy a; - assert (b.z == 12); + fail_unless!((b.z == 12)); f(b); - assert (a.z == 12); - assert (b.z == 13); + fail_unless!((a.z == 12)); + fail_unless!((b.z == 13)); } diff --git a/src/test/run-pass/extern-call-deep.rs b/src/test/run-pass/extern-call-deep.rs index f5947b462e6..cf396695d26 100644 --- a/src/test/run-pass/extern-call-deep.rs +++ b/src/test/run-pass/extern-call-deep.rs @@ -33,5 +33,5 @@ fn count(n: uint) -> uint { pub fn main() { let result = count(1000u); debug!("result = %?", result); - assert result == 1000u; + fail_unless!(result == 1000u); } diff --git a/src/test/run-pass/extern-call-deep2.rs b/src/test/run-pass/extern-call-deep2.rs index 0bc6d86c927..3175ddf9784 100644 --- a/src/test/run-pass/extern-call-deep2.rs +++ b/src/test/run-pass/extern-call-deep2.rs @@ -36,6 +36,6 @@ pub fn main() { do task::spawn { let result = count(1000u); debug!("result = %?", result); - assert result == 1000u; + fail_unless!(result == 1000u); }; } diff --git a/src/test/run-pass/extern-call-scrub.rs b/src/test/run-pass/extern-call-scrub.rs index 7802dfa61ce..e4566772556 100644 --- a/src/test/run-pass/extern-call-scrub.rs +++ b/src/test/run-pass/extern-call-scrub.rs @@ -40,6 +40,6 @@ pub fn main() { do task::spawn { let result = count(12u); debug!("result = %?", result); - assert result == 2048u; + fail_unless!(result == 2048u); }; } diff --git a/src/test/run-pass/extern-call.rs b/src/test/run-pass/extern-call.rs index e66a44a5487..d0c75b7c739 100644 --- a/src/test/run-pass/extern-call.rs +++ b/src/test/run-pass/extern-call.rs @@ -33,5 +33,5 @@ fn fact(n: uint) -> uint { pub fn main() { let result = fact(10u); debug!("result = %?", result); - assert result == 3628800u; + fail_unless!(result == 3628800u); } diff --git a/src/test/run-pass/extern-crosscrate.rs b/src/test/run-pass/extern-crosscrate.rs index b95074c6f88..7bc68333f4a 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); debug!("result = %?", result); - assert result == 3628800u; + fail_unless!(result == 3628800u); } diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index 6ef31445140..ed1567897eb 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -36,7 +36,7 @@ fn count(n: uint) -> uint { pub fn main() { for iter::repeat(100u) { do task::spawn { - assert count(5u) == 16u; + fail_unless!(count(5u) == 16u); }; } } diff --git a/src/test/run-pass/extern-take-value.rs b/src/test/run-pass/extern-take-value.rs index d3d99f0fffc..513d9d284d0 100644 --- a/src/test/run-pass/extern-take-value.rs +++ b/src/test/run-pass/extern-take-value.rs @@ -20,6 +20,6 @@ pub fn main() { let b: *u8 = f; let c: *u8 = g; - assert a == b; - assert a != c; + fail_unless!(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 1695a0e7909..4f94193b856 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -35,7 +35,7 @@ pub fn main() { do task::spawn { let result = count(5u); debug!("result = %?", result); - assert result == 16u; + fail_unless!(result == 16u); }; } } diff --git a/src/test/run-pass/fact.rs b/src/test/run-pass/fact.rs index 93f4dd43959..21ac3fcdf5f 100644 --- a/src/test/run-pass/fact.rs +++ b/src/test/run-pass/fact.rs @@ -32,7 +32,7 @@ fn f(x: int) -> int { } pub fn main() { - assert (f(5) == 120); + fail_unless!((f(5) == 120)); // debug!("all done"); } diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index e28191ce35e..fc03eaf3b03 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -25,6 +25,6 @@ fn fact_(f: @fn(v: int) -> int, n: int) -> int { pub fn main() { let fact = fix(fact_); - assert (fact(5) == 120); - assert (fact(2) == 2); + fail_unless!((fact(5) == 120)); + fail_unless!((fact(2) == 2)); } diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 0c34a94c982..fcd3b2e0a18 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -25,6 +25,6 @@ fn fact_(f: @fn(v: int) -> int, n: int) -> int { pub fn main() { let fact = fix(fact_); - assert (fact(5) == 120); - assert (fact(2) == 2); + fail_unless!((fact(5) == 120)); + fail_unless!((fact(2) == 2)); } diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index 54a7c9959ff..8c104f4f88b 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -15,6 +15,6 @@ pub fn main() { let arr = [1,2,3]; let arr2 = arr; - assert(arr[1] == 2); - assert(arr2[2] == 3); + fail_unless!((arr[1] == 2)); + fail_unless!((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 1ee1ad02201..87fdbf071d2 100644 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ b/src/test/run-pass/fixed_length_vec_glue.rs @@ -14,5 +14,5 @@ pub fn main() { let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = sys::log_str(&struc); - assert(s == ~"{a: 13, b: [1, 2, 3], c: 42}"); + fail_unless!((s == ~"{a: 13, 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 daab9684cf4..7ae38c45b99 100644 --- a/src/test/run-pass/float-nan.rs +++ b/src/test/run-pass/float-nan.rs @@ -12,80 +12,80 @@ extern mod std; pub fn main() { let nan = float::NaN; - assert(float::is_NaN(nan)); + fail_unless!((float::is_NaN(nan))); let inf = float::infinity; - assert(-inf == float::neg_infinity); + fail_unless!((-inf == float::neg_infinity)); - 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(float::is_NaN(nan + inf)); - assert(float::is_NaN(nan + -inf)); - assert(float::is_NaN(nan + 0.)); - assert(float::is_NaN(nan + 1.)); - assert(float::is_NaN(nan * 1.)); - assert(float::is_NaN(nan / 1.)); - assert(float::is_NaN(nan / 0.)); - assert(float::is_NaN(0. / 0.)); - assert(float::is_NaN(-inf + inf)); - assert(float::is_NaN(inf - inf)); + fail_unless!((float::is_NaN(nan + inf))); + fail_unless!((float::is_NaN(nan + -inf))); + fail_unless!((float::is_NaN(nan + 0.))); + fail_unless!((float::is_NaN(nan + 1.))); + fail_unless!((float::is_NaN(nan * 1.))); + fail_unless!((float::is_NaN(nan / 1.))); + fail_unless!((float::is_NaN(nan / 0.))); + fail_unless!((float::is_NaN(0. / 0.))); + fail_unless!((float::is_NaN(-inf + inf))); + fail_unless!((float::is_NaN(inf - inf))); - assert(!float::is_NaN(-1.)); - assert(!float::is_NaN(0.)); - assert(!float::is_NaN(0.1)); - assert(!float::is_NaN(1.)); - assert(!float::is_NaN(inf)); - assert(!float::is_NaN(-inf)); - assert(!float::is_NaN(1./-inf)); + fail_unless!((!float::is_NaN(-1.))); + fail_unless!((!float::is_NaN(0.))); + fail_unless!((!float::is_NaN(0.1))); + fail_unless!((!float::is_NaN(1.))); + fail_unless!((!float::is_NaN(inf))); + fail_unless!((!float::is_NaN(-inf))); + fail_unless!((!float::is_NaN(1./-inf))); } diff --git a/src/test/run-pass/float2.rs b/src/test/run-pass/float2.rs index 12d2dbafc4b..b9de5c66fe0 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 (a == b); - assert (c < b); - assert (c == d); - assert (e < g); - assert (f < h); - assert (g == 1000000.0f32); - assert (h == i); - assert (j > k); - assert (k < a); + fail_unless!((a == b)); + fail_unless!((c < b)); + fail_unless!((c == d)); + fail_unless!((e < g)); + fail_unless!((f < h)); + fail_unless!((g == 1000000.0f32)); + fail_unless!((h == i)); + 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 573c5302698..bbb1ec5bfa7 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/fn-assign-managed-to-bare-1.rs b/src/test/run-pass/fn-assign-managed-to-bare-1.rs index 6facfc92d3e..a9bd5587de2 100644 --- a/src/test/run-pass/fn-assign-managed-to-bare-1.rs +++ b/src/test/run-pass/fn-assign-managed-to-bare-1.rs @@ -14,7 +14,7 @@ fn add(n: int) -> @fn(int) -> int { } pub fn main() { - assert add(3)(4) == 7; + fail_unless!(add(3)(4) == 7); let add3 : fn(int)->int = add(3); - assert add3(4) == 7; + fail_unless!(add3(4) == 7); } diff --git a/src/test/run-pass/fn-assign-managed-to-bare-2.rs b/src/test/run-pass/fn-assign-managed-to-bare-2.rs index be07da77baa..3d788cd25d7 100644 --- a/src/test/run-pass/fn-assign-managed-to-bare-2.rs +++ b/src/test/run-pass/fn-assign-managed-to-bare-2.rs @@ -15,14 +15,14 @@ fn add(n: int) -> @fn(int) -> int { pub fn main() { - assert add(3)(4) == 7; + fail_unless!(add(3)(4) == 7); let add1 : @fn(int)->int = add(1); - assert add1(6) == 7; + fail_unless!(add1(6) == 7); let add2 : &(@fn(int)->int) = &add(2); - assert (*add2)(5) == 7; + fail_unless!((*add2)(5) == 7); let add3 : &fn(int)->int = add(3); - assert add3(4) == 7; + fail_unless!(add3(4) == 7); } diff --git a/src/test/run-pass/fn-bare-assign.rs b/src/test/run-pass/fn-bare-assign.rs index ded30c6c7d6..356777a64d3 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 i == 10; + fail_unless!(i == 10); *called = true; } @@ -21,5 +21,5 @@ pub fn main() { let mut called = false; let h = f; g(h, &mut called); - assert called == true; + fail_unless!(called == true); } diff --git a/src/test/run-pass/fn-bare-spawn.rs b/src/test/run-pass/fn-bare-spawn.rs index 9b2a8d0c681..4bfd1756ce6 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 i == 100; + fail_unless!(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 28ac3f88b24..411eb5ffb09 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: fn((int,int)) = |(x, y)| { - assert x == 1; - assert y == 2; + fail_unless!(x == 1); + fail_unless!(y == 2); }; f((1, 2)); } diff --git a/src/test/run-pass/for-destruct.rs b/src/test/run-pass/for-destruct.rs index 6a91c5b0ee8..4209791c87f 100644 --- a/src/test/run-pass/for-destruct.rs +++ b/src/test/run-pass/for-destruct.rs @@ -12,6 +12,6 @@ struct Pair { x: int, y: int } pub fn main() { for vec::each(~[Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) |elt| { - assert (elt.x + elt.y == 30); + fail_unless!((elt.x + elt.y == 30)); } } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 4d7486b7263..8d705447531 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -20,8 +20,8 @@ pub fn main() { do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } } - assert (a[0] == 0); - assert (a[1] == 1); - assert (a[2] == 10); - assert (a[3] == 11); + fail_unless!((a[0] == 0)); + fail_unless!((a[1] == 1)); + fail_unless!((a[2] == 10)); + fail_unless!((a[3] == 11)); } diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index d1fe6fab63c..8bbfe90ba03 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; log(debug, _0); log(debug, _1); - assert (_0 + 10 == i); + fail_unless!((_0 + 10 == i)); i += 1; j = _1; }; - assert (j == 45); + fail_unless!((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 86456321e80..52451585250 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -17,7 +17,7 @@ pub fn main() { do first_ten |i| { debug!("main"); log(debug, i); sum = sum + i; } debug!("sum"); log(debug, sum); - assert (sum == 45); + fail_unless!((sum == 45)); } fn first_ten(it: fn(int)) { diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index 86f23dd5210..516be9fcda8 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -19,6 +19,6 @@ pub fn main() { extern fn callback(data: libc::uintptr_t) { unsafe { let data: *int = cast::transmute(data); - assert *data == 100; + fail_unless!(*data == 100); } } diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 77ddd5eb7f9..6d7e0a6cfcc 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -29,5 +29,5 @@ fn strlen(str: ~str) -> uint { pub fn main() { let len = strlen(~"Rust"); - assert(len == 4u); + fail_unless!((len == 4u)); } diff --git a/src/test/run-pass/foreign-lib-path.rs b/src/test/run-pass/foreign-lib-path.rs index 3a0304afdba..337ec978858 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 IDONTKNOW() == 0x_BAD_DOOD_u32; + fail_unless!(IDONTKNOW() == 0x_BAD_DOOD_u32); } diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index b51f60f95a8..5e611b260d0 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -17,5 +17,5 @@ pub fn main() { let a: int = direct(3); // direct let b: int = ho(direct); // indirect unbound - assert (a == b); + fail_unless!((a == b)); } diff --git a/src/test/run-pass/fun-indirect-call.rs b/src/test/run-pass/fun-indirect-call.rs index a200d5f6559..659c508e3a3 100644 --- a/src/test/run-pass/fun-indirect-call.rs +++ b/src/test/run-pass/fun-indirect-call.rs @@ -17,5 +17,5 @@ fn f() -> int { return 42; } pub fn main() { let g: extern fn() -> int = f; let i: int = g(); - assert (i == 42); + fail_unless!((i == 42)); } diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index 95902acc848..1d791471f8f 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); log(debug, *actual); - assert (*expected == *actual); + fail_unless!((*expected == *actual)); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 3cb6409a254..f09780706b9 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>(copy expected); log(debug, *actual); - assert (*expected == *actual); + fail_unless!((*expected == *actual)); } diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index 43c6acd3f3d..3c4e1a857a7 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::(Box{x: 1, y: 2, z: 3}); - assert (x.y == 2); + fail_unless!((x.y == 2)); } diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 264703439e8..003b760465d 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -24,6 +24,6 @@ pub fn main() { let b = f::(10); log(debug, b.a); log(debug, b.b); - assert (b.a == 10); - assert (b.b == 10); + fail_unless!((b.a == 10)); + fail_unless!((b.b == 10)); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index 7039fad1a9a..bd7e01d08d4 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 (*rbfoo.x == foo); + fail_unless!((*rbfoo.x == foo)); } diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 3d3cc028f35..b0da35ac82c 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 (*rbfoo.x == foo); + fail_unless!((*rbfoo.x == foo)); } diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index fcd356bcd2d..3dbbd62ff7f 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -16,4 +16,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-fn.rs b/src/test/run-pass/generic-fn.rs index 2fad81f4db2..8f0158df642 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -25,13 +25,13 @@ pub fn main() { let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::(x); log(debug, y); - assert (x == y); + fail_unless!((x == y)); b = id::(a); log(debug, b); - assert (a == b); + fail_unless!((a == b)); q = id::(p); x = p.z; y = q.z; log(debug, y); - assert (x == y); + fail_unless!((x == y)); } diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index 5279ef043f5..60e1c1a7c37 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -25,6 +25,6 @@ impl Foo for S { pub fn main() { let x = @S { x: 1 }; let y = x as @Foo; - assert y.get() == 1; + fail_unless!(y.get() == 1); } diff --git a/src/test/run-pass/generic-tag-alt.rs b/src/test/run-pass/generic-tag-alt.rs index 020111d55ac..1229f7df544 100644 --- a/src/test/run-pass/generic-tag-alt.rs +++ b/src/test/run-pass/generic-tag-alt.rs @@ -15,7 +15,7 @@ enum foo { arm(T), } fn altfoo(f: foo) { let mut hit = false; match f { arm::(x) => { debug!("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 c9024756328..56395bf8cb0 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -18,14 +18,14 @@ struct Pair { x: int, y: int } pub fn main() { let nop: noption = some::(5); - match nop { some::(n) => { log(debug, n); assert (n == 5); } } + match nop { some::(n) => { log(debug, n); fail_unless!((n == 5)); } } let nop2: noption = some(Pair{x: 17, y: 42}); match nop2 { some(t) => { log(debug, t.x); log(debug, t.y); - assert (t.x == 17); - assert (t.y == 42); + fail_unless!((t.x == 17)); + fail_unless!((t.y == 42)); } } } diff --git a/src/test/run-pass/generic-temporary.rs b/src/test/run-pass/generic-temporary.rs index d9c6dcef1f5..5c9d63610a8 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) { log(debug, a); assert (a == 1); } +fn chk(a: int) { log(debug, a); fail_unless!((a == 1)); } fn apply(produce: extern fn() -> T, consume: extern fn(T)) { diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index 3f6f8e7af68..bb4e5ea14ad 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() { log(debug, get_third((1, 2, 3))); - assert (get_third((1, 2, 3)) == 3); - assert (get_third((5u8, 6u8, 7u8)) == 7u8); + fail_unless!((get_third((1, 2, 3)) == 3)); + fail_unless!((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 bc62b23bc48..0579604faef 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 (x.x == 10); - assert (x.y == 12); + fail_unless!((x.x == 10)); + fail_unless!((x.y == 12)); } diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index dc88f7acfbd..98c7c660e69 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -14,5 +14,5 @@ fn box(x: Triple) -> ~Triple { return ~x; } pub fn main() { let x: ~Triple = box::(Triple{x: 1, y: 2, z: 3}); - assert (x.y == 2); + fail_unless!((x.y == 2)); } diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index 8af3cf75a00..272889e5b9a 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/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index 5aac0ab3fed..1647fd53353 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -9,5 +9,5 @@ fn xyzzy(q: Q) -> uint { pub fn main() { - assert xyzzy(R(Some(5))) == 0; + fail_unless!(xyzzy(R(Some(5))) == 0); } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 7aba929d626..66667487001 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 (a == 2); + fail_unless!((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 (b == 2); + fail_unless!((b == 2)); } diff --git a/src/test/run-pass/i32-sub.rs b/src/test/run-pass/i32-sub.rs index a7364d7cf65..71e4b9a8039 100644 --- a/src/test/run-pass/i32-sub.rs +++ b/src/test/run-pass/i32-sub.rs @@ -12,4 +12,4 @@ // -*- rust -*- -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/i8-incr.rs b/src/test/run-pass/i8-incr.rs index 9f1a75dbf23..ca6254f84c2 100644 --- a/src/test/run-pass/i8-incr.rs +++ b/src/test/run-pass/i8-incr.rs @@ -17,5 +17,5 @@ pub fn main() { let y: i8 = -12i8; x = x + 1i8; x = x - 1i8; - assert (x == y); + fail_unless!((x == y)); } diff --git a/src/test/run-pass/impl-variance.rs b/src/test/run-pass/impl-variance.rs index 59e248dfc1b..d772b76108e 100644 --- a/src/test/run-pass/impl-variance.rs +++ b/src/test/run-pass/impl-variance.rs @@ -18,9 +18,9 @@ impl foo for ~[const T] { pub fn main() { let v = ~[const 0]; - assert v.foo() == 1u; + fail_unless!(v.foo() == 1u); let v = ~[0]; - assert v.foo() == 1u; + fail_unless!(v.foo() == 1u); let mut v = ~[0]; - assert v.foo() == 1u; + fail_unless!(v.foo() == 1u); } diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index ed532fab544..4fb3a0c1a16 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -17,5 +17,5 @@ use core::vec::*; pub fn main() { let mut v = from_elem(0u, 0); v = vec::append(v, ~[4, 2]); - assert (reversed(v) == ~[2, 4]); + fail_unless!((reversed(v) == ~[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 c72df610210..baaa41f5bba 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 x_message == ~"lots"; + fail_unless!(x_message == ~"lots"); let y = 2i; let y_message = match y { 0 .. 1 => { ~"not many" } _ => { ~"lots" } }; - assert y_message == ~"lots"; + fail_unless!(y_message == ~"lots"); let z = 1u64; let z_message = match z { 0 .. 1 => { ~"not many" } _ => { ~"lots" } }; - assert z_message == ~"not many"; + fail_unless!(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 0185b19b481..50b31361cee 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -34,7 +34,7 @@ fn test_box() { { let a = @r(i); } - assert *i == 1; + fail_unless!(*i == 1); } fn test_rec() { @@ -42,7 +42,7 @@ fn test_rec() { { let a = Box {x: r(i)}; } - assert *i == 1; + fail_unless!(*i == 1); } fn test_tag() { @@ -54,7 +54,7 @@ fn test_tag() { { let a = t0(r(i)); } - assert *i == 1; + fail_unless!(*i == 1); } fn test_tup() { @@ -62,7 +62,7 @@ fn test_tup() { { let a = (r(i), 0); } - assert *i == 1; + fail_unless!(*i == 1); } fn test_unique() { @@ -70,7 +70,7 @@ fn test_unique() { { let a = ~r(i); } - assert *i == 1; + fail_unless!(*i == 1); } fn test_box_rec() { @@ -80,7 +80,7 @@ fn test_box_rec() { x: r(i) }; } - assert *i == 1; + fail_unless!(*i == 1); } pub fn main() { diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs index d4d765dfc1d..d9fcbb4cb3e 100644 --- a/src/test/run-pass/int-conversion-coherence.rs +++ b/src/test/run-pass/int-conversion-coherence.rs @@ -21,6 +21,6 @@ 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 10.plus() == 20; + fail_unless!(10.plus() == 20); } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs index 7673cc034d1..e4b195a0204 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 (v[3u] == 3); - assert (v[3u8] == 3); - assert (v[3i8] == 3); - assert (v[3u32] == 3); - assert (v[3i32] == 3); + fail_unless!((v[3u] == 3)); + fail_unless!((v[3u8] == 3)); + fail_unless!((v[3i8] == 3)); + fail_unless!((v[3u32] == 3)); + fail_unless!((v[3i32] == 3)); log(debug, v[3u8]); - assert (s[3u] == 'd' as u8); - assert (s[3u8] == 'd' as u8); - assert (s[3i8] == 'd' as u8); - assert (s[3u32] == 'd' as u8); - assert (s[3i32] == 'd' as u8); + fail_unless!((s[3u] == 'd' as u8)); + fail_unless!((s[3u8] == 'd' as u8)); + fail_unless!((s[3i8] == 'd' as u8)); + fail_unless!((s[3u32] == 'd' as u8)); + fail_unless!((s[3i32] == 'd' as u8)); log(debug, s[3u8]); } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 16c88edc784..5d25dafdd06 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -25,16 +25,16 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert ::rusti::pref_align_of::() == 8u; - assert ::rusti::min_align_of::() == 4u; + fail_unless!(::rusti::pref_align_of::() == 8u); + fail_unless!(::rusti::min_align_of::() == 4u); } } #[cfg(target_arch = "x86_64")] pub fn main() { unsafe { - assert ::rusti::pref_align_of::() == 8u; - assert ::rusti::min_align_of::() == 8u; + fail_unless!(::rusti::pref_align_of::() == 8u); + fail_unless!(::rusti::min_align_of::() == 8u); } } } @@ -44,8 +44,8 @@ mod m { #[cfg(target_arch = "x86")] pub fn main() { unsafe { - assert ::rusti::pref_align_of::() == 8u; - assert ::rusti::min_align_of::() == 8u; + fail_unless!(::rusti::pref_align_of::() == 8u); + fail_unless!(::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 24a4de89b45..f4025658f7f 100644 --- a/src/test/run-pass/intrinsic-atomics-cc.rs +++ b/src/test/run-pass/intrinsic-atomics-cc.rs @@ -18,6 +18,6 @@ pub fn main() { unsafe { let mut x = 1; atomic_xchg(&mut x, 5); - assert x == 5; + fail_unless!(x == 5); } } diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index 38a0e601aff..4e571f90602 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -33,32 +33,32 @@ pub fn main() { unsafe { let mut x = ~1; - assert rusti::atomic_cxchg(x, 1, 2) == 1; - assert *x == 2; + fail_unless!(rusti::atomic_cxchg(x, 1, 2) == 1); + fail_unless!(*x == 2); - assert rusti::atomic_cxchg_acq(x, 1, 3) == 2; - assert *x == 2; + fail_unless!(rusti::atomic_cxchg_acq(x, 1, 3) == 2); + fail_unless!(*x == 2); - assert rusti::atomic_cxchg_rel(x, 2, 1) == 2; - assert *x == 1; + fail_unless!(rusti::atomic_cxchg_rel(x, 2, 1) == 2); + fail_unless!(*x == 1); - assert rusti::atomic_xchg(x, 0) == 1; - assert *x == 0; + fail_unless!(rusti::atomic_xchg(x, 0) == 1); + fail_unless!(*x == 0); - assert rusti::atomic_xchg_acq(x, 1) == 0; - assert *x == 1; + fail_unless!(rusti::atomic_xchg_acq(x, 1) == 0); + fail_unless!(*x == 1); - assert rusti::atomic_xchg_rel(x, 0) == 1; - assert *x == 0; + fail_unless!(rusti::atomic_xchg_rel(x, 0) == 1); + fail_unless!(*x == 0); - assert rusti::atomic_xadd(x, 1) == 0; - assert rusti::atomic_xadd_acq(x, 1) == 1; - assert rusti::atomic_xadd_rel(x, 1) == 2; - assert *x == 3; + fail_unless!(rusti::atomic_xadd(x, 1) == 0); + fail_unless!(rusti::atomic_xadd_acq(x, 1) == 1); + fail_unless!(rusti::atomic_xadd_rel(x, 1) == 2); + fail_unless!(*x == 3); - assert rusti::atomic_xsub(x, 1) == 3; - assert rusti::atomic_xsub_acq(x, 1) == 2; - assert rusti::atomic_xsub_rel(x, 1) == 1; - assert *x == 0; + fail_unless!(rusti::atomic_xsub(x, 1) == 3); + fail_unless!(rusti::atomic_xsub_acq(x, 1) == 2); + fail_unless!(rusti::atomic_xsub_rel(x, 1) == 1); + fail_unless!(*x == 0); } } diff --git a/src/test/run-pass/intrinsic-frame-address.rs b/src/test/run-pass/intrinsic-frame-address.rs index a0abded65ed..6c25291c48d 100644 --- a/src/test/run-pass/intrinsic-frame-address.rs +++ b/src/test/run-pass/intrinsic-frame-address.rs @@ -21,7 +21,7 @@ mod rusti { pub fn main() { unsafe { do rusti::frame_address |addr| { - assert addr.is_not_null(); + fail_unless!(addr.is_not_null()); } } } diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 0861f121565..7e0a8173f7e 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -21,6 +21,6 @@ pub fn main() { let mut x = @1; let mut y = @2; rusti::move_val(&mut y, x); - assert *y == 1; + fail_unless!(*y == 1); } } diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index f0a31acd11b..8731b812f4a 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -40,83 +40,83 @@ pub fn main() { unsafe { use rusti::*; - assert(ctpop8(0i8) == 0i8); - assert(ctpop16(0i16) == 0i16); - assert(ctpop32(0i32) == 0i32); - assert(ctpop64(0i64) == 0i64); + fail_unless!((ctpop8(0i8) == 0i8)); + fail_unless!((ctpop16(0i16) == 0i16)); + fail_unless!((ctpop32(0i32) == 0i32)); + fail_unless!((ctpop64(0i64) == 0i64)); - assert(ctpop8(1i8) == 1i8); - assert(ctpop16(1i16) == 1i16); - assert(ctpop32(1i32) == 1i32); - assert(ctpop64(1i64) == 1i64); + fail_unless!((ctpop8(1i8) == 1i8)); + fail_unless!((ctpop16(1i16) == 1i16)); + fail_unless!((ctpop32(1i32) == 1i32)); + fail_unless!((ctpop64(1i64) == 1i64)); - assert(ctpop8(10i8) == 2i8); - assert(ctpop16(10i16) == 2i16); - assert(ctpop32(10i32) == 2i32); - assert(ctpop64(10i64) == 2i64); + fail_unless!((ctpop8(10i8) == 2i8)); + fail_unless!((ctpop16(10i16) == 2i16)); + fail_unless!((ctpop32(10i32) == 2i32)); + fail_unless!((ctpop64(10i64) == 2i64)); - assert(ctpop8(100i8) == 3i8); - assert(ctpop16(100i16) == 3i16); - assert(ctpop32(100i32) == 3i32); - assert(ctpop64(100i64) == 3i64); + fail_unless!((ctpop8(100i8) == 3i8)); + fail_unless!((ctpop16(100i16) == 3i16)); + fail_unless!((ctpop32(100i32) == 3i32)); + fail_unless!((ctpop64(100i64) == 3i64)); - assert(ctpop8(-1i8) == 8i8); - assert(ctpop16(-1i16) == 16i16); - assert(ctpop32(-1i32) == 32i32); - assert(ctpop64(-1i64) == 64i64); + fail_unless!((ctpop8(-1i8) == 8i8)); + fail_unless!((ctpop16(-1i16) == 16i16)); + fail_unless!((ctpop32(-1i32) == 32i32)); + fail_unless!((ctpop64(-1i64) == 64i64)); - assert(ctlz8(0i8) == 8i8); - assert(ctlz16(0i16) == 16i16); - assert(ctlz32(0i32) == 32i32); - assert(ctlz64(0i64) == 64i64); + fail_unless!((ctlz8(0i8) == 8i8)); + fail_unless!((ctlz16(0i16) == 16i16)); + fail_unless!((ctlz32(0i32) == 32i32)); + fail_unless!((ctlz64(0i64) == 64i64)); - assert(ctlz8(1i8) == 7i8); - assert(ctlz16(1i16) == 15i16); - assert(ctlz32(1i32) == 31i32); - assert(ctlz64(1i64) == 63i64); + fail_unless!((ctlz8(1i8) == 7i8)); + fail_unless!((ctlz16(1i16) == 15i16)); + fail_unless!((ctlz32(1i32) == 31i32)); + fail_unless!((ctlz64(1i64) == 63i64)); - assert(ctlz8(10i8) == 4i8); - assert(ctlz16(10i16) == 12i16); - assert(ctlz32(10i32) == 28i32); - assert(ctlz64(10i64) == 60i64); + fail_unless!((ctlz8(10i8) == 4i8)); + fail_unless!((ctlz16(10i16) == 12i16)); + fail_unless!((ctlz32(10i32) == 28i32)); + fail_unless!((ctlz64(10i64) == 60i64)); - assert(ctlz8(100i8) == 1i8); - assert(ctlz16(100i16) == 9i16); - assert(ctlz32(100i32) == 25i32); - assert(ctlz64(100i64) == 57i64); + fail_unless!((ctlz8(100i8) == 1i8)); + fail_unless!((ctlz16(100i16) == 9i16)); + fail_unless!((ctlz32(100i32) == 25i32)); + fail_unless!((ctlz64(100i64) == 57i64)); - assert(cttz8(-1i8) == 0i8); - assert(cttz16(-1i16) == 0i16); - assert(cttz32(-1i32) == 0i32); - assert(cttz64(-1i64) == 0i64); + fail_unless!((cttz8(-1i8) == 0i8)); + fail_unless!((cttz16(-1i16) == 0i16)); + fail_unless!((cttz32(-1i32) == 0i32)); + fail_unless!((cttz64(-1i64) == 0i64)); - assert(cttz8(0i8) == 8i8); - assert(cttz16(0i16) == 16i16); - assert(cttz32(0i32) == 32i32); - assert(cttz64(0i64) == 64i64); + fail_unless!((cttz8(0i8) == 8i8)); + fail_unless!((cttz16(0i16) == 16i16)); + fail_unless!((cttz32(0i32) == 32i32)); + fail_unless!((cttz64(0i64) == 64i64)); - assert(cttz8(1i8) == 0i8); - assert(cttz16(1i16) == 0i16); - assert(cttz32(1i32) == 0i32); - assert(cttz64(1i64) == 0i64); + fail_unless!((cttz8(1i8) == 0i8)); + fail_unless!((cttz16(1i16) == 0i16)); + fail_unless!((cttz32(1i32) == 0i32)); + fail_unless!((cttz64(1i64) == 0i64)); - assert(cttz8(10i8) == 1i8); - assert(cttz16(10i16) == 1i16); - assert(cttz32(10i32) == 1i32); - assert(cttz64(10i64) == 1i64); + fail_unless!((cttz8(10i8) == 1i8)); + fail_unless!((cttz16(10i16) == 1i16)); + fail_unless!((cttz32(10i32) == 1i32)); + fail_unless!((cttz64(10i64) == 1i64)); - assert(cttz8(100i8) == 2i8); - assert(cttz16(100i16) == 2i16); - assert(cttz32(100i32) == 2i32); - assert(cttz64(100i64) == 2i64); + fail_unless!((cttz8(100i8) == 2i8)); + fail_unless!((cttz16(100i16) == 2i16)); + fail_unless!((cttz32(100i32) == 2i32)); + fail_unless!((cttz64(100i64) == 2i64)); - assert(cttz8(-1i8) == 0i8); - assert(cttz16(-1i16) == 0i16); - assert(cttz32(-1i32) == 0i32); - assert(cttz64(-1i64) == 0i64); + fail_unless!((cttz8(-1i8) == 0i8)); + fail_unless!((cttz16(-1i16) == 0i16)); + fail_unless!((cttz32(-1i32) == 0i32)); + fail_unless!((cttz64(-1i64) == 0i64)); - assert(bswap16(0x0A0Bi16) == 0x0B0Ai16); - assert(bswap32(0x0ABBCC0Di32) == 0x0DCCBB0Ai32); - assert(bswap64(0x0122334455667708i64) == 0x0877665544332201i64); + fail_unless!((bswap16(0x0A0Bi16) == 0x0B0Ai16)); + fail_unless!((bswap32(0x0ABBCC0Di32) == 0x0DCCBB0Ai32)); + fail_unless!((bswap64(0x0122334455667708i64) == 0x0877665544332201i64)); } } diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index c59425264a3..b0db48057b1 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -54,54 +54,54 @@ pub fn main() { unsafe { use rusti::*; - assert(sqrtf32(64f32).fuzzy_eq(&8f32)); - assert(sqrtf64(64f64).fuzzy_eq(&8f64)); + fail_unless!((sqrtf32(64f32).fuzzy_eq(&8f32))); + fail_unless!((sqrtf64(64f64).fuzzy_eq(&8f64))); - assert(powif32(25f32, -2i32).fuzzy_eq(&0.0016f32)); - assert(powif64(23.2f64, 2i32).fuzzy_eq(&538.24f64)); + fail_unless!((powif32(25f32, -2i32).fuzzy_eq(&0.0016f32))); + fail_unless!((powif64(23.2f64, 2i32).fuzzy_eq(&538.24f64))); - assert(sinf32(0f32).fuzzy_eq(&0f32)); - assert(sinf64(f64::consts::pi / 2f64).fuzzy_eq(&1f64)); + fail_unless!((sinf32(0f32).fuzzy_eq(&0f32))); + fail_unless!((sinf64(f64::consts::pi / 2f64).fuzzy_eq(&1f64))); - assert(cosf32(0f32).fuzzy_eq(&1f32)); - assert(cosf64(f64::consts::pi * 2f64).fuzzy_eq(&1f64)); + fail_unless!((cosf32(0f32).fuzzy_eq(&1f32))); + fail_unless!((cosf64(f64::consts::pi * 2f64).fuzzy_eq(&1f64))); - assert(powf32(25f32, -2f32).fuzzy_eq(&0.0016f32)); - assert(powf64(400f64, 0.5f64).fuzzy_eq(&20f64)); + fail_unless!((powf32(25f32, -2f32).fuzzy_eq(&0.0016f32))); + fail_unless!((powf64(400f64, 0.5f64).fuzzy_eq(&20f64))); - assert(fabsf32(expf32(1f32) - f32::consts::e).fuzzy_eq(&0f32)); - assert(expf64(1f64).fuzzy_eq(&f64::consts::e)); + fail_unless!((fabsf32(expf32(1f32) - f32::consts::e).fuzzy_eq(&0f32))); + fail_unless!((expf64(1f64).fuzzy_eq(&f64::consts::e))); - assert(exp2f32(10f32).fuzzy_eq(&1024f32)); - assert(exp2f64(50f64).fuzzy_eq(&1125899906842624f64)); + fail_unless!((exp2f32(10f32).fuzzy_eq(&1024f32))); + fail_unless!((exp2f64(50f64).fuzzy_eq(&1125899906842624f64))); - assert(fabsf32(logf32(f32::consts::e) - 1f32).fuzzy_eq(&0f32)); - assert(logf64(1f64).fuzzy_eq(&0f64)); + fail_unless!((fabsf32(logf32(f32::consts::e) - 1f32).fuzzy_eq(&0f32))); + fail_unless!((logf64(1f64).fuzzy_eq(&0f64))); - assert(log10f32(10f32).fuzzy_eq(&1f32)); - assert(log10f64(f64::consts::e).fuzzy_eq(&f64::consts::log10_e)); + fail_unless!((log10f32(10f32).fuzzy_eq(&1f32))); + fail_unless!((log10f64(f64::consts::e).fuzzy_eq(&f64::consts::log10_e))); - assert(log2f32(8f32).fuzzy_eq(&3f32)); - assert(log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e)); + fail_unless!((log2f32(8f32).fuzzy_eq(&3f32))); + fail_unless!((log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e))); - assert(fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32)); - assert(fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e)); + fail_unless!((fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32))); + fail_unless!((fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e))); - assert(fabsf32(-1.0f32).fuzzy_eq(&1.0f32)); - assert(fabsf64(34.2f64).fuzzy_eq(&34.2f64)); + fail_unless!((fabsf32(-1.0f32).fuzzy_eq(&1.0f32))); + fail_unless!((fabsf64(34.2f64).fuzzy_eq(&34.2f64))); - assert(floorf32(3.8f32).fuzzy_eq(&3.0f32)); - assert(floorf64(-1.1f64).fuzzy_eq(&-2.0f64)); + fail_unless!((floorf32(3.8f32).fuzzy_eq(&3.0f32))); + fail_unless!((floorf64(-1.1f64).fuzzy_eq(&-2.0f64))); // 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-1112.rs b/src/test/run-pass/issue-1112.rs index e2a91910975..111dd43747f 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 x.b == 9u8; - assert x.c == true; - assert x.d == 10u8; - assert x.e == 11u16; - assert x.f == 12u8; - assert x.g == 13u8; + fail_unless!(x.b == 9u8); + fail_unless!(x.c == true); + fail_unless!(x.d == 10u8); + fail_unless!(x.e == 11u16); + fail_unless!(x.f == 12u8); + fail_unless!(x.g == 13u8); } diff --git a/src/test/run-pass/issue-1458.rs b/src/test/run-pass/issue-1458.rs index b5c8a0d3138..7ef47ed1dda 100644 --- a/src/test/run-pass/issue-1458.rs +++ b/src/test/run-pass/issue-1458.rs @@ -18,5 +18,5 @@ fn ret_plus_one() -> extern fn(fn() -> int) -> int { pub fn main() { let z = do (ret_plus_one()) || { 2 }; - assert z == 3; + fail_unless!(z == 3); } diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index 305bd69a57e..577d74c4118 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 noise(cat(tabby)) == Some(~"meow"); - assert noise(dog(pug)) == Some(~"woof"); - assert noise(rabbit(~"Hilbert", upright)) == None; - assert noise(tiger) == Some(~"roar"); + fail_unless!(noise(cat(tabby)) == Some(~"meow")); + fail_unless!(noise(dog(pug)) == Some(~"woof")); + fail_unless!(noise(rabbit(~"Hilbert", upright)) == None); + fail_unless!(noise(tiger) == Some(~"roar")); } diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index 7b44f79e50d..7cf255e0172 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -44,5 +44,5 @@ mod m { pub fn main() { let mut y: int = 5; let x: &mut int = &mut y; - assert (lgamma(1.0 as c_double, x) == 0.0 as c_double); + fail_unless!((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 ada3852812c..22e69c92a1a 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(x == 42); + fail_unless!((x == 42)); } diff --git a/src/test/run-pass/issue-2428.rs b/src/test/run-pass/issue-2428.rs index d8b11dc0113..766bc23173c 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 (Bar as int == quux); + fail_unless!((Bar as int == quux)); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 4a7263266b7..31812d4637c 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -73,7 +73,7 @@ pub mod pipes { pub fn send(mut p: send_packet, -payload: T) { let mut 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 { @@ -110,7 +110,7 @@ pub mod pipes { return Some(option::unwrap(payload)) } terminated => { - assert old_state == terminated; + fail_unless!(old_state == terminated); return None; } } diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index 438abe98413..4c8559f0552 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -28,5 +28,5 @@ fn defer(b: &'r mut bool) -> defer/&r { pub fn main() { let mut dtor_ran = false; let _ = defer(&mut dtor_ran); - assert(dtor_ran); + fail_unless!((dtor_ran)); } diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index 75fc9f3a87e..9fa1d56406a 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -28,5 +28,5 @@ fn defer(b: &'r mut bool) -> defer/&r { pub fn main() { let mut dtor_ran = false; defer(&mut dtor_ran); - assert(dtor_ran); + fail_unless!((dtor_ran)); } diff --git a/src/test/run-pass/issue-2748-b.rs b/src/test/run-pass/issue-2748-b.rs index f5720881221..7e5730a3db1 100644 --- a/src/test/run-pass/issue-2748-b.rs +++ b/src/test/run-pass/issue-2748-b.rs @@ -13,6 +13,6 @@ pub fn main() { let x = &[1,2,3]; let y = x; let z = thing(x); - assert(z[2] == x[2]); - assert(z[1] == y[1]); + fail_unless!((z[2] == x[2])); + fail_unless!((z[1] == y[1])); } diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index d97c3c3de5e..dee2483462d 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -22,12 +22,12 @@ impl Drop for Kitty { #[cfg(target_arch = "x86_64")] pub fn main() { - assert (sys::size_of::() == 8 as uint); - assert (sys::size_of::() == 16 as uint); + fail_unless!((sys::size_of::() == 8 as uint)); + fail_unless!((sys::size_of::() == 16 as uint)); } #[cfg(target_arch = "x86")] pub fn main() { - assert (sys::size_of::() == 4 as uint); - assert (sys::size_of::() == 8 as uint); + fail_unless!((sys::size_of::() == 4 as uint)); + fail_unless!((sys::size_of::() == 8 as uint)); } diff --git a/src/test/run-pass/issue-2936.rs b/src/test/run-pass/issue-2936.rs index 52f1678fd02..2e343e9afe6 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 x == 5; + fail_unless!(x == 5); } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 0ad88e350a6..72af21368f1 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -41,5 +41,5 @@ pub fn main() { io::println(fmt!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint)); } - assert bools == bools2; + fail_unless!(bools == bools2); } diff --git a/src/test/run-pass/issue-3091.rs b/src/test/run-pass/issue-3091.rs index 5a38da1f1d2..a218df591c5 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 &x == &y; + fail_unless!(&x == &y); } diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs index b0a3223bb3b..f0e1779ba37 100644 --- a/src/test/run-pass/issue-3168.rs +++ b/src/test/run-pass/issue-3168.rs @@ -26,6 +26,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-3176.rs b/src/test/run-pass/issue-3176.rs index e0c074c968f..c1008e581ea 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -30,6 +30,6 @@ pub fn main() { c.send(()); }; 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-3211.rs b/src/test/run-pass/issue-3211.rs index 435ac8e7bfe..c759ca1ad0f 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -3,6 +3,6 @@ pub fn main() { for 4096.times { x += 1; } - assert x == 4096; + fail_unless!(x == 4096); io::println(fmt!("x = %u", x)); } diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 1f9dd6e3b6f..6a1f00de21a 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 0e4f7d9749d..b472d3a105b 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -22,7 +22,7 @@ fn tester() let loader: rsrc_loader = |_path| {result::Ok(~"more blah")}; let path = path::from_str("blah"); - assert loader(&path).is_ok(); + fail_unless!(loader(&path).is_ok()); } pub fn main() {} diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index aff0b4fc71e..0486357dc69 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -33,7 +33,7 @@ fn tester() let table = HashMap(); table.insert(@~"one", 1); table.insert(@~"two", 2); - assert check_strs(table.to_str(), ~"xxx"); // not sure what expected should be + fail_unless!(check_strs(table.to_str(), ~"xxx")); // not sure what expected should be } pub fn main() {} diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 4671b25ce22..ad6cae0bff9 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -182,7 +182,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...")); } @@ -192,7 +192,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.*.")); } @@ -201,7 +201,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 1b666fd5649..5d0d65820e1 100644 --- a/src/test/run-pass/issue-3574.rs +++ b/src/test/run-pass/issue-3574.rs @@ -22,6 +22,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-3683.rs b/src/test/run-pass/issue-3683.rs index e254ac809a4..79e205d262a 100644 --- a/src/test/run-pass/issue-3683.rs +++ b/src/test/run-pass/issue-3683.rs @@ -24,5 +24,5 @@ impl Foo for int { } pub fn main() { - assert(3.b() == 5); + fail_unless!((3.b() == 5)); } diff --git a/src/test/run-pass/issue-3935.rs b/src/test/run-pass/issue-3935.rs index 2f240184479..e0832bc74b2 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-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index ce0ae648562..84136b40a7b 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -37,5 +37,5 @@ impl Point: Movable; pub fn main() { let p = Point{ x: 1, y: 2}; p.translate(3); - assert p.X() == 4; + fail_unless!(p.X() == 4); } diff --git a/src/test/run-pass/issue-3979-xcrate.rs b/src/test/run-pass/issue-3979-xcrate.rs index 18ad14153d7..e87e7692855 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 p.X() == 4; + fail_unless!(p.X() == 4); } diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index 6d6be35bfa0..3ff677cf1fe 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -40,5 +40,5 @@ impl Movable for Point; pub fn main() { let mut p = Point{ x: 1, y: 2}; p.translate(3); - assert p.X() == 4; + fail_unless!(p.X() == 4); } diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index d89e0e7d95e..ef947ef3cd7 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -3,6 +3,6 @@ pub fn main() { for 999_999.times() { count += 1; } - assert count == 999_999; + fail_unless!(count == 999_999); io::println(fmt!("%u", count)); } diff --git a/src/test/run-pass/issue-4448.rs b/src/test/run-pass/issue-4448.rs index 6deb5f46b48..80cc9a72c33 100644 --- a/src/test/run-pass/issue-4448.rs +++ b/src/test/run-pass/issue-4448.rs @@ -12,7 +12,7 @@ fn main() { let (port, chan) = comm::stream::<&static/str>(); do task::spawn { - assert port.recv() == "hello, world"; + fail_unless!(port.recv() == "hello, world"); } chan.send("hello, world"); diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index 119739f7fdb..d46f62c6ae0 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -30,5 +30,5 @@ pub fn main() { let p = Some(r(b)); } - assert *b == 1; + fail_unless!(*b == 1); } diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs index 572cf69e1d9..86fa5be0a22 100644 --- a/src/test/run-pass/issue2378c.rs +++ b/src/test/run-pass/issue2378c.rs @@ -20,5 +20,5 @@ use issue2378b::{methods}; pub fn main() { let x = {a: just(3), b: just(5)}; - assert x[0u] == (3, 5); + fail_unless!(x[0u] == (3, 5)); } diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 943d87a5222..55ffd15259d 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"; log(debug, copy s); 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,42 +22,42 @@ 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"; log(debug, s); } fn test_stack_add() { - assert (~"a" + ~"b" == ~"ab"); + fail_unless!((~"a" + ~"b" == ~"ab")); let s: ~str = ~"a"; - assert (s + s == ~"aa"); - assert (~"" + ~"" == ~""); + fail_unless!((s + s == ~"aa")); + fail_unless!((~"" + ~"" == ~"")); } -fn test_stack_heap_add() { assert (~"a" + ~"bracadabra" == ~"abracadabra"); } +fn test_stack_heap_add() { fail_unless!((~"a" + ~"bracadabra" == ~"abracadabra")); } fn test_heap_add() { - assert (~"this should" + ~" totally work" == ~"this should totally work"); + fail_unless!((~"this should" + ~" totally work" == ~"this should totally work")); } fn test_append() { let mut s = ~""; s += ~"a"; - assert (s == ~"a"); + fail_unless!((s == ~"a")); let mut s = ~"a"; s += ~"b"; log(debug, copy s); - assert (s == ~"ab"); + fail_unless!((s == ~"ab")); let mut s = ~"c"; s += ~"offee"; - assert (s == ~"coffee"); + fail_unless!((s == ~"coffee")); s += ~"&tea"; - assert (s == ~"coffee&tea"); + fail_unless!((s == ~"coffee&tea")); } pub fn main() { diff --git a/src/test/run-pass/iter-all.rs b/src/test/run-pass/iter-all.rs index d5801a743cb..62b4825067f 100644 --- a/src/test/run-pass/iter-all.rs +++ b/src/test/run-pass/iter-all.rs @@ -11,11 +11,11 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } pub fn main() { - assert ![1u, 2u].all(is_even); - assert [2u, 4u].all(is_even); - assert [].all(is_even); + fail_unless!(![1u, 2u].all(is_even)); + fail_unless!([2u, 4u].all(is_even)); + fail_unless!([].all(is_even)); - assert !iter::all(&Some(1u), is_even); - assert iter::all(&Some(2u), is_even); - assert iter::all(&None::, is_even); + fail_unless!(!iter::all(&Some(1u), is_even)); + fail_unless!(iter::all(&Some(2u), is_even)); + fail_unless!(iter::all(&None::, is_even)); } diff --git a/src/test/run-pass/iter-any.rs b/src/test/run-pass/iter-any.rs index 3a98a28dc24..e23a87287e7 100644 --- a/src/test/run-pass/iter-any.rs +++ b/src/test/run-pass/iter-any.rs @@ -11,11 +11,11 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } pub fn main() { - assert ![1u, 3u].any(is_even); - assert [1u, 2u].any(is_even); - assert ![].any(is_even); + fail_unless!(![1u, 3u].any(is_even)); + fail_unless!([1u, 2u].any(is_even)); + fail_unless!(![].any(is_even)); - assert !iter::any(&Some(1u), is_even); - assert iter::any(&Some(2u), is_even); - assert !iter::any(&None::, is_even); + fail_unless!(!iter::any(&Some(1u), is_even)); + fail_unless!(iter::any(&Some(2u), is_even)); + fail_unless!(!iter::any(&None::, is_even)); } diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs index bac85c87517..f56779a3c7a 100644 --- a/src/test/run-pass/iter-contains.rs +++ b/src/test/run-pass/iter-contains.rs @@ -9,12 +9,12 @@ // except according to those terms. pub fn main() { - assert [].contains(&22u) == false; - assert [1u, 3u].contains(&22u) == false; - assert [22u, 1u, 3u].contains(&22u) == true; - assert [1u, 22u, 3u].contains(&22u) == true; - assert [1u, 3u, 22u].contains(&22u) == true; - assert iter::contains(&None::, &22u) == false; - assert iter::contains(&Some(1u), &22u) == false; - assert iter::contains(&Some(22u), &22u) == true; + fail_unless!([].contains(&22u) == false); + fail_unless!([1u, 3u].contains(&22u) == false); + fail_unless!([22u, 1u, 3u].contains(&22u) == true); + fail_unless!([1u, 22u, 3u].contains(&22u) == true); + fail_unless!([1u, 3u, 22u].contains(&22u) == true); + fail_unless!(iter::contains(&None::, &22u) == false); + fail_unless!(iter::contains(&Some(1u), &22u) == false); + fail_unless!(iter::contains(&Some(22u), &22u) == true); } diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs index f2977655518..8de0a727a52 100644 --- a/src/test/run-pass/iter-count.rs +++ b/src/test/run-pass/iter-count.rs @@ -9,11 +9,11 @@ // except according to those terms. pub fn main() { - assert [].count(&22u) == 0u; - assert [1u, 3u].count(&22u) == 0u; - assert [22u, 1u, 3u].count(&22u) == 1u; - assert [22u, 1u, 22u].count(&22u) == 2u; - assert iter::count(&None::, &22u) == 0u; - assert iter::count(&Some(1u), &22u) == 0u; - assert iter::count(&Some(22u), &22u) == 1u; + fail_unless!([].count(&22u) == 0u); + fail_unless!([1u, 3u].count(&22u) == 0u); + fail_unless!([22u, 1u, 3u].count(&22u) == 1u); + fail_unless!([22u, 1u, 22u].count(&22u) == 2u); + fail_unless!(iter::count(&None::, &22u) == 0u); + fail_unless!(iter::count(&Some(1u), &22u) == 0u); + fail_unless!(iter::count(&Some(22u), &22u) == 1u); } diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs index 9746fab2eb8..150b435bd5c 100644 --- a/src/test/run-pass/iter-eachi.rs +++ b/src/test/run-pass/iter-eachi.rs @@ -11,17 +11,17 @@ pub fn main() { let mut c = 0u; for [1u, 2u, 3u, 4u, 5u].eachi |i, v| { - assert (i + 1u) == *v; + fail_unless!((i + 1u) == *v); c += 1u; } - assert c == 5u; + fail_unless!(c == 5u); for iter::eachi(&None::) |i, v| { fail!(); } let mut c = 0u; for iter::eachi(&Some(1u)) |i, v| { - assert (i + 1u) == *v; + fail_unless!((i + 1u) == *v); c += 1u; } - assert c == 1u; + fail_unless!(c == 1u); } diff --git a/src/test/run-pass/iter-filter-to-vec.rs b/src/test/run-pass/iter-filter-to-vec.rs index b654151079b..f96ff5efd81 100644 --- a/src/test/run-pass/iter-filter-to-vec.rs +++ b/src/test/run-pass/iter-filter-to-vec.rs @@ -11,9 +11,9 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } pub fn main() { - assert [1, 3].filter_to_vec(is_even) == ~[]; - assert [1, 2, 3].filter_to_vec(is_even) == ~[2]; - assert iter::filter_to_vec(&None::, is_even) == ~[]; - assert iter::filter_to_vec(&Some(1u), is_even) == ~[]; - assert iter::filter_to_vec(&Some(2u), is_even) == ~[2]; + fail_unless!([1, 3].filter_to_vec(is_even) == ~[]); + fail_unless!([1, 2, 3].filter_to_vec(is_even) == ~[2]); + fail_unless!(iter::filter_to_vec(&None::, is_even) == ~[]); + fail_unless!(iter::filter_to_vec(&Some(1u), is_even) == ~[]); + fail_unless!(iter::filter_to_vec(&Some(2u), is_even) == ~[2]); } diff --git a/src/test/run-pass/iter-flat-map-to-vec.rs b/src/test/run-pass/iter-flat-map-to-vec.rs index cf54ebf2fe9..2ed6f95e455 100644 --- a/src/test/run-pass/iter-flat-map-to-vec.rs +++ b/src/test/run-pass/iter-flat-map-to-vec.rs @@ -15,15 +15,15 @@ fn incd_if_even(x: &uint) -> Option { } pub fn main() { - assert (~[1u, 3u]).flat_map_to_vec(repeat) == ~[1u, 1u, 3u, 3u]; - assert (~[]).flat_map_to_vec(repeat) == ~[]; - assert iter::flat_map_to_vec(&None::, repeat) == ~[]; - assert iter::flat_map_to_vec(&Some(1u), repeat) == ~[1u, 1u]; - assert iter::flat_map_to_vec(&Some(2u), repeat) == ~[2u, 2u]; + fail_unless!((~[1u, 3u]).flat_map_to_vec(repeat) == ~[1u, 1u, 3u, 3u]); + fail_unless!((~[]).flat_map_to_vec(repeat) == ~[]); + fail_unless!(iter::flat_map_to_vec(&None::, repeat) == ~[]); + fail_unless!(iter::flat_map_to_vec(&Some(1u), repeat) == ~[1u, 1u]); + fail_unless!(iter::flat_map_to_vec(&Some(2u), repeat) == ~[2u, 2u]); - assert (~[1u, 2u, 5u]).flat_map_to_vec(incd_if_even) == ~[3u]; - assert (~[]).flat_map_to_vec(incd_if_even) == ~[]; - assert iter::flat_map_to_vec(&None::, incd_if_even) == ~[]; - assert iter::flat_map_to_vec(&Some(1u), incd_if_even) == ~[]; - assert iter::flat_map_to_vec(&Some(2u), incd_if_even) == ~[3u]; + fail_unless!((~[1u, 2u, 5u]).flat_map_to_vec(incd_if_even) == ~[3u]); + fail_unless!((~[]).flat_map_to_vec(incd_if_even) == ~[]); + fail_unless!(iter::flat_map_to_vec(&None::, incd_if_even) == ~[]); + fail_unless!(iter::flat_map_to_vec(&Some(1u), incd_if_even) == ~[]); + fail_unless!(iter::flat_map_to_vec(&Some(2u), incd_if_even) == ~[3u]); } diff --git a/src/test/run-pass/iter-foldl.rs b/src/test/run-pass/iter-foldl.rs index 41ac8282347..cbfb2fb7bc6 100644 --- a/src/test/run-pass/iter-foldl.rs +++ b/src/test/run-pass/iter-foldl.rs @@ -11,9 +11,9 @@ fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) } pub fn main() { - assert [1u, 3u].foldl(20f, add) == 24f; - assert [].foldl(20f, add) == 20f; - assert iter::foldl(&None::, 20f, add) == 20f; - assert iter::foldl(&Some(1u), 20f, add) == 21f; - assert iter::foldl(&Some(2u), 20f, add) == 22f; + fail_unless!([1u, 3u].foldl(20f, add) == 24f); + fail_unless!([].foldl(20f, add) == 20f); + fail_unless!(iter::foldl(&None::, 20f, add) == 20f); + fail_unless!(iter::foldl(&Some(1u), 20f, add) == 21f); + fail_unless!(iter::foldl(&Some(2u), 20f, add) == 22f); } diff --git a/src/test/run-pass/iter-map-to-vec.rs b/src/test/run-pass/iter-map-to-vec.rs index edbd372ad84..f2361376fd8 100644 --- a/src/test/run-pass/iter-map-to-vec.rs +++ b/src/test/run-pass/iter-map-to-vec.rs @@ -11,9 +11,9 @@ fn inc(x: &uint) -> uint { *x + 1 } pub fn main() { - assert [1, 3].map_to_vec(inc) == ~[2, 4]; - assert [1, 2, 3].map_to_vec(inc) == ~[2, 3, 4]; - assert iter::map_to_vec(&None::, inc) == ~[]; - assert iter::map_to_vec(&Some(1u), inc) == ~[2]; - assert iter::map_to_vec(&Some(2u), inc) == ~[3]; + fail_unless!([1, 3].map_to_vec(inc) == ~[2, 4]); + fail_unless!([1, 2, 3].map_to_vec(inc) == ~[2, 3, 4]); + fail_unless!(iter::map_to_vec(&None::, inc) == ~[]); + fail_unless!(iter::map_to_vec(&Some(1u), inc) == ~[2]); + fail_unless!(iter::map_to_vec(&Some(2u), inc) == ~[3]); } diff --git a/src/test/run-pass/iter-min-max.rs b/src/test/run-pass/iter-min-max.rs index 1c95432b2b9..188aff44007 100644 --- a/src/test/run-pass/iter-min-max.rs +++ b/src/test/run-pass/iter-min-max.rs @@ -11,11 +11,11 @@ fn is_even(&&x: uint) -> bool { (x % 2u) == 0u } pub fn main() { - assert [1u, 3u].min() == 1u; - assert [3u, 1u].min() == 1u; - assert iter::min(&Some(1u)) == 1u; + fail_unless!([1u, 3u].min() == 1u); + fail_unless!([3u, 1u].min() == 1u); + fail_unless!(iter::min(&Some(1u)) == 1u); - assert [1u, 3u].max() == 3u; - assert [3u, 1u].max() == 3u; - assert iter::max(&Some(3u)) == 3u; + fail_unless!([1u, 3u].max() == 3u); + fail_unless!([3u, 1u].max() == 3u); + fail_unless!(iter::max(&Some(3u)) == 3u); } diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index 16f27db7bf2..5fdd60bedb3 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: fn(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/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs index ab102944b1e..00fcb17a0b0 100644 --- a/src/test/run-pass/iter-to-vec.rs +++ b/src/test/run-pass/iter-to-vec.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - assert [1u, 3u].to_vec() == ~[1u, 3u]; + fail_unless!([1u, 3u].to_vec() == ~[1u, 3u]); let e: ~[uint] = ~[]; - assert e.to_vec() == ~[]; - assert iter::to_vec(&None::) == ~[]; - assert iter::to_vec(&Some(1u)) == ~[1u]; - assert iter::to_vec(&Some(2u)) == ~[2u]; + fail_unless!(e.to_vec() == ~[]); + fail_unless!(iter::to_vec(&None::) == ~[]); + fail_unless!(iter::to_vec(&Some(1u)) == ~[1u]); + fail_unless!(iter::to_vec(&Some(2u)) == ~[2u]); } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index aa61a35d6e3..410286d683f 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -14,11 +14,11 @@ fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } pub fn main() { let mut d = double(1); - assert (d[0] == 1); - assert (d[1] == 1); + fail_unless!((d[0] == 1)); + fail_unless!((d[1] == 1)); d = double_int(1); - assert (d[0] == 1); - assert (d[1] == 1); + fail_unless!((d[0] == 1)); + fail_unless!((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 0ef09d39663..bb6ed754ab6 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -22,5 +22,5 @@ fn repeater(v: @A) -> repeat { pub fn main() { let x = &3; let y = repeater(@x); - assert *x == *(y.get()); + fail_unless!(*x == *(y.get())); } 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 b5fb4368098..40075e12f4b 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() -> @fn() -> int { } pub fn main() { - assert foo()() == 22; + fail_unless!(foo()() == 22); } diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index 258f4714cf8..b86f7974bc3 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; log(debug, x || incr(&mut y)); - assert (y == 10); - if true && x { assert (true); } else { assert (false); } + fail_unless!((y == 10)); + if true && x { fail_unless!((true)); } else { fail_unless!((false)); } } diff --git a/src/test/run-pass/let-destruct-fresh-mem.rs b/src/test/run-pass/let-destruct-fresh-mem.rs index caccd1ac15c..0b085f1fd32 100644 --- a/src/test/run-pass/let-destruct-fresh-mem.rs +++ b/src/test/run-pass/let-destruct-fresh-mem.rs @@ -16,8 +16,8 @@ pub fn main() { let mut X {x: x, y: @A {a: a}} = u; x = 100; a = 100; - assert (x == 100); - assert (a == 100); - assert (u.x == 10); - assert (u.y.a == 20); + fail_unless!((x == 100)); + fail_unless!((a == 100)); + fail_unless!((u.x == 10)); + fail_unless!((u.y.a == 20)); } diff --git a/src/test/run-pass/let-destruct.rs b/src/test/run-pass/let-destruct.rs index 1a111135563..eec3064cbbd 100644 --- a/src/test/run-pass/let-destruct.rs +++ b/src/test/run-pass/let-destruct.rs @@ -14,5 +14,5 @@ struct X { x: xx, y: int } pub fn main() { let @X {x: xx(x), y: y} = @X{x: xx(10), y: 20}; - assert (x + y == 30); + fail_unless!((x + y == 30)); } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index bad813aef52..c232ab42dfc 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -15,20 +15,20 @@ pub fn main() { let mut y = 0; for x.each |i| { log(debug, *i); y += *i; } log(debug, y); - assert (y == 6); + fail_unless!((y == 6)); let s = ~"hello there"; let mut i: int = 0; for str::each(s) |c| { - 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; log(debug, i); log(debug, c); } - assert (i == 11); + fail_unless!((i == 11)); } diff --git a/src/test/run-pass/log-degen-enum.rs b/src/test/run-pass/log-degen-enum.rs index fc17ec96ea6..79ad6e8a250 100644 --- a/src/test/run-pass/log-degen-enum.rs +++ b/src/test/run-pass/log-degen-enum.rs @@ -13,5 +13,5 @@ enum Foo = uint; pub fn main() { let x = Foo(1); let y = fmt!("%?", x); - assert y == ~"Foo(1)"; + fail_unless!(y == ~"Foo(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 46db3d32340..a521b5fe478 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 @@ -19,13 +19,13 @@ enum foo { } fn check_log(exp: ~str, v: T) { - assert exp == fmt!("%?", v); + fail_unless!(exp == fmt!("%?", v)); } pub fn main() { let x = list::from_vec(~[a(22u), b(~"hi")]); let exp = ~"@Cons(a(22), @Cons(b(~\"hi\"), @Nil))"; let act = fmt!("%?", x); - assert act == exp; + fail_unless!(act == exp); check_log(exp, x); } 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 dcf11afbc17..bbd05daf49f 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 ~"a(22)" == fmt!("%?", a(22u)); - assert ~"b(~\"hi\")" == fmt!("%?", b(~"hi")); - assert ~"c" == fmt!("%?", c); - assert ~"d" == fmt!("%?", d); + fail_unless!(~"a(22)" == fmt!("%?", a(22u))); + fail_unless!(~"b(~\"hi\")" == fmt!("%?", b(~"hi"))); + fail_unless!(~"c" == fmt!("%?", c)); + fail_unless!(~"d" == fmt!("%?", d)); } diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs index 3774253b59b..d41867f1722 100644 --- a/src/test/run-pass/log-str.rs +++ b/src/test/run-pass/log-str.rs @@ -10,8 +10,8 @@ pub fn main() { let act = sys::log_str(&~[1, 2, 3]); - assert ~"~[1, 2, 3]" == act; + fail_unless!(~"~[1, 2, 3]" == act); let act = fmt!("%?/%6?", ~[1, 2, 3], ~"hi"); - assert act == ~"~[1, 2, 3]/ ~\"hi\""; + fail_unless!(act == ~"~[1, 2, 3]/ ~\"hi\""); } diff --git a/src/test/run-pass/loop-break-cont-1.rs b/src/test/run-pass/loop-break-cont-1.rs index b91770b3e39..a07203c9e13 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 05a1764ed5a..753c7c019b5 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 (i == 10u); + fail_unless!((i == 10u)); let mut is_even = false; loop { if i == 21u { @@ -31,7 +31,7 @@ pub fn main() { } is_even = true; } - assert !is_even; + fail_unless!(!is_even); loop { log(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/loop-scope.rs b/src/test/run-pass/loop-scope.rs index df5b55268a1..55697a086aa 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.each |x| { sum += *x; } - assert (sum == 60); + fail_unless!((sum == 60)); } diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index ad8f7b9cecf..304e76d0ee4 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -23,7 +23,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-path.rs b/src/test/run-pass/macro-path.rs index a721f8c9469..da5d79baadf 100644 --- a/src/test/run-pass/macro-path.rs +++ b/src/test/run-pass/macro-path.rs @@ -20,5 +20,5 @@ macro_rules! foo { } pub fn main() { - assert foo!(m::t) == 10; + fail_unless!(foo!(m::t) == 10); } diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index b4b0d3d0a22..26ad97ce21d 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -27,16 +27,16 @@ pub fn main() { ); mylet!(y, 8*2); - assert(y == 16); + fail_unless!((y == 16)); myfn!(mult, (a,b), { a*b } ); - assert (mult(2, add(4,4)) == 16); + fail_unless!((mult(2, add(4,4)) == 16)); macro_rules! actually_an_expr_macro ( () => ( 16 ) ) - assert { actually_an_expr_macro!() } == 16; + fail_unless!({ actually_an_expr_macro!() } == 16); } diff --git a/src/test/run-pass/mod-inside-fn.rs b/src/test/run-pass/mod-inside-fn.rs index 75dd2af9943..768578d691e 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 f() == 720; + fail_unless!(f() == 720); } diff --git a/src/test/run-pass/mod-merge-hack.rs b/src/test/run-pass/mod-merge-hack.rs index cd904681013..2f910fdbc2c 100644 --- a/src/test/run-pass/mod-merge-hack.rs +++ b/src/test/run-pass/mod-merge-hack.rs @@ -14,6 +14,6 @@ mod myint32; pub fn main() { - assert myint32::bits == 32; - assert myint32::min(10, 20) == 10; + fail_unless!(myint32::bits == 32); + fail_unless!(myint32::min(10, 20) == 10); } diff --git a/src/test/run-pass/mod_dir_path.rs b/src/test/run-pass/mod_dir_path.rs index a79115a6fb8..0d43e24809d 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 mod_dir_simple::syrup::foo() == 10; + fail_unless!(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 0d3ed8b2b0b..0f6e94bce33 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 pancakes::syrup::foo() == 10; + fail_unless!(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 06c9e507d2f..881eac72ebd 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 pancakes::test::foo() == 10; + fail_unless!(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 43f94303863..c0019bcfd7c 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 biscuits::test::foo() == 10; - assert gravy::test::foo() == 10; + fail_unless!(biscuits::test::foo() == 10); + fail_unless!(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 4377334309f..5c8ae86dfbc 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 mod_dir_simple::load_another_mod::test::foo() == 10; + fail_unless!(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 9303d8184e0..0ec7ce8ecc4 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 mod_dir_simple::test::foo() == 10; + fail_unless!(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 f041aa9672d..56169456318 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 mod_file_aux::foo() == 10; + fail_unless!(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 463132919c7..0130d62867d 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 m::foo() == 10; + fail_unless!(m::foo() == 10); } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 1f803f28e7a..56de6319649 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -40,8 +40,8 @@ fn transform(x: Option) -> Option<~str> { } pub fn main() { - assert transform(Some(10)) == Some(~"11"); - assert transform(None) == None; + fail_unless!(transform(Some(10)) == Some(~"11")); + fail_unless!(transform(None) == None); assert (~[~"hi"]) .bind(|x| ~[copy *x, *x + ~"!"] ) .bind(|x| ~[copy *x, *x + ~"?"] ) == diff --git a/src/test/run-pass/monomorphize-trait-in-fn-at.rs b/src/test/run-pass/monomorphize-trait-in-fn-at.rs index ee9af0d9d6c..6e5d92da1cb 100644 --- a/src/test/run-pass/monomorphize-trait-in-fn-at.rs +++ b/src/test/run-pass/monomorphize-trait-in-fn-at.rs @@ -26,5 +26,5 @@ impl ty_ops for () { pub fn main() { let fn_env: @fn() -> uint = || mk_nil(()); - assert fn_env() == 22u; + fail_unless!(fn_env() == 22u); } diff --git a/src/test/run-pass/morestack-address.rs b/src/test/run-pass/morestack-address.rs index 77d0a60a5e2..9497ca83ecc 100644 --- a/src/test/run-pass/morestack-address.rs +++ b/src/test/run-pass/morestack-address.rs @@ -19,7 +19,7 @@ mod rusti { pub fn main() { unsafe { let addr = rusti::morestack_addr(); - assert addr.is_not_null(); + fail_unless!(addr.is_not_null()); error!("%?", addr); } } diff --git a/src/test/run-pass/morestack3.rs b/src/test/run-pass/morestack3.rs index 748d765f2c3..78ec8c8037b 100644 --- a/src/test/run-pass/morestack3.rs +++ b/src/test/run-pass/morestack3.rs @@ -21,15 +21,15 @@ fn getbig(a0: int, a8: int, a9: int) -> int { - assert a0 + 1 == a1; - assert a1 + 1 == a2; - assert a2 + 1 == a3; - assert a3 + 1 == a4; - assert a4 + 1 == a5; - assert a5 + 1 == a6; - assert a6 + 1 == a7; - assert a7 + 1 == a8; - assert a8 + 1 == a9; + fail_unless!(a0 + 1 == a1); + fail_unless!(a1 + 1 == a2); + fail_unless!(a2 + 1 == a3); + fail_unless!(a3 + 1 == a4); + fail_unless!(a4 + 1 == a5); + fail_unless!(a5 + 1 == a6); + fail_unless!(a6 + 1 == a7); + fail_unless!(a7 + 1 == a8); + fail_unless!(a8 + 1 == a9); if a0 != 0 { let j = getbig(a0 - 1, a1 - 1, @@ -41,7 +41,7 @@ fn getbig(a0: int, a7 - 1, a8 - 1, a9 - 1); - assert j == a0 - 1; + fail_unless!(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 45ba5eb9748..06c4586cdfc 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -19,8 +19,8 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; - assert (test(true, copy x) == 2); - assert (test(true, copy x) == 2); - assert (test(true, copy x) == 2); - assert (test(false, x) == 5); + fail_unless!((test(true, copy x) == 2)); + fail_unless!((test(true, copy x) == 2)); + fail_unless!((test(true, copy x) == 2)); + fail_unless!((test(false, x) == 5)); } diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs index 35cbe6e080c..f7e5758c462 100644 --- a/src/test/run-pass/move-1.rs +++ b/src/test/run-pass/move-1.rs @@ -19,8 +19,8 @@ fn test(x: bool, foo: @Triple) -> int { pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; - assert (test(true, x) == 2); - assert (test(true, x) == 2); - assert (test(true, x) == 2); - assert (test(false, x) == 5); + fail_unless!((test(true, x) == 2)); + fail_unless!((test(true, x) == 2)); + fail_unless!((test(true, x) == 2)); + fail_unless!((test(false, x) == 5)); } diff --git a/src/test/run-pass/move-2-unique.rs b/src/test/run-pass/move-2-unique.rs index bc3b5405f18..08f67a7fa5c 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 23ec3a178c1..0294ff99733 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.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-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 82b8d2c9609..be6dc8b2004 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -22,7 +22,7 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; for uint::range(0u, 10000u) |_i| { - assert (test(true, copy x) == 2); + fail_unless!((test(true, copy x) == 2)); } - assert (test(false, x) == 5); + fail_unless!((test(false, x) == 5)); } diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs index 161dc55f8a3..01d56282d7e 100644 --- a/src/test/run-pass/move-3.rs +++ b/src/test/run-pass/move-3.rs @@ -22,7 +22,7 @@ fn test(x: bool, foo: @Triple) -> int { pub fn main() { let x = @Triple{x: 1, y: 2, z: 3}; for uint::range(0u, 10000u) |i| { - assert (test(true, x) == 2); + fail_unless!((test(true, x) == 2)); } - assert (test(false, x) == 5); + fail_unless!((test(false, x) == 5)); } diff --git a/src/test/run-pass/move-4-unique.rs b/src/test/run-pass/move-4-unique.rs index 8845bdfffe1..2f393b156ea 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-4.rs b/src/test/run-pass/move-4.rs index 1a5432620d3..a1a76040593 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -24,5 +24,5 @@ fn test(foo: @Triple) -> @Triple { pub fn main() { let x = @Triple{a: 1, b: 2, c: 3}; let y = test(x); - assert (y.c == 3); + 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 21969418c34..4275513d61e 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 8c843d2da68..24444f5ebdb 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.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.rs b/src/test/run-pass/move-arg.rs index 570fa6ee391..288abb6fb39 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/move-scalar.rs b/src/test/run-pass/move-scalar.rs index a7ddc4e4cdb..5fdef34b33a 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 (x == 42); + fail_unless!((x == 42)); } diff --git a/src/test/run-pass/multi-let.rs b/src/test/run-pass/multi-let.rs index 332e104ed77..275fee25d72 100644 --- a/src/test/run-pass/multi-let.rs +++ b/src/test/run-pass/multi-let.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub fn main() { let x = 10, y = x; assert (y == 10); } +pub fn main() { let x = 10, y = x; 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 8d3f28fb3dc..a092e3bcc18 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -10,11 +10,11 @@ fn f(mut y: ~int) { *y = 5; - assert *y == 5; + fail_unless!(*y == 5); } fn g() { - let frob: fn(~int) = |mut q| { *q = 2; assert *q == 2; }; + let frob: fn(~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 4acc052a732..d63f1b40dc8 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,13 +11,13 @@ fn test1() { let mut ints = [0, ..32]; ints[0] += 1; - assert ints[0] == 1; + fail_unless!(ints[0] == 1); } fn test2() { let mut ints = [0, ..32]; for vec::each_mut(ints) |i| { *i += 22; } - for ints.each |i| { assert *i == 22; } + for ints.each |i| { fail_unless!(*i == 22); } } pub fn main() { diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs index b82bd82ea6b..36f8b436753 100644 --- a/src/test/run-pass/mutable-alias-vec.rs +++ b/src/test/run-pass/mutable-alias-vec.rs @@ -22,5 +22,5 @@ pub fn main() { grow(&mut v); let len = vec::len::(v); log(debug, len); - assert (len == 3 as uint); + fail_unless!((len == 3 as uint)); } diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index 2f2930dbab7..eeda69e621d 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -27,7 +27,7 @@ pub fn main() { // fn b(x:int) -> int { fail!(); } let z = b(42); - assert(z.i == 42); - assert(z.do_stuff() == 37); + fail_unless!((z.i == 42)); + fail_unless!((z.do_stuff() == 37)); } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 10d76cdd977..9da3f44fc6d 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -15,13 +15,13 @@ 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, _} => { fail!(); } } let mut x@B {b, _} = B {a: 10, b: C {c: 20}}; x.b.c = 30; - assert b.c == 20; + fail_unless!(b.c == 20); let mut y@D {d, _} = D {a: 10, d: C {c: 20}}; y.d.c = 30; - assert d.c == 20; + fail_unless!(d.c == 20); } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index 21a3e350689..267946e7b2e 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -19,11 +19,11 @@ fn ff() -> @fn(int) -> int { } pub fn main() { - assert f(10, |a| a) == 10; + fail_unless!(f(10, |a| a) == 10); g(||()); - assert do f(10) |a| { a } == 10; + fail_unless!(do f(10) |a| { a } == 10); do g() { } let _x: @fn() -> int = || 10; let _y: @fn(int) -> int = |a| a; - assert ff()(10) == 11; + fail_unless!(ff()(10) == 11); } diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 01e554ad041..d661fecc526 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -16,7 +16,7 @@ fn myvec_elt(mv: myvec) -> X { return mv[0]; } pub fn main() { let mv = myvec(~[1, 2, 3]); - assert (myvec_deref(copy mv)[1] == 2); - assert (myvec_elt(copy mv) == 1); - assert (mv[2] == 3); + fail_unless!((myvec_deref(copy mv)[1] == 2)); + fail_unless!((myvec_elt(copy mv) == 1)); + fail_unless!((mv[2] == 3)); } diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index 18c446fe350..41b16193ca1 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -17,5 +17,5 @@ fn compute(i: mytype) -> int { return i.val + 20; } pub fn main() { let myval = mytype(Mytype{compute: compute, val: 30}); io::println(fmt!("%d", compute(myval))); - assert ((myval.compute)(myval) == 50); + fail_unless!(((myval.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 931c4cbad79..83273a7aae6 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -23,12 +23,12 @@ pure fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } pure 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)); - assert (*safe_head(mylist) == 1u); + fail_unless!((nonempty_list(mylist))); + fail_unless!((*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 2a1f94a1d8c..6260de64cd8 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: fn(T)) { } fn check_int(x: int) { - assert x == 22; + fail_unless!(x == 22); } fn check_struct(x: X) { diff --git a/src/test/run-pass/nullary-or-pattern.rs b/src/test/run-pass/nullary-or-pattern.rs index 4b913ccb9b6..cda68d72ed6 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 (or_alt(a) == 42); - assert (or_alt(b) == 42); + fail_unless!((or_alt(a) == 42)); + fail_unless!((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 f5c49bbf4d0..766576ffe6a 100644 --- a/src/test/run-pass/numeric-method-autoexport.rs +++ b/src/test/run-pass/numeric-method-autoexport.rs @@ -15,26 +15,26 @@ pub fn main() { // ints // num - assert 15i.add(&6) == 21; - assert 15i8.add(&6i8) == 21i8; - assert 15i16.add(&6i16) == 21i16; - assert 15i32.add(&6i32) == 21i32; - assert 15i64.add(&6i64) == 21i64; + fail_unless!(15i.add(&6) == 21); + fail_unless!(15i8.add(&6i8) == 21i8); + fail_unless!(15i16.add(&6i16) == 21i16); + fail_unless!(15i32.add(&6i32) == 21i32); + fail_unless!(15i64.add(&6i64) == 21i64); // uints // num - assert 15u.add(&6u) == 21u; - assert 15u8.add(&6u8) == 21u8; - assert 15u16.add(&6u16) == 21u16; - assert 15u32.add(&6u32) == 21u32; - assert 15u64.add(&6u64) == 21u64; + fail_unless!(15u.add(&6u) == 21u); + fail_unless!(15u8.add(&6u8) == 21u8); + fail_unless!(15u16.add(&6u16) == 21u16); + fail_unless!(15u32.add(&6u32) == 21u32); + fail_unless!(15u64.add(&6u64) == 21u64); // times 15u.times(|| false); // floats // num - assert 10f.to_int() == 10; - assert 10f32.to_int() == 10; - assert 10f64.to_int() == 10; + fail_unless!(10f.to_int() == 10); + fail_unless!(10f32.to_int() == 10); + fail_unless!(10f64.to_int() == 10); } diff --git a/src/test/run-pass/one-tuple.rs b/src/test/run-pass/one-tuple.rs index 9d01fbface0..fe56dc30af9 100644 --- a/src/test/run-pass/one-tuple.rs +++ b/src/test/run-pass/one-tuple.rs @@ -13,12 +13,12 @@ fn main() { match ('c',) { (x,) => { - assert x == 'c'; + fail_unless!(x == 'c'); } } // test the 1-tuple type too let x: (char,) = ('d',); let (y,) = x; - assert y == 'd'; + fail_unless!(y == 'd'); } diff --git a/src/test/run-pass/opeq.rs b/src/test/run-pass/opeq.rs index ee669899154..3a0d0c29441 100644 --- a/src/test/run-pass/opeq.rs +++ b/src/test/run-pass/opeq.rs @@ -16,14 +16,14 @@ pub fn main() { let mut x: int = 1; x *= 2; log(debug, x); - assert (x == 2); + fail_unless!((x == 2)); x += 3; log(debug, x); - assert (x == 5); + fail_unless!((x == 5)); x *= x; log(debug, x); - assert (x == 25); + fail_unless!((x == 25)); x /= 5; log(debug, x); - assert (x == 5); + fail_unless!((x == 5)); } diff --git a/src/test/run-pass/operator-associativity.rs b/src/test/run-pass/operator-associativity.rs index 0223fee549f..a1af35be653 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/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs index b56f7fa961e..3d2fd649f15 100644 --- a/src/test/run-pass/operator-overloading-explicit-self.rs +++ b/src/test/run-pass/operator-overloading-explicit-self.rs @@ -21,6 +21,6 @@ pub impl S { pub fn main() { let mut s = S { x: 1 }; s += S { x: 2 }; - assert s.x == 3; + fail_unless!(s.x == 3); } diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index 8c3423bf844..3873cdf615b 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -56,14 +56,14 @@ pub fn main() { let mut p = Point {x: 10, y: 20}; p += Point {x: 101, y: 102}; p = p - Point {x: 100, y: 100}; - assert p + Point {x: 5, y: 5} == Point {x: 16, y: 27}; - assert -p == Point {x: -11, y: -22}; - assert p[true] == 11; - assert p[false] == 22; + fail_unless!(p + Point {x: 5, y: 5} == Point {x: 16, y: 27}); + fail_unless!(-p == Point {x: -11, y: -22}); + fail_unless!(p[true] == 11); + fail_unless!(p[false] == 22); let q = !p; - assert q.x == !(p.x); - assert q.y == !(p.y); + fail_unless!(q.x == !(p.x)); + fail_unless!(q.y == !(p.y)); // Issue #1733 let result: ~fn(int) = |_|(); diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 7616ff5007e..d2e5911111d 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -35,5 +35,5 @@ pub fn main() { let c = unwrap(b); } - assert *x == 0; + fail_unless!(*x == 0); } diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index cc0a9e05f61..c787b8dbbf2 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 (or_alt(c) == 0); - assert (or_alt(a(10, 100, 0u)) == 110); - assert (or_alt(b(20, 200)) == 220); + fail_unless!((or_alt(c) == 0)); + fail_unless!((or_alt(a(10, 100, 0u)) == 110)); + fail_unless!((or_alt(b(20, 200)) == 220)); } 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 c667aeb1c10..a60a761e277 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 uint::range(0u, 10u) |i| { let yyy = src_id; - assert (yyy == 0u); + fail_unless!((yyy == 0u)); } } _ => { } diff --git a/src/test/run-pass/pipe-peek.rs b/src/test/run-pass/pipe-peek.rs index 25fa1a956bf..4058e5a492d 100644 --- a/src/test/run-pass/pipe-peek.rs +++ b/src/test/run-pass/pipe-peek.rs @@ -24,9 +24,9 @@ proto! oneshot ( pub fn main() { let (c, p) = oneshot::init(); - assert !pipes::peek(&p); + fail_unless!(!pipes::peek(&p)); oneshot::client::signal(c); - assert pipes::peek(&p); + fail_unless!(pipes::peek(&p)); } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index e6a7edd7a6b..0c80fdb3a34 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -48,7 +48,7 @@ pub fn main() { error!("selecting"); let (i, _, _) = select(~[left, right]); error!("selected"); - assert i == 0; + fail_unless!(i == 0); error!("waiting for pipes"); let stream::send(x, _) = recv(p); @@ -60,7 +60,7 @@ pub fn main() { let (i, m, _) = select(~[left, right]); error!("selected %?", i); if m.is_some() { - assert i == 1; + fail_unless!(i == 1); } }); diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 5112f2be4d9..cbee1801768 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -17,5 +17,5 @@ pub fn main() { let p = &arena::Arena(); let x = p.alloc(|| 4u); io::print(fmt!("%u", *x)); - assert *x == 4u; + fail_unless!(*x == 4u); } diff --git a/src/test/run-pass/private-class-field.rs b/src/test/run-pass/private-class-field.rs index 0abb758bd7e..cb92125c5d8 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 (nyan.meow_count() == 52u); + fail_unless!((nyan.meow_count() == 52u)); } diff --git a/src/test/run-pass/propagate-expected-type-through-block.rs b/src/test/run-pass/propagate-expected-type-through-block.rs index d41e629b5da..20a6d130774 100644 --- a/src/test/run-pass/propagate-expected-type-through-block.rs +++ b/src/test/run-pass/propagate-expected-type-through-block.rs @@ -8,5 +8,5 @@ pub fn main() { let y = copy y; |x| *x + *y }; - assert foo(@22) == 25; + fail_unless!(foo(@22) == 25); } diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 12e54c9c191..a7daa566480 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -23,26 +23,26 @@ pub fn main() { /* let x = @mut 6; let y = x.get(); - assert y == 6; + fail_unless!(y == 6); */ let x = @6; let y = x.get(); debug!("y=%d", y); - assert y == 6; + fail_unless!(y == 6); let mut x = ~6; let y = x.get(); debug!("y=%d", y); - assert y == 6; + fail_unless!(y == 6); let x = ~6; let y = x.get(); debug!("y=%d", y); - assert y == 6; + fail_unless!(y == 6); let x = &6; let y = x.get(); debug!("y=%d", y); - assert y == 6; + fail_unless!(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 0091962dcf3..f7f6b9b05e3 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -27,15 +27,15 @@ pub fn main() { let x = ~[1, 2, 3]; let y = call_sum(x); debug!("y==%d", y); - assert y == 6; + fail_unless!(y == 6); let mut x = ~[1, 2, 3]; let y = x.sum(); debug!("y==%d", y); - assert y == 6; + fail_unless!(y == 6); let x = ~[1, 2, 3]; let y = x.sum(); debug!("y==%d", y); - assert y == 6; + fail_unless!(y == 6); } diff --git a/src/test/run-pass/readalias.rs b/src/test/run-pass/readalias.rs index 555a73c73d3..b5327638327 100644 --- a/src/test/run-pass/readalias.rs +++ b/src/test/run-pass/readalias.rs @@ -14,6 +14,6 @@ // -*- rust -*- 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/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 495aee1690f..e5a13fe9c54 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -55,12 +55,12 @@ pub fn main() { debug!("y = %s", y); // per clang/gcc the alignment of `inner` is 4 on x86. - assert rusti::min_align_of::() == m::align(); + fail_unless!(rusti::min_align_of::() == m::align()); // per clang/gcc the size of `outer` should be 12 // because `inner`s alignment was 4. - assert sys::size_of::() == m::size(); + fail_unless!(sys::size_of::() == m::size()); - assert y == ~"{c8: 22, t: {c64: 44}}"; + fail_unless!(y == ~"{c8: 22, t: {c64: 44}}"); } } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 4106f87f380..e02a1edf8a6 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -69,12 +69,12 @@ pub fn main() { debug!("y = %s", y); // per clang/gcc the alignment of `Inner` is 4 on x86. - assert rusti::min_align_of::() == m::m::align(); + fail_unless!(rusti::min_align_of::() == m::m::align()); // per clang/gcc the size of `Outer` should be 12 // because `Inner`s alignment was 4. - assert sys::size_of::() == m::m::size(); + fail_unless!(sys::size_of::() == m::m::size()); - assert y == ~"{c8: 22, t: {c64: 44}}"; + fail_unless!(y == ~"{c8: 22, t: {c64: 44}}"); } } diff --git a/src/test/run-pass/rec-extend.rs b/src/test/run-pass/rec-extend.rs index 6b9eb51ef25..a15c8e07a2f 100644 --- a/src/test/run-pass/rec-extend.rs +++ b/src/test/run-pass/rec-extend.rs @@ -18,10 +18,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 (origin.x == 0); - assert (origin.y == 0); - assert (right.x == 10); - assert (right.y == 0); - assert (up.x == 0); - assert (up.y == 10); + fail_unless!((origin.x == 0)); + fail_unless!((origin.y == 0)); + fail_unless!((right.x == 10)); + fail_unless!((right.y == 0)); + fail_unless!((up.x == 0)); + fail_unless!((up.y == 10)); } diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index 8d49ed43ffc..f6bee493478 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -17,21 +17,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 (fst(r).x == x1); - assert (fst(r).y == y1); - assert (snd(r).x == x2); - assert (snd(r).y == y2); + fail_unless!((fst(r).x == x1)); + fail_unless!((fst(r).y == y1)); + fail_unless!((snd(r).x == x2)); + fail_unless!((snd(r).y == y2)); } pub fn main() { let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22}); - assert (fst(r).x == 10); - assert (fst(r).y == 20); - assert (snd(r).x == 11); - assert (snd(r).y == 22); + fail_unless!((fst(r).x == 10)); + fail_unless!((fst(r).y == 20)); + fail_unless!((snd(r).x == 11)); + fail_unless!((snd(r).y == 22)); let r2 = r; let x: int = fst(r2).x; - assert (x == 10); + fail_unless!((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 34d0ad7535b..3dd35a3f519 100644 --- a/src/test/run-pass/rec.rs +++ b/src/test/run-pass/rec.rs @@ -15,21 +15,21 @@ struct Rect {x: int, y: int, w: int, h: int} fn f(r: Rect, x: int, y: int, w: int, h: int) { - assert (r.x == x); - assert (r.y == y); - assert (r.w == w); - assert (r.h == h); + fail_unless!((r.x == x)); + fail_unless!((r.y == y)); + fail_unless!((r.w == w)); + fail_unless!((r.h == h)); } pub fn main() { let r: Rect = Rect {x: 10, y: 20, w: 100, h: 200}; - assert (r.x == 10); - assert (r.y == 20); - assert (r.w == 100); - assert (r.h == 200); + fail_unless!((r.x == 10)); + fail_unless!((r.y == 20)); + fail_unless!((r.w == 100)); + fail_unless!((r.h == 200)); let r2: Rect = r; let x: int = r2.x; - assert (x == 10); + fail_unless!((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 ad986ddb752..40d99fa805c 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -20,6 +20,6 @@ fn m(in: t3) -> int { } pub fn main() { - assert (m(c(T2 {x: a(10), y: 5}, 4u)) == 10); - assert (m(c(T2 {x: b(10u), y: 5}, 4u)) == 19); + fail_unless!((m(c(T2 {x: a(10), y: 5}, 4u)) == 10)); + fail_unless!((m(c(T2 {x: b(10u), y: 5}, 4u)) == 19)); } diff --git a/src/test/run-pass/region-dependent-addr-of.rs b/src/test/run-pass/region-dependent-addr-of.rs index ca6e48d1518..a3f5c41e1ac 100644 --- a/src/test/run-pass/region-dependent-addr-of.rs +++ b/src/test/run-pass/region-dependent-addr-of.rs @@ -87,29 +87,29 @@ pub fn main() { v6: Some(C { f: 31 })}}; let p = get_v1(&a); - assert *p == a.value.v1; + fail_unless!(*p == a.value.v1); let p = get_v2(&a, 1); - assert *p == a.value.v2[1]; + fail_unless!(*p == a.value.v2[1]); let p = get_v3(&a, 1); - assert *p == a.value.v3[1]; + fail_unless!(*p == a.value.v3[1]); let p = get_v4(&a, 1); - assert *p == a.value.v4.f; + fail_unless!(*p == a.value.v4.f); let p = get_v5(&a, 1); - assert *p == a.value.v5.f; + fail_unless!(*p == a.value.v5.f); let p = get_v6_a(&a, 1); - assert *p == a.value.v6.get().f; + fail_unless!(*p == a.value.v6.get().f); let p = get_v6_b(&a, 1); - assert *p == a.value.v6.get().f; + fail_unless!(*p == a.value.v6.get().f); let p = get_v6_c(&a, 1); - assert *p == a.value.v6.get().f; + fail_unless!(*p == a.value.v6.get().f); let p = get_v5_ref(&a, 1); - assert *p == a.value.v5.f; + fail_unless!(*p == a.value.v5.f); } diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs index 249b00e6812..59dbbde7b77 100644 --- a/src/test/run-pass/region-return-interior-of-option.rs +++ b/src/test/run-pass/region-return-interior-of-option.rs @@ -20,13 +20,13 @@ pub fn main() { { let y = get(&x); - assert *y == 23; + fail_unless!(*y == 23); } x = Some(24); { let y = get(&x); - assert *y == 24; + fail_unless!(*y == 24); } } diff --git a/src/test/run-pass/regions-appearance-constraint.rs b/src/test/run-pass/regions-appearance-constraint.rs index 0b7b9728ae4..aa2e2598697 100644 --- a/src/test/run-pass/regions-appearance-constraint.rs +++ b/src/test/run-pass/regions-appearance-constraint.rs @@ -25,7 +25,7 @@ fn testfn(cond: bool) { x = @5; y = @6; - assert *a == exp; + fail_unless!(*a == exp); } pub fn main() { diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index f42e7015969..8ef3eaf41fe 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -16,5 +16,5 @@ pub fn main() { let p = @22u; let r = foo(p); debug!("r=%u", r); - assert r == 22u; + fail_unless!(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 987f672a2fb..7edc0879101 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 r == 'h' as u8; + fail_unless!(r == 'h' as u8); let p = ~"hello"; let r = foo(p); - assert r == 'h' as u8; + fail_unless!(r == 'h' as u8); } diff --git a/src/test/run-pass/regions-borrow-evec-at.rs b/src/test/run-pass/regions-borrow-evec-at.rs index 73764ee1a6c..b3c62fb0ead 100644 --- a/src/test/run-pass/regions-borrow-evec-at.rs +++ b/src/test/run-pass/regions-borrow-evec-at.rs @@ -17,5 +17,5 @@ fn foo(x: &[uint]) -> uint { pub fn main() { let p = @[22u]; let r = foo(p); - assert r == 22u; + fail_unless!(r == 22u); } diff --git a/src/test/run-pass/regions-borrow-evec-fixed.rs b/src/test/run-pass/regions-borrow-evec-fixed.rs index 9f45da1268a..010daac8cc1 100644 --- a/src/test/run-pass/regions-borrow-evec-fixed.rs +++ b/src/test/run-pass/regions-borrow-evec-fixed.rs @@ -16,5 +16,5 @@ fn foo(x: &[int]) -> int { pub fn main() { let p = [1,2,3,4,5]; - assert foo(p) == 1; + fail_unless!(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 09a3e6f4a84..d55caa9b46e 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 r == 1; + fail_unless!(r == 1); let p = ~[5,4,3,2,1]; let r = foo(p); - assert r == 5; + fail_unless!(r == 5); } diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index 00d7ec6448c..a2d06b6e23b 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 r == 3u; + fail_unless!(r == 3u); } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index dd040767f6b..6bd42769cec 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -19,7 +19,7 @@ fn box_it(+x: &'r fn()) -> closure_box/&r { pub fn main() { let mut i = 3; let cl_box = box_it(|| i += 1); - assert i == 3; + fail_unless!(i == 3); (cl_box.cl)(); - assert i == 4; + fail_unless!(i == 4); } 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 a35a7cfa829..6a03b4f910b 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -13,5 +13,5 @@ fn bar(x: &uint) -> uint { *x } pub fn main() { let p = @3u; - assert bar(foo(p)) == 3; + fail_unless!(bar(foo(p)) == 3); } 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 a31354512b3..619a79b1ab5 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 @@ -20,7 +20,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 676d595f212..e5e24a55843 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -14,6 +14,6 @@ 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-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 444aca8b138..69945a31f6d 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 @@ -14,7 +14,7 @@ pub fn main() { let x = @3; loop { let y = borrow(x); - assert *x == *y; + fail_unless!(*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 3054438387b..9c4cb0d436d 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -17,6 +17,6 @@ fn x_coord(p: &r/Point) -> &r/int { pub fn main() { let p = @Point {x: 3, y: 4}; let xc = x_coord(p); - assert *xc == 3; + fail_unless!(*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 b84de89feb8..eba9bb592bb 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(x: &a/int) -> int { } pub fn main() { - assert has_one(&2) == 22; + fail_unless!(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 12f631755a9..0477bd2d196 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(x: &a/int, y: &b/int) -> int { } pub fn main() { - assert has_two(&20, &2) == 22; + fail_unless!(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 ec5b30fa308..b1fa7287fdb 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 with(&foo) == 22; + fail_unless!(with(&foo) == 22); } diff --git a/src/test/run-pass/regions-infer-contravariance.rs b/src/test/run-pass/regions-infer-contravariance.rs index 1406240c1d1..1c263a6f0c6 100644 --- a/src/test/run-pass/regions-infer-contravariance.rs +++ b/src/test/run-pass/regions-infer-contravariance.rs @@ -21,7 +21,7 @@ fn with(bi: &r/boxed_int) { // contravariant with respect to `&r`. See also // compile-fail/regions-infer-invariance-due-to-mutability.rs let bi: &blk/boxed_int/&blk = bi; - assert *get(bi) == 22; + fail_unless!(*get(bi) == 22); } pub fn main() { diff --git a/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs b/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs index 588db79a6c5..3420b8be9c7 100644 --- a/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs +++ b/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs @@ -24,5 +24,5 @@ fn get_int(g: &G) -> int { fn main() { let foo = Foo { field: 22 }; - assert get_int(&foo) == 22; + fail_unless!(get_int(&foo) == 22); } diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index ea981dc5fb7..500ce356018 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 parameterized(&x) == 3u; + fail_unless!(parameterized(&x) == 3u); } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index 819499b3953..22cdd477077 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -30,5 +30,5 @@ pub fn main() { let ctxt = Ctxt { v: 22 }; let hc = HasCtxt { c: &ctxt }; - assert get_v(@hc as @get_ctxt) == 22; + fail_unless!(get_v(@hc as @get_ctxt) == 22); } diff --git a/src/test/run-pass/resolve-issue-2428.rs b/src/test/run-pass/resolve-issue-2428.rs index b5d3514154a..20cda911cdd 100644 --- a/src/test/run-pass/resolve-issue-2428.rs +++ b/src/test/run-pass/resolve-issue-2428.rs @@ -12,4 +12,4 @@ const 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-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index af3c92db8f6..f4ba34807d3 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -33,5 +33,5 @@ pub fn main() { let (c, _d) = b; log(debug, c); } - assert *i == 1; + fail_unless!(*i == 1); } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 2b00aea2b4c..9894d2382dd 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -30,7 +30,7 @@ fn shrinky_pointer(i: @@mut int) -> shrinky_pointer { pub fn main() { let my_total = @@mut 10; - { let pt = shrinky_pointer(my_total); assert (pt.look_at() == 10); } + { let pt = shrinky_pointer(my_total); fail_unless!((pt.look_at() == 10)); } log(error, fmt!("my_total = %d", **my_total)); - assert (**my_total == 9); + fail_unless!((**my_total == 9)); } diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs index d32a60ee4f8..e43b90c30b0 100644 --- a/src/test/run-pass/resource-generic.rs +++ b/src/test/run-pass/resource-generic.rs @@ -33,5 +33,5 @@ pub fn main() { fn dec_box(i: @mut int) { *i -= 1; } { let _i = finish(Arg{val: box, fin: dec_box}); } - assert (*box == 9); + fail_unless!((*box == 9)); } diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index 54b543c7c3f..53c76680bde 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -38,5 +38,5 @@ pub fn main() { let c = @mut true; sink(none); sink(some(close_res(c))); - assert (!*c); + fail_unless!((!*c)); } diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index 3f11a9bdce3..da2aa2b8cd4 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -33,11 +33,11 @@ fn bail_deep(x: ~[~[bool]]) { let mut seen = false; for iter(copy x) |x| { for iter(copy *x) |x| { - assert !seen; + fail_unless!(!seen); if *x { seen = true; return; } } } - assert !seen; + fail_unless!(!seen); } fn ret_deep() -> ~str { @@ -55,17 +55,17 @@ pub fn main() { last = *e; if *e == 5 { break; } if *e % 2 == 1 { loop; } - assert *e % 2 == 0; + fail_unless!(*e % 2 == 0); }; - assert last == 5; + fail_unless!(last == 5); - assert find_pos(1, ~[0, 1, 2, 3]) == Some(1u); - assert find_pos(1, ~[0, 4, 2, 3]) == None; - assert find_pos(~"hi", ~[~"foo", ~"bar", ~"baz", ~"hi"]) == Some(3u); + fail_unless!(find_pos(1, ~[0, 1, 2, 3]) == Some(1u)); + fail_unless!(find_pos(1, ~[0, 4, 2, 3]) == None); + fail_unless!(find_pos(~"hi", ~[~"foo", ~"bar", ~"baz", ~"hi"]) == Some(3u)); bail_deep(~[~[false, false], ~[true, true], ~[false, true]]); bail_deep(~[~[true]]); bail_deep(~[~[false, false, false]]); - assert ret_deep() == ~"hi"; + fail_unless!(ret_deep() == ~"hi"); } diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs index e0524a3c36f..cb0a531929a 100644 --- a/src/test/run-pass/rt-sched-1.rs +++ b/src/test/run-pass/rt-sched-1.rs @@ -38,13 +38,13 @@ pub fn main() { let new_sched_id = rustrt::rust_new_sched(num_threads); error!("new_sched_id %?", new_sched_id); let new_task_id = rustrt::rust_new_task_in_sched(new_sched_id); - assert !new_task_id.is_null(); + fail_unless!(!new_task_id.is_null()); let f: ~fn() = || { unsafe { let child_sched_id = rustrt::rust_get_sched_id(); error!("child_sched_id %?", child_sched_id); - assert child_sched_id != parent_sched_id; - assert child_sched_id == new_sched_id; + fail_unless!(child_sched_id != parent_sched_id); + fail_unless!(child_sched_id == new_sched_id); ch.send(()); } }; diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs index 7846db4ff2f..a5b2d07bdc6 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/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index c0af726dd8d..08434011a1c 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -21,13 +21,13 @@ fn make_generic_record(a: A, b: B) -> Pair { fn test05_start(f: &~fn(v: float, v: ~str) -> Pair) { let p = (*f)(22.22f, ~"Hi"); log(debug, copy p); - assert p.a == 22.22f; - assert p.b == ~"Hi"; + fail_unless!(p.a == 22.22f); + fail_unless!(p.b == ~"Hi"); let q = (*f)(44.44f, ~"Ho"); log(debug, copy q); - assert q.a == 44.44f; - assert q.b == ~"Ho"; + fail_unless!(q.a == 44.44f); + fail_unless!(q.b == ~"Ho"); } fn spawn(f: extern fn(&~fn(A,B)->Pair)) { diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 92e709a3738..33e6eb6c855 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: fn(uint) -> uint) -> uint { pub fn main() { let y = test(|x| 4u * x); - assert y == 88u; + fail_unless!(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 9b71f678122..726efd2946d 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -18,7 +18,7 @@ fn test05() { let three = ~3; let fn_to_send: ~fn(int) = |n| { log(error, *three + n); // will copy x into the closure - assert(*three == 3); + fail_unless!((*three == 3)); }; task::spawn(|| { test05_start(fn_to_send); diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index 6a7832fe6a9..22df0553718 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]); - assert (~[1, 2, 3] == ~[1, 2, 3]); - assert (~[1, 2, 3] != ~[1, 1, 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])); + fail_unless!((~[1, 2, 3] == ~[1, 2, 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 a23bb21c77d..0c6ab3c65b1 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -28,4 +28,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/shift.rs b/src/test/run-pass/shift.rs index ad0b82a905b..c6165c1530a 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 1 << 1i8 << 1u8 << 1i16 << 1 as char << 1u64 == 32; + fail_unless!(1 << 1i8 << 1u8 << 1i16 << 1 as char << 1u64 == 32); } fn test_expr() { let v10 = 10 as uint; let v4 = 4 as u8; let v2 = 2 as u8; - assert (v10 >> v2 == v2 as uint); - assert (v10 << v4 == 160 as uint); + fail_unless!((v10 >> v2 == v2 as uint)); + fail_unless!((v10 << v4 == 160 as uint)); let v10 = 10 as u8; let v4 = 4 as uint; let v2 = 2 as uint; - assert (v10 >> v2 == v2 as u8); - assert (v10 << v4 == 160 as u8); + fail_unless!((v10 >> v2 == v2 as u8)); + fail_unless!((v10 << v4 == 160 as u8)); let v10 = 10 as int; let v4 = 4 as i8; let v2 = 2 as i8; - assert (v10 >> v2 == v2 as int); - assert (v10 << v4 == 160 as int); + fail_unless!((v10 >> v2 == v2 as int)); + fail_unless!((v10 << v4 == 160 as int)); let v10 = 10 as i8; let v4 = 4 as int; let v2 = 2 as int; - assert (v10 >> v2 == v2 as i8); - assert (v10 << v4 == 160 as i8); + fail_unless!((v10 >> v2 == v2 as i8)); + fail_unless!((v10 << v4 == 160 as i8)); let v10 = 10 as uint; let v4 = 4 as int; let v2 = 2 as int; - assert (v10 >> v2 == v2 as uint); - assert (v10 << v4 == 160 as uint); + fail_unless!((v10 >> v2 == v2 as uint)); + fail_unless!((v10 << v4 == 160 as uint)); } fn test_const() { const r1_1: uint = 10u >> 2u8; const r2_1: uint = 10u << 4u8; - assert r1_1 == 2 as uint; - assert r2_1 == 160 as uint; + fail_unless!(r1_1 == 2 as uint); + fail_unless!(r2_1 == 160 as uint); const r1_2: u8 = 10u8 >> 2u; const r2_2: u8 = 10u8 << 4u; - assert r1_2 == 2 as u8; - assert r2_2 == 160 as u8; + fail_unless!(r1_2 == 2 as u8); + fail_unless!(r2_2 == 160 as u8); const r1_3: int = 10 >> 2i8; const r2_3: int = 10 << 4i8; - assert r1_3 == 2 as int; - assert r2_3 == 160 as int; + fail_unless!(r1_3 == 2 as int); + fail_unless!(r2_3 == 160 as int); const r1_4: i8 = 10i8 >> 2; const r2_4: i8 = 10i8 << 4; - assert r1_4 == 2 as i8; - assert r2_4 == 160 as i8; + fail_unless!(r1_4 == 2 as i8); + fail_unless!(r2_4 == 160 as i8); const r1_5: uint = 10u >> 2i8; const r2_5: uint = 10u << 4i8; - assert r1_5 == 2 as uint; - assert r2_5 == 160 as uint; + fail_unless!(r1_5 == 2 as uint); + fail_unless!(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 fbce196dd39..e7e954bd787 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(thing as int == -3); + fail_unless!((thing as int == -3)); } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 4111b505490..a9daf15e433 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -19,7 +19,7 @@ use core::comm::*; type ctx = Chan; fn iotask(cx: &ctx, ip: ~str) { - assert (ip == ~"localhost"); + fail_unless!((ip == ~"localhost")); } pub fn main() { diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 8c328081186..31281355258 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -17,7 +17,7 @@ pub fn main() { task::spawn(|| child(10) ); } -fn child(&&i: int) { log(error, i); assert (i == 10); } +fn child(&&i: int) { log(error, i); fail_unless!((i == 10)); } // Local Variables: // mode: rust; diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index f62593cecec..7327c3b84ad 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -22,15 +22,15 @@ fn child(&&args: (int, int, int, int, int, int, int, int, int)) { log(error, i7); log(error, i8); log(error, i9); - assert (i1 == 10); - assert (i2 == 20); - assert (i3 == 30); - assert (i4 == 40); - assert (i5 == 50); - assert (i6 == 60); - assert (i7 == 70); - assert (i8 == 80); - assert (i9 == 90); + fail_unless!((i1 == 10)); + fail_unless!((i2 == 20)); + fail_unless!((i3 == 30)); + fail_unless!((i4 == 40)); + fail_unless!((i5 == 50)); + fail_unless!((i6 == 60)); + fail_unless!((i7 == 70)); + fail_unless!((i8 == 80)); + fail_unless!((i9 == 90)); } // Local Variables: diff --git a/src/test/run-pass/stable-addr-of.rs b/src/test/run-pass/stable-addr-of.rs index f1f50d83d1a..1b623fa6426 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 ptr::addr_of(&foo) == ptr::addr_of(&foo); + fail_unless!(ptr::addr_of(&foo) == ptr::addr_of(&foo)); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index c39a0f36d58..1613eec7405 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -29,8 +29,8 @@ pub fn main() { } } - assert path.exists(); - assert path.get_size() == Some(1000); + fail_unless!(path.exists()); + fail_unless!(path.get_size() == Some(1000)); os::remove_dir(&dir); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index d1b2870fef6..2ad01557e80 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -54,13 +54,13 @@ impl vec_utils for ~[T] { } pub fn main() { - assert 10u.plus() == 30; - assert (~"hi").plus() == 200; + fail_unless!(10u.plus() == 30); + fail_unless!((~"hi").plus() == 200); - assert (~[1]).length_().str() == ~"1"; - assert (~[3, 4]).map_(|a| *a + 4 )[0] == 7; - assert (~[3, 4]).map_::(|a| *a as uint + 4u )[0] == 7u; + fail_unless!((~[1]).length_().str() == ~"1"); + fail_unless!((~[3, 4]).map_(|a| *a + 4 )[0] == 7); + fail_unless!((~[3, 4]).map_::(|a| *a as uint + 4u )[0] == 7u); let mut x = 0u; 10u.multi(|_n| x += 2u ); - assert x == 20u; + fail_unless!(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 9a9533d7c8a..f51eb6e1ae2 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 i == 22; + fail_unless!(i == 22); } diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index d9461c48be8..a2148fb0ef5 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -80,15 +80,15 @@ fn seq_range>(lo: uint, hi: uint) -> BT { pub fn main() { let v: @[int] = seq_range(0, 10); - assert v == @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + fail_unless!(v == @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); let v: @[int] = map(&[1,2,3], |x| 1+x); - assert v == @[2, 3, 4]; + fail_unless!(v == @[2, 3, 4]); let v: ~[int] = map(&[1,2,3], |x| 1+x); - assert v == ~[2, 3, 4]; + fail_unless!(v == ~[2, 3, 4]); - assert bool_like::select(true, 9, 14) == 9; - assert !andand(true, false); - assert andand(7, 12) == 12; - assert andand(0, 12) == 0; + fail_unless!(bool_like::select(true, 9, 14) == 9); + fail_unless!(!andand(true, false)); + fail_unless!(andand(7, 12) == 12); + fail_unless!(andand(0, 12) == 0); } diff --git a/src/test/run-pass/static-method-xcrate.rs b/src/test/run-pass/static-method-xcrate.rs index 30fcc7aec34..f768edf7b9b 100644 --- a/src/test/run-pass/static-method-xcrate.rs +++ b/src/test/run-pass/static-method-xcrate.rs @@ -17,7 +17,7 @@ use readMaybeRenamed = static_methods_crate::read::readMaybe; pub fn main() { let result: int = read(~"5"); - assert result == 5; - assert readMaybeRenamed(~"false") == Some(false); - assert readMaybeRenamed(~"foo") == None::; + fail_unless!(result == 5); + fail_unless!(readMaybeRenamed(~"false") == Some(false)); + fail_unless!(readMaybeRenamed(~"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 63d25240df8..be83fe4d3ab 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -29,7 +29,7 @@ mod a { pub fn main() { let x: int = a::Foo::foo(); let y: uint = a::Foo::foo(); - assert x == 3; - assert y == 5; + fail_unless!(x == 3); + fail_unless!(y == 5); } diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index a3eaf6198fb..085b9c5d349 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -17,7 +17,7 @@ fn test1() { let mut s: ~str = ~"hello"; s += ~"world"; log(debug, copy s); - assert (s[9] == 'd' as u8); + fail_unless!((s[9] == 'd' as u8)); } fn test2() { @@ -28,8 +28,8 @@ fn test2() { let b: ~str = ~"ABC" + ff + ~"ABC"; log(debug, copy a); log(debug, copy b); - assert (a == ~"abcABCabc"); - assert (b == ~"ABCabcABC"); + fail_unless!((a == ~"abcABCabc")); + fail_unless!((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 6901adaec70..10bec14c285 100644 --- a/src/test/run-pass/str-concat.rs +++ b/src/test/run-pass/str-concat.rs @@ -17,5 +17,5 @@ pub fn main() { let b: ~str = ~"world"; let s: ~str = a + b; log(debug, copy s); - assert (s[9] == 'd' as u8); + fail_unless!((s[9] == 'd' as u8)); } diff --git a/src/test/run-pass/str-growth.rs b/src/test/run-pass/str-growth.rs index 3240ab0831d..72d198cc63d 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 += ~"b"; - assert (s[0] == 'a' as u8); - assert (s[1] == 'b' as u8); + fail_unless!((s[0] == 'a' as u8)); + fail_unless!((s[1] == 'b' as u8)); s += ~"c"; s += ~"d"; - assert (s[0] == 'a' as u8); - assert (s[1] == 'b' as u8); - assert (s[2] == 'c' as u8); - assert (s[3] == 'd' as u8); + fail_unless!((s[0] == 'a' as u8)); + fail_unless!((s[1] == 'b' as u8)); + fail_unless!((s[2] == 'c' as u8)); + fail_unless!((s[3] == 'd' as u8)); } diff --git a/src/test/run-pass/str-idx.rs b/src/test/run-pass/str-idx.rs index a9484ccccdc..a61a7818ca3 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]; log(debug, c); - assert (c == 0x6f as u8); + fail_unless!((c == 0x6f as u8)); } diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index 8ff84536227..254bffecf61 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -21,6 +21,6 @@ is a test"; is \ another \ test"; - assert (a == ~"this is a test"); - assert (b == ~"this is another test"); + fail_unless!((a == ~"this is a test")); + fail_unless!((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 7bda8476763..f9f700a6ec8 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 { log(error, str::len(a)); - assert (str::len(a) == expected_len); + fail_unless!((str::len(a) == 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-deref.rs b/src/test/run-pass/struct-deref.rs index 5bf2b70e7fb..f560c72eec3 100644 --- a/src/test/run-pass/struct-deref.rs +++ b/src/test/run-pass/struct-deref.rs @@ -12,6 +12,6 @@ struct Foo(int); pub fn main() { let x: Foo = Foo(2); - assert *x == 2; + fail_unless!(*x == 2); } diff --git a/src/test/run-pass/struct-destructuring-cross-crate.rs b/src/test/run-pass/struct-destructuring-cross-crate.rs index 6c2324bbc50..a32c6204a99 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 mod 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 a == 1; - assert b == 2; + fail_unless!(a == 1); + fail_unless!(b == 2); } diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index 64f75e37051..61b09239bc1 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -4,6 +4,6 @@ struct Foo { pub fn main() { let f = Foo { x: @3 }; - assert *f.x == 3; + fail_unless!(*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 e36f2d91e42..0658b72af6b 100644 --- a/src/test/run-pass/struct-like-variant-match.rs +++ b/src/test/run-pass/struct-like-variant-match.rs @@ -22,12 +22,12 @@ enum Foo { fn f(x: &Foo) { match *x { Baz { x: x, y: y } => { - assert x == 1.0; - assert y == 2.0; + fail_unless!(x == 1.0); + fail_unless!(y == 2.0); } Bar { y: y, x: x } => { - assert x == 1; - assert y == 2; + fail_unless!(x == 1); + fail_unless!(y == 2); } } } diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 57984f32ab5..dbee7226228 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -32,10 +32,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 qq.a == q.c + 1u64; - assert qq.b == q.d - 1u64; - assert qq.c == q.a + 1u64; - assert qq.d == q.b - 1u64; + fail_unless!(qq.a == q.c + 1u64); + fail_unless!(qq.b == q.d - 1u64); + fail_unless!(qq.c == q.a + 1u64); + fail_unless!(qq.d == q.b - 1u64); } } @@ -49,9 +49,9 @@ fn test2() { error!("a: %f", ff.a as float); error!("b: %u", ff.b as uint); error!("c: %f", ff.c as float); - assert ff.a == f.c + 1.0f64; - assert ff.b == 0xff_u8; - assert ff.c == f.a - 1.0f64; + fail_unless!(ff.a == f.c + 1.0f64); + fail_unless!(ff.b == 0xff_u8); + fail_unless!(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 a11608bc52e..f32fc27e3aa 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -22,15 +22,15 @@ impl cmp::Eq for foo { pub fn main() { let a = (1, 2, 3); let b = (1, 2, 3); - assert (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 == b)); + 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); - assert (x == large); - assert (x != small); + fail_unless!((x != y)); + fail_unless!((x == large)); + fail_unless!((x != small)); } diff --git a/src/test/run-pass/swap-1.rs b/src/test/run-pass/swap-1.rs index d4d4668cd55..ff114e8084a 100644 --- a/src/test/run-pass/swap-1.rs +++ b/src/test/run-pass/swap-1.rs @@ -10,5 +10,5 @@ pub fn main() { let mut x = 3; let mut y = 7; - x <-> y; assert (x == 7); assert (y == 3); + x <-> y; fail_unless!((x == 7)); fail_unless!((y == 3)); } diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 0f1ad1624c6..7f63e87235f 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -13,10 +13,10 @@ fn swap(v: &mut [T], i: int, j: int) { v[i] <-> v[j]; } pub fn main() { let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6]; swap(a, 2, 4); - assert (a[2] == 4); - assert (a[4] == 2); + fail_unless!((a[2] == 4)); + fail_unless!((a[4] == 2)); let mut n = 42; n <-> a[0]; - assert (a[0] == 42); - assert (n == 0); + fail_unless!((a[0] == 42)); + fail_unless!((n == 0)); } diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index ddd0743083f..1c0f31165d3 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -13,7 +13,7 @@ extern mod std; fn test(actual: ~str, expected: ~str) { log(debug, copy actual); log(debug, copy expected); - assert (actual == expected); + fail_unless!((actual == expected)); } pub fn main() { @@ -250,13 +250,13 @@ fn part6() { fn percent() { let s = fmt!("ab%%cd"); - assert(s == ~"ab%cd"); + fail_unless!((s == ~"ab%cd")); } fn more_floats() { - assert ~"3.1416" == fmt!("%.4f", 3.14159); - assert ~"3" == fmt!("%.0f", 3.14159); - assert ~"99" == fmt!("%.0f", 98.5); - assert ~"7.0000" == fmt!("%.4f", 6.999999999); - assert ~"3.141590000" == fmt!("%.9f", 3.14159); + fail_unless!(~"3.1416" == fmt!("%.4f", 3.14159)); + fail_unless!(~"3" == fmt!("%.0f", 3.14159)); + fail_unless!(~"99" == fmt!("%.0f", 98.5)); + fail_unless!(~"7.0000" == fmt!("%.4f", 6.999999999)); + fail_unless!(~"3.141590000" == fmt!("%.9f", 3.14159)); } diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs index 42a475866a9..b171cdfae8c 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/run-pass/syntax-extension-minor.rs @@ -11,7 +11,7 @@ pub fn main() { let asdf_fdsa = ~"<.<"; - assert (concat_idents!(asd, f_f, dsa) == ~"<.<"); + fail_unless!((concat_idents!(asd, f_f, dsa) == ~"<.<")); assert (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 65ef3cc4f69..39480c42e2e 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -20,11 +20,11 @@ pub mod m1 { macro_rules! indirect_line( () => ( line!() ) ) pub fn main() { - assert(line!() == 23); - assert(col!() == 11); - assert(indirect_line!() == 25); - assert(file!().to_owned().ends_with(~"syntax-extension-source-utils.rs")); - assert(stringify!((2*3) + 5).to_owned() == ~"( 2 * 3 ) + 5"); + fail_unless!((line!() == 23)); + fail_unless!((col!() == 11)); + fail_unless!((indirect_line!() == 25)); + fail_unless!((file!().to_owned().ends_with(~"syntax-extension-source-utils.rs"))); + fail_unless!((stringify!((2*3) + 5).to_owned() == ~"( 2 * 3 ) + 5")); assert(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() == ~"victory robot 6"); @@ -35,5 +35,5 @@ pub fn main() { 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 ffbd91d0a3a..23b9d5d4a3f 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -30,5 +30,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 953b4d55177..4d7c669ba7d 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -40,32 +40,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-shape.rs b/src/test/run-pass/tag-align-shape.rs index 2ebb9b2a7d5..cb2f9522df0 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -25,5 +25,5 @@ pub fn main() { let x = {c8: 22u8, t: a_tag(44u64)}; let y = fmt!("%?", x); debug!("y = %s", y); - assert y == "(22, a_tag(44))"; + fail_unless!(y == "(22, a_tag(44))"); } diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index 29043554c72..a4cbffbc120 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -30,5 +30,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-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 244712836d1..d8f469d2ff5 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -19,8 +19,8 @@ enum color { pub fn main() { let act = fmt!("%?", red); io::println(act); - assert ~"red" == act; - assert ~"green" == fmt!("%?", green); - assert ~"white" == fmt!("%?", white); + fail_unless!(~"red" == act); + fail_unless!(~"green" == fmt!("%?", green)); + fail_unless!(~"white" == fmt!("%?", white)); } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index d7571b3a47b..2f87142d688 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::reinterpret_cast(color) == val; - assert color as int == val; - assert color as float == val as float; - assert get_color_alt(color) == name; - assert get_color_if(color) == name; + //fail_unless!(unsafe::reinterpret_cast(color) == val); + fail_unless!(color as int == val); + fail_unless!(color as float == val as float); + 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 e9e7fdeaddf..729e11dfc64 100644 --- a/src/test/run-pass/tag.rs +++ b/src/test/run-pass/tag.rs @@ -34,6 +34,6 @@ impl cmp::Eq for colour { pure 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 3d1c9842476..8a413b53c2d 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -12,7 +12,7 @@ // -*- rust -*- -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 1a7733274fe..a7af09101f6 100644 --- a/src/test/run-pass/tail-direct.rs +++ b/src/test/run-pass/tail-direct.rs @@ -12,7 +12,7 @@ // -*- rust -*- -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-0.rs b/src/test/run-pass/task-comm-0.rs index 3e71875c4b5..b163703ca48 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -36,5 +36,5 @@ fn test05() { log(error, value); value = po.recv(); log(error, value); - assert (value == 30); + fail_unless!((value == 30)); } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 21c141d18a2..2e5da9a1a23 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -19,10 +19,10 @@ fn start(c: &comm::Chan>) { let mut a; let mut b; a = p.recv(); - assert a == ~"A"; + fail_unless!(a == ~"A"); log(error, a); b = p.recv(); - assert b == ~"B"; + fail_unless!(b == ~"B"); log(error, b); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index e2ac5623db3..c50dfe79169 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 (r1.val0 == 0); - assert (r1.val1 == 1u8); - assert (r1.val2 == '2'); + fail_unless!((r1.val0 == 0)); + fail_unless!((r1.val1 == 1u8)); + fail_unless!((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 (v1[0] == 0); - assert (v1[1] == 1); - assert (v1[2] == 2); + fail_unless!((v1[0] == 0)); + fail_unless!((v1[1] == 1)); + fail_unless!((v1[2] == 2)); } fn test_str() { @@ -39,10 +39,10 @@ fn test_str() { let s0 = ~"test"; ch.send(s0); let s1 = po.recv(); - assert (s1[0] == 't' as u8); - assert (s1[1] == 'e' as u8); - assert (s1[2] == 's' as u8); - assert (s1[3] == 't' as u8); + fail_unless!((s1[0] == 't' as u8)); + fail_unless!((s1[1] == 'e' as u8)); + fail_unless!((s1[2] == 's' as u8)); + fail_unless!((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 (t1 == tag1); + fail_unless!((t1 == tag1)); t1 = po.recv(); - assert (t1 == tag2(10)); + fail_unless!((t1 == tag2(10))); t1 = po.recv(); - assert (t1 == tag3(10, 11u8, 'A')); + fail_unless!((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 (i == 10); + fail_unless!((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 9ef76e06d7e..9772c0d181d 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -67,5 +67,5 @@ fn test00() { log(error, sum); // assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) * // number_of_messages)); - assert (sum == 480); + fail_unless!((sum == 480)); } diff --git a/src/test/run-pass/task-comm-4.rs b/src/test/run-pass/task-comm-4.rs index dc4dc27229c..5e43ea1f493 100644 --- a/src/test/run-pass/task-comm-4.rs +++ b/src/test/run-pass/task-comm-4.rs @@ -46,5 +46,5 @@ fn test00() { r = p.recv(); sum += r; log(debug, r); - assert (sum == 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8); + fail_unless!((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 0256c1cbb87..50c032c0754 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 (sum == number_of_messages * (number_of_messages - 1) / 2); + fail_unless!((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 c18090ea45f..69c58723289 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 (sum == 1998000); + fail_unless!((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 21eb93e8d09..88f41655c52 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -56,5 +56,5 @@ fn test00() { i += 1; } - assert (sum == number_of_messages * 4 * (number_of_messages * 4 - 1) / 2); + fail_unless!((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 4e540538657..95fe7867d0c 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -41,5 +41,5 @@ fn test00() { option::unwrap(result).recv(); - assert (sum == number_of_messages * (number_of_messages - 1) / 2); + fail_unless!((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 db2ad2de61b..4c63e24d5bc 100644 --- a/src/test/run-pass/task-comm-chan-nil.rs +++ b/src/test/run-pass/task-comm-chan-nil.rs @@ -19,5 +19,5 @@ pub fn main() { let (po, ch) = comm::stream(); ch.send(()); let n: () = po.recv(); - assert (n == ()); + fail_unless!((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 cbfff832736..7456c6efbd4 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 x_in_parent == x_in_child; + fail_unless!(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 1775bba934c..a07e5c6cf3f 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 result == 43; + fail_unless!(result == 43); } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index fb3756320f5..677852a74d6 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -55,7 +55,7 @@ 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 as to_str) == expected; + fail_unless!(t2.to_str() == expected); + fail_unless!(foo(t2 as to_str) == expected); t1.left = Some(t2); // create cycle } 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 19b62598604..5670ae39acc 100644 --- a/src/test/run-pass/trait-default-method-bound-subst.rs +++ b/src/test/run-pass/trait-default-method-bound-subst.rs @@ -21,5 +21,5 @@ fn f>(i: V, j: T, k: U) -> (T, U) { } pub fn main () { - assert f(0, 1, 2) == (1, 2); + fail_unless!(f(0, 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 424ba02b6fb..cba45c6bb23 100644 --- a/src/test/run-pass/trait-default-method-bound-subst2.rs +++ b/src/test/run-pass/trait-default-method-bound-subst2.rs @@ -21,5 +21,5 @@ fn f>(i: V, j: T) -> T { } pub fn main () { - assert f(0, 2) == 2; + fail_unless!(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 f8f51312b18..5a9b4fbb9e6 100644 --- a/src/test/run-pass/trait-default-method-bound-subst3.rs +++ b/src/test/run-pass/trait-default-method-bound-subst3.rs @@ -21,6 +21,6 @@ fn f(i: V, j: T, k: T) -> (T, T) { } pub fn main () { - assert f(0, 1, 2) == (1, 2); - assert f(0, 1u8, 2u8) == (1u8, 2u8); + fail_unless!(f(0, 1, 2) == (1, 2)); + fail_unless!(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 0f994ca9402..ee0feafa5c1 100644 --- a/src/test/run-pass/trait-default-method-bound-subst4.rs +++ b/src/test/run-pass/trait-default-method-bound-subst4.rs @@ -21,6 +21,6 @@ fn f>(i: V, j: uint) -> uint { } pub fn main () { - assert f::(0, 2u) == 2u; - assert f::(0, 2u) == 2u; + fail_unless!(f::(0, 2u) == 2u); + fail_unless!(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 be50b434055..4c2c030eaab 100644 --- a/src/test/run-pass/trait-default-method-bound.rs +++ b/src/test/run-pass/trait-default-method-bound.rs @@ -17,7 +17,7 @@ trait A { impl A for int { } fn f(i: T) { - assert i.g() == 10; + fail_unless!(i.g() == 10); } pub fn main () { diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 4a6651fe205..b375b5f328f 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -42,8 +42,8 @@ fn bar>(x: T) -> ~[~str] { } pub fn main() { - assert foo(~[1]) == ~[~"hi"]; - assert bar::(~[4, 5]) == ~[~"4", ~"5"]; - assert bar::<~str, ~[~str]>(~[~"x", ~"y"]) == ~[~"x", ~"y"]; - assert bar::<(), ~[()]>(~[()]) == ~[~"()"]; + fail_unless!(foo(~[1]) == ~[~"hi"]); + fail_unless!(bar::(~[4, 5]) == ~[~"4", ~"5"]); + fail_unless!(bar::<~str, ~[~str]>(~[~"x", ~"y"]) == ~[~"x", ~"y"]); + fail_unless!(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 6b8dd43d58b..15611d19979 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 a.f() == 10; - assert a.g() == 20; - assert a.h() == 30; + fail_unless!(a.f() == 10); + fail_unless!(a.g() == 20); + fail_unless!(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 302076da7a2..1efdd06767c 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() -> int { 20 } } impl Baz for A { fn h() -> int { 30 } } fn f(a: &T) { - assert a.f() == 10; - assert a.g() == 20; - assert a.h() == 30; + fail_unless!(a.f() == 10); + fail_unless!(a.g() == 20); + fail_unless!(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 7ebbc8e83cb..efc4cfa6156 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() -> int { 20 } } impl Baz for A { fn h() -> int { 30 } } fn f(a: &T) { - assert a.f() == 10; - assert a.g() == 20; - assert a.h() == 30; + fail_unless!(a.f() == 10); + fail_unless!(a.g() == 20); + fail_unless!(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 f02145896be..75dea9c500a 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -23,6 +23,6 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert gg(a) == 10; + fail_unless!(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 11a0918ba78..e8d553dae18 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -26,6 +26,6 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert gg(a) == 10; + fail_unless!(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 caa69382e13..3447cbad84a 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,7 +35,7 @@ pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; - assert afoo.f() == 10; - assert abar.g() == 20; + fail_unless!(afoo.f() == 10); + fail_unless!(abar.g() == 20); } diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs index 1cfc091c249..d066f49c732 100644 --- a/src/test/run-pass/trait-inheritance-cast.rs +++ b/src/test/run-pass/trait-inheritance-cast.rs @@ -36,8 +36,8 @@ pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; - assert afoo.f() == 10; - assert abar.g() == 20; - assert abar.f() == 10; + fail_unless!(afoo.f() == 10); + fail_unless!(abar.g() == 20); + fail_unless!(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 f344837a22d..cc6d5fa736f 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,6 +25,6 @@ impl Bar for aux::A { pub fn main() { let a = &aux::A { x: 3 }; - assert a.g() == 10; + fail_unless!(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 5a1f109ac32..47b5f60233b 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -22,6 +22,6 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - assert a.g() == 10; + fail_unless!(a.g() == 10); } diff --git a/src/test/run-pass/trait-inheritance-diamond.rs b/src/test/run-pass/trait-inheritance-diamond.rs index a4a3991f9e8..2bebf1c9932 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 x.a() == 10; - assert x.b() == 20; - assert x.c() == 30; - assert x.d() == 40; + fail_unless!(x.a() == 10); + fail_unless!(x.b() == 20); + fail_unless!(x.c() == 30); + fail_unless!(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 ad4d3ebc0b5..5c84e2af4b7 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 x.a() == 10; - assert x.b() == 20; - assert x.c() == 30; + fail_unless!(x.a() == 10); + fail_unless!(x.b() == 20); + fail_unless!(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 5b6a754488e..57a5f2bc0e1 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 x.a() == 10; - assert y.a() == 10; - assert y.b() == 20; - assert z.a() == 10; - assert z.c() == 30; + fail_unless!(x.a() == 10); + fail_unless!(y.a() == 10); + fail_unless!(y.b() == 20); + fail_unless!(z.a() == 10); + fail_unless!(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 7ecc15a0d81..ce370854a41 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -29,7 +29,7 @@ pure fn mi(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); - assert x != y; - assert x == z; + fail_unless!(x != y); + fail_unless!(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 1d59f1fc19e..f97412f4207 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -23,8 +23,8 @@ pure 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 a == mi(8); - assert b == mi(-2); - assert c == mi(15); + fail_unless!(a == mi(8)); + fail_unless!(b == mi(-2)); + fail_unless!(c == mi(15)); } diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index a4d7e33891f..aadc0650958 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -42,8 +42,8 @@ pure 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 a == mi(8); - assert b == mi(-2); - assert c == mi(15); + fail_unless!(a == mi(8)); + fail_unless!(b == mi(-2)); + fail_unless!(c == mi(15)); } diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index 29e2cb2f173..f56a50f1430 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -26,7 +26,7 @@ fn gg(a: &T) -> int { pub fn main() { let a = &A { x: 3 }; - assert ff(a) == 10; - assert gg(a) == 20; + fail_unless!(ff(a) == 10); + fail_unless!(gg(a) == 20); } diff --git a/src/test/run-pass/trait-inheritance-static.rs b/src/test/run-pass/trait-inheritance-static.rs index 2659d30c2b9..1d11870b21a 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 v.v == 1; + fail_unless!(v.v == 1); } diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs index ccc7f1fc4c0..30fefa7501f 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 v.v == 1; + fail_unless!(v.v == 1); } diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index ab755da7099..77e15a802e4 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -41,6 +41,6 @@ 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 == 13; + fail_unless!(z.val == 13); } diff --git a/src/test/run-pass/trait-inheritance-visibility.rs b/src/test/run-pass/trait-inheritance-visibility.rs index 8518137bbb8..861e9c0c84a 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 x.f() == 10; + fail_unless!(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 5925888650d..78e3b43730e 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() -> int { 30 } } impl Quux for A; fn f(a: &T) { - assert a.f() == 10; - assert a.g() == 20; - assert a.h() == 30; + fail_unless!(a.f() == 10); + fail_unless!(a.g() == 20); + fail_unless!(a.h() == 30); } pub fn main() { diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index a00ca615685..d55ca35fff2 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -26,6 +26,6 @@ impl Foo for A { pub fn main() { let a = A { x: 3 }; let b = (&a) as &Foo; - assert b.f() == 3; + fail_unless!(b.f() == 3); } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 23d03ba2172..29de9d1df81 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -31,16 +31,16 @@ impl to_str for ~[T] { } pub fn main() { - assert 1.to_str() == ~"1"; - assert (~[2, 3, 4]).to_str() == ~"[2, 3, 4]"; + fail_unless!(1.to_str() == ~"1"); + fail_unless!((~[2, 3, 4]).to_str() == ~"[2, 3, 4]"); fn indirect(x: T) -> ~str { x.to_str() + ~"!" } - 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-macro.rs b/src/test/run-pass/traits-default-method-macro.rs index 43d8121c0b4..f3f20cc50be 100644 --- a/src/test/run-pass/traits-default-method-macro.rs +++ b/src/test/run-pass/traits-default-method-macro.rs @@ -25,5 +25,5 @@ impl Foo for Baz { pub fn main() { let q = Quux; - assert q.bar() == ~"test"; + fail_unless!(q.bar() == ~"test"); } diff --git a/src/test/run-pass/traits-default-method-self.rs b/src/test/run-pass/traits-default-method-self.rs index 5a62d36f3e8..3531b12d1f9 100644 --- a/src/test/run-pass/traits-default-method-self.rs +++ b/src/test/run-pass/traits-default-method-self.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/traits-default-method-trivial.rs b/src/test/run-pass/traits-default-method-trivial.rs index 639741a55f3..fbfce37242d 100644 --- a/src/test/run-pass/traits-default-method-trivial.rs +++ b/src/test/run-pass/traits-default-method-trivial.rs @@ -26,5 +26,5 @@ impl Cat for int { } pub fn main() { - assert 5.meow(); + fail_unless!(5.meow()); } diff --git a/src/test/run-pass/tup.rs b/src/test/run-pass/tup.rs index 01d2600708d..6bcaca9a08c 100644 --- a/src/test/run-pass/tup.rs +++ b/src/test/run-pass/tup.rs @@ -13,15 +13,15 @@ type point = (int, int); fn f(p: point, x: int, y: int) { let (a, b) = p; - assert (a == x); - assert (b == y); + fail_unless!((a == x)); + fail_unless!((b == y)); } pub fn main() { let p: point = (10, 20); let (a, b) = p; - assert (a == 10); - assert (b == 20); + fail_unless!((a == 10)); + fail_unless!((b == 20)); let p2: point = p; f(p, 10, 20); f(p2, 10, 20); diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index dcecacf975a..82fa411b231 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -14,7 +14,7 @@ pub fn main() { let x = Foo(1, 2); let Foo(y, z) = x; io::println(fmt!("%d %d", y, z)); - assert y == 1; - assert z == 2; + fail_unless!(y == 1); + fail_unless!(z == 2); } diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index e127ba6d4c9..cd867adebc1 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 a == 1; - assert b == 2; + fail_unless!(a == 1); + fail_unless!(b == 2); io::println(fmt!("%d %d", a, b)); } } diff --git a/src/test/run-pass/type-namespace.rs b/src/test/run-pass/type-namespace.rs index 56b9c4700b9..2fb8f34120c 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 2c50e73cd57..bd90277cddd 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -13,19 +13,19 @@ use sys::rustrt::size_of; extern mod std; pub fn main() { - assert (size_of::() == 1 as uint); - assert (size_of::() == 4 as uint); - assert (size_of::() == 4 as uint); - assert (size_of::() == 1 as uint); - assert (size_of::() == 4 as uint); - assert (size_of::<{a: u8, b: i8}>() == 2 as uint); - assert (size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint); + fail_unless!((size_of::() == 1 as uint)); + fail_unless!((size_of::() == 4 as uint)); + fail_unless!((size_of::() == 4 as uint)); + fail_unless!((size_of::() == 1 as uint)); + fail_unless!((size_of::() == 4 as uint)); + fail_unless!((size_of::<{a: u8, b: i8}>() == 2 as uint)); + fail_unless!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint)); // Alignment causes padding before the char and the u32. assert (size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() == 16 as uint); - assert (size_of::() == size_of::()); - assert (size_of::<{a: int, b: ()}>() == size_of::()); - assert (size_of::<{a: int, b: (), c: ()}>() == size_of::()); - assert (size_of::() == size_of::<{x: int}>()); + fail_unless!((size_of::() == size_of::())); + fail_unless!((size_of::<{a: int, b: ()}>() == size_of::())); + fail_unless!((size_of::<{a: int, b: (), c: ()}>() == size_of::())); + fail_unless!((size_of::() == size_of::<{x: int}>())); } diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 07f1306e406..6dc43dd892c 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -47,13 +47,13 @@ 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)), branch(@leaf(magenta), @leaf(cyan))); diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index a586457519b..df9230a5dae 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -46,13 +46,13 @@ 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)) .isEq(branch(@leaf(magenta), @leaf(cyan))); diff --git a/src/test/run-pass/typestate-multi-decl.rs b/src/test/run-pass/typestate-multi-decl.rs index 68fff0cf8f5..9b8e84da6e0 100644 --- a/src/test/run-pass/typestate-multi-decl.rs +++ b/src/test/run-pass/typestate-multi-decl.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub fn main() { let x = 10, y = 20; let z = x + y; assert (z == 30); } +pub fn main() { let x = 10, y = 20; let z = x + y; fail_unless!((z == 30)); } diff --git a/src/test/run-pass/u32-decr.rs b/src/test/run-pass/u32-decr.rs index a720bd5f2b5..6f05ee5669d 100644 --- a/src/test/run-pass/u32-decr.rs +++ b/src/test/run-pass/u32-decr.rs @@ -15,5 +15,5 @@ pub fn main() { let mut word: u32 = 200000u32; word = word - 1u32; - assert (word == 199999u32); + fail_unless!((word == 199999u32)); } diff --git a/src/test/run-pass/u8-incr-decr.rs b/src/test/run-pass/u8-incr-decr.rs index e99a5d9e081..83e8fb1ffa2 100644 --- a/src/test/run-pass/u8-incr-decr.rs +++ b/src/test/run-pass/u8-incr-decr.rs @@ -24,5 +24,5 @@ pub fn main() { y = y - 9u8; // 0x9 - assert (x == y); + fail_unless!((x == y)); } diff --git a/src/test/run-pass/u8-incr.rs b/src/test/run-pass/u8-incr.rs index 44f0c9b19ba..2617437d17c 100644 --- a/src/test/run-pass/u8-incr.rs +++ b/src/test/run-pass/u8-incr.rs @@ -17,7 +17,7 @@ pub fn main() { let y: u8 = 12u8; x = x + 1u8; x = x - 1u8; - assert (x == y); + fail_unless!((x == y)); // x = 14u8; // x = x + 1u8; diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index 1bb04aef286..340a247c241 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 = copy i; *i = 2; *j = 3; - assert *i == 2; - assert *j == 3; + fail_unless!(*i == 2); + fail_unless!(*j == 3); } diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index 9a49fefdef0..fec3f7b626a 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -13,5 +13,5 @@ pub fn main() { let mut j = ~2; // Should drop the previous value of j j = i; - assert *j == 1; + fail_unless!(*j == 1); } diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index d6992e4623f..4254c12bac3 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -15,7 +15,7 @@ fn f(t: T) -> T { pub fn main() { let t = f(~100); - assert t == ~100; + fail_unless!(t == ~100); let t = f(~@~[100]); - assert t == ~@~[100]; + fail_unless!(t == ~@~[100]); } diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index c1a2c33cc45..4f283d11eea 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 *i == 1; + fail_unless!(*i == 1); } diff --git a/src/test/run-pass/unique-autoderef-field.rs b/src/test/run-pass/unique-autoderef-field.rs index 4bbdc9b4cd4..7326c642cf0 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 i.j == 100; + fail_unless!(i.j == 100); } diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 45e4b798969..a96f7d5c167 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 i[0] == 100; + fail_unless!(i[0] == 100); } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index 9d6ed4933bc..237ade196f0 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-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index babba058f52..42921f24c75 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 a == 10; + fail_unless!(a == 10); } _ { fail!(); } }*/ /*alt x { ~t1(a) { - assert a == 10; + fail_unless!(a == 10); } _ { fail!(); } }*/ diff --git a/src/test/run-pass/unique-copy-box.rs b/src/test/run-pass/unique-copy-box.rs index c1ee7f844d3..22e05213e5d 100644 --- a/src/test/run-pass/unique-copy-box.rs +++ b/src/test/run-pass/unique-copy-box.rs @@ -16,6 +16,6 @@ pub fn main() { let j = copy i; let rc2 = sys::refcount(*i); error!("rc1: %u rc2: %u", rc1, rc2); - assert rc1 + 1u == rc2; + fail_unless!(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 67e59cb08e0..2d15f09021e 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 = copy i; *i = 2; *j = 3; - assert *i == 2; - assert *j == 3; + fail_unless!(*i == 2); + fail_unless!(*j == 3); } diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index a856d37d4fc..809ca5bae0d 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 *j == 1; + fail_unless!(*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 96e91093d37..1632a537174 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 *i == 100; + fail_unless!(*i == 100); } diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index 7723eafc035..402d05fbcef 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 *j == 100; + fail_unless!(*j == 100); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 96e91093d37..1632a537174 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 *i == 100; + fail_unless!(*i == 100); } diff --git a/src/test/run-pass/unique-destructure.rs b/src/test/run-pass/unique-destructure.rs index 513e3c01757..c3047d5da05 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 a + b == 300; + fail_unless!(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 12e9820361d..850af69b347 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 *i == 100; + fail_unless!(*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 ddf87707e36..09be9e178ce 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 *i == 200; + fail_unless!(*i == 200); } diff --git a/src/test/run-pass/unique-fn-arg.rs b/src/test/run-pass/unique-fn-arg.rs index c35b40991df..030e11e46f6 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 *i == 100; + fail_unless!(*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 427bd8966b8..d645c3c21a6 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 f() == ~100; + fail_unless!(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 ac8796674ab..95b95913e98 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 = copy a; - assert *a[0] == 10; - assert *b[0] == 10; + fail_unless!(*a[0] == 10); + fail_unless!(*b[0] == 10); // This should only modify the value in a, not b *a[0] = 20; - assert *a[0] == 20; - assert *b[0] == 10; + fail_unless!(*a[0] == 20); + fail_unless!(*b[0] == 10); } diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 0a6a3a0ef5d..62e9e03d3a1 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 3cc18457286..9844a55c960 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -13,11 +13,11 @@ use core::cmp::Eq; fn sendable() { fn f(i: T, j: T) { - assert i == j; + fail_unless!(i == j); } fn g(i: T, j: T) { - assert i != j; + fail_unless!(i != j); } let i = ~100; @@ -31,11 +31,11 @@ fn sendable() { fn copyable() { fn f(i: T, j: T) { - assert i == j; + fail_unless!(i == j); } fn g(i: T, j: T) { - assert i != j; + fail_unless!(i != j); } let i = ~100; @@ -49,11 +49,11 @@ fn copyable() { fn noncopyable() { fn f(i: T, j: T) { - assert i == j; + fail_unless!(i == j); } fn g(i: T, j: T) { - assert i != j; + fail_unless!(i != j); } let i = ~100; diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index 5988a3e8658..ac64b388a05 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -12,5 +12,5 @@ pub fn main() { let i = ~100; let j = ~200; let j = i; - assert *j == 100; + fail_unless!(*j == 100); } diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index 08a496987c0..2f8b0a84b04 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 *i == 100; + fail_unless!(*i == 100); } diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index 5e778d581d3..3dc80e26b1c 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 *j == 100; + fail_unless!(*j == 100); } diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index 8784dbeb0af..4e7c751b883 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 *i == 1; + fail_unless!(*i == 1); } diff --git a/src/test/run-pass/unique-object.rs b/src/test/run-pass/unique-object.rs index 031b17ceb8f..f2aab3bbb51 100644 --- a/src/test/run-pass/unique-object.rs +++ b/src/test/run-pass/unique-object.rs @@ -25,6 +25,6 @@ impl Foo for Bar { pub fn main() { let x = ~Bar { x: 10 }; let y = x as ~Foo; - assert y.f() == 10; + fail_unless!(y.f() == 10); } diff --git a/src/test/run-pass/unique-pinned-nocopy-2.rs b/src/test/run-pass/unique-pinned-nocopy-2.rs index 7da21b1081e..3fc22c9a5a5 100644 --- a/src/test/run-pass/unique-pinned-nocopy-2.rs +++ b/src/test/run-pass/unique-pinned-nocopy-2.rs @@ -29,5 +29,5 @@ pub fn main() { { let j = ~r(i); } - assert *i == 1; + fail_unless!(*i == 1); } diff --git a/src/test/run-pass/unique-rec.rs b/src/test/run-pass/unique-rec.rs index 20d30e45d08..b1b833f9163 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 bar.x == 1; + fail_unless!(bar.x == 1); } diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index 7be6907a0c7..d7c70b55080 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -31,5 +31,5 @@ pub fn main() { actual += *j; } - assert expected == actual; + fail_unless!(expected == actual); } diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index 75fc71441f8..3b2569c2712 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -14,5 +14,5 @@ pub fn main() { let (p, c) = stream(); c.send(~100); let v = p.recv(); - assert v == ~100; + fail_unless!(v == ~100); } diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index a024cda75c3..fd869d2e043 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -12,6 +12,6 @@ pub fn main() { let mut i = ~100; let mut j = ~200; i <-> j; - assert i == ~200; - assert j == ~100; + fail_unless!(i == ~200); + fail_unless!(j == ~100); } diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs index 6684069c38b..1468b47706d 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 *x == 3; + fail_unless!(*x == 3); } } diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 2693a8d3942..80672f78514 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 c = SharedChan(c); task::spawn_unlinked(|| f(c.clone()) ); error!("hiiiiiiiii"); - assert p.recv(); + fail_unless!(p.recv()); } diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index 0a6e1471671..c2b4049c306 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 (yen as int == 0xa5); - assert (c_cedilla as int == 0xe7); - assert (thorn as int == 0xfe); - assert (y_diaeresis as int == 0xff); - assert (pi as int == 0x3a0); + fail_unless!((yen as int == 0xa5)); + fail_unless!((c_cedilla as int == 0xe7)); + fail_unless!((thorn as int == 0xfe)); + fail_unless!((y_diaeresis as int == 0xff)); + fail_unless!((pi as int == 0x3a0)); - assert (pi as int == '\u03a0' as int); - assert ('\x0a' as int == '\n' as int); + fail_unless!((pi as int == '\u03a0' as int)); + fail_unless!(('\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 (oo as int == 0xd6); + fail_unless!((oo as int == 0xd6)); fn check_str_eq(a: ~str, b: ~str) { let mut i: int = 0; @@ -46,7 +46,7 @@ pub fn main() { log(debug, ab); let bb: u8 = b[i]; log(debug, bb); - assert (ab == bb); + fail_unless!((ab == bb)); i += 1; } } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 147c81a263f..cfbb7398159 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -15,25 +15,25 @@ pub fn main() { let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char]; let s: ~str = str::from_chars(chs); - assert (str::len(s) == 10u); - assert (str::char_len(s) == 4u); - assert (vec::len(str::chars(s)) == 4u); - assert (str::from_chars(str::chars(s)) == s); - assert (str::char_at(s, 0u) == 'e'); - assert (str::char_at(s, 1u) == 'é'); + fail_unless!((str::len(s) == 10u)); + fail_unless!((str::char_len(s) == 4u)); + fail_unless!((vec::len(str::chars(s)) == 4u)); + fail_unless!((str::from_chars(str::chars(s)) == s)); + fail_unless!((str::char_at(s, 0u) == 'e')); + fail_unless!((str::char_at(s, 1u) == 'é')); - assert (str::is_utf8(str::to_bytes(s))); - assert (!str::is_utf8(~[0x80_u8])); - assert (!str::is_utf8(~[0xc0_u8])); - assert (!str::is_utf8(~[0xc0_u8, 0x10_u8])); + fail_unless!((str::is_utf8(str::to_bytes(s)))); + fail_unless!((!str::is_utf8(~[0x80_u8]))); + fail_unless!((!str::is_utf8(~[0xc0_u8]))); + fail_unless!((!str::is_utf8(~[0xc0_u8, 0x10_u8]))); let mut stack = ~"a×c€"; - assert (str::pop_char(&mut stack) == '€'); - assert (str::pop_char(&mut stack) == 'c'); + fail_unless!((str::pop_char(&mut stack) == '€')); + fail_unless!((str::pop_char(&mut stack) == 'c')); str::push_char(&mut stack, 'u'); - assert (stack == ~"a×u"); - assert (str::shift_char(&mut stack) == 'a'); - assert (str::shift_char(&mut stack) == '×'); + fail_unless!((stack == ~"a×u")); + fail_unless!((str::shift_char(&mut stack) == 'a')); + fail_unless!((str::shift_char(&mut stack) == '×')); str::unshift_char(&mut stack, 'ß'); - 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 7cd04d5f7b4..58fd9216b15 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -12,8 +12,8 @@ pub fn main() { let ε = 0.00001; let Π = 3.14; let लंच = Π * Π + 1.54; - assert float::abs((लंच - 1.54) - (Π * Π)) < ε; - assert საჭმელად_გემრიელი_სადილი() == 0; + fail_unless!(float::abs((लंच - 1.54) - (Π * Π)) < ε); + fail_unless!(საჭმელად_გემრიელი_სადილი() == 0); } fn საჭმელად_გემრიელი_სადილი() -> int { @@ -37,9 +37,9 @@ fn საჭმელად_გემრიელი_სადილი() -> int // Lunchy arithmetic, mm. - assert hádegismatur * ручек * обед == 1000; - assert 10 == ארוחת_צהריי; - assert ランチ + 午餐 + μεσημεριανό == 30; - assert ăn_trưa + อาหารกลางวัน == 20; + fail_unless!(hádegismatur * ручек * обед == 1000); + fail_unless!(10 == ארוחת_צהריי); + fail_unless!(ランチ + 午餐 + μεσημεριανό == 30); + fail_unless!(ăn_trưa + อาหารกลางวัน == 20); return (абед + լանչ) >> غداء; } diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index 82a18a8ebfc..a7371f5fcf3 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -14,7 +14,7 @@ pub fn main() { let b: ~[int] = ~[6, 7, 8, 9, 0]; let v: ~[int] = a + b; log(debug, v[9]); - assert (v[0] == 1); - assert (v[7] == 8); - assert (v[9] == 0); + fail_unless!((v[0] == 1)); + fail_unless!((v[7] == 8)); + fail_unless!((v[9] == 0)); } diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index ebfb3831045..84049c9a756 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 += ~[3]; v += ~[4]; v += ~[5]; - assert (v[0] == 1); - assert (v[1] == 2); - assert (v[2] == 3); - assert (v[3] == 4); - assert (v[4] == 5); + fail_unless!((v[0] == 1)); + fail_unless!((v[1] == 2)); + fail_unless!((v[2] == 3)); + fail_unless!((v[3] == 4)); + fail_unless!((v[4] == 5)); } diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index f4eedb288b6..615d77f18e9 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -3,7 +3,7 @@ pub fn main() { match x { [2, .._] => ::core::util::unreachable(), [1, ..tail] => { - assert tail == [2, 3]; + fail_unless!(tail == [2, 3]); } [_] => ::core::util::unreachable(), [] => ::core::util::unreachable() @@ -13,9 +13,9 @@ pub fn main() { match y { ([_, _, _], 0.5) => ::core::util::unreachable(), ([(1, a), (b, false), ..tail], _) => { - assert a == true; - assert b == 2; - assert tail.is_empty(); + fail_unless!(a == true); + fail_unless!(b == 2); + fail_unless!(tail.is_empty()); } ([..tail], _) => ::core::util::unreachable() } diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 1c7aec7682f..1cbd0d78c02 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -17,11 +17,11 @@ pub fn main() { ::core::util::unreachable(); } [a, b, c, d, e] => { - assert a == 1; - assert b == 2; - assert c == 3; - assert d == 4; - assert e == 5; + fail_unless!(a == 1); + fail_unless!(b == 2); + fail_unless!(c == 3); + fail_unless!(d == 4); + fail_unless!(e == 5); } _ => { ::core::util::unreachable(); @@ -29,5 +29,5 @@ pub fn main() { } let product = foldl(x, 1, |a, b| a * *b); - assert product == 120; + fail_unless!(product == 120); } diff --git a/src/test/run-pass/vec-position.rs b/src/test/run-pass/vec-position.rs index fe186a78ed7..a1dddf33025 100644 --- a/src/test/run-pass/vec-position.rs +++ b/src/test/run-pass/vec-position.rs @@ -10,7 +10,7 @@ pub fn main() { let mut v = ~[1, 2, 3]; - assert v.position(|x| *x == 1) == Some(0); - assert v.position(|x| *x == 3) == Some(2); - assert v.position(|x| *x == 17) == None; + fail_unless!(v.position(|x| *x == 1) == Some(0)); + fail_unless!(v.position(|x| *x == 3) == Some(2)); + fail_unless!(v.position(|x| *x == 17) == None); } diff --git a/src/test/run-pass/vec-self-append.rs b/src/test/run-pass/vec-self-append.rs index 44031f5deaa..614a884c08c 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 (vec::len(a) == 10u); - assert (a[0] == 0); - assert (a[1] == 1); - assert (a[2] == 2); - assert (a[3] == 3); - assert (a[4] == 4); - assert (a[5] == 0); - assert (a[6] == 1); - assert (a[7] == 2); - assert (a[8] == 3); - assert (a[9] == 4); + fail_unless!((vec::len(a) == 10u)); + fail_unless!((a[0] == 0)); + fail_unless!((a[1] == 1)); + fail_unless!((a[2] == 2)); + fail_unless!((a[3] == 3)); + fail_unless!((a[4] == 4)); + fail_unless!((a[5] == 0)); + fail_unless!((a[6] == 1)); + fail_unless!((a[7] == 2)); + fail_unless!((a[8] == 3)); + fail_unless!((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 (vec::len(a) == 6u); - assert (a[0] == 0); - assert (a[1] == 1); - assert (a[2] == 2); - assert (a[3] == 0); - assert (a[4] == 1); - assert (a[5] == 2); + fail_unless!((vec::len(a) == 6u)); + fail_unless!((a[0] == 0)); + fail_unless!((a[1] == 1)); + fail_unless!((a[2] == 2)); + fail_unless!((a[3] == 0)); + fail_unless!((a[4] == 1)); + fail_unless!((a[5] == 2)); } fn test_loop() { @@ -48,7 +48,7 @@ fn test_loop() { let mut expected_len = 1u; while i > 0 { log(error, vec::len(a)); - assert (vec::len(a) == expected_len); + fail_unless!((vec::len(a) == 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 3fcd69ce40a..71963e073db 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -29,7 +29,7 @@ pub fn main() { let x = @mut 0; { let l = &[foo(x)]; - assert *l[0].x == 0; + fail_unless!(*l[0].x == 0); } - assert *x == 1; + fail_unless!(*x == 1); } diff --git a/src/test/run-pass/vec-slice.rs b/src/test/run-pass/vec-slice.rs index e77f8c72033..cbf5edd1718 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 = vec::slice(v, 1, 3); - assert (v2[0] == 2); - assert (v2[1] == 3); + fail_unless!((v2[0] == 2)); + fail_unless!((v2[1] == 3)); } diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 0dc66c091ba..6fbae42435e 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -10,18 +10,18 @@ pub fn main() { ]; match x { [first, ..tail] => { - assert first.string == ~"foo"; - assert tail.len() == 2; - assert tail[0].string == ~"bar"; - assert tail[1].string == ~"baz"; + fail_unless!(first.string == ~"foo"); + fail_unless!(tail.len() == 2); + fail_unless!(tail[0].string == ~"bar"); + fail_unless!(tail[1].string == ~"baz"); match tail { [Foo { _ }, _, Foo { _ }, ..tail] => { ::core::util::unreachable(); } [Foo { string: a }, Foo { string: b }] => { - assert a == ~"bar"; - assert b == ~"baz"; + fail_unless!(a == ~"bar"); + fail_unless!(b == ~"baz"); } _ => { ::core::util::unreachable(); diff --git a/src/test/run-pass/vec-to_str.rs b/src/test/run-pass/vec-to_str.rs index fed091e0fe6..b7130bfc719 100644 --- a/src/test/run-pass/vec-to_str.rs +++ b/src/test/run-pass/vec-to_str.rs @@ -9,16 +9,16 @@ // except according to those terms. pub fn main() { - assert (~[0, 1]).to_str() == ~"[0, 1]"; - assert (&[1, 2]).to_str() == ~"[1, 2]"; - assert (@[2, 3]).to_str() == ~"[2, 3]"; + fail_unless!((~[0, 1]).to_str() == ~"[0, 1]"); + fail_unless!((&[1, 2]).to_str() == ~"[1, 2]"); + fail_unless!((@[2, 3]).to_str() == ~"[2, 3]"); let foo = ~[3, 4]; let bar = &[4, 5]; let baz = @[5, 6]; - assert foo.to_str() == ~"[3, 4]"; - assert bar.to_str() == ~"[4, 5]"; - assert baz.to_str() == ~"[5, 6]"; + fail_unless!(foo.to_str() == ~"[3, 4]"); + fail_unless!(bar.to_str() == ~"[4, 5]"); + fail_unless!(baz.to_str() == ~"[5, 6]"); } diff --git a/src/test/run-pass/vec-trailing-comma.rs b/src/test/run-pass/vec-trailing-comma.rs index d433aa5534c..28914792720 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 (v1[2] == v2[2]); + fail_unless!((v1[2] == v2[2])); let v3: ~[int] = ~[10,]; let v4: ~[int] = ~[10]; - assert (v3[0] == v4[0]); + fail_unless!((v3[0] == v4[0])); } diff --git a/src/test/run-pass/vec.rs b/src/test/run-pass/vec.rs index 4a1be51e55e..07365f346a7 100644 --- a/src/test/run-pass/vec.rs +++ b/src/test/run-pass/vec.rs @@ -14,12 +14,12 @@ // -*- rust -*- pub fn main() { let v: ~[int] = ~[10, 20]; - assert (v[0] == 10); - assert (v[1] == 20); + fail_unless!((v[0] == 10)); + fail_unless!((v[1] == 20)); let mut x: int = 0; - assert (v[x] == 10); - assert (v[x + 1] == 20); + fail_unless!((v[x] == 10)); + fail_unless!((v[x + 1] == 20)); x = x + 1; - assert (v[x] == 20); - assert (v[x - 1] == 10); + fail_unless!((v[x] == 20)); + fail_unless!((v[x - 1] == 10)); } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 5b515ae5434..5e3201eae17 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -22,7 +22,7 @@ fn what() { let i = @mut false; let dont = {||the(i)}; dont(); - assert (*i); + fail_unless!((*i)); } fn zombiejesus() { @@ -61,8 +61,8 @@ fn hammertime() -> int { fn canttouchthis() -> uint { pure fn p() -> bool { true } - let _a = (assert (true)) == (assert (p())); - let _c = (assert (p())) == (); + let _a = (fail_unless!((true)) == (assert (p()))); + let _c = (fail_unless!((p())) == ()); let _b: bool = (log(debug, 0) == (return 0u)); } diff --git a/src/test/run-pass/while-cont.rs b/src/test/run-pass/while-cont.rs index c13c2d1e7d7..9181f721305 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)); log(debug, i); i -= 1; loop; diff --git a/src/test/run-pass/while-loop-constraints-2.rs b/src/test/run-pass/while-loop-constraints-2.rs index df5f5904793..39d3e2d9747 100644 --- a/src/test/run-pass/while-loop-constraints-2.rs +++ b/src/test/run-pass/while-loop-constraints-2.rs @@ -18,5 +18,5 @@ pub fn main() { while false { x = y; y = z; } log(debug, y); } - assert (y == 42 && z == 50); + fail_unless!((y == 42 && z == 50)); } diff --git a/src/test/run-pass/while-with-break.rs b/src/test/run-pass/while-with-break.rs index 8bbea140c60..dafae6b77c7 100644 --- a/src/test/run-pass/while-with-break.rs +++ b/src/test/run-pass/while-with-break.rs @@ -15,5 +15,5 @@ pub fn main() { break; } } - assert (i == 95); + fail_unless!((i == 95)); } diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index c9c5ce0c928..cfc94b67b57 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -19,5 +19,5 @@ fn f(p: &mut Point) { p.z = 13; } pub fn main() { let mut x: Point = Point {x: 10, y: 11, z: 12}; f(&mut x); - assert (x.z == 13); + fail_unless!((x.z == 13)); } diff --git a/src/test/run-pass/x86stdcall.rs b/src/test/run-pass/x86stdcall.rs index fb1ec6cd891..b1421dce0ae 100644 --- a/src/test/run-pass/x86stdcall.rs +++ b/src/test/run-pass/x86stdcall.rs @@ -25,7 +25,7 @@ pub fn main() { kernel32::SetLastError(expected); let actual = kernel32::GetLastError(); log(error, actual); - assert (expected == actual); + fail_unless!((expected == actual)); } } diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index b1d07d66507..e61f512cfcd 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -30,9 +30,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(target_os = "macos")] diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index fdb6989b7bb..1876e976c50 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -12,7 +12,7 @@ // succeed at runtime fn enum_chars(start: u8, end: u8) -> ~[char] { - assert start < end; + fail_unless!(start < end); let mut i = start; let mut r = ~[]; while i <= end { r.push(i as char); i += 1u as u8; } @@ -20,7 +20,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { } fn enum_uints(start: uint, end: uint) -> ~[uint] { - assert start < end; + fail_unless!(start < end); let mut i = start; let mut r = ~[]; while i <= end { r.push(i); i += 1u; } @@ -34,6 +34,6 @@ pub fn main() { let ps = vec::zip(chars, ints); - assert (ps.head() == &('a', 1u)); - assert (ps.last() == &(j as char, 10u)); + fail_unless!((ps.head() == &('a', 1u))); + fail_unless!((ps.last() == &(j as char, 10u))); }