diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-13 04:30:41 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-13 04:30:41 -0500 |
| commit | 3f3630d7e349361116416dce36d2f69d7c3e318c (patch) | |
| tree | 836ce54c606706f23a0a7524a3628b6e464c051c /test | |
| parent | 8bb5f54b292efacc03ff8d7cc6f59ae36c24305d (diff) | |
| download | zig-3f3630d7e349361116416dce36d2f69d7c3e318c.tar.gz zig-3f3630d7e349361116416dce36d2f69d7c3e318c.zip | |
IR: implement the rest of the builtin functions
* returnAddress
* frameAddress
* addWithOverflow
* subWithOverflow
* mulWithOverflow
* shlWithOverflow
* alignOf
Diffstat (limited to 'test')
| -rw-r--r-- | test/self_hosted2.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/self_hosted2.zig b/test/self_hosted2.zig index 83665f6d27..4569218b79 100644 --- a/test/self_hosted2.zig +++ b/test/self_hosted2.zig @@ -329,6 +329,20 @@ fn intTypeBuiltin() { } +fn overflowIntrinsics() { + var result: u8 = undefined; + assert(@addWithOverflow(u8, 250, 100, &result)); + assert(!@addWithOverflow(u8, 100, 150, &result)); + assert(result == 250); +} + +fn shlWithOverflow() { + var result: u16 = undefined; + assert(@shlWithOverflow(u16, 0b0010111111111111, 3, &result)); + assert(!@shlWithOverflow(u16, 0b0010111111111111, 2, &result)); + assert(result == 0b1011111111111100); +} + fn assert(ok: bool) { if (!ok) @unreachable(); @@ -361,6 +375,8 @@ fn runAllTests() { exactDivision(); truncate(); intTypeBuiltin(); + overflowIntrinsics(); + shlWithOverflow(); } export nakedcc fn _start() -> unreachable { |
