Support Infinity
Unclear if this was intentional or not but is Infinity supported?
It seems to oddly hang when parsed:
> coffee
coffee> c = require 'cson-safe'
{ stringify: [Function], parse: [Function] }
coffee> c.parse('Infinity')
...
Since we allow 1/0, -1/0 it might be good to also support Infinity for consistency. Other pro arguments include that JSON can include Infinity (though it's kind of messy since it doesn't serialize properly):
coffee> JSON.parse('{ "x": 1.0e+1024 }')
{ x: Infinity }
coffee> JSON.parse('{ "x": -1.0e+1024 }')
{ x: -Infinity }
coffee> JSON.stringify(JSON.parse('{ "x": -1.0e+1024 }'))
'{"x":null}'
Related to this would be the question if NaN should be supported. I can't come up with a way to produce the same value in JSON, so I'm tending to make it fail (but definitely adding a test for it as well).
Just curious, does the snippet I provided hang for you as well when run?
Was expecting it to hang, based on your description - but (from inside this project):
> coffee
coffee> require('./').parse('Infinity')
SyntaxError: Syntax error on line 1, column 1: Unexpected Identifier
Cool, thanks for letting me know, must be something else going on.
Adding a test for now to have it covered (#3). The test passes on my machine (0.10.24) and on travis (0.10.25, 0.8.26, 0.11.11).
@kevinsawicki it doesn’t “hang” for you—you’ve run into https://github.com/jashkenas/coffee-script/issues/3388.