This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$ zig test make_struct.zig | |
// make_struct.zig:20:7: error: no member named 'int64' in struct 'makeStruct((struct []const u8 constant),i64)' | |
// v1.int64 = -123; | |
// Seems the "name" parameter needs to be a "symbol" | |
// and the return would be something like: | |
// return struct { @symbol(name): T, }; | |
fn makeStruct(comptime name: []const u8, comptime T: type) type { | |
return struct { name: T, }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$ zig test opaquetype.zig | |
//opaquetype.zig:8:30: error: parameter of type '(anonymous opaque at opaquetype.zig:12:30)' not allowed | |
// fn getValue(pOpaqueSelf: @OpaqueType()) u32 { | |
// ^ | |
const assert = @import("std").debug.assert; | |
const S = struct { | |
const Self = @This(); | |
value: u32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const assert = std.debug.assert; | |
const warn = std.debug.warn; | |
const builtin = @import("builtin"); | |
const TypeId = builtin.TypeId; | |
test "u0" { | |
var zero: u0 = 0; | |
var pZeroOptional: ?*u0 = &zero; | |
assert(pZeroOptional != null); // this is true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const assert = std.debug.assert; | |
test "u0-memory-address" { | |
var one: u1 = 1; | |
var zero: u0 = 0; | |
var pZero = &zero; | |
assert(pZero == &zero); | |
// $ zig test u0.zig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = @import("std").debug.assert; | |
// zig: ../src/analyze.cpp:499: ZigType* get_pointer_to_type_extra(CodeGen*, ZigType*, bool, bool, PtrLen, uint32_t, uint32_t, uint32_t): Assertion `byte_alignment == 0' failed. | |
// Aborted (core dumped) | |
test "u0-packed-struct-fails" { | |
const S = packed struct { f0: u0, }; | |
var s = S { .f0 = 0, }; | |
assert(s.f0 == 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const S1 = struct { | |
n: u32, | |
} | |
fn S2() type { | |
return S1 { | |
m: u64, | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ zig test --test-filter approxEql.sum.large.f64 modules/zig-approxEql/approxeql.zig | |
Test 1/1 approxEql.sum.large.f64... | |
x=8.988465674311579e+307 end=8.988465674311085e+307 | |
approxEql: x=8.988465674311579e+307 y=8.988465674311085e+307 digits=0 digits == 0 result=true | |
approxEql: x=8.988465674311579e+307 y=8.988465674311085e+307 digits=1 abs_diff=4.9397047660984315e+294 max_diff=1.0e+00 scaled_max_diff=8.988465674311579e+306 scaled_epsilon=1.9958403095347196e+292 result=true | |
approxEql: x=8.988465674311579e+307 y=8.988465674311085e+307 digits=2 abs_diff=4.9397047660984315e+294 max_diff=1.0e-01 scaled_max_diff=8.988465674311578e+305 scaled_epsilon=1.9958403095347196e+292 result=true | |
approxEql: x=8.988465674311579e+307 y=8.988465674311085e+307 digits=3 abs_diff=4.9397047660984315e+294 max_diff=1.0e-02 scaled_max_diff=8.988465674311578e+304 scaled_epsilon=1.9958403095347196e+292 result=true | |
approxEql: x=8.988465674311579e+307 y=8.988465674311085e+307 digits=4 abs_diff=4.9397047660984315e+294 max_diff=1.0e-03 scaled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQINBFrXsMwBEACTOyxM37EOX5IUjQoS1ApAV8jjK6cEPtPwaHMg4YnpnbdrHXXK | |
2E+CKr4JFJp0qJ8vm0VyUKnv/VE+dARHtVS1mIdglP0+l1pJWodLHKmxa5R7tP2x | |
u5/BQf3w2vhjQSgUQfd/hFOaHQpFfqRF87/9Yitz6pIuOlxZii0PDPBGDkzaTYFj | |
z5VOpWSFGVHIo6uGUd8DMC8lw4N0WBC08jivkclSKpJtazbmMuBMgcWwbwbAMEg3 | |
BE6ouBG48F82UWKgVNxypTfULfV1l0aEhb/I5v33u38I/IQdM5x9k+C++teSY9FJ | |
y9F6kYLdzwLU0pDSJXsac9EAX5uKDe7Zn/jxWt97v4VZPPhTyc/pbuwkvF+q0Ef4 | |
Ixa5YWBmcEFCIQl3BLc3QUdljzODJfU5KwcJjBUcv1AbWXxmFy0msdpBP5wQJYTL | |
M0D/q+FHQ1BAV45M0nnO4olgyDfSvbt+0ce1rEpw9hoyakIkM18ivV+2Bs+NvVZH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ /usr/bin/c++ -v -O3 -DNDEBUG -rdynamic CMakeFiles/zig.dir/src/analyze.cpp.o CMakeFiles/zig.dir/src/ast_render.cpp.o CMakeFiles/zig.dir/src/bigfloat.cpp.o CMakeFiles/zig.dir/src/bigint.cpp.o CMakeFiles/zig.dir/src/buffer.cpp.o CMakeFiles/zig.dir/src/c_tokenizer.cpp.o CMakeFiles/zig.dir/src/cache_hash.cpp.o CMakeFiles/zig.dir/src/codegen.cpp.o CMakeFiles/zig.dir/src/compiler.cpp.o CMakeFiles/zig.dir/src/errmsg.cpp.o CMakeFiles/zig.dir/src/error.cpp.o CMakeFiles/zig.dir/src/ir.cpp.o CMakeFiles/zig.dir/src/ir_print.cpp.o CMakeFiles/zig.dir/src/libc_installation.cpp.o CMakeFiles/zig.dir/src/link.cpp.o CMakeFiles/zig.dir/src/main.cpp.o CMakeFiles/zig.dir/src/os.cpp.o CMakeFiles/zig.dir/src/parser.cpp.o CMakeFiles/zig.dir/src/range_set.cpp.o CMakeFiles/zig.dir/src/target.cpp.o CMakeFiles/zig.dir/src/tokenizer.cpp.o CMakeFiles/zig.dir/src/translate_c.cpp.o CMakeFiles/zig.dir/src/util.cpp.o -o zig -L/home/wink/local/lib -Wl,-v,--verbose,-rpath,/home/wink/local/lib::::: libzig_cpp.a libopt_c_util.a libembedded_s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rm -rf * .ninja_* && cmake ../llvm -G Ninja -DCMAKE_INSTALL_PREFIX=~/local.master -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;libunwind;compiler-rt;lld;lldb;polly;debuginfo-tests" -DLLVM_BUILD_LLVM_DYLIB=ON | |
-- The C compiler identification is GNU 8.3.0 | |
-- The CXX compiler identification is GNU 8.3.0 | |
-- The ASM compiler identification is GNU | |
-- Found assembler: /usr/bin/cc | |
-- Check for working C compiler: /usr/bin/cc | |
-- Check for working C compiler: /usr/bin/cc -- works | |
-- Detecting C compiler ABI info | |
-- Detecting C compiler ABI info - done | |
-- Detecting C compile features |