Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e2605b42
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2605b42
编写于
1月 31, 2015
作者:
S
Steven Fackler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename #[should_fail] to #[should_panic]
上级
2574009a
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
136 addition
and
128 deletion
+136
-128
src/compiletest/compiletest.rs
src/compiletest/compiletest.rs
+1
-1
src/libarena/lib.rs
src/libarena/lib.rs
+1
-1
src/libcollections/enum_set.rs
src/libcollections/enum_set.rs
+1
-1
src/libcollections/slice.rs
src/libcollections/slice.rs
+13
-13
src/libcollections/str.rs
src/libcollections/str.rs
+3
-3
src/libcollections/string.rs
src/libcollections/string.rs
+5
-5
src/libcollections/vec.rs
src/libcollections/vec.rs
+9
-9
src/libcollections/vec_deque.rs
src/libcollections/vec_deque.rs
+1
-1
src/libcollections/vec_map.rs
src/libcollections/vec_map.rs
+1
-1
src/libcoretest/cell.rs
src/libcoretest/cell.rs
+1
-1
src/libcoretest/finally.rs
src/libcoretest/finally.rs
+1
-1
src/libcoretest/fmt/num.rs
src/libcoretest/fmt/num.rs
+1
-1
src/libcoretest/iter.rs
src/libcoretest/iter.rs
+1
-1
src/libcoretest/option.rs
src/libcoretest/option.rs
+3
-3
src/libcoretest/result.rs
src/libcoretest/result.rs
+1
-1
src/librand/distributions/exponential.rs
src/librand/distributions/exponential.rs
+2
-2
src/librand/distributions/gamma.rs
src/librand/distributions/gamma.rs
+1
-1
src/librand/distributions/mod.rs
src/librand/distributions/mod.rs
+3
-3
src/librand/distributions/normal.rs
src/librand/distributions/normal.rs
+2
-2
src/librand/distributions/range.rs
src/librand/distributions/range.rs
+2
-2
src/librustc_back/sha2.rs
src/librustc_back/sha2.rs
+1
-1
src/librustdoc/test.rs
src/librustdoc/test.rs
+6
-6
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/map.rs
+1
-1
src/libstd/old_io/buffered.rs
src/libstd/old_io/buffered.rs
+1
-1
src/libstd/old_io/extensions.rs
src/libstd/old_io/extensions.rs
+1
-1
src/libstd/old_io/timer.rs
src/libstd/old_io/timer.rs
+3
-3
src/libstd/old_path/windows.rs
src/libstd/old_path/windows.rs
+1
-1
src/libstd/rand/mod.rs
src/libstd/rand/mod.rs
+2
-2
src/libstd/rand/reader.rs
src/libstd/rand/reader.rs
+1
-1
src/libstd/sync/condvar.rs
src/libstd/sync/condvar.rs
+1
-1
src/libstd/sync/future.rs
src/libstd/sync/future.rs
+1
-1
src/libstd/sync/task_pool.rs
src/libstd/sync/task_pool.rs
+1
-1
src/libstd/sys/common/wtf8.rs
src/libstd/sys/common/wtf8.rs
+5
-5
src/libsyntax/codemap.rs
src/libsyntax/codemap.rs
+1
-1
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+2
-2
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-1
src/libsyntax/test.rs
src/libsyntax/test.rs
+22
-14
src/libsyntax/util/interner.rs
src/libsyntax/util/interner.rs
+1
-1
src/libsyntax/util/small_vector.rs
src/libsyntax/util/small_vector.rs
+2
-2
src/libtest/lib.rs
src/libtest/lib.rs
+26
-26
src/test/run-fail/test-should-fail-bad-message.rs
src/test/run-fail/test-should-fail-bad-message.rs
+1
-1
src/test/run-pass/test-should-fail-good-message.rs
src/test/run-pass/test-should-fail-good-message.rs
+2
-2
未找到文件。
src/compiletest/compiletest.rs
浏览文件 @
e2605b42
...
...
@@ -332,7 +332,7 @@ pub fn make_test<F>(config: &Config, testfile: &Path, f: F) -> test::TestDescAnd
desc
:
test
::
TestDesc
{
name
:
make_test_name
(
config
,
testfile
),
ignore
:
header
::
is_test_ignored
(
config
,
testfile
),
should_
fail
:
test
::
ShouldFail
::
No
,
should_
panic
:
test
::
ShouldPanic
::
No
,
},
testfn
:
f
(),
}
...
...
src/libarena/lib.rs
浏览文件 @
e2605b42
...
...
@@ -323,7 +323,7 @@ fn test_arena_destructors() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_arena_destructors_fail
()
{
let
arena
=
Arena
::
new
();
// Put some stuff in the arena.
...
...
src/libcollections/enum_set.rs
浏览文件 @
e2605b42
...
...
@@ -490,7 +490,7 @@ fn test_operators() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_overflow
()
{
#[allow(dead_code)]
#[derive(Copy)]
...
...
src/libcollections/slice.rs
浏览文件 @
e2605b42
...
...
@@ -1647,14 +1647,14 @@ fn test_tail_mut() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_tail_empty
()
{
let
a
=
Vec
::
<
i32
>
::
new
();
a
.tail
();
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_tail_mut_empty
()
{
let
mut
a
=
Vec
::
<
i32
>
::
new
();
a
.tail_mut
();
...
...
@@ -1681,14 +1681,14 @@ fn test_init_mut() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_init_empty
()
{
let
a
=
Vec
::
<
i32
>
::
new
();
a
.init
();
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_init_mut_empty
()
{
let
mut
a
=
Vec
::
<
i32
>
::
new
();
a
.init_mut
();
...
...
@@ -1790,7 +1790,7 @@ fn test_swap_remove() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_swap_remove_fail
()
{
let
mut
v
=
vec!
[
1
];
let
_
=
v
.swap_remove
(
0
);
...
...
@@ -2205,7 +2205,7 @@ fn test_insert() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_insert_oob
()
{
let
mut
a
=
vec!
[
1
,
2
,
3
];
a
.insert
(
4
,
5
);
...
...
@@ -2229,7 +2229,7 @@ fn test_remove() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_remove_fail
()
{
let
mut
a
=
vec!
[
1
];
let
_
=
a
.remove
(
0
);
...
...
@@ -2253,7 +2253,7 @@ fn test_slice_2() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_permute_fail
()
{
let
v
:
[(
Box
<
_
>
,
Rc
<
_
>
);
4
]
=
[(
box
0
,
Rc
::
new
(
0
)),
(
box
0
,
Rc
::
new
(
0
)),
...
...
@@ -2528,7 +2528,7 @@ fn test_windowsator() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_windowsator_0
()
{
let
v
=
&
[
1
,
2
,
3
,
4
];
let
_
it
=
v
.windows
(
0
);
...
...
@@ -2564,7 +2564,7 @@ fn test_chunksator() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_chunksator_0
()
{
let
v
=
&
[
1
,
2
,
3
,
4
];
let
_
it
=
v
.chunks
(
0
);
...
...
@@ -2647,7 +2647,7 @@ fn test_bytes_set_memory() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_overflow_does_not_cause_segfault
()
{
let
mut
v
=
vec!
[];
v
.reserve_exact
(
-
1
);
...
...
@@ -2656,7 +2656,7 @@ fn test_overflow_does_not_cause_segfault() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_overflow_does_not_cause_segfault_managed
()
{
let
mut
v
=
vec!
[
Rc
::
new
(
1
)];
v
.reserve_exact
(
-
1
);
...
...
@@ -2833,7 +2833,7 @@ fn test_mut_chunks_rev() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_mut_chunks_0
()
{
let
mut
v
=
[
1
,
2
,
3
,
4
];
let
_
it
=
v
.chunks_mut
(
0
);
...
...
src/libcollections/str.rs
浏览文件 @
e2605b42
...
...
@@ -1877,7 +1877,7 @@ fn test_slice_2() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_fail
()
{
"中华Việt Nam"
.slice
(
0
,
2
);
}
...
...
@@ -2095,7 +2095,7 @@ fn test_as_bytes() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_as_bytes_fail
()
{
// Don't double free. (I'm not sure if this exercises the
// original problem code path anymore.)
...
...
@@ -2132,7 +2132,7 @@ fn test_subslice_offset() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_subslice_offset_2
()
{
let
a
=
"alchemiter"
;
let
b
=
"cruxtruder"
;
...
...
src/libcollections/string.rs
浏览文件 @
e2605b42
...
...
@@ -1232,14 +1232,14 @@ fn test_str_truncate() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_str_truncate_invalid_len
()
{
let
mut
s
=
String
::
from_str
(
"12345"
);
s
.truncate
(
6
);
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_str_truncate_split_codepoint
()
{
let
mut
s
=
String
::
from_str
(
"
\
u{FC}"
);
// ü
s
.truncate
(
1
);
...
...
@@ -1272,7 +1272,7 @@ fn remove() {
assert_eq!
(
s
,
"ไทย中华Vit Nam; foobar"
);
}
#[test]
#[should_
fail
]
#[test]
#[should_
panic
]
fn
remove_bad
()
{
"ศ"
.to_string
()
.remove
(
1
);
}
...
...
@@ -1286,8 +1286,8 @@ fn insert() {
assert_eq!
(
s
,
"ệfooยbar"
);
}
#[test]
#[should_
fail
]
fn
insert_bad1
()
{
""
.to_string
()
.insert
(
1
,
't'
);
}
#[test]
#[should_
fail
]
fn
insert_bad2
()
{
"ệ"
.to_string
()
.insert
(
1
,
't'
);
}
#[test]
#[should_
panic
]
fn
insert_bad1
()
{
""
.to_string
()
.insert
(
1
,
't'
);
}
#[test]
#[should_
panic
]
fn
insert_bad2
()
{
"ệ"
.to_string
()
.insert
(
1
,
't'
);
}
#[test]
fn
test_slicing
()
{
...
...
src/libcollections/vec.rs
浏览文件 @
e2605b42
...
...
@@ -2242,7 +2242,7 @@ fn drop(&mut self) {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_vec_truncate_fail
()
{
struct
BadElem
(
i32
);
impl
Drop
for
BadElem
{
...
...
@@ -2265,49 +2265,49 @@ fn test_index() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_index_out_of_bounds
()
{
let
vec
=
vec!
[
1
,
2
,
3
];
let
_
=
vec
[
3
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_out_of_bounds_1
()
{
let
x
=
vec!
[
1
,
2
,
3
,
4
,
5
];
&
x
[
-
1
..
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_out_of_bounds_2
()
{
let
x
=
vec!
[
1
,
2
,
3
,
4
,
5
];
&
x
[
..
6
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_out_of_bounds_3
()
{
let
x
=
vec!
[
1
,
2
,
3
,
4
,
5
];
&
x
[
-
1
..
4
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_out_of_bounds_4
()
{
let
x
=
vec!
[
1
,
2
,
3
,
4
,
5
];
&
x
[
1
..
6
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_slice_out_of_bounds_5
()
{
let
x
=
vec!
[
1
,
2
,
3
,
4
,
5
];
&
x
[
3
..
2
];
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_swap_remove_empty
()
{
let
mut
vec
=
Vec
::
<
i32
>
::
new
();
vec
.swap_remove
(
0
);
...
...
@@ -2326,7 +2326,7 @@ fn test_move_iter_unwrap() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_map_in_place_incompatible_types_fail
()
{
let
v
=
vec!
[
0
,
1
,
2
];
v
.map_in_place
(|
_
|
());
...
...
src/libcollections/vec_deque.rs
浏览文件 @
e2605b42
...
...
@@ -1884,7 +1884,7 @@ fn test_index() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_index_out_of_bounds
()
{
let
mut
deq
=
VecDeque
::
new
();
for
i
in
1
..
4
{
...
...
src/libcollections/vec_map.rs
浏览文件 @
e2605b42
...
...
@@ -1432,7 +1432,7 @@ fn test_index() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_index_nonexistent
()
{
let
mut
map
=
VecMap
::
new
();
...
...
src/libcoretest/cell.rs
浏览文件 @
e2605b42
...
...
@@ -109,7 +109,7 @@ fn double_borrow_single_release_no_borrow_mut() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
discard_doesnt_unborrow
()
{
let
x
=
RefCell
::
new
(
0
);
let
_
b
=
x
.borrow
();
...
...
src/libcoretest/finally.rs
浏览文件 @
e2605b42
...
...
@@ -30,7 +30,7 @@ fn test_success() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_fail
()
{
let
mut
i
=
0
;
try_finally
(
...
...
src/libcoretest/fmt/num.rs
浏览文件 @
e2605b42
...
...
@@ -161,7 +161,7 @@ fn test_format_radix() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_radix_base_too_large
()
{
let
_
=
radix
(
55
,
37
);
}
...
...
src/libcoretest/iter.rs
浏览文件 @
e2605b42
...
...
@@ -581,7 +581,7 @@ fn test_rposition() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_rposition_panic
()
{
let
v
:
[(
Box
<
_
>
,
Box
<
_
>
);
4
]
=
[(
box
0
,
box
0
),
(
box
0
,
box
0
),
...
...
src/libcoretest/option.rs
浏览文件 @
e2605b42
...
...
@@ -80,7 +80,7 @@ fn test_option_dance() {
assert
!
(
y
.is_none
());
}
#[test]
#[should_
fail
]
#[test]
#[should_
panic
]
fn
test_option_too_much_dance
()
{
let
mut
y
=
Some
(
marker
::
NoCopy
);
let
_
y2
=
y
.take
()
.unwrap
();
...
...
@@ -139,14 +139,14 @@ fn test_unwrap() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_unwrap_panic1
()
{
let
x
:
Option
<
int
>
=
None
;
x
.unwrap
();
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_unwrap_panic2
()
{
let
x
:
Option
<
String
>
=
None
;
x
.unwrap
();
...
...
src/libcoretest/result.rs
浏览文件 @
e2605b42
...
...
@@ -126,7 +126,7 @@ fn handler(msg: &'static str) -> int {
}
#[test]
#[should_
fail
]
#[should_
panic
]
pub
fn
test_unwrap_or_else_panic
()
{
fn
handler
(
msg
:
&
'static
str
)
->
int
{
if
msg
==
"I got this."
{
...
...
src/librand/distributions/exponential.rs
浏览文件 @
e2605b42
...
...
@@ -109,12 +109,12 @@ fn test_exp() {
}
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_exp_invalid_lambda_zero
()
{
Exp
::
new
(
0.0
);
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_exp_invalid_lambda_neg
()
{
Exp
::
new
(
-
10.0
);
}
...
...
src/librand/distributions/gamma.rs
浏览文件 @
e2605b42
...
...
@@ -356,7 +356,7 @@ fn test_chi_squared_large() {
}
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_chi_squared_invalid_dof
()
{
ChiSquared
::
new
(
-
1.0
);
}
...
...
src/librand/distributions/mod.rs
浏览文件 @
e2605b42
...
...
@@ -351,16 +351,16 @@ fn test_weighted_choice() {
[
50
,
51
,
52
,
53
,
54
,
55
,
56
]);
}
#[test]
#[should_
fail
]
#[test]
#[should_
panic
]
fn
test_weighted_choice_no_items
()
{
WeightedChoice
::
<
int
>
::
new
(
&
mut
[]);
}
#[test]
#[should_
fail
]
#[test]
#[should_
panic
]
fn
test_weighted_choice_zero_weight
()
{
WeightedChoice
::
new
(
&
mut
[
Weighted
{
weight
:
0
,
item
:
0
},
Weighted
{
weight
:
0
,
item
:
1
}]);
}
#[test]
#[should_
fail
]
#[test]
#[should_
panic
]
fn
test_weighted_choice_weight_overflows
()
{
let
x
=
(
-
1
)
as
uint
/
2
;
// x + x + 2 is the overflow
WeightedChoice
::
new
(
&
mut
[
Weighted
{
weight
:
x
,
item
:
0
},
...
...
src/librand/distributions/normal.rs
浏览文件 @
e2605b42
...
...
@@ -175,7 +175,7 @@ fn test_normal() {
}
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_normal_invalid_sd
()
{
Normal
::
new
(
10.0
,
-
1.0
);
}
...
...
@@ -191,7 +191,7 @@ fn test_log_normal() {
}
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_log_normal_invalid_sd
()
{
LogNormal
::
new
(
10.0
,
-
1.0
);
}
...
...
src/librand/distributions/range.rs
浏览文件 @
e2605b42
...
...
@@ -169,12 +169,12 @@ mod tests {
use
distributions
::{
Sample
,
IndependentSample
};
use
super
::
Range
as
Range
;
#[should_
fail
]
#[should_
panic
]
#[test]
fn
test_range_bad_limits_equal
()
{
Range
::
new
(
10
,
10
);
}
#[should_
fail
]
#[should_
panic
]
#[test]
fn
test_range_bad_limits_flipped
()
{
Range
::
new
(
10
,
5
);
...
...
src/librustc_back/sha2.rs
浏览文件 @
e2605b42
...
...
@@ -548,7 +548,7 @@ fn test_add_bytes_to_bits_ok() {
// A simple failure case - adding 1 to the max value
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_add_bytes_to_bits_overflow
()
{
super
::
add_bytes_to_bits
::
<
u64
>
(
Int
::
max_value
(),
1
);
}
...
...
src/librustdoc/test.rs
浏览文件 @
e2605b42
...
...
@@ -114,7 +114,7 @@ pub fn run(input: &str,
#[allow(deprecated)]
fn
runtest
(
test
:
&
str
,
cratename
:
&
str
,
libs
:
SearchPaths
,
externs
:
core
::
Externs
,
should_
fail
:
bool
,
no_run
:
bool
,
as_test_harness
:
bool
)
{
should_
panic
:
bool
,
no_run
:
bool
,
as_test_harness
:
bool
)
{
// the test harness wants its own `main` & top level functions, so
// never wrap the test in `fn main() { ... }`
let
test
=
maketest
(
test
,
Some
(
cratename
),
true
,
as_test_harness
);
...
...
@@ -210,9 +210,9 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
" - maybe your tempdir is mounted with noexec?"
}
else
{
""
}),
Ok
(
out
)
=>
{
if
should_
fail
&&
out
.status
.success
()
{
if
should_
panic
&&
out
.status
.success
()
{
panic!
(
"test executable succeeded when it should have failed"
);
}
else
if
!
should_
fail
&&
!
out
.status
.success
()
{
}
else
if
!
should_
panic
&&
!
out
.status
.success
()
{
panic!
(
"test executable failed:
\n
{:?}"
,
str
::
from_utf8
(
&
out
.stdout
));
}
...
...
@@ -279,7 +279,7 @@ pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs,
}
pub
fn
add_test
(
&
mut
self
,
test
:
String
,
should_
fail
:
bool
,
no_run
:
bool
,
should_ignore
:
bool
,
as_test_harness
:
bool
)
{
should_
panic
:
bool
,
no_run
:
bool
,
should_ignore
:
bool
,
as_test_harness
:
bool
)
{
let
name
=
if
self
.use_headers
{
let
s
=
self
.current_header
.as_ref
()
.map
(|
s
|
&**
s
)
.unwrap_or
(
""
);
format!
(
"{}_{}"
,
s
,
self
.cnt
)
...
...
@@ -295,14 +295,14 @@ pub fn add_test(&mut self, test: String,
desc
:
testing
::
TestDesc
{
name
:
testing
::
DynTestName
(
name
),
ignore
:
should_ignore
,
should_
fail
:
testing
::
ShouldFail
::
No
,
// compiler failures are test failures
should_
panic
:
testing
::
ShouldPanic
::
No
,
// compiler failures are test failures
},
testfn
:
testing
::
DynTestFn
(
Thunk
::
new
(
move
||
{
runtest
(
&
test
,
&
cratename
,
libs
,
externs
,
should_
fail
,
should_
panic
,
no_run
,
as_test_harness
);
}))
...
...
src/libstd/collections/hash/map.rs
浏览文件 @
e2605b42
...
...
@@ -2197,7 +2197,7 @@ fn test_index() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_index_nonexistent
()
{
let
mut
map
=
HashMap
::
new
();
...
...
src/libstd/old_io/buffered.rs
浏览文件 @
e2605b42
...
...
@@ -658,7 +658,7 @@ fn test_chars() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
dont_panic_in_drop_on_panicked_flush
()
{
struct
FailFlushWriter
;
...
...
src/libstd/old_io/extensions.rs
浏览文件 @
e2605b42
...
...
@@ -396,7 +396,7 @@ fn read_to_end() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
read_to_end_error
()
{
let
mut
reader
=
ThreeChunkReader
{
count
:
0
,
...
...
src/libstd/old_io/timer.rs
浏览文件 @
e2605b42
...
...
@@ -333,7 +333,7 @@ fn sleep() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
oneshot_fail
()
{
let
mut
timer
=
Timer
::
new
()
.unwrap
();
let
_
rx
=
timer
.oneshot
(
Duration
::
milliseconds
(
1
));
...
...
@@ -341,7 +341,7 @@ fn oneshot_fail() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
period_fail
()
{
let
mut
timer
=
Timer
::
new
()
.unwrap
();
let
_
rx
=
timer
.periodic
(
Duration
::
milliseconds
(
1
));
...
...
@@ -349,7 +349,7 @@ fn period_fail() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
normal_fail
()
{
let
_
timer
=
Timer
::
new
()
.unwrap
();
panic!
();
...
...
src/libstd/old_path/windows.rs
浏览文件 @
e2605b42
...
...
@@ -1324,7 +1324,7 @@ fn test_null_byte() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_not_utf8_panics
()
{
Path
::
new
(
b
"hello
\x80
.txt"
);
}
...
...
src/libstd/rand/mod.rs
浏览文件 @
e2605b42
...
...
@@ -500,14 +500,14 @@ fn test_gen_range() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_gen_range_panic_int
()
{
let
mut
r
=
thread_rng
();
r
.gen_range
(
5
,
-
2
);
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_gen_range_panic_uint
()
{
let
mut
r
=
thread_rng
();
r
.gen_range
(
5
,
2
);
...
...
src/libstd/rand/reader.rs
浏览文件 @
e2605b42
...
...
@@ -114,7 +114,7 @@ fn test_reader_rng_fill_bytes() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_reader_rng_insufficient_bytes
()
{
let
mut
rng
=
ReaderRng
::
new
(
MemReader
::
new
(
vec!
()));
let
mut
v
=
[
0
;
3
];
...
...
src/libstd/sync/condvar.rs
浏览文件 @
e2605b42
...
...
@@ -479,7 +479,7 @@ fn wait_timeout_with() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
two_mutexes
()
{
static
M1
:
StaticMutex
=
MUTEX_INIT
;
static
M2
:
StaticMutex
=
MUTEX_INIT
;
...
...
src/libstd/sync/future.rs
浏览文件 @
e2605b42
...
...
@@ -204,7 +204,7 @@ fn test_spawn() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_future_panic
()
{
let
mut
f
=
Future
::
spawn
(
move
||
panic!
());
let
_
x
:
String
=
f
.get
();
...
...
src/libstd/sync/task_pool.rs
浏览文件 @
e2605b42
...
...
@@ -164,7 +164,7 @@ fn test_works() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_zero_tasks_panic
()
{
TaskPool
::
new
(
0
);
}
...
...
src/libstd/sys/common/wtf8.rs
浏览文件 @
e2605b42
...
...
@@ -1030,14 +1030,14 @@ fn wtf8buf_truncate() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
wtf8buf_truncate_fail_code_point_boundary
()
{
let
mut
string
=
Wtf8Buf
::
from_str
(
"aé"
);
string
.truncate
(
2
);
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
wtf8buf_truncate_fail_longer
()
{
let
mut
string
=
Wtf8Buf
::
from_str
(
"aé"
);
string
.truncate
(
4
);
...
...
@@ -1133,7 +1133,7 @@ fn wtf8_slice() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
wtf8_slice_not_code_point_boundary
()
{
&
Wtf8
::
from_str
(
"aé 💩"
)[
2
..
4
];
}
...
...
@@ -1144,7 +1144,7 @@ fn wtf8_slice_from() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
wtf8_slice_from_not_code_point_boundary
()
{
&
Wtf8
::
from_str
(
"aé 💩"
)[
2
..
];
}
...
...
@@ -1155,7 +1155,7 @@ fn wtf8_slice_to() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
wtf8_slice_to_not_code_point_boundary
()
{
&
Wtf8
::
from_str
(
"aé 💩"
)[
5
..
];
}
...
...
src/libsyntax/codemap.rs
浏览文件 @
e2605b42
...
...
@@ -922,7 +922,7 @@ fn t1 () {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
t2
()
{
let
cm
=
CodeMap
::
new
();
let
fm
=
cm
.new_filemap
(
"blork.rs"
.to_string
(),
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
e2605b42
...
...
@@ -1656,7 +1656,7 @@ fn test_ecfg() -> ExpansionConfig<'static> {
}
// make sure that macros can't escape fns
#[should_
fail
]
#[should_
panic
]
#[test]
fn
macros_cant_escape_fns_test
()
{
let
src
=
"fn bogus() {macro_rules! z (() => (3+4));}
\
fn inty() -> i32 { z!() }"
.to_string
();
...
...
@@ -1670,7 +1670,7 @@ fn test_ecfg() -> ExpansionConfig<'static> {
}
// make sure that macros can't escape modules
#[should_
fail
]
#[should_
panic
]
#[test]
fn
macros_cant_escape_mods_test
()
{
let
src
=
"mod foo {macro_rules! z (() => (3+4));}
\
fn inty() -> i32 { z!() }"
.to_string
();
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
e2605b42
...
...
@@ -813,7 +813,7 @@ fn sp(a: u32, b: u32) -> Span {
}))
}
#[should_
fail
]
#[should_
panic
]
#[test]
fn
bad_path_expr_1
()
{
string_to_expr
(
"::abc::def::return"
.to_string
());
}
...
...
src/libsyntax/test.rs
浏览文件 @
e2605b42
...
...
@@ -37,7 +37,7 @@
use
ptr
::
P
;
use
util
::
small_vector
::
SmallVector
;
enum
Should
Fail
{
enum
Should
Panic
{
No
,
Yes
(
Option
<
InternedString
>
),
}
...
...
@@ -47,7 +47,7 @@ struct Test {
path
:
Vec
<
ast
::
Ident
>
,
bench
:
bool
,
ignore
:
bool
,
should_
fail
:
ShouldFail
should_
panic
:
ShouldPanic
}
struct
TestCtxt
<
'a
>
{
...
...
@@ -136,7 +136,7 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
path
:
self
.cx.path
.clone
(),
bench
:
is_bench_fn
(
&
self
.cx
,
&*
i
),
ignore
:
is_ignored
(
&*
i
),
should_
fail
:
should_fail
(
&*
i
)
should_
panic
:
should_panic
(
&*
i
,
self
.cx.span_diagnostic
)
};
self
.cx.testfns
.push
(
test
);
self
.tests
.push
(
i
.ident
);
...
...
@@ -378,15 +378,23 @@ fn is_ignored(i: &ast::Item) -> bool {
i
.attrs
.iter
()
.any
(|
attr
|
attr
.check_name
(
"ignore"
))
}
fn
should_fail
(
i
:
&
ast
::
Item
)
->
ShouldFail
{
match
i
.attrs
.iter
()
.find
(|
attr
|
attr
.check_name
(
"should_fail"
))
{
fn
should_panic
(
i
:
&
ast
::
Item
,
diag
:
&
diagnostic
::
SpanHandler
)
->
ShouldPanic
{
match
i
.attrs
.iter
()
.find
(|
attr
|
{
if
attr
.check_name
(
"should_panic"
)
{
return
true
;
}
if
attr
.check_name
(
"should_fail"
)
{
diag
.span_warn
(
attr
.span
,
"`#[should_fail]` is deprecated. Use `#[should_panic]`
\
instead"
);
return
true
;
}
false
})
{
Some
(
attr
)
=>
{
let
msg
=
attr
.meta_item_list
()
.and_then
(|
list
|
list
.iter
()
.find
(|
mi
|
mi
.check_name
(
"expected"
)))
.and_then
(|
mi
|
mi
.value_str
());
Should
Fail
::
Yes
(
msg
)
Should
Panic
::
Yes
(
msg
)
}
None
=>
Should
Fail
::
No
,
None
=>
Should
Panic
::
No
,
}
}
...
...
@@ -617,13 +625,13 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
vec!
[
name_expr
]);
let
ignore_expr
=
ecx
.expr_bool
(
span
,
test
.ignore
);
let
should_
fail
_path
=
|
name
|
{
ecx
.path
(
span
,
vec!
[
self_id
,
test_id
,
ecx
.ident_of
(
"Should
Fail
"
),
ecx
.ident_of
(
name
)])
let
should_
panic
_path
=
|
name
|
{
ecx
.path
(
span
,
vec!
[
self_id
,
test_id
,
ecx
.ident_of
(
"Should
Panic
"
),
ecx
.ident_of
(
name
)])
};
let
fail_expr
=
match
test
.should_
fail
{
Should
Fail
::
No
=>
ecx
.expr_path
(
should_fail
_path
(
"No"
)),
Should
Fail
::
Yes
(
ref
msg
)
=>
{
let
path
=
should_
fail
_path
(
"Yes"
);
let
fail_expr
=
match
test
.should_
panic
{
Should
Panic
::
No
=>
ecx
.expr_path
(
should_panic
_path
(
"No"
)),
Should
Panic
::
Yes
(
ref
msg
)
=>
{
let
path
=
should_
panic
_path
(
"Yes"
);
let
arg
=
match
*
msg
{
Some
(
ref
msg
)
=>
ecx
.expr_some
(
span
,
ecx
.expr_str
(
span
,
msg
.clone
())),
None
=>
ecx
.expr_none
(
span
),
...
...
@@ -638,7 +646,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
test_path
(
"TestDesc"
),
vec!
[
field
(
"name"
,
name_expr
),
field
(
"ignore"
,
ignore_expr
),
field
(
"should_
fail
"
,
fail_expr
)]);
field
(
"should_
panic
"
,
fail_expr
)]);
let
mut
visible_path
=
match
cx
.toplevel_reexport
{
...
...
src/libsyntax/util/interner.rs
浏览文件 @
e2605b42
...
...
@@ -234,7 +234,7 @@ mod tests {
use
ast
::
Name
;
#[test]
#[should_
fail
]
#[should_
panic
]
fn
i1
()
{
let
i
:
Interner
<
RcStr
>
=
Interner
::
new
();
i
.get
(
Name
(
13
));
...
...
src/libsyntax/util/small_vector.rs
浏览文件 @
e2605b42
...
...
@@ -236,13 +236,13 @@ fn test_move_iter() {
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_expect_one_zero
()
{
let
_
:
isize
=
SmallVector
::
zero
()
.expect_one
(
""
);
}
#[test]
#[should_
fail
]
#[should_
panic
]
fn
test_expect_one_many
()
{
SmallVector
::
many
(
vec!
(
1
,
2
))
.expect_one
(
""
);
}
...
...
src/libtest/lib.rs
浏览文件 @
e2605b42
...
...
@@ -90,7 +90,7 @@ pub mod test {
Metric
,
MetricMap
,
StaticTestFn
,
StaticTestName
,
DynTestName
,
DynTestFn
,
run_test
,
test_main
,
test_main_static
,
filter_tests
,
parse_opts
,
StaticBenchFn
,
Should
Fail
};
parse_opts
,
StaticBenchFn
,
Should
Panic
};
}
pub
mod
stats
;
...
...
@@ -202,7 +202,7 @@ pub struct Bencher {
}
#[derive(Copy,
Clone,
Debug,
PartialEq,
Eq,
Hash)]
pub
enum
Should
Fail
{
pub
enum
Should
Panic
{
No
,
Yes
(
Option
<&
'static
str
>
)
}
...
...
@@ -213,7 +213,7 @@ pub enum ShouldFail {
pub
struct
TestDesc
{
pub
name
:
TestName
,
pub
ignore
:
bool
,
pub
should_
fail
:
ShouldFail
,
pub
should_
panic
:
ShouldPanic
,
}
unsafe
impl
Send
for
TestDesc
{}
...
...
@@ -351,10 +351,10 @@ fn usage(binary: &str) {
takes no arguments.
#[bench] - Indicates a function is a benchmark to be run. This
function takes one argument (test::Bencher).
#[should_
fail
] - This function (also labeled with #[test]) will only pass if
the code causes a
failure
(an assertion failure or panic!)
#[should_
panic
] - This function (also labeled with #[test]) will only pass if
the code causes a
panic
(an assertion failure or panic!)
A message may be provided, which the failure string must
contain: #[should_
fail
(expected = "foo")].
contain: #[should_
panic
(expected = "foo")].
#[ignore] - When applied to a function which is already attributed as a
test, then the test runner will ignore these tests during
normal test runs. Running with --ignored will run these
...
...
@@ -717,13 +717,13 @@ fn should_sort_failures_before_printing_them() {
let
test_a
=
TestDesc
{
name
:
StaticTestName
(
"a"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
No
should_
panic
:
ShouldPanic
::
No
};
let
test_b
=
TestDesc
{
name
:
StaticTestName
(
"b"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
No
should_
panic
:
ShouldPanic
::
No
};
let
mut
st
=
ConsoleTestState
{
...
...
@@ -953,10 +953,10 @@ fn run_test_inner(desc: TestDesc,
}
fn
calc_result
(
desc
:
&
TestDesc
,
task_result
:
Result
<
(),
Box
<
Any
+
Send
>>
)
->
TestResult
{
match
(
&
desc
.should_
fail
,
task_result
)
{
(
&
Should
Fail
::
No
,
Ok
(()))
|
(
&
Should
Fail
::
Yes
(
None
),
Err
(
_
))
=>
TrOk
,
(
&
Should
Fail
::
Yes
(
Some
(
msg
)),
Err
(
ref
err
))
match
(
&
desc
.should_
panic
,
task_result
)
{
(
&
Should
Panic
::
No
,
Ok
(()))
|
(
&
Should
Panic
::
Yes
(
None
),
Err
(
_
))
=>
TrOk
,
(
&
Should
Panic
::
Yes
(
Some
(
msg
)),
Err
(
ref
err
))
if
err
.downcast_ref
::
<
String
>
()
.map
(|
e
|
&**
e
)
.or_else
(||
err
.downcast_ref
::
<&
'static
str
>
()
.map
(|
e
|
*
e
))
...
...
@@ -1151,7 +1151,7 @@ mod tests {
use
test
::{
TrFailed
,
TrIgnored
,
TrOk
,
filter_tests
,
parse_opts
,
TestDesc
,
TestDescAndFn
,
TestOpts
,
run_test
,
MetricMap
,
StaticTestName
,
DynTestName
,
DynTestFn
,
Should
Fail
};
StaticTestName
,
DynTestName
,
DynTestFn
,
Should
Panic
};
use
std
::
thunk
::
Thunk
;
use
std
::
sync
::
mpsc
::
channel
;
...
...
@@ -1162,7 +1162,7 @@ pub fn do_not_run_ignored_tests() {
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
true
,
should_
fail
:
ShouldFail
::
No
,
should_
panic
:
ShouldPanic
::
No
,
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1179,7 +1179,7 @@ fn f() { }
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
true
,
should_
fail
:
ShouldFail
::
No
,
should_
panic
:
ShouldPanic
::
No
,
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1190,13 +1190,13 @@ fn f() { }
}
#[test]
fn
test_should_
fail
()
{
fn
test_should_
panic
()
{
fn
f
()
{
panic!
();
}
let
desc
=
TestDescAndFn
{
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
Yes
(
None
)
should_
panic
:
ShouldPanic
::
Yes
(
None
)
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1207,13 +1207,13 @@ fn test_should_fail() {
}
#[test]
fn
test_should_
fail
_good_message
()
{
fn
test_should_
panic
_good_message
()
{
fn
f
()
{
panic!
(
"an error message"
);
}
let
desc
=
TestDescAndFn
{
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
Yes
(
Some
(
"error message"
))
should_
panic
:
ShouldPanic
::
Yes
(
Some
(
"error message"
))
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1224,13 +1224,13 @@ fn test_should_fail_good_message() {
}
#[test]
fn
test_should_
fail
_bad_message
()
{
fn
test_should_
panic
_bad_message
()
{
fn
f
()
{
panic!
(
"an error message"
);
}
let
desc
=
TestDescAndFn
{
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
Yes
(
Some
(
"foobar"
))
should_
panic
:
ShouldPanic
::
Yes
(
Some
(
"foobar"
))
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1241,13 +1241,13 @@ fn test_should_fail_bad_message() {
}
#[test]
fn
test_should_
fail
_but_succeeds
()
{
fn
test_should_
panic
_but_succeeds
()
{
fn
f
()
{
}
let
desc
=
TestDescAndFn
{
desc
:
TestDesc
{
name
:
StaticTestName
(
"whatever"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
Yes
(
None
)
should_
panic
:
ShouldPanic
::
Yes
(
None
)
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
f
())),
};
...
...
@@ -1283,7 +1283,7 @@ pub fn filter_for_ignored_option() {
desc
:
TestDesc
{
name
:
StaticTestName
(
"1"
),
ignore
:
true
,
should_
fail
:
ShouldFail
::
No
,
should_
panic
:
ShouldPanic
::
No
,
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
{})),
},
...
...
@@ -1291,7 +1291,7 @@ pub fn filter_for_ignored_option() {
desc
:
TestDesc
{
name
:
StaticTestName
(
"2"
),
ignore
:
false
,
should_
fail
:
ShouldFail
::
No
,
should_
panic
:
ShouldPanic
::
No
,
},
testfn
:
DynTestFn
(
Thunk
::
new
(
move
||
{})),
});
...
...
@@ -1327,7 +1327,7 @@ fn testfn() { }
desc
:
TestDesc
{
name
:
DynTestName
((
*
name
)
.clone
()),
ignore
:
false
,
should_
fail
:
ShouldFail
::
No
,
should_
panic
:
ShouldPanic
::
No
,
},
testfn
:
DynTestFn
(
Thunk
::
new
(
testfn
)),
};
...
...
src/test/run-fail/test-should-fail-bad-message.rs
浏览文件 @
e2605b42
...
...
@@ -14,7 +14,7 @@
// ignore-pretty: does not work well with `--test`
#[test]
#[should_
fail
(expected
=
"foobar"
)]
#[should_
panic
(expected
=
"foobar"
)]
fn
test_foo
()
{
panic!
(
"blah"
)
}
src/test/run-pass/test-should-fail-good-message.rs
浏览文件 @
e2605b42
...
...
@@ -12,13 +12,13 @@
// ignore-pretty: does not work well with `--test`
#[test]
#[should_
fail
(expected
=
"foo"
)]
#[should_
panic
(expected
=
"foo"
)]
fn
test_foo
()
{
panic!
(
"foo bar"
)
}
#[test]
#[should_
fail
(expected
=
"foo"
)]
#[should_
panic
(expected
=
"foo"
)]
fn
test_foo_dynamic
()
{
panic!
(
"{} bar"
,
"foo"
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录