authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:41:36-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:41:36-05:00
loge4bc8d22c2f518353d31d8c99de8d35e5ead0c67
treeedf0b974211cd0c65000e5e39f771c7d6b9f7694
parent3ef447fa20f54f75ad3b9be59768b4ef284cb941

fix some tests


1 files changed, 11 insertions(+), 21 deletions(-)

test/run_tests.cpp+11-21
...@@ -1022,16 +1022,15 @@ const x = foo();...@@ -1022,16 +1022,15 @@ const x = foo();
1022 )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression");1022 )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression");
10231023
1024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(1024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
1025fn f(s: []u8) -> []u8 {1025const src = "aoeu";
1026 s ++ "foo"1026const a = src[0...] ++ "foo";
1027}1027 )SOURCE", 1, ".tmp_source.zig:3:14: error: expected array or C string literal, found '[]u8'");
1028 )SOURCE", 1, ".tmp_source.zig:3:5: error: expected array or C string literal, found '[]u8'");
10291028
1030 add_compile_fail_case("non compile time array concatenation", R"SOURCE(1029 add_compile_fail_case("non compile time array concatenation", R"SOURCE(
1031fn f(s: [10]u8) -> []u8 {1030fn f(s: [10]u8) -> []u8 {
1032 s ++ "foo"1031 s ++ "foo"
1033}1032}
1034 )SOURCE", 1, ".tmp_source.zig:3:5: error: array concatenation requires constant expression");1033 )SOURCE", 1, ".tmp_source.zig:3:5: error: unable to evaluate constant expression");
10351034
1036 add_compile_fail_case("@cImport with bogus include", R"SOURCE(1035 add_compile_fail_case("@cImport with bogus include", R"SOURCE(
1037const c = @cImport(@cInclude("bogus.h"));1036const c = @cImport(@cInclude("bogus.h"));
...@@ -1041,14 +1040,8 @@ const c = @cImport(@cInclude("bogus.h"));...@@ -1041,14 +1040,8 @@ const c = @cImport(@cInclude("bogus.h"));
1041 add_compile_fail_case("address of number literal", R"SOURCE(1040 add_compile_fail_case("address of number literal", R"SOURCE(
1042const x = 3;1041const x = 3;
1043const y = &x;1042const y = &x;
1044 )SOURCE", 1, ".tmp_source.zig:3:12: error: unable to get address of type '(integer literal)'");1043fn foo() -> &const i32 { y }
10451044 )SOURCE", 1, ".tmp_source.zig:4:26: error: expected type '&const i32', found '&const (integer literal)'");
1046 add_compile_fail_case("@typeOf number literal", R"SOURCE(
1047const x = 3;
1048const Foo = struct {
1049 index: @typeOf(x),
1050};
1051 )SOURCE", 1, ".tmp_source.zig:4:20: error: type '(integer literal)' not eligible for @typeOf");
10521045
1053 add_compile_fail_case("integer overflow error", R"SOURCE(1046 add_compile_fail_case("integer overflow error", R"SOURCE(
1054const x : u8 = 300;1047const x : u8 = 300;
...@@ -1077,7 +1070,7 @@ const members = []member_fn_type {...@@ -1077,7 +1070,7 @@ const members = []member_fn_type {
1077 Foo.member_b,1070 Foo.member_b,
1078};1071};
10791072
1080fn f(foo: Foo, index: i32) {1073fn f(foo: Foo, index: usize) {
1081 const result = members[index]();1074 const result = members[index]();
1082}1075}
1083 )SOURCE", 1, ".tmp_source.zig:21:34: error: expected 1 arguments, found 0");1076 )SOURCE", 1, ".tmp_source.zig:21:34: error: expected 1 arguments, found 0");
...@@ -1094,10 +1087,7 @@ const fns = []fn(){ a, b, c };...@@ -1094,10 +1087,7 @@ const fns = []fn(){ a, b, c };
1094fn a() -> i32 {0}1087fn a() -> i32 {0}
1095fn b() -> i32 {1}1088fn b() -> i32 {1}
1096fn c() -> i32 {2}1089fn c() -> i32 {2}
1097 )SOURCE", 3,1090 )SOURCE", 1, ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'");
1098 ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'",
1099 ".tmp_source.zig:2:24: error: expected type 'fn()', found 'fn() -> i32'",
1100 ".tmp_source.zig:2:27: error: expected type 'fn()', found 'fn() -> i32'");
11011091
1102 add_compile_fail_case("extern function pointer mismatch", R"SOURCE(1092 add_compile_fail_case("extern function pointer mismatch", R"SOURCE(
1103const fns = [](fn(i32)->i32){ a, b, c };1093const fns = [](fn(i32)->i32){ a, b, c };
...@@ -1126,11 +1116,11 @@ const x = @compileVar("bogus");...@@ -1126,11 +1116,11 @@ const x = @compileVar("bogus");
1126 )SOURCE", 1, ".tmp_source.zig:2:23: error: unrecognized compile variable: 'bogus'");1116 )SOURCE", 1, ".tmp_source.zig:2:23: error: unrecognized compile variable: 'bogus'");
11271117
11281118
1129 add_compile_fail_case("@constEval", R"SOURCE(1119 add_compile_fail_case("@staticEval", R"SOURCE(
1130fn a(x: i32) {1120fn a(x: i32) {
1131 const y = @constEval(x);1121 const y = @staticEval(x);
1132}1122}
1133 )SOURCE", 1, ".tmp_source.zig:3:26: error: unable to evaluate constant expression");1123 )SOURCE", 1, ".tmp_source.zig:3:27: error: unable to evaluate constant expression");
11341124
1135 add_compile_fail_case("non constant expression in array size outside function", R"SOURCE(1125 add_compile_fail_case("non constant expression in array size outside function", R"SOURCE(
1136const Foo = struct {1126const Foo = struct {