diff --git a/test/test.html b/test/test.html index fc176056..d7fc6adf 100644 --- a/test/test.html +++ b/test/test.html @@ -72,7 +72,6 @@ 'compilation' 'comprehensions' 'existence' - 'expressions' 'functions' 'helpers' 'heredocs' diff --git a/test/test_chaining.coffee b/test/test_chaining.coffee index 9ce2486e..2c43bd34 100644 --- a/test/test_chaining.coffee +++ b/test/test_chaining.coffee @@ -7,6 +7,17 @@ result = identityWrap(identityWrap(true))()() ok result +# Should be able to look at prototypes on keywords. +obj = + withAt: -> @::prop + withThis: -> this::prop + proto: + prop: 100 +obj.prototype = obj.proto +eq obj.withAt() , 100 +eq obj.withThis(), 100 + + # Chained accesses split on period/newline, backwards and forwards. str = 'god' diff --git a/test/test_expressions.coffee b/test/test_expressions.coffee deleted file mode 100644 index 9572a6c7..00000000 --- a/test/test_expressions.coffee +++ /dev/null @@ -1,40 +0,0 @@ -# Ensure that we don't wrap Nodes that are "pureStatement" in a closure. -items = [1, 2, 3, "bacon", 4, 5] - -for item in items - break if item is "bacon" - -findit = (items) -> - for item in items - return item if item is "bacon" - -ok findit(items) is "bacon" - - -# When when a closure wrapper is generated for expression conversion, make sure -# that references to "this" within the wrapper are safely converted as well. -obj = { - num: 5 - func: -> - this.result = if false - 10 - else - "a" - "b" - this.num -} - -ok obj.num is obj.func() -ok obj.num is obj.result - - -# Should be able to look at prototypes on keywords. -obj = - withAt: -> @::prop - withThis: -> this::prop - proto: - prop: 100 - -obj.prototype = obj.proto -ok obj.withAt() is 100 -ok obj.withThis() is 100 \ No newline at end of file diff --git a/test/test_returns.coffee b/test/test_returns.coffee index 343669f5..eb2d8e2e 100644 --- a/test/test_returns.coffee +++ b/test/test_returns.coffee @@ -30,4 +30,29 @@ func = -> when 'a' then 42 else return 23 -ok func() is 42 \ No newline at end of file +eq func(), 42 + +# Ensure that we don't wrap Nodes that are "pureStatement" in a closure. +items = [1, 2, 3, "bacon", 4, 5] + +findit = (items) -> + for item in items + return item if item is "bacon" + +ok findit(items) is "bacon" + + +# When a closure wrapper is generated for expression conversion, make sure +# that references to "this" within the wrapper are safely converted as well. +obj = + num: 5 + func: -> + this.result = if false + 10 + else + "a" + "b" + this.num + +eq obj.num, obj.func() +eq obj.num, obj.result