File tree Expand file tree Collapse file tree 4 files changed +52
-8
lines changed Expand file tree Collapse file tree 4 files changed +52
-8
lines changed Original file line number Diff line number Diff line change 41
41
* ** DONE** atoms
42
42
* ** DONE** exceptions
43
43
* ** DONE** allow generated scripts to run in browser (avoid require)
44
- * ** DONE** fnth (fn bound to this) ** TODO ** test
45
- * ** DONE** be consistent in binding to this ** TODO ** test
44
+ * ** DONE** fnth (fn bound to this)
45
+ * ** DONE** be consistent in binding to this
46
46
47
47
* ** DONE** testing
48
48
49
49
* example with node
50
- * example with React
50
+ * ** DONE ** example with React
51
51
52
52
## 0.3.0 Add the nice to have
53
53
54
54
* destructuring
55
+ * multiline strings
55
56
* CPS modeled after tame.js
56
57
In tame we would have something like
57
58
(await (setTimeout (defer) 100))
74
75
* named parameters and defaults
75
76
* optional arguments to functions (catpured in a vector)
76
77
* regular expressions
77
- * expression problem
78
+ * implement a REPL
78
79
* additional functions/forms
79
80
* condp case
80
81
* for (comprehension)
Original file line number Diff line number Diff line change @@ -385,7 +385,7 @@ macro _sexpr {
385
385
_sexpr $fn . apply ( this , _sexpr ( clj_to_js $args ) )
386
386
}
387
387
388
- rule { ( bind $fn $obj ) } => {
388
+ rule { ( bind $obj $fn ) } => {
389
389
_sexpr $fn . bind ( $obj )
390
390
}
391
391
@@ -678,6 +678,10 @@ macro ki {
678
678
} ( ) ) ; }
679
679
}
680
680
681
+ //case {_ macro ($x ...) ($y ...)} => {
682
+ // return #{};
683
+ //}
684
+
681
685
case { $ki ( $x . . . ) } => {
682
686
683
687
var Token = {
Original file line number Diff line number Diff line change @@ -385,7 +385,7 @@ macro _sexpr {
385
385
_sexpr $fn . apply ( this , _sexpr ( clj_to_js $args ) )
386
386
}
387
387
388
- rule { ( bind $fn $obj ) } => {
388
+ rule { ( bind $obj $fn ) } => {
389
389
_sexpr $fn . bind ( $obj )
390
390
}
391
391
@@ -678,6 +678,10 @@ macro ki {
678
678
} ( ) ) ; }
679
679
}
680
680
681
+ //case {_ macro ($x ...) ($y ...)} => {
682
+ // return #{};
683
+ //}
684
+
681
685
case { $ki ( $x . . . ) } => {
682
686
683
687
var Token = {
Original file line number Diff line number Diff line change @@ -548,8 +548,8 @@ describe("bind", function() {
548
548
ki ( do
549
549
( def a { :a 1 :b 2 } )
550
550
( defn f [ ] ( get this :a ) ) )
551
- expect ( ki ( ( bind f a ) ) ) . to . eql ( 1 ) ;
552
- expect ( ki ( ( bind ( fn [ ] ( get this :a ) ) a ) ) ) . to . eql ( 1 ) ;
551
+ expect ( ki ( ( bind a f ) ) ) . to . eql ( 1 ) ;
552
+ expect ( ki ( ( bind a ( fn [ ] ( get this :a ) ) ) ) ) . to . eql ( 1 ) ;
553
553
} ) ;
554
554
555
555
} ) ;
@@ -613,6 +613,41 @@ describe("exceptions", function() {
613
613
614
614
} ) ;
615
615
616
+ describe ( "this and fnth" , function ( ) {
617
+
618
+ it ( "should handle binding this fn-wise correctly from within IIFN" , function ( ) {
619
+
620
+ ki require core
621
+
622
+ ki ( defn somefn [ ] ( letv [ a 1 ] this . someprop ) ) ;
623
+ var bar = { someprop : 1 } ;
624
+ var baz = { } ;
625
+
626
+ expect ( ki ( ( bind bar somefn ) ) ) . to . eql ( 1 ) ;
627
+ expect ( ki ( ( bind baz somefn ) ) ) . to . eql ( undefined ) ;
628
+ expect ( ki ( somefn ) ) . to . eql ( undefined ) ;
629
+
630
+ } ) ;
631
+
632
+ it ( "should allow a shorthand notation for defining a fn bound to the enclosing this" , function ( ) {
633
+
634
+ ki require core
635
+
636
+ var fn1 , fn2 ;
637
+ ki ( do
638
+ ( js this . jee = 1 )
639
+ ( letv [ a ( fn [ ] this . jee )
640
+ b ( fnth [ ] this . jee ) ]
641
+ ( js fn1 = a )
642
+ ( js fn2 = b ) ) ) ;
643
+
644
+ expect ( fn1 . bind ( { jee : 2 } ) ( ) ) . to . eql ( 2 ) ;
645
+ expect ( fn2 . bind ( { jee : 2 } ) ( ) ) . to . eql ( 1 ) ;
646
+
647
+ } ) ;
648
+
649
+ } ) ;
650
+
616
651
describe ( "str" , function ( ) {
617
652
618
653
it ( "should allow to concatenate strings and literals" , function ( ) {
You can’t perform that action at this time.
0 commit comments