Browse Source

Sol Part 52: This Statement Is False!

Graham Northup 4 years ago
parent
commit
c3d6bdfb33
Signed by: Grissess <grissess@nexusg.org> GPG Key ID: 5D000E6F539376FB
5 changed files with 265 additions and 2 deletions
  1. 1
    0
      .gitignore
  2. 9
    2
      .gitlab-ci.yml
  3. 7
    0
      Makefile
  4. 245
    0
      data/test_out.txt
  5. 3
    0
      solrun.c

+ 1
- 0
.gitignore View File

@@ -11,3 +11,4 @@ iss*
11 11
 *.sol
12 12
 _build
13 13
 doxyxml
14
+valgrind.log

+ 9
- 2
.gitlab-ci.yml View File

@@ -17,8 +17,15 @@ run:
17 17
         - make
18 18
         - echo "exit()" | ./sol r programs/interp.sol
19 19
 
20
-test:
20
+test_boot:
21 21
     stage: test
22 22
     script:
23 23
         - make
24
-        - ./sol r programs/test.sol
24
+        - ./sol r programs/test.sol | tee test_out.txt
25
+        - diff test_out.txt data/test_out.txt
26
+
27
+all_tests:
28
+    stage: test
29
+    script:
30
+        - make
31
+        - make test

+ 7
- 0
Makefile View File

@@ -2,10 +2,17 @@ CFLAGS= -g
2 2
 LDFLAGS= -lm -ldl -lreadline
3 3
 OBJ= lex.yy.o parser.tab.o dsl/seq.o dsl/list.o dsl/array.o dsl/generic.o astprint.o runtime.o gc.o object.o state.o builtins.o solrun.o
4 4
 
5
+.PHONY: all test
6
+
5 7
 all: $(OBJ)
6 8
 	git submodule init && git submodule sync && git submodule update
7 9
 	gcc $(CFLAGS) $? $(LDFLAGS) -o sol
8 10
 
11
+test: all $(sort $(patsubst tests/%.sol,test_%,$(wildcard tests/*.sol)))
12
+
13
+test_%: tests/%.sol
14
+	./sol r $?
15
+
9 16
 %.o: %.c
10 17
 	gcc -c -o $@ $? $(CFLAGS)
11 18
 

+ 245
- 0
data/test_out.txt View File

@@ -0,0 +1,245 @@
1
+--- Empty functions 
2
+None 
3
+--- While loop 
4
+1 
5
+2 
6
+3 
7
+4 
8
+5 
9
+6 
10
+7 
11
+8 
12
+9 
13
+--- Range 
14
+[0, 1, 2, 3, 4] 
15
+--- Iter list 
16
+1 
17
+2 
18
+3 
19
+4 
20
+5 
21
+--- Index list 
22
+0 1 
23
+1 2 
24
+2 3 
25
+3 4 
26
+4 5 
27
+--- mul9 
28
+9 
29
+18 
30
+27 
31
+36 
32
+45 
33
+--- Iter mul9 
34
+0 9 
35
+1 18 
36
+2 27 
37
+3 36 
38
+4 45 
39
+--- Mapgen 
40
+{[10] = ... (0x1409410), [6] = ... (0x1409310), ["this time with spaces"] = 6.283185, ["sublist"] = [1, ... (0x14091d0), 2, 3, 5, 8], ["submap"] = {["health"] = 42.000000, ["stamina"] = 100}, ["string"] = "hello", ["integer"] = ... (0x14091d0)} 
41
+--- Map iter 
42
+10 10 
43
+6 6 
44
+this time with spaces 6.283185 
45
+sublist [1, ... (0x14091d0), 2, 3, 5, 8] 
46
+submap {["health"] = 42.000000, ["stamina"] = 100} 
47
+string hello 
48
+integer 1 
49
+--- try 
50
+{["c"] = <Function>} 
51
+[1, 15] 
52
+{} 
53
+[0, "Undefined method (call on singlet)", [[<Stmt[LIST]>, {["bad"] = <Function bad>, ["x"] = {}}], [<Stmt[RET]>, ... (0x145db20)]]] 
54
+{["c"] = <Function>} 
55
+15 
56
+--- Induced errors 
57
+[0, "lp0 on fire", [[<Stmt[LIST]>, {["raise"] = <Function raise>, ["x"] = ... (0x145e2c0)}], [<Stmt[EXPR]>, ... (0x145f060)]]] 
58
+--- Indexing 
59
+1 
60
+1 
61
+6 
62
+--- Function binding 
63
+8 9 10 
64
+11 12 13 
65
+--- Iterators 
66
+1 
67
+2 
68
+3 
69
+4 
70
+5 
71
+6 
72
+7 
73
+8 
74
+9 
75
+10 
76
+--- Method calls 
77
+1 2 
78
+{["a"] = <Function>} 3 
79
+--- Special methods 
80
+Index {["__call"] = <Function>, ["__setindex"] = <Function>, ["__index"] = <Function>} 3 
81
+Index {["__call"] = <Function>, ["__setindex"] = <Function>, ["__index"] = <Function>} 5 
82
+3 5 
83
+SetIndex {["__call"] = <Function>, ["__setindex"] = <Function>, ["__index"] = <Function>} a 7 
84
+Call {["__call"] = <Function>, ["__setindex"] = <Function>, ["__index"] = <Function>} q r 
85
+q 
86
+{["__setindex"] = {["b"] = 2, ["a"] = 1}, ["__index"] = ... (0x1464400)} 1 2 
87
+{["__setindex"] = {["b"] = 2, ["a"] = 1}, ["__index"] = ... (0x1464400)} {... (0x1465400), ... (0x1465140)} 
88
+--- Data sharing 
89
+{["b"] = [1, 2, 3, 4, 5], ["a"] = ... (0x1465980)} 
90
+{["b"] = [1, 2, 7, "c", 5], ["a"] = ... (0x1465980)} 
91
+{["b"] = [1, 7, "c", "f", "q"], ["a"] = ... (0x1465980)} 
92
+--- Arithmetic structure operations 
93
+abcd 
94
+lolololololololololololololololololololololololololololololololol 
95
+[1, 2, 3, 4, 5] 
96
+[1, 2, 3, ... (0x14091d0), ... (0x1409210), ... (0x1409250), ... (0x14091d0), ... (0x1409210), ... (0x1409250), ... (0x14091d0), ... (0x1409210), ... (0x1409250), ... (0x14091d0), ... (0x1409210), ... (0x1409250)] 
97
+{["c"] = 3, ["b"] = 2, ["a"] = 1} 
98
+--- Map/filter 
99
+[1, 2, 3, 4, 5] 
100
+[3, 6, 9, 12, 15] 
101
+[3, 9, 15] 
102
+--- Map/filter chain 
103
+[3, 9, 15] 
104
+--- Exec/eval 
105
+Hello from exec! 
106
+8 
107
+Hello from subtest! 
108
+--- Modulus 
109
+2 
110
+3 
111
+0 
112
+--- Special function manipulation 
113
+<Function foo> 
114
+<Function bar> 
115
+[1, 2, 3] 
116
+["b", 1, 2, 3] 
117
+--- Function body swapping 
118
+<Function a> 0 
119
+<Function b> 2 
120
+<Stmt[LIST]> 
121
+<Stmt[LIST]> 
122
+<Function a> 2 
123
+<Function b> 0 
124
+<Stmt[LIST]> 
125
+<Function a> 4 
126
+<Function b> 4 
127
+--- More complicated ASTs 
128
+<Function outer> <Stmt[LIST]> [<Stmt[EXPR]>, <Stmt[EXPR]>, <Stmt[RET]>] 
129
+--- Exec- and eval-by-parse 
130
+Hello from parse()! 
131
+8 
132
+--- Mutating ASTs 
133
+<Function f> <Stmt[LIST]> 12 
134
+<Function f> <Stmt[LIST]> 12 
135
+a= 1 , b= 2 
136
+<Function g> <Stmt[LIST]> None 
137
+a= 1 , b= 2 
138
+<Function g> <Stmt[LIST]> None 
139
+--- AST Environments 
140
+"<Stmt[LIST]> 
141
+a is <Function a> and b is <Function b> 
142
+{["b"] = 2, ["a"] = 1} 
143
+a is 1 and b is 2 
144
+{["b"] = 5, ["a"] = 4} 
145
+{["b"] = ["world"], ["a"] = "hello"} 
146
+a is hello and b is ["world"] 
147
+{["b"] = 5, ["a"] = 4} 
148
+{["__index"] = {["b"] = 2, ["a"] = 1}} 
149
+{["b"] = 2, ["a"] = 1} 
150
+a is 1 and b is 2 
151
+{["b"] = 5, ["a"] = 4, ["__index"] = {["b"] = 2, ["a"] = 1}} 
152
+{["b"] = 2, ["a"] = 1} 
153
+--- Basic buffers 
154
+(buffer.fromstring =  <CFunction> ) 
155
+<Buffer @0x1474380 size 14 
156
+(b.get =  <CFunction> ) 
157
+Hello, world! 
158
+QeLlo, world! 
159
+, world! 
160
+1816946001 
161
+1886545252 
162
+derpo, world! 
163
+derpo, world! 
164
+Goodbye! Goodbye! 
165
+"A string!" 
166
+
167
+...is a SOL_STRING 
168
+(buffer.sizeof.ptr =  8 ) 
169
+(buffer.sizeof.int =  4 ) 
170
+(buffer.sizeof.int*2 =  8 ) 
171
+(buffer.sizeof.int*2 + buffer.sizeof.ptr =  16 ) 
172
+...string buffer: <Buffer @0x14743e0> 
173
+...with value: A string! 
174
+--- IO redirection 
175
+A line! 
176
+An object: {["c"] = "turkey", ["b"] = 2, ["a"] = 1} 
177
+Something mysterious :o 
178
+Writing directly to a file :D...restored stdout. 
179
+Buffered output was: 
180
+"" 
181
+
182
+...second time. 
183
+Hey there! 
184
+lolololololololololololololololololololololololololololololololol 
185
+...restored. 
186
+Output was: 
187
+"" 
188
+
189
+--- Substrings 
190
+"This is a test!" 
191
+
192
+"his is a test" 
193
+
194
+"s is a te" 
195
+
196
+"s " 
197
+
198
+"s is a t" 
199
+
200
+"" 
201
+
202
+--- Splitting 
203
+"This is a test!" 
204
+
205
+["This", "is", "a", "test!"] 
206
+
207
+["Th", "s ", "s a test!"] 
208
+
209
+["This is a test!"] 
210
+
211
+["Th", "s ", "s ", " t", "st!"] 
212
+
213
+"This" "string" 
214
+
215
+"is" "string" 
216
+
217
+"a" "string" 
218
+
219
+"test!" "string" 
220
+
221
+--- Continue/break 
222
+0 
223
+1 
224
+2 
225
+3 
226
+4 
227
+5 
228
+--- 
229
+1 
230
+3 
231
+5 
232
+7 
233
+9 
234
+--- Control expressions 
235
+1 is true 
236
+0 is false 
237
+[1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018] 
238
+( 0 ) 
239
+( 1 ) 
240
+( 2 ) 
241
+( 3 ) 
242
+( 4 ) 
243
+( 5 ) 
244
+5 
245
+--- All done! 

+ 3
- 0
solrun.c View File

@@ -67,6 +67,9 @@ int main(int argc, char **argv) {
67 67
 		printf("Toplevel return: ");
68 68
 		ob_print(state.ret);
69 69
 		printf("\n");
70
+		if(sol_is_int(state.ret)) {
71
+			result = state.ret->ival;
72
+		}
70 73
 	}
71 74
 	st_free(program);
72 75
 	sol_state_cleanup(&state);

Loading…
Cancel
Save