aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/export.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-03-04 13:21:11 +0000
committerVeikka Tuominen <git@vexu.eu>2023-03-21 15:04:39 +0200
commitf9b5829508e4f9a7e2eee2f05f58a38c00318d91 (patch)
treed56e7826469317dfebe7d7c87fa58071b1d38546 /test/behavior/export.zig
parent5e161c102d4a99be4903d0074ea2513ebcdb985b (diff)
downloadzig-f9b5829508e4f9a7e2eee2f05f58a38c00318d91.tar.gz
zig-f9b5829508e4f9a7e2eee2f05f58a38c00318d91.zip
Sema: implement @export for arbitrary values
Diffstat (limited to 'test/behavior/export.zig')
-rw-r--r--test/behavior/export.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/behavior/export.zig b/test/behavior/export.zig
index fb35fc6fc6..6123aa593b 100644
--- a/test/behavior/export.zig
+++ b/test/behavior/export.zig
@@ -70,3 +70,22 @@ test "exporting using field access" {
_ = S.Inner.x;
}
+
+test "exporting comptime-known value" {
+ const x: u32 = 10;
+ @export(x, .{ .name = "exporting_comptime_known_value_foo" });
+ const S = struct {
+ extern const exporting_comptime_known_value_foo: u32;
+ };
+ try expect(S.exporting_comptime_known_value_foo == 10);
+}
+
+test "exporting comptime var" {
+ comptime var x: u32 = 5;
+ @export(x, .{ .name = "exporting_comptime_var_foo" });
+ x = 7; // modifying this now shouldn't change anything
+ const S = struct {
+ extern const exporting_comptime_var_foo: u32;
+ };
+ try expect(S.exporting_comptime_var_foo == 5);
+}