Moving all of the 'test_issues' tests from 'hiatus' to their proper locations...

This commit is contained in:
Jeremy Ashkenas
2010-05-31 15:13:48 -04:00
parent 90f96af720
commit 39b8bbc39b
4 changed files with 46 additions and 54 deletions

View File

@@ -93,4 +93,24 @@ SubClass: ->
SuperClass extends TopClass
SubClass extends SuperClass
ok (new SubClass()).prop is 'top-super-sub'
ok (new SubClass()).prop is 'top-super-sub'
# '@' referring to the current instance, and not being coerced into a call.
class ClassName
am_i: ->
@ instanceof ClassName
obj: new ClassName()
ok obj.am_i()
# super() calls in constructors of classes that are defined as object properties.
class Hive
constructor: (name) -> @name: name
class Hive.Bee extends Hive
constructor: (name) -> super name
maya: new Hive.Bee 'Maya'
ok maya.name is 'Maya'

View File

@@ -1,51 +0,0 @@
# Issue #381: Reserved words can be used as object properties.
obj: {
is: -> 1
of: 'many'
}
ok obj.is() is 1
ok obj.of is 'many'
# Issue #380: problem with @ and instanceof
class ClassName
am_i: ->
@ instanceof ClassName
obj: new ClassName()
ok obj.am_i()
# Issue #383: Numbers that start with . not recognized
value: .25 + .75
ok value is 1
value: 0.0 + -.25 - -.75 + 0.0
ok value is 0.5
deepEqual [0..10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
deepEqual [0...10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# Issue #390: super() calls in constructor of classes that are defined as object properties
class Hive
constructor: (name) -> @name: name
class Hive.Bee extends Hive
constructor: (name) -> super name
maya: new Hive.Bee('Maya')
ok maya.name is 'Maya'
# Issue #397: Can't use @variable in switch in instance method
obj: {
value: true
fn: ->
result: switch @value
when true then 'Hello!'
else 'Bye!'
}
ok obj.fn() is 'Hello!'

View File

@@ -14,6 +14,17 @@ neg: (3 -4)
ok neg is -1
# Decimal number literals.
value: .25 + .75
ok value is 1
value: 0.0 + -.25 - -.75 + 0.0
ok value is 0.5
# Decimals don't interfere with ranges.
ok [0..10].join(' ') is '0 1 2 3 4 5 6 7 8 9 10'
ok [0...10].join(' ') is '0 1 2 3 4 5 6 7 8 9'
func: ->
return if true
@@ -78,8 +89,8 @@ ok moe.hello() is 'Hello Moe'
obj: {
'is': -> yes,
'not': -> no,
is: -> yes,
'not': -> no,
}
ok obj.is()

View File

@@ -71,3 +71,15 @@ result: switch
else 3
ok result is 2
# Should be able to use "@properties" within the switch clause.
obj: {
num: 101
func: ->
switch @num
when 101 then '101!'
else 'other'
}
ok obj.func() is '101!'