Closed stefanos82 closed 3 years ago
Another observation is how single quotes when used are interpreted as double quotes.
This code expect_ast("return ''", n.Block{n.Return{n.String{''}}})
is been interpreted as
Block {
Return {
String {
""
}
}
}
and it's no different than expect_ast('return ""', n.Block{n.Return{n.String{""}}})
Eemmm...seems like there's an issue in escape sequence
ast as well:
it("escape sequence", function()
expect_ast([[return "\a"]], n.Block{n.Return{n.String{"\a"}}})
expect_ast([[return "\b"]], n.Block{n.Return{n.String{"\b"}}})
expect_ast([[return "\f"]], n.Block{n.Return{n.String{"\f"}}})
expect_ast([[return "\n"]], n.Block{n.Return{n.String{"\n"}}})
expect_ast([[return "\r"]], n.Block{n.Return{n.String{"\r"}}})
expect_ast([[return "\t"]], n.Block{n.Return{n.String{"\t"}}})
expect_ast([[return "\v"]], n.Block{n.Return{n.String{"\v"}}})
expect_ast([[return "\\"]], n.Block{n.Return{n.String{"\\"}}})
expect_ast([[return "\'"]], n.Block{n.Return{n.String{"\'"}}})
expect_ast([[return "\""]], n.Block{n.Return{n.String{"\""}}})
...
I have tested it with:
return [[return "\a"]]
return [[return "\b"]]
return [[return "\f"]]
return [[return "\n"]]
return [[return "\r"]]
return [[return "\t"]]
return [[return "\v"]]
return [[return "\\"]]
return [[return "\'"]]
return [[return "\""]]
and produced the following output:
Block {
Return {
String {
"return \"\\a\""
}
},
Return {
String {
"return \"\\b\""
}
},
Return {
String {
"return \"\\f\""
}
},
Return {
String {
"return \"\\n\""
}
},
Return {
String {
"return \"\\r\""
}
},
Return {
String {
"return \"\\t\""
}
},
Return {
String {
"return \"\\v\""
}
},
Return {
String {
"return \"\\\\\""
}
},
Return {
String {
"return \"\\'\""
}
},
Return {
String {
"return \"\\\"\""
}
}
}
There aren't any issues there, all the above outputs is working as expected.
I'm studying
syntaxdefs_spec
and have found a mismatch between some tests.For these two
expect_ast()
which I tested in my demo, I got different output:the culprit
the output for
return [[\ntest]]
the output for
return [[\ntest\n]]