From 42d0a8960c3aaaf6b24724bd156fb6c1d935f4ac Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 26 Mar 2024 23:42:32 +0100 Subject: [PATCH] add raw string syntax-extension to unit tests #321 --- README.md | 2 +- tests/parser.scm | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 410c5ee0..eaddff99 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/tests/parser.scm b/tests/parser.scm index 2d5b235e..2de6eccb 100644 --- a/tests/parser.scm +++ b/tests/parser.scm @@ -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) @@ -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)