mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Merge remote-tracking branch 'origin/master'
Conflicts: lib/coffee-script/coffee-script.js lib/coffee-script/lexer.js lib/coffee-script/parser.js src/lexer.coffee
This commit is contained in:
@@ -365,3 +365,13 @@ test '#2213: invocations within destructured parameters', ->
|
||||
throws -> CoffeeScript.compile '({a()})->'
|
||||
throws -> CoffeeScript.compile '({a:b()})->'
|
||||
throws -> CoffeeScript.compile '({a:b.c()})->'
|
||||
|
||||
test '#2532: compound assignment with terminator', ->
|
||||
doesNotThrow -> CoffeeScript.compile """
|
||||
a = "hello"
|
||||
a +=
|
||||
"
|
||||
world
|
||||
!
|
||||
"
|
||||
"""
|
||||
|
||||
@@ -676,3 +676,7 @@ test "#2052: classes should work in strict mode", ->
|
||||
class A
|
||||
catch e
|
||||
ok no
|
||||
|
||||
test "#2630: class bodies can't reference arguments", ->
|
||||
throws ->
|
||||
CoffeeScript.compile('class Test then arguments')
|
||||
|
||||
@@ -199,10 +199,17 @@ test "#2258: allow whitespace-style parameter lists in function definitions", ->
|
||||
a, b, c
|
||||
) -> c
|
||||
eq func(1, 2, 3), 3
|
||||
|
||||
|
||||
func = (
|
||||
a
|
||||
b
|
||||
c
|
||||
) -> b
|
||||
eq func(1, 2, 3), 2
|
||||
eq func(1, 2, 3), 2
|
||||
|
||||
test "#2621: fancy destructuring in parameter lists", ->
|
||||
func = ({ prop1: { key1 }, prop2: { key2, key3: [a, b, c] } }) ->
|
||||
eq(key2, 'key2')
|
||||
eq(a, 'a')
|
||||
|
||||
func({prop1: {key1: 'key1'}, prop2: {key2: 'key2', key3: ['a', 'b', 'c']}})
|
||||
|
||||
48
test/literate.litcoffee
Normal file
48
test/literate.litcoffee
Normal file
@@ -0,0 +1,48 @@
|
||||
Literate CoffeeScript Test
|
||||
--------------------------
|
||||
|
||||
comment comment
|
||||
|
||||
test "basic literate CoffeeScript parsing", ->
|
||||
ok yes
|
||||
|
||||
now with a...
|
||||
|
||||
test "broken up indentation", ->
|
||||
|
||||
... broken up ...
|
||||
|
||||
do ->
|
||||
|
||||
... nested block.
|
||||
|
||||
ok yes
|
||||
|
||||
Code in `backticks is not parsed` and...
|
||||
|
||||
test "comments in indented blocks work", ->
|
||||
do ->
|
||||
do ->
|
||||
# Regular comment.
|
||||
|
||||
###
|
||||
Block comment.
|
||||
###
|
||||
|
||||
ok yes
|
||||
|
||||
Regular [Markdown](http://example.com/markdown) features, like links
|
||||
and unordered lists, are fine:
|
||||
|
||||
* I
|
||||
|
||||
* Am
|
||||
|
||||
* A
|
||||
|
||||
* List
|
||||
|
||||
Tabs work too:
|
||||
|
||||
test "tabbed code", ->
|
||||
ok yes
|
||||
@@ -28,6 +28,12 @@ test "operators should respect new lines as spaced", ->
|
||||
test "multiple operators should space themselves", ->
|
||||
eq (+ +1), (- -1)
|
||||
|
||||
test "compound operators on successive lines", ->
|
||||
a = 1
|
||||
a +=
|
||||
1
|
||||
eq a, 2
|
||||
|
||||
test "bitwise operators", ->
|
||||
eq 2, (10 & 3)
|
||||
eq 11, (10 | 3)
|
||||
@@ -275,16 +281,16 @@ test "#2155 ... conditional assignment to a closure", ->
|
||||
func = -> x ?= (-> if true then 'hi')
|
||||
func()
|
||||
eq x(), 'hi'
|
||||
|
||||
|
||||
test "#2197: Existential existential double trouble", ->
|
||||
counter = 0
|
||||
func = -> counter++
|
||||
func()? ? 100
|
||||
eq counter, 1
|
||||
|
||||
|
||||
test "#2567: Optimization of negated existential produces correct result", ->
|
||||
a = 1
|
||||
ok !(!a?)
|
||||
ok !b?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user