Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
491ed7f1
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,发现更多精彩内容 >>
提交
491ed7f1
编写于
8月 04, 2011
作者:
E
Erick Tryzelaar
提交者:
Brian Anderson
8月 09, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Port the fuzzer and tests to ivec type [T] syntax.
上级
8b150452
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
36 addition
and
44 deletion
+36
-44
src/fuzzer/ast_match.rs
src/fuzzer/ast_match.rs
+2
-2
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+6
-6
src/fuzzer/ivec_fuzz.rs
src/fuzzer/ivec_fuzz.rs
+15
-15
src/test/pretty/ivec-type.pp
src/test/pretty/ivec-type.pp
+0
-4
src/test/pretty/ivec-type.rs
src/test/pretty/ivec-type.rs
+1
-5
src/test/run-pass/alloca-from-derived-tydesc.rs
src/test/run-pass/alloca-from-derived-tydesc.rs
+1
-1
src/test/run-pass/ivec-tag.rs
src/test/run-pass/ivec-tag.rs
+3
-3
src/test/stdtest/either.rs
src/test/stdtest/either.rs
+8
-8
未找到文件。
src/fuzzer/ast_match.rs
浏览文件 @
491ed7f1
use
std
;
import
std
::
ivec
;
fn
ivec_equal
[
T
](
v
:
&
T
[],
u
:
&
T
[
],
element_equality_test
:
fn
(
&
T
,
&
T
)
->
bool
)
fn
ivec_equal
[
T
](
v
:
&
[
T
],
u
:
&
[
T
],
element_equality_test
:
fn
(
&
T
,
&
T
)
->
bool
)
->
bool
{
let
Lv
=
ivec
::
len
(
v
);
if
Lv
!=
ivec
::
len
(
u
)
{
ret
false
;
}
...
...
@@ -24,4 +24,4 @@ fn main() {
assert
(
ivec_equal
(
~
[
5
,
5
],
~
[
5
,
5
],
builtin_equal
));
log_err
"Pass"
;
}
\ No newline at end of file
}
src/fuzzer/fuzzer.rs
浏览文件 @
491ed7f1
...
...
@@ -38,7 +38,7 @@ fn contains(haystack: &str, needle: &str) -> bool {
str
::
find
(
haystack
,
needle
)
!=
-
1
}
fn
find_rust_files
(
files
:
&
mutable
str
[
],
path
:
str
)
{
fn
find_rust_files
(
files
:
&
mutable
[
str
],
path
:
str
)
{
if
str
::
ends_with
(
path
,
".rs"
)
{
if
file_contains
(
path
,
"xfail-stage1"
)
{
//log_err "Skipping " + path + " because it is marked as xfail-stage1";
...
...
@@ -89,10 +89,10 @@ fn safe_to_steal(e: ast::expr_) -> bool {
}
}
fn
steal_exprs
(
crate
:
&
ast
::
crate
)
->
ast
::
expr
[
]
{
let
exprs
:
@
mutable
ast
::
expr
[
]
=
@
mutable
~
[];
fn
steal_exprs
(
crate
:
&
ast
::
crate
)
->
[
ast
::
expr
]
{
let
exprs
:
@
mutable
[
ast
::
expr
]
=
@
mutable
~
[];
// "Stash" is not type-parameterized because of the need for safe_to_steal
fn
stash_expr
(
es
:
@
mutable
ast
::
expr
[
],
e
:
&@
ast
::
expr
)
{
fn
stash_expr
(
es
:
@
mutable
[
ast
::
expr
],
e
:
&@
ast
::
expr
)
{
if
safe_to_steal
(
e
.node
)
{
*
es
+=
~
[
*
e
];
}
else
{
/* now my indices are wrong :( */
}
...
...
@@ -316,7 +316,7 @@ fn check_roundtrip_convergence(code: &str, maxIters: uint) {
}
}
fn
check_convergence
(
files
:
&
str
[
])
{
fn
check_convergence
(
files
:
&
[
str
])
{
log_err
#
fmt
(
"pp convergence tests: %u files"
,
ivec
::
len
(
files
));
for
file
in
files
{
if
!
file_is_confusing
(
file
)
{
...
...
@@ -330,7 +330,7 @@ fn check_convergence(files: &str[]) {
}
}
fn
check_variants
(
files
:
&
str
[
])
{
fn
check_variants
(
files
:
&
[
str
])
{
for
file
in
files
{
if
!
file_is_confusing
(
file
)
{
let
s
=
ioivec
::
read_whole_file_str
(
file
);
...
...
src/fuzzer/ivec_fuzz.rs
浏览文件 @
491ed7f1
...
...
@@ -7,8 +7,8 @@
two functions, "return the number of possible edits" and "return edit #n"
It would be nice if this could be data-driven, so the two functions could share information:
type vec_modifier = rec(fn (&
T[] v, uint i) -> T[
] fun, uint lo, uint di);
const
vec_modifier[
] vec_modifiers = ~[rec(fun=vec_omit, 0u, 1u), ...];
type vec_modifier = rec(fn (&
[T] v, uint i) -> [T
] fun, uint lo, uint di);
const
[vec_modifier
] vec_modifiers = ~[rec(fun=vec_omit, 0u, 1u), ...];
But that gives me "error: internal compiler error unimplemented consts that's not a plain literal".
https://github.com/graydon/rust/issues/570
...
...
@@ -26,24 +26,24 @@
import
std
::
ivec
::
len
;
import
std
::
int
;
//fn vec_reverse(&
T[] v) -> T[
] { ... }
//fn vec_reverse(&
[T] v) -> [T
] { ... }
fn
vec_omit
[
T
](
v
:
&
T
[],
i
:
uint
)
->
T
[
]
{
fn
vec_omit
[
T
](
v
:
&
[
T
],
i
:
uint
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
+
slice
(
v
,
i
+
1u
,
len
(
v
))
}
fn
vec_dup
[
T
](
v
:
&
T
[],
i
:
uint
)
->
T
[
]
{
fn
vec_dup
[
T
](
v
:
&
[
T
],
i
:
uint
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
+
~
[
v
.
(
i
)]
+
slice
(
v
,
i
,
len
(
v
))
}
fn
vec_swadj
[
T
](
v
:
&
T
[],
i
:
uint
)
->
T
[
]
{
fn
vec_swadj
[
T
](
v
:
&
[
T
],
i
:
uint
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
+
~
[
v
.
(
i
+
1u
),
v
.
(
i
)]
+
slice
(
v
,
i
+
2u
,
len
(
v
))
}
fn
vec_prefix
[
T
](
v
:
&
T
[],
i
:
uint
)
->
T
[
]
{
slice
(
v
,
0u
,
i
)
}
fn
vec_suffix
[
T
](
v
:
&
T
[],
i
:
uint
)
->
T
[
]
{
slice
(
v
,
i
,
len
(
v
))
}
fn
vec_prefix
[
T
](
v
:
&
[
T
],
i
:
uint
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
}
fn
vec_suffix
[
T
](
v
:
&
[
T
],
i
:
uint
)
->
[
T
]
{
slice
(
v
,
i
,
len
(
v
))
}
fn
vec_poke
[
T
](
v
:
&
T
[],
i
:
uint
,
x
:
&
T
)
->
T
[
]
{
fn
vec_poke
[
T
](
v
:
&
[
T
],
i
:
uint
,
x
:
&
T
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
+
~
[
x
]
+
slice
(
v
,
i
+
1u
,
len
(
v
))
}
fn
vec_insert
[
T
](
v
:
&
T
[],
i
:
uint
,
x
:
&
T
)
->
T
[
]
{
fn
vec_insert
[
T
](
v
:
&
[
T
],
i
:
uint
,
x
:
&
T
)
->
[
T
]
{
slice
(
v
,
0u
,
i
)
+
~
[
x
]
+
slice
(
v
,
i
,
len
(
v
))
}
...
...
@@ -54,8 +54,8 @@ fn vec_insert[T](v: &T[], i: uint, x: &T) -> T[] {
}
// Returns a bunch of modified versions of v, some of which introduce new elements (borrowed from xs).
fn
vec_edits
[
T
](
v
:
&
T
[],
xs
:
&
T
[])
->
T
[][
]
{
let
edits
:
T
[][
]
=
~
[];
fn
vec_edits
[
T
](
v
:
&
[
T
],
xs
:
&
[
T
])
->
[[
T
]
]
{
let
edits
:
[[
T
]
]
=
~
[];
let
Lv
:
uint
=
len
(
v
);
if
Lv
!=
1u
{
...
...
@@ -85,7 +85,7 @@ fn vec_edits[T](v: &T[], xs: &T[]) -> T[][] {
}
// Would be nice if this were built in: https://github.com/graydon/rust/issues/424
fn
vec_to_str
(
v
:
&
int
[
])
->
str
{
fn
vec_to_str
(
v
:
&
[
int
])
->
str
{
let
i
=
0u
;
let
s
=
"["
;
while
i
<
len
(
v
)
{
...
...
@@ -96,7 +96,7 @@ fn vec_to_str(v: &int[]) -> str {
ret
s
+
"]"
;
}
fn
show_edits
(
a
:
&
int
[],
xs
:
&
int
[
])
{
fn
show_edits
(
a
:
&
[
int
],
xs
:
&
[
int
])
{
log_err
"=== Edits of "
+
vec_to_str
(
a
)
+
" ==="
;
let
b
=
vec_edits
(
a
,
xs
);
for
each
i
:
uint
in
ix
(
0u
,
1u
,
len
(
b
))
{
log_err
vec_to_str
(
b
.
(
i
));
}
...
...
@@ -111,4 +111,4 @@ fn demo_edits() {
show_edits
(
~
[
1
,
2
,
3
,
4
],
xs
);
}
fn
main
()
{
demo_edits
();
}
\ No newline at end of file
fn
main
()
{
demo_edits
();
}
src/test/pretty/ivec-type.pp
浏览文件 @
491ed7f1
...
...
@@ -3,7 +3,3 @@
fn
f1
(
x
:
[
int
])
{
}
fn
g1
()
{
f1
(
~
[
1
,
2
,
3
]);
}
fn
f2
(
x
:
[
int
])
{
}
fn
g2
()
{
f2
(
~
[
1
,
2
,
3
]);
}
src/test/pretty/ivec-type.rs
浏览文件 @
491ed7f1
// pp-exact:ivec-type.pp
fn
f1
(
x
:
int
[
])
{
}
fn
f1
(
x
:
[
int
])
{
}
fn
g1
()
{
f1
(
~
[
1
,
2
,
3
]);
}
fn
f2
(
x
:
[
int
])
{
}
fn
g2
()
{
f2
(
~
[
1
,
2
,
3
]);
}
src/test/run-pass/alloca-from-derived-tydesc.rs
浏览文件 @
491ed7f1
tag
option
[
T
]
{
some
(
T
);
none
;
}
type
r
[
T
]
=
{
mutable
v
:
(
option
[
T
])[
]};
type
r
[
T
]
=
{
mutable
v
:
[
option
[
T
]
]};
fn
f
[
T
]()
->
[
T
]
{
ret
~
[];
}
...
...
src/test/run-pass/ivec-tag.rs
浏览文件 @
491ed7f1
use
std
;
fn
producer
(
c
:
chan
[
u8
[
]])
{
fn
producer
(
c
:
chan
[
[
u8
]])
{
c
<
|
~
[
1u8
,
2u8
,
3u8
,
4u8
,
5u8
,
6u8
,
7u8
,
8u8
,
9u8
,
10u8
,
11u8
,
12u8
,
13u8
];
}
fn
main
()
{
let
p
:
port
[
u8
[
]]
=
port
();
let
p
:
port
[
[
u8
]]
=
port
();
let
prod
:
task
=
spawn
producer
(
chan
(
p
));
let
data
:
u8
[
];
let
data
:
[
u8
];
p
|
>
data
;
}
src/test/stdtest/either.rs
浏览文件 @
491ed7f1
...
...
@@ -27,14 +27,14 @@ fn test_lefts() {
#[test]
fn
test_lefts_none
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[
right
(
10
),
right
(
10
)];
let
input
:
[
t
[
int
,
int
]
]
=
~
[
right
(
10
),
right
(
10
)];
let
result
=
lefts
(
input
);
assert
(
len
(
result
)
==
0u
);
}
#[test]
fn
test_lefts_empty
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[];
let
input
:
[
t
[
int
,
int
]
]
=
~
[];
let
result
=
lefts
(
input
);
assert
(
len
(
result
)
==
0u
);
}
...
...
@@ -48,14 +48,14 @@ fn test_rights() {
#[test]
fn
test_rights_none
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[
left
(
10
),
left
(
10
)];
let
input
:
[
t
[
int
,
int
]
]
=
~
[
left
(
10
),
left
(
10
)];
let
result
=
rights
(
input
);
assert
(
len
(
result
)
==
0u
);
}
#[test]
fn
test_rights_empty
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[];
let
input
:
[
t
[
int
,
int
]
]
=
~
[];
let
result
=
rights
(
input
);
assert
(
len
(
result
)
==
0u
);
}
...
...
@@ -73,7 +73,7 @@ fn test_partition() {
#[test]
fn
test_partition_no_lefts
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[
right
(
10
),
right
(
11
)];
let
input
:
[
t
[
int
,
int
]
]
=
~
[
right
(
10
),
right
(
11
)];
let
result
=
partition
(
input
);
assert
(
len
(
result
.lefts
)
==
0u
);
assert
(
len
(
result
.rights
)
==
2u
);
...
...
@@ -81,7 +81,7 @@ fn test_partition_no_lefts() {
#[test]
fn
test_partition_no_rights
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[
left
(
10
),
left
(
11
)];
let
input
:
[
t
[
int
,
int
]
]
=
~
[
left
(
10
),
left
(
11
)];
let
result
=
partition
(
input
);
assert
(
len
(
result
.lefts
)
==
2u
);
assert
(
len
(
result
.rights
)
==
0u
);
...
...
@@ -89,8 +89,8 @@ fn test_partition_no_rights() {
#[test]
fn
test_partition_empty
()
{
let
input
:
(
t
[
int
,
int
])[
]
=
~
[];
let
input
:
[
t
[
int
,
int
]
]
=
~
[];
let
result
=
partition
(
input
);
assert
(
len
(
result
.lefts
)
==
0u
);
assert
(
len
(
result
.rights
)
==
0u
);
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录