Skip to content

Commit

Permalink
yet another small cleanup and obscure bugfix related to #2333
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed May 16, 2012
1 parent 1810d9f commit df54c63
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 62 deletions.
13 changes: 1 addition & 12 deletions lib/coffee-script/helpers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 17 additions & 32 deletions lib/coffee-script/repl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/nodes.coffee
Expand Up @@ -806,13 +806,10 @@ exports.Obj = class Obj extends Base
quoteNormalised = switch s[0]
when '"' then s[1...-1].replace /\\"/g, '"'
when "'" then s[1...-1].replace /\\'/g, "'"
octalNormalised = quoteNormalised.replace /\\([0abtnvfr\n\\])/, (match, c) ->
map =
0:"\0", a:"\a", b:"\b", t:"\t", n:"\n", v:"\v",
f:"\f", r:"\r", "\\":"\\", "\n":""
map[c]
octalNormalised.replace /\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/i, (match, h, u) ->
escapeNormalised = quoteNormalised.replace /\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/ig, (match, h, u) ->
String.fromCharCode parseInt (h ? u), 16
escapeNormalised.replace /\\([\s\S])/g, (match, c) ->
{0:"\0", b:"\b", t:"\t", n:"\n", v:"\v", f:"\f", r:"\r", "\\":"\\", "\n":""}[c] ? c
isDuplicate = (x) ->
mx = x.match /^['"]/
(y) ->
Expand Down
7 changes: 5 additions & 2 deletions test/strict.coffee
Expand Up @@ -70,10 +70,13 @@ test "#2333: more duplicate property prohibitions", ->
strict '{.1:0, 1e-1:0}'
strict '{100:0, 1e2:0}'
strict '{"\\0":0, "\\x00":0}'
strict '{"\\n":0, "\\x0A":0}'
strict '{"\\a", "\\u0061"}'
strict '{"\\t":0, "\\x09":0}'
strict '{"c":0, "\\c":0}'
strict '{"\\\\":0, "\\x5c":0}'
strict "{'\n0':0, 0:0}"
strict '{"\n0":0, 0:0}'
strict "{'\\\n0':0, 0:0}"
strict '{"\\\n0":0, "\\x00":0}'
strict 'a = 0; {a, "a":0}'
strict "{'\\'a':0, \"'a\":0}"
strict "{'\\\\a':0, '\\\\a':0}"
Expand Down

1 comment on commit df54c63

@michaelficarra
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What could have happened with this commit? There are changes to /lib/coffee-script/repl.js? Weren't those already pushed earlier? I see changes from 5c8eef2...8dcbe54. Weird...

Please sign in to comment.