diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-08 01:52:57 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-08 01:52:57 -0500 |
| commit | 7d0fb281fee16d9c99f61c5bce090018228ae6df (patch) | |
| tree | 4fe6b845e03cb6b19e399283f5501d444cf2185a /test | |
| parent | a148096e6a2d28e6248eed9b5a4ad40482b74149 (diff) | |
| download | zig-7d0fb281fee16d9c99f61c5bce090018228ae6df.tar.gz zig-7d0fb281fee16d9c99f61c5bce090018228ae6df.zip | |
IR: a bunch of fixes and some additions
* add errorName builtin function
* add assertion for generated memcopy being on correct types
* respect handle_is_ptr for constant values
* fix return codegen to respect sret semantics
* remove ArrayLen IR instruction; we already have StructFieldPtr
with "len" field
* fix gen_const_val for pointers inside aggregates
Diffstat (limited to 'test')
| -rw-r--r-- | test/self_hosted2.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/self_hosted2.zig b/test/self_hosted2.zig index 6776e21bf9..7bca89a206 100644 --- a/test/self_hosted2.zig +++ b/test/self_hosted2.zig @@ -238,6 +238,26 @@ fn testMinValueAndMaxValue() { assert(@minValue(i64) == -9223372036854775808); } +fn first4KeysOfHomeRow() -> []const u8 { + "aoeu" +} + +fn testReturnStringFromFunction() { + assert(memeql(first4KeysOfHomeRow(), "aoeu")); +} + +pub fn memeql(a: []const u8, b: []const u8) -> bool { + sliceEql(u8, a, b) +} + +pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { + if (a.len != b.len) return false; + for (a) |item, index| { + if (b[index] != item) return false; + } + return true; +} + fn assert(ok: bool) { if (!ok) @unreachable(); @@ -263,6 +283,7 @@ fn runAllTests() { testStaticAddOne(); testInlineVarsAgain(); testMinValueAndMaxValue(); + testReturnStringFromFunction(); } export nakedcc fn _start() -> unreachable { |
