summaryrefslogtreecommitdiffstats
path: root/tests/byte-code
diff options
context:
space:
mode:
Diffstat (limited to 'tests/byte-code')
-rw-r--r--tests/byte-code/composite.slang34
-rw-r--r--tests/byte-code/hello.slang17
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/byte-code/composite.slang b/tests/byte-code/composite.slang
new file mode 100644
index 000000000..41729b6c2
--- /dev/null
+++ b/tests/byte-code/composite.slang
@@ -0,0 +1,34 @@
+//TEST:INTERPRET(filecheck=CHECK):
+struct Inner
+{
+ int header;
+ int array[3];
+}
+struct MyType
+{
+ float3 value1;
+ float3 value2;
+ Inner inner;
+}
+MyType getValue()
+{
+ MyType t = { float3(1, 2, 3), float3(-1,-2, 3), { 4, { 5, 6, 7 } } };
+ return t;
+}
+int main()
+{
+ var t = getValue();
+ int sum = 0;
+ for (int i = 0; i < 3; ++i)
+ {
+ sum += t.inner.array[i];
+ }
+ t.value1 += t.value2;
+ for (int i = 0; i < 3; i++)
+ {
+ sum += (int)t.value1[i];
+ }
+ //CHECK: 24
+ printf("%d\n", sum);
+ return 0;
+}
diff --git a/tests/byte-code/hello.slang b/tests/byte-code/hello.slang
new file mode 100644
index 000000000..f3c13cbab
--- /dev/null
+++ b/tests/byte-code/hello.slang
@@ -0,0 +1,17 @@
+//TEST:INTERPRET(filecheck=BC): -disasm
+//TEST:INTERPRET(filecheck=CHECK):
+
+int main(int argc, NativeString* argv)
+{
+ printf("hello world\n");
+ for (int i = 0; i < argc; ++i)
+ {
+ printf("%s\n", argv[i]);
+ }
+ return 100;
+}
+
+// CHECK: hello world
+// CHECK: {{.*}}hello.slang
+// BC: func main
+// BC: ret \ No newline at end of file