Skip to content

Commit a618d0d

Browse files
committed
std: Convert test to camel case
1 parent 9c988eb commit a618d0d

File tree

4 files changed

+70
-71
lines changed

4 files changed

+70
-71
lines changed

src/compiletest/compiletest.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn run_tests(config: config) {
122122
if !res { fail ~"Some tests failed"; }
123123
}
124124

125-
fn test_opts(config: config) -> test::test_opts {
125+
fn test_opts(config: config) -> test::TestOpts {
126126
{filter:
127127
match config.filter {
128128
option::Some(s) => option::Some(s),
@@ -137,7 +137,7 @@ fn test_opts(config: config) -> test::test_opts {
137137
}
138138
}
139139

140-
fn make_tests(config: config) -> ~[test::test_desc] {
140+
fn make_tests(config: config) -> ~[test::TestDesc] {
141141
debug!("making tests from %s",
142142
config.src_base.to_str());
143143
let mut tests = ~[];
@@ -175,7 +175,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
175175
}
176176

177177
fn make_test(config: config, testfile: &Path) ->
178-
test::test_desc {
178+
test::TestDesc {
179179
{
180180
name: make_test_name(config, testfile),
181181
fn: make_test_closure(config, testfile),
@@ -188,7 +188,7 @@ fn make_test_name(config: config, testfile: &Path) -> ~str {
188188
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
189189
}
190190

191-
fn make_test_closure(config: config, testfile: &Path) -> test::test_fn {
191+
fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
192192
let testfile = testfile.to_str();
193193
fn~() { runtest::run(config, testfile) }
194194
}

src/libstd/std.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ mod unicode;
9292

9393
// Compiler support modules
9494

95-
#[allow(non_camel_case_types)] // XXX
9695
mod test;
9796
#[allow(non_camel_case_types)] // XXX
9897
mod serialization;

src/libstd/test.rs

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use libc::size_t;
1313
use task::TaskBuilder;
1414
use comm = core::comm;
1515

16-
export test_name;
17-
export test_fn;
18-
export test_desc;
16+
export TestName;
17+
export TestFn;
18+
export TestDesc;
1919
export test_main;
20-
export test_result;
21-
export test_opts;
22-
export tr_ok;
23-
export tr_failed;
24-
export tr_ignored;
20+
export TestResult;
21+
export TestOpts;
22+
export TrOk;
23+
export TrFailed;
24+
export TrIgnored;
2525
export run_tests_console;
2626

2727
#[abi = "cdecl"]
@@ -33,26 +33,26 @@ extern mod rustrt {
3333
// paths; i.e. it should be a series of identifiers seperated by double
3434
// colons. This way if some test runner wants to arrange the tests
3535
// hierarchically it may.
36-
type test_name = ~str;
36+
type TestName = ~str;
3737

3838
// A function that runs a test. If the function returns successfully,
3939
// the test succeeds; if the function fails then the test fails. We
4040
// may need to come up with a more clever definition of test in order
4141
// to support isolation of tests into tasks.
42-
type test_fn = fn~();
42+
type TestFn = fn~();
4343

4444
// The definition of a single test. A test runner will run a list of
4545
// these.
46-
type test_desc = {
47-
name: test_name,
48-
fn: test_fn,
46+
type TestDesc = {
47+
name: TestName,
48+
fn: TestFn,
4949
ignore: bool,
5050
should_fail: bool
5151
};
5252

5353
// The default console test runner. It accepts the command line
5454
// arguments and a vector of test_descs (generated at compile time).
55-
fn test_main(args: ~[~str], tests: ~[test_desc]) {
55+
fn test_main(args: ~[~str], tests: ~[TestDesc]) {
5656
let opts =
5757
match parse_opts(args) {
5858
either::Left(o) => o,
@@ -61,13 +61,13 @@ fn test_main(args: ~[~str], tests: ~[test_desc]) {
6161
if !run_tests_console(opts, tests) { fail ~"Some tests failed"; }
6262
}
6363

64-
type test_opts = {filter: Option<~str>, run_ignored: bool,
64+
type TestOpts = {filter: Option<~str>, run_ignored: bool,
6565
logfile: Option<~str>};
6666

67-
type opt_res = Either<test_opts, ~str>;
67+
type OptRes = Either<TestOpts, ~str>;
6868

6969
// Parses command line arguments into test options
70-
fn parse_opts(args: ~[~str]) -> opt_res {
70+
fn parse_opts(args: ~[~str]) -> OptRes {
7171
let args_ = vec::tail(args);
7272
let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")];
7373
let matches =
@@ -90,55 +90,55 @@ fn parse_opts(args: ~[~str]) -> opt_res {
9090
return either::Left(test_opts);
9191
}
9292

93-
enum test_result { tr_ok, tr_failed, tr_ignored, }
93+
enum TestResult { TrOk, TrFailed, TrIgnored, }
9494

95-
impl test_result : Eq {
96-
pure fn eq(&&other: test_result) -> bool {
95+
impl TestResult : Eq {
96+
pure fn eq(&&other: TestResult) -> bool {
9797
(self as uint) == (other as uint)
9898
}
9999
}
100100

101-
type console_test_state =
101+
type ConsoleTestState =
102102
@{out: io::Writer,
103103
log_out: Option<io::Writer>,
104104
use_color: bool,
105105
mut total: uint,
106106
mut passed: uint,
107107
mut failed: uint,
108108
mut ignored: uint,
109-
mut failures: ~[test_desc]};
109+
mut failures: ~[TestDesc]};
110110

111111
// A simple console test runner
112-
fn run_tests_console(opts: test_opts,
113-
tests: ~[test_desc]) -> bool {
112+
fn run_tests_console(opts: TestOpts,
113+
tests: ~[TestDesc]) -> bool {
114114

115-
fn callback(event: testevent, st: console_test_state) {
115+
fn callback(event: TestEvent, st: ConsoleTestState) {
116116
debug!("callback(event=%?)", event);
117117
match event {
118-
te_filtered(filtered_tests) => {
118+
TeFiltered(filtered_tests) => {
119119
st.total = vec::len(filtered_tests);
120120
let noun = if st.total != 1u { ~"tests" } else { ~"test" };
121121
st.out.write_line(fmt!("\nrunning %u %s", st.total, noun));
122122
}
123-
te_wait(test) => st.out.write_str(fmt!("test %s ... ", test.name)),
124-
te_result(test, result) => {
123+
TeWait(test) => st.out.write_str(fmt!("test %s ... ", test.name)),
124+
TeResult(test, result) => {
125125
match st.log_out {
126126
Some(f) => write_log(f, result, test),
127127
None => ()
128128
}
129129
match result {
130-
tr_ok => {
130+
TrOk => {
131131
st.passed += 1u;
132132
write_ok(st.out, st.use_color);
133133
st.out.write_line(~"");
134134
}
135-
tr_failed => {
135+
TrFailed => {
136136
st.failed += 1u;
137137
write_failed(st.out, st.use_color);
138138
st.out.write_line(~"");
139139
vec::push(st.failures, copy test);
140140
}
141-
tr_ignored => {
141+
TrIgnored => {
142142
st.ignored += 1u;
143143
write_ignored(st.out, st.use_color);
144144
st.out.write_line(~"");
@@ -188,12 +188,12 @@ fn run_tests_console(opts: test_opts,
188188

189189
return success;
190190

191-
fn write_log(out: io::Writer, result: test_result, test: test_desc) {
191+
fn write_log(out: io::Writer, result: TestResult, test: TestDesc) {
192192
out.write_line(fmt!("%s %s",
193193
match result {
194-
tr_ok => ~"ok",
195-
tr_failed => ~"failed",
196-
tr_ignored => ~"ignored"
194+
TrOk => ~"ok",
195+
TrFailed => ~"failed",
196+
TrIgnored => ~"ignored"
197197
}, test.name));
198198
}
199199
@@ -220,7 +220,7 @@ fn run_tests_console(opts: test_opts,
220220
}
221221
}
222222
223-
fn print_failures(st: console_test_state) {
223+
fn print_failures(st: ConsoleTestState) {
224224
st.out.write_line(~"\nfailures:");
225225
let failures = copy st.failures;
226226
let failures = vec::map(failures, |test| test.name);
@@ -270,19 +270,19 @@ fn should_sort_failures_before_printing_them() {
270270
271271
fn use_color() -> bool { return get_concurrency() == 1u; }
272272
273-
enum testevent {
274-
te_filtered(~[test_desc]),
275-
te_wait(test_desc),
276-
te_result(test_desc, test_result),
273+
enum TestEvent {
274+
TeFiltered(~[TestDesc]),
275+
TeWait(TestDesc),
276+
TeResult(TestDesc, TestResult),
277277
}
278278
279-
type monitor_msg = (test_desc, test_result);
279+
type MonitorMsg = (TestDesc, TestResult);
280280
281-
fn run_tests(opts: test_opts, tests: ~[test_desc],
282-
callback: fn@(testevent)) {
281+
fn run_tests(opts: TestOpts, tests: ~[TestDesc],
282+
callback: fn@(TestEvent)) {
283283
284284
let mut filtered_tests = filter_tests(opts, tests);
285-
callback(te_filtered(copy filtered_tests));
285+
callback(TeFiltered(copy filtered_tests));
286286
287287
// It's tempting to just spawn all the tests at once, but since we have
288288
// many tests that run in other processes we would be making a big mess.
@@ -304,7 +304,7 @@ fn run_tests(opts: test_opts, tests: ~[test_desc],
304304
// We are doing one test at a time so we can print the name
305305
// of the test before we run it. Useful for debugging tests
306306
// that hang forever.
307-
callback(te_wait(copy test));
307+
callback(TeWait(copy test));
308308
}
309309
run_test(test, ch);
310310
wait_idx += 1u;
@@ -313,9 +313,9 @@ fn run_tests(opts: test_opts, tests: ~[test_desc],
313313
314314
let (test, result) = core::comm::recv(p);
315315
if concurrency != 1u {
316-
callback(te_wait(copy test));
316+
callback(TeWait(copy test));
317317
}
318-
callback(te_result(test, result));
318+
callback(TeResult(test, result));
319319
wait_idx -= 1u;
320320
done_idx += 1u;
321321
}
@@ -335,8 +335,8 @@ fn get_concurrency() -> uint {
335335
}
336336
337337
#[allow(non_implicitly_copyable_typarams)]
338-
fn filter_tests(opts: test_opts,
339-
tests: ~[test_desc]) -> ~[test_desc] {
338+
fn filter_tests(opts: TestOpts,
339+
tests: ~[TestDesc]) -> ~[TestDesc] {
340340
let mut filtered = copy tests;
341341
342342
// Remove tests that don't match the test filter
@@ -349,8 +349,8 @@ fn filter_tests(opts: test_opts,
349349
option::None => ~""
350350
};
351351
352-
fn filter_fn(test: test_desc, filter_str: ~str) ->
353-
Option<test_desc> {
352+
fn filter_fn(test: TestDesc, filter_str: ~str) ->
353+
Option<TestDesc> {
354354
if str::contains(test.name, filter_str) {
355355
return option::Some(copy test);
356356
} else { return option::None; }
@@ -363,7 +363,7 @@ fn filter_tests(opts: test_opts,
363363
filtered = if !opts.run_ignored {
364364
filtered
365365
} else {
366-
fn filter(test: test_desc) -> Option<test_desc> {
366+
fn filter(test: TestDesc) -> Option<TestDesc> {
367367
if test.ignore {
368368
return option::Some({name: test.name,
369369
fn: copy test.fn,
@@ -377,7 +377,7 @@ fn filter_tests(opts: test_opts,
377377
378378
// Sort the tests alphabetically
379379
filtered = {
380-
pure fn lteq(t1: &test_desc, t2: &test_desc) -> bool {
380+
pure fn lteq(t1: &TestDesc, t2: &TestDesc) -> bool {
381381
str::le(t1.name, t2.name)
382382
}
383383
sort::merge_sort(lteq, filtered)
@@ -386,11 +386,11 @@ fn filter_tests(opts: test_opts,
386386
return filtered;
387387
}
388388
389-
type test_future = {test: test_desc, wait: fn@() -> test_result};
389+
type TestFuture = {test: TestDesc, wait: fn@() -> TestResult};
390390
391-
fn run_test(+test: test_desc, monitor_ch: comm::Chan<monitor_msg>) {
391+
fn run_test(+test: TestDesc, monitor_ch: comm::Chan<MonitorMsg>) {
392392
if test.ignore {
393-
core::comm::send(monitor_ch, (copy test, tr_ignored));
393+
core::comm::send(monitor_ch, (copy test, TrIgnored));
394394
return;
395395
}
396396
@@ -406,13 +406,13 @@ fn run_test(+test: test_desc, monitor_ch: comm::Chan<monitor_msg>) {
406406
};
407407
}
408408
409-
fn calc_result(test: test_desc, task_succeeded: bool) -> test_result {
409+
fn calc_result(test: TestDesc, task_succeeded: bool) -> TestResult {
410410
if task_succeeded {
411-
if test.should_fail { tr_failed }
412-
else { tr_ok }
411+
if test.should_fail { TrFailed }
412+
else { TrOk }
413413
} else {
414-
if test.should_fail { tr_ok }
415-
else { tr_failed }
414+
if test.should_fail { TrOk }
415+
else { TrFailed }
416416
}
417417
}
418418
@@ -432,7 +432,7 @@ mod tests {
432432
let ch = core::comm::Chan(p);
433433
run_test(desc, ch);
434434
let (_, res) = core::comm::recv(p);
435-
assert res != tr_ok;
435+
assert res != TrOk;
436436
}
437437
438438
#[test]
@@ -448,7 +448,7 @@ mod tests {
448448
let ch = core::comm::Chan(p);
449449
run_test(desc, ch);
450450
let (_, res) = core::comm::recv(p);
451-
assert res == tr_ignored;
451+
assert res == TrIgnored;
452452
}
453453
454454
#[test]
@@ -465,7 +465,7 @@ mod tests {
465465
let ch = core::comm::Chan(p);
466466
run_test(desc, ch);
467467
let (_, res) = core::comm::recv(p);
468-
assert res == tr_ok;
468+
assert res == TrOk;
469469
}
470470
471471
#[test]
@@ -481,7 +481,7 @@ mod tests {
481481
let ch = core::comm::Chan(p);
482482
run_test(desc, ch);
483483
let (_, res) = core::comm::recv(p);
484-
assert res == tr_failed;
484+
assert res == TrFailed;
485485
}
486486
487487
#[test]

src/rustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] {
264264
fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
265265
let test_desc_ty_path =
266266
path_node(mk_path(cx, ~[cx.sess.ident_of(~"test"),
267-
cx.sess.ident_of(~"test_desc")]));
267+
cx.sess.ident_of(~"TestDesc")]));
268268

269269
let test_desc_ty: ast::ty =
270270
{id: cx.sess.next_node_id(),

0 commit comments

Comments
 (0)