aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-30 02:33:01 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 21:17:22 +0200
commitfc9f889b376ccec4a795ca87874f8efa22321726 (patch)
treef5bd1aabbe5af107e797c628ab6ab61e378864d3 /tests
parentC parser add basic float support. (diff)
downloadcalp-fc9f889b376ccec4a795ca87874f8efa22321726.tar.gz
calp-fc9f889b376ccec4a795ca87874f8efa22321726.tar.xz
Fix escape sequences in chars and strings.
Diffstat (limited to 'tests')
-rw-r--r--tests/test/cpp.scm25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/test/cpp.scm b/tests/test/cpp.scm
index 32072932..fa767fe3 100644
--- a/tests/test/cpp.scm
+++ b/tests/test/cpp.scm
@@ -514,23 +514,38 @@
(test-group "String with only escape"
(let ((form (string #\" #\\ #\" #\")))
- (test-equal `(string "\"") (lex form))
+ (test-equal `(string (escaped-char "\"")) (lex form))
(test-equal #vu8(34 0) (run form))))
(test-group "String with escape at start"
(let ((form (string #\" #\\ #\" #\a #\")))
- (test-equal `(string "\"a") (lex form))
+ (test-equal `(string (escaped-char "\"") "a") (lex form))
(test-equal #vu8(34 #x61 0) (run form))))
(test-group "String with escape at end"
(let ((form (string #\" #\a #\\ #\" #\")))
- (test-equal `(string "a\"") (lex form))
+ (test-equal `(string "a" (escaped-char "\"")) (lex form))
(test-equal #vu8(#x61 34 0) (run form))))
(test-group "String with escape in middle"
(let ((form (string #\" #\a #\\ #\" #\b #\")))
- (test-equal `(string "a\"b") (lex form))
- (test-equal #vu8(#x61 34 #x62 0) (run form)))))
+ (test-equal `(string "a" (escaped-char "\"") "b") (lex form))
+ (test-equal #vu8(#x61 34 #x62 0) (run form))))
+
+ ;; \e is semi non-standard
+ (test-group "String with bakslash-e esacpe"
+ (let ((form "\"\\e\""))
+ (test-equal '(string (escaped-char "e")) (lex form))
+ (test-equal #vu8(#x1b 0) (run form))))
+
+ (test-group "String with byte secquence escape"
+ (let ((form "\"\\xf0\\x9f\\x92\\xa9\""))
+ (test-equal '(string (escaped-char (base-16-char "f0"))
+ (escaped-char (base-16-char "9f"))
+ (escaped-char (base-16-char "92"))
+ (escaped-char (base-16-char "a9")))
+ (lex form))
+ (test-equal #vu8(#xf0 #x9f #x92 #xa9 0) (run form)))))
(test-group "__asm__"
(let ((form "__asm__(\".globl \" __XSTRING(sym))"))