stage2: implement @truncate

This commit is contained in:
Andrew Kelley
2021-08-01 16:13:58 -07:00
parent 6ae0825e7f
commit ddf14323ea
12 changed files with 380 additions and 279 deletions

View File

@@ -1,3 +1,6 @@
const std = @import("std");
const expect = std.testing.expect;
// normal comment
/// this is a documentation comment
@@ -7,3 +10,11 @@ fn emptyFunctionWithComments() void {}
test "empty function with comments" {
emptyFunctionWithComments();
}
test "truncate" {
try expect(testTruncate(0x10fd) == 0xfd);
comptime try expect(testTruncate(0x10fd) == 0xfd);
}
fn testTruncate(x: u32) u8 {
return @truncate(u8, x);
}