Diff
Not logged in

Differences From Artifact [cdb82702a34f8def]:

To Artifact [62b3543f769fc9c9]:


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