-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: generate Lua 5.1 friendly string escape sequences
Fixes #761
- Loading branch information
1 parent
5163a43
commit 7319958
Showing
3 changed files
with
150 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local util = require("spec.util") | ||
|
||
describe("string literal code generation", function() | ||
it("generates Lua 5.1 compatible escape sequences in string literals", util.gen([[ | ||
local _hex_bytes = "\xDe\xAD\xbE\xef\x05" | ||
local _unicode = "hello \u{4e16}\u{754C}" | ||
local _whitespace_removal = "hello\z | ||
, world!" | ||
local _source_new_lines_get_preserved = 0 | ||
]], [[ | ||
local _hex_bytes = "\222\173\190\239\005" | ||
local _unicode = "hello \228\184\150\231\149\140" | ||
local _whitespace_removal = "hello, world!" | ||
local _source_new_lines_get_preserved = 0 | ||
]])) | ||
|
||
it("does not substitute escape sequences in [[strings]]", util.gen([==[ | ||
local _literal_string = [[ | ||
foo | ||
\000\xee\u{ffffff} | ||
bar | ||
]] | ||
]==], [==[ | ||
local _literal_string = [[ | ||
foo | ||
\000\xee\u{ffffff} | ||
bar | ||
]] | ||
]==])) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters