Skip to content

Commit

Permalink
add raw string syntax-extension to unit tests #321
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 26, 2024
1 parent 1474957 commit 42d0a89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18.1-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
[![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&e4274f7b300c563d1f26f6a3e61f0483)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&9f65c95b7f6055b3d1a1bccc49ad59d6)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips)
Expand Down
19 changes: 18 additions & 1 deletion tests/parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@

(unset-special! "#nil")

(set-special! "$" 'raw-string lips.specials.SYMBOL)

(define (raw-string)
(if (char=? (peek-char) #\")
(begin
(read-char)
(let loop ((result (vector)) (char (peek-char)))
(read-char)
(if (char=? char #\")
(apply string (vector->list result))
(loop (vector-append result (vector char)) (peek-char)))))))

(define parser/t9 $"foo \ bar")

(unset-special! "$")

(test "parser: #!fold-case"
(lambda (t)
(define foo 10)
Expand All @@ -75,7 +91,8 @@
(t.is parser/t5 ':foo)
(t.is parser/t6 27)
(t.is parser/t7 '(let ((x 3)) (let ((.x x)) (* .x .x .x))))
(t.is parser/t8 '(() () () () ()))))
(t.is parser/t8 '(() () () () ()))
(t.is parser/t9 "foo \\ bar")))

(test "parser: escape hex literals"
(lambda (t)
Expand Down

0 comments on commit 42d0a89

Please sign in to comment.