1313#  Binary Integer Literals
1414#  Binary notation is understood as would be decimal notation.
1515
16+ toJS  =  (str ) -> 
17+   CoffeeScript .compile  str, bare :  yes 
18+   .replace  / ^ \s + | \s + $ / g' ' #  Trim leading/trailing whitespace
19+ 
1620test  " Parser recognises binary numbers" -> 
1721  eq  4 , 0b100 
1822
23+ test  " Binary literals are compiled to binary literals" -> 
24+   input  =  """ 
25+   a = 0b100 
26+   """  
27+ 
28+   output  =  """ 
29+   var a; 
30+ 
31+   a = 0b100; 
32+   """  
33+ 
34+   eq  toJS (input), output
35+ 
1936#  Decimal Integer Literals
2037
2138test  " call methods directly on numbers" -> 
@@ -24,6 +41,32 @@ test "call methods directly on numbers", ->
2441
2542eq  - 1 , 3  - 4 
2643
44+ test  " Decimal literals are compiled to decimal literals" -> 
45+   input  =  """ 
46+   a = 10 
47+   """  
48+ 
49+   output  =  """ 
50+   var a; 
51+ 
52+   a = 10; 
53+   """  
54+ 
55+   eq  toJS (input), output
56+ 
57+ test  " Decimal literals are compiled to decimal literals" -> 
58+   input  =  """ 
59+   a = 10.1 
60+   """  
61+ 
62+   output  =  """ 
63+   var a; 
64+ 
65+   a = 10.1; 
66+   """  
67+ 
68+   eq  toJS (input), output
69+ 
2770# 764: Numbers should be indexable
2871eq  Number :: toString , 42 [' toString' 
2972
@@ -66,6 +109,19 @@ test "Python-style octal literal notation '0o777'", ->
66109  eq  Number :: toString , 0o777 [' toString' 
67110  eq  Number :: toString , 0o777 .toString 
68111
112+ test  " Octal literals are compiled to octal literals" -> 
113+   input  =  """ 
114+   a = 0o123 
115+   """  
116+ 
117+   output  =  """ 
118+   var a; 
119+ 
120+   a = 0o123; 
121+   """  
122+ 
123+   eq  toJS (input), output
124+ 
69125test  " #2060: Disallow uppercase radix prefixes and exponential notation" -> 
70126  for  char in  [' b' ' o' ' x' ' e' 
71127    program  =  " 0#{ char} " 
0 commit comments