Added tests for array/struct impl, but they in general require printing

to screen
This commit is contained in:
Mitchell Plamann
2015-04-06 01:21:41 -04:00
parent 447b40710e
commit 30e983e656
11 changed files with 150 additions and 0 deletions

12
test/arrays.c0 Normal file
View File

@@ -0,0 +1,12 @@
#use <conio>
int main() {
int[] A = alloc_array(int, -2);
A[3] = 0;
A[3] = 1;
A[3] = 2;
A[3] = 3;
printint(A[3]);
return 0;
}

52
test/arrays.c0.bc0 Normal file
View File

@@ -0,0 +1,52 @@
C0 C0 FF EE # magic number
00 09 # version 4, arch = 1 (64 bits)
00 00 # int pool count
# int pool
00 00 # string pool total size
# string pool
00 01 # function count
# function_pool
#<main>
00 00 # number of arguments = 0
00 01 # number of local variables = 1
00 33 # code length = 51 bytes
10 FE # bipush -2 # -2
BC 04 # newarray 4 # alloc_array(int, -(2))
36 00 # vstore 0 # A = alloc_array(int, -(2));
15 00 # vload 0 # A
10 03 # bipush 3 # 3
63 # aadds # &A[3]
10 00 # bipush 0 # 0
4E # imstore # A[3] = 0;
15 00 # vload 0 # A
10 03 # bipush 3 # 3
63 # aadds # &A[3]
10 01 # bipush 1 # 1
4E # imstore # A[3] = 1;
15 00 # vload 0 # A
10 03 # bipush 3 # 3
63 # aadds # &A[3]
10 02 # bipush 2 # 2
4E # imstore # A[3] = 2;
15 00 # vload 0 # A
10 03 # bipush 3 # 3
63 # aadds # &A[3]
10 03 # bipush 3 # 3
4E # imstore # A[3] = 3;
15 00 # vload 0 # A
10 03 # bipush 3 # 3
63 # aadds # &A[3]
2E # imload # A[3]
B7 00 00 # invokenative 0 # printint(A[3])
57 # pop # (ignore result)
10 00 # bipush 0 # 0
B0 # return #
00 01 # native count
# native pool
00 01 00 09 # printint

1
test/arrays.c0.bc0out Normal file
View File

@@ -0,0 +1 @@
30

0
test/arrays.c0.c0out Normal file
View File

BIN
test/arrays.c0.ex Executable file

Binary file not shown.

18
test/structs.c0 Normal file
View File

@@ -0,0 +1,18 @@
#use <conio>
struct test {
int a;
string b;
int c;
};
int main() {
struct test* t = alloc(struct test);
t->a = 1;
t->b = "potato chip";
t->c = 23;
print(t->b);
printint(t->a);
printint(t->c);
return 0;
}

54
test/structs.c0.bc0 Normal file
View File

@@ -0,0 +1,54 @@
C0 C0 FF EE # magic number
00 09 # version 4, arch = 1 (64 bits)
00 00 # int pool count
# int pool
00 0C # string pool total size
# string pool
70 6F 74 61 74 6F 20 63 68 69 70 00 # "potato chip"
00 01 # function count
# function_pool
#<main>
00 00 # number of arguments = 0
00 01 # number of local variables = 1
00 38 # code length = 56 bytes
BB 18 # new 24 # alloc(struct test)
36 00 # vstore 0 # t = alloc(struct test);
15 00 # vload 0 # t
62 00 # aaddf 0 # &t->a
10 01 # bipush 1 # 1
4E # imstore # t->a = 1;
15 00 # vload 0 # t
62 08 # aaddf 8 # &t->b
14 00 00 # aldc 0 # s[0] = "potato chip"
4F # amstore # t->b = "potato chip";
15 00 # vload 0 # t
62 10 # aaddf 16 # &t->c
10 17 # bipush 23 # 23
4E # imstore # t->c = 23;
15 00 # vload 0 # t
62 08 # aaddf 8 # &t->b
2F # amload # t->b
B7 00 00 # invokenative 0 # print(t->b)
57 # pop # (ignore result)
15 00 # vload 0 # t
62 00 # aaddf 0 # &t->a
2E # imload # t->a
B7 00 01 # invokenative 1 # printint(t->a)
57 # pop # (ignore result)
15 00 # vload 0 # t
62 10 # aaddf 16 # &t->c
2E # imload # t->c
B7 00 01 # invokenative 1 # printint(t->c)
57 # pop # (ignore result)
10 00 # bipush 0 # 0
B0 # return #
00 02 # native count
# native pool
00 01 00 06 # print
00 01 00 09 # printint

1
test/structs.c0.bc0out Normal file
View File

@@ -0,0 +1 @@
potato chip1230

1
test/structs.c0.c0out Normal file
View File

@@ -0,0 +1 @@
potato chip1230

BIN
test/structs.c0.ex Executable file

Binary file not shown.

View File

@@ -37,3 +37,14 @@ exports.testIF = doTest("testif.c0.bc0", 32);
exports.testDSQUARED = doTest("dsquared.c0.bc0", 17068); exports.testDSQUARED = doTest("dsquared.c0.bc0", 17068);
exports.testArrays = function(test) {
var result = c0vm.execute(parser.parse("arrays.c0.bc0"), callbacks, false);
test.ok(false, "test.bc0 - Did not print to screen correctly");
test.done();
}
exports.testStructs = function(test) {
var result = c0vm.execute(parser.parse("structs.c0.bc0"), callbacks, false);
test.ok(false, "test.bc0 - Did not print to screen correctly");
test.done();
}