Diff
Not logged in

Differences From Artifact [cdb82702a34f8def]:

To Artifact [62b3543f769fc9c9]:


175 175 assert_eq( r.val, new IntValue(BigInt(21+21*21)) ); 176 176 assert_eq( r.ctx.get("x","@val"), new IntValue(BigInt(21+21*21)) ); 177 177 assert_nothrow( r.ctx.get("x","@val") ); 178 178 assert_throw!RuntimeException( r.ctx.get("y","@val") ); 179 179 } 180 180 unittest 181 181 { 182 - assert_nothrow( evalString(`print("Hello, world!");`) ); 183 - assert_nothrow( evalString(`print(fun(){});`) ); 184 -} 185 -unittest 186 -{ 187 182 assert_eq( evalString(`let x=1; let y=(let x=2); x`).val, new IntValue(BigInt(1)) ); 188 183 assert_eq( evalString(`let x=1; let y=(let x=2;fun(){x}); y()`).val, new IntValue(BigInt(2)) ); 189 184 } 190 185 unittest 191 186 { 192 187 assert_eq( evalString(`@a x=1; @b x=2; @a(x)`).val, new IntValue(BigInt(1)) ); 193 188 assert_eq( evalString(`@a x=1; @b x=2; @b(x)`).val, new IntValue(BigInt(2)) ); 194 189 assert_eq( evalString(`let x=1; let _ = (@a x=2;2); x`).val, new IntValue(BigInt(1)) ); 195 190 assert_throw!Error( evalString(`let x=1; let _ = (@a x=2;2); @a(x)`) ); 196 191 } 197 192 198 193 unittest 199 194 { 200 - assert_nothrow( evalString(`var fac = fun(x){ 201 - 1; 202 - }; 203 - print(fac(3));`)); 204 - assert_nothrow( evalString(`var fac = fun(x){ 195 + assert_eq( evalString(`var fac = fun(x){ 205 196 if(x) 206 197 { x*fac(x-1); } 207 198 else 208 199 { 1; }; 209 200 }; 210 - print(fac(10));`)); 211 - assert_nothrow( evalString(`var fib = fun(x){ 201 + fac(10);`).val, new IntValue(BigInt(10*9*8*5040))); 202 + assert_eq( evalString(`var fib = fun(x){ 212 203 if(x<2) 213 204 { 1; } 214 205 else 215 206 { fib(x-1) + fib(x-2); }; 216 207 }; 217 - print(fib(10));`)); 208 + fib(10);`).val, new IntValue(BigInt(89))); 218 209 }