Skip to content

Commit 1a03b54

Browse files
committed
---
yaml --- r: 7034 b: refs/heads/master c: 0e98e64 h: refs/heads/master v: v3
1 parent 10f879f commit 1a03b54

File tree

19 files changed

+820
-677
lines changed

19 files changed

+820
-677
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a16acc0c105c438a5cf1500eb4c4a5c4388c2dca
2+
refs/heads/master: 0e98e64bc2eb1ed87dfcb030a92c9e112c5df7a2

trunk/src/comp/middle/ast_map.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ fn map_native_item(cx: ctx, i: @native_item) {
8888

8989
fn map_expr(cx: ctx, ex: @expr) {
9090
cx.map.insert(ex.id, node_expr(ex));
91+
alt ex.node {
92+
expr_anon_obj(ao) {
93+
for m in ao.methods {
94+
cx.map.insert(m.id, node_obj_method(m));
95+
}
96+
}
97+
_ {}
98+
}
9199
}
92100

93101
fn new_smallintmap_int_adapter<copy V>() -> std::map::hashmap<int, V> {

trunk/src/comp/middle/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
726726
}
727727
}
728728
}
729-
ast_map::node_obj_method(method) {
729+
ast_map::node_obj_method(method) | ast_map::node_method(method) {
730730
(method.ident, method.decl.output, method.id)
731731
}
732732
ast_map::node_res_ctor(item) {

trunk/src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ mod util;
55
mod header;
66
mod runtest;
77
mod common;
8+
mod errors;
89

910
// Local Variables:
1011
// fill-column: 78;
1112
// indent-tabs-mode: nil
1213
// c-basic-offset: 4
1314
// buffer-file-coding-system: utf-8-unix
14-
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
1515
// End:

trunk/src/compiletest/errors.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import option;
2+
import str;
3+
import std::io;
4+
import std::fs;
5+
6+
import common::config;
7+
8+
export load_errors;
9+
export expected_error;
10+
11+
type expected_error = { line: uint, kind: str, msg: str };
12+
13+
// Load any test directives embedded in the file
14+
fn load_errors(testfile: str) -> [expected_error] {
15+
let error_patterns = [];
16+
let rdr = result::get(io::file_reader(testfile));
17+
let line_num = 1u;
18+
while !rdr.eof() {
19+
let ln = rdr.read_line();
20+
error_patterns += parse_expected(line_num, ln);
21+
line_num += 1u;
22+
}
23+
ret error_patterns;
24+
}
25+
26+
fn parse_expected(line_num: uint, line: str) -> [expected_error] {
27+
let error_tag = "//!";
28+
let idx0 = str::find(line, error_tag);
29+
if idx0 < 0 { ret []; }
30+
let idx = (idx0 as uint) + str::byte_len(error_tag);
31+
32+
// "//!^^^ kind msg" denotes a message expected
33+
// three lines above current line:
34+
let adjust_line = 0u;
35+
let len = str::byte_len(line);
36+
while idx < len && line[idx] == ('^' as u8) {
37+
adjust_line += 1u;
38+
idx += 1u;
39+
}
40+
41+
// Extract kind:
42+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
43+
let start_kind = idx;
44+
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
45+
let kind = str::to_lower(str::slice(line, start_kind, idx));
46+
47+
// Extract msg:
48+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
49+
let msg = str::slice(line, idx, len);
50+
51+
#debug("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
52+
53+
ret [{line: line_num - adjust_line, kind: kind, msg: msg}];
54+
}

trunk/src/compiletest/runtest.rs

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ fn run_cfail_test(cx: cx, props: test_props, testfile: str) {
4242
}
4343

4444
check_correct_failure_status(procres);
45-
check_error_patterns(props, testfile, procres);
45+
46+
let expected_errors = errors::load_errors(testfile);
47+
if vec::is_not_empty(expected_errors) {
48+
if vec::is_not_empty(props.error_patterns) {
49+
fatal("both error pattern and expected errors specified");
50+
}
51+
check_expected_errors(expected_errors, testfile, procres);
52+
} else {
53+
check_error_patterns(props, testfile, procres);
54+
}
4655
}
4756

4857
fn run_rfail_test(cx: cx, props: test_props, testfile: str) {
@@ -181,7 +190,9 @@ actual:\n\
181190
}
182191
}
183192

184-
fn check_error_patterns(props: test_props, testfile: str, procres: procres) {
193+
fn check_error_patterns(props: test_props,
194+
testfile: str,
195+
procres: procres) {
185196
if vec::is_empty(props.error_patterns) {
186197
fatal("no error pattern specified in " + testfile);
187198
}
@@ -218,6 +229,63 @@ fn check_error_patterns(props: test_props, testfile: str, procres: procres) {
218229
}
219230
}
220231

232+
fn check_expected_errors(expected_errors: [errors::expected_error],
233+
testfile: str,
234+
procres: procres) {
235+
236+
// true if we found the error in question
237+
let found_flags = vec::init_elt_mut(false, vec::len(expected_errors));
238+
239+
if procres.status == 0 {
240+
fatal("process did not return an error status");
241+
}
242+
243+
let prefixes = vec::map(expected_errors, {|ee|
244+
#fmt("%s:%u:", testfile, ee.line)
245+
});
246+
247+
// Scan and extract our error/warning messages,
248+
// which look like:
249+
// filename:line1:col1: line2:col2: *error:* msg
250+
// filename:line1:col1: line2:col2: *warning:* msg
251+
// where line1:col1: is the starting point, line2:col2:
252+
// is the ending point, and * represents ANSI color codes.
253+
for line: str in str::split(procres.stdout, '\n' as u8) {
254+
let was_expected = false;
255+
vec::iteri(expected_errors) {|i, ee|
256+
if !found_flags[i] {
257+
#debug["prefix=%s ee.kind=%s ee.msg=%s line=%s",
258+
prefixes[i], ee.kind, ee.msg, line];
259+
if (str::starts_with(line, prefixes[i]) &&
260+
str::contains(line, ee.kind) &&
261+
str::contains(line, ee.msg)) {
262+
found_flags[i] = true;
263+
was_expected = true;
264+
}
265+
}
266+
}
267+
268+
// ignore this msg which gets printed at the end
269+
if str::contains(line, "aborting due to previous errors") {
270+
was_expected = true;
271+
}
272+
273+
if !was_expected && (str::contains(line, "error") ||
274+
str::contains(line, "warning")) {
275+
fatal_procres(#fmt["unexpected error pattern '%s'!", line],
276+
procres);
277+
}
278+
}
279+
280+
uint::range(0u, vec::len(found_flags)) {|i|
281+
if !found_flags[i] {
282+
let ee = expected_errors[i];
283+
fatal_procres(#fmt["expected %s on line %u not found: %s",
284+
ee.kind, ee.line, ee.msg], procres);
285+
}
286+
}
287+
}
288+
221289
type procargs = {prog: str, args: [str]};
222290

223291
type procres = {status: int, stdout: str, stderr: str, cmdline: str};

trunk/src/etc/cmathconsts.c

Lines changed: 0 additions & 92 deletions
This file was deleted.

trunk/src/libcore/bessel.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)