aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-20 08:04:46 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-20 08:04:46 -0500
commit079728752eca4cffbb4f7e8dc06d5e23b81d7627 (patch)
tree552dcf5837bf1b3f4cab297bed4a9e0e0bea4c0f /test
parent067968c57f2c7ed4f0606913aa608f6c2be418d2 (diff)
downloadzig-079728752eca4cffbb4f7e8dc06d5e23b81d7627.tar.gz
zig-079728752eca4cffbb4f7e8dc06d5e23b81d7627.zip
deduplicate compile errors for undeclared identifiers
closes #111
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig24
-rw-r--r--test/tests.zig3
2 files changed, 20 insertions, 7 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 86dfd59bee..a9c748bcda 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1,6 +1,22 @@
const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
+ cases.addCase(x: {
+ var tc = cases.create(
+ "deduplicate undeclared identifier",
+ \\export fn a() void {
+ \\ x += 1;
+ \\}
+ \\export fn b() void {
+ \\ x += 1;
+ \\}
+ ,
+ ".tmp_source.zig:2:5: error: use of undeclared identifier 'x'",
+ );
+ tc.expect_exact = true;
+ break :x tc;
+ });
+
cases.addTest(
"export generic function",
\\export fn foo(num: var) i32 {
@@ -2280,7 +2296,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\}
,
".tmp_source.zig:2:5: error: use of undeclared identifier 'i'",
- ".tmp_source.zig:2:12: error: use of undeclared identifier 'i'",
);
cases.add(
@@ -5618,8 +5633,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
".tmp_source.zig:2:26: error: vector element type must be integer, float, or pointer; '@Vector(4, u8)' is invalid",
);
- cases.add(
- "compileLog of tagged enum doesn't crash the compiler",
+ cases.add("compileLog of tagged enum doesn't crash the compiler",
\\const Bar = union(enum(u32)) {
\\ X: i32 = 1
\\};
@@ -5631,7 +5645,5 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\pub fn main () void {
\\ comptime testCompileLog(Bar{.X = 123});
\\}
- ,
- ".tmp_source.zig:6:5: error: found compile log statement"
- );
+ , ".tmp_source.zig:6:5: error: found compile log statement");
}
diff --git a/test/tests.zig b/test/tests.zig
index f9c9207f05..2591ab4f2a 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -716,7 +716,8 @@ pub const CompileErrorContext = struct {
for (self.case.expected_errors.toSliceConst()) |expected| {
if (mem.indexOf(u8, stderr, expected) == null) {
warn(
- \\\n=========== Expected compile error: ============
+ \\
+ \\=========== Expected compile error: ============
\\{}
\\
, expected);