mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
defer: + is:
This commit is contained in:
parent
5105ab2351
commit
62be7a78f1
2 changed files with 38 additions and 1 deletions
|
@ -52,4 +52,14 @@
|
|||
: endcase ( #branches #branchesi*a -- ) immediate 0 do resolve loop ;
|
||||
|
||||
var: exit.prim ( primitive exit - in case some word needs to override )
|
||||
` exit exit.prim !
|
||||
` exit exit.prim !
|
||||
|
||||
: nop ;
|
||||
: defer:
|
||||
word create
|
||||
['] lit ,
|
||||
['] nop ,
|
||||
['] exec ,
|
||||
['] exit , ;
|
||||
|
||||
: is: ( xt -- ) ` 'longValue' jvm-call-method 1+ ! ;
|
|
@ -1139,6 +1139,33 @@ public class FclTest {
|
|||
assertEquals(42, evalPop(" ': tst 42 ; tst' eval").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsetDefer() {
|
||||
eval("defer: xx");
|
||||
eval("xx");
|
||||
assertEquals(0, fcl.stackSize());
|
||||
eval(": tst xx ;");
|
||||
assertEquals(0, fcl.stackSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefer() { // only works for colon defs and not for primitives
|
||||
eval("defer: d1");
|
||||
eval("defer: d2");
|
||||
eval(": tst d1 d2 + ;");
|
||||
eval(": i1 11 ;");
|
||||
eval(": i2 22 ;");
|
||||
eval(": i3 42 ;");
|
||||
eval("` i1 is: d1");
|
||||
eval("` i2 is: d2");
|
||||
assertEquals(11, evalPop("d1").intValue());
|
||||
assertEquals(22, evalPop("d2").intValue());
|
||||
assertEquals(33, evalPop("tst").intValue());
|
||||
eval("` i3 is: d1");
|
||||
assertEquals(42, evalPop("d1").intValue());
|
||||
assertEquals(42+22, evalPop("tst").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHttpHeaders() {
|
||||
assertEquals(
|
||||
|
|
Loading…
Reference in a new issue