aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-18 15:47:21 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-18 15:47:21 -0700
commit5e33175517807c6e50fe66f8d6c65fc094c8e11a (patch)
tree004fc843be6c452f0c925915d080b8ab09432723 /test/run_tests.cpp
parent832454f38b3ef635ee03fb54c382d8be02ac7c9e (diff)
downloadzig-5e33175517807c6e50fe66f8d6c65fc094c8e11a.tar.gz
zig-5e33175517807c6e50fe66f8d6c65fc094c8e11a.zip
add @embed_file builtin function
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 7b5b90e4ae..fdc03b0ae0 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -600,6 +600,20 @@ fn do_test() -> %void {
}
fn its_gonna_pass() -> %void { }
)SOURCE", "before\nafter\ndefer3\ndefer1\n");
+
+
+ {
+ TestCase *tc = add_simple_case("@embed_file", R"SOURCE(
+const foo_txt = @embed_file("foo.txt");
+const io = @import("std").io;
+
+pub fn main(args: [][]u8) -> %void {
+ %%io.stdout.printf(foo_txt);
+}
+ )SOURCE", "1234\nabcd\n");
+
+ add_source_file(tc, "foo.txt", "1234\nabcd\n");
+ }
}
@@ -1173,6 +1187,10 @@ fn fibbonaci(x: i32) -> i32 {
".tmp_source.zig:3:1: error: function evaluation exceeded 1000 branches",
".tmp_source.zig:2:37: note: called from here",
".tmp_source.zig:4:40: note: quota exceeded here");
+
+ add_compile_fail_case("@embed_file with bogus file", R"SOURCE(
+const resource = @embed_file("bogus.txt");
+ )SOURCE", 1, ".tmp_source.zig:2:18: error: unable to find './bogus.txt'");
}
//////////////////////////////////////////////////////////////////////////////