From 97e1c92eee2558b283aca15ca23a28766ce11079 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 15 May 2017 20:17:02 +0200 Subject: [PATCH 3/4] Add some unit tests --- distribution/manifest | 2 ++ tests/msgs-test.scm | 13 +++++++++++++ tests/msgs.expected | 6 ++++++ tests/runtests.sh | 4 ++++ tests/scrutiny.expected | 2 +- 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/msgs-test.scm create mode 100644 tests/msgs.expected diff --git a/distribution/manifest b/distribution/manifest index 7e9c3adb..8d03aa8a 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -234,6 +234,8 @@ tests/reverser/tags/1.1/reverser.scm tests/rev-app.scm tests/user-pass-tests.scm tests/version-tests.scm +tests/msgs-test.scm +tests/msgs.expected tweaks.scm Makefile Makefile.android diff --git a/tests/msgs-test.scm b/tests/msgs-test.scm new file mode 100644 index 00000000..dd7baf31 --- /dev/null +++ b/tests/msgs-test.scm @@ -0,0 +1,13 @@ +(module boo * + (import scheme) + (define var 42)) +(module foo * + (import scheme chicken boo) +(define-syntax bar + (syntax-rules ())) +(set! bar 42) ;; set!-ing a macro +(set! var 42) ;; set!-ing an imported identifier +(let ((var #f)) (set! var 42)) ;; set!-ing a local variable +(letrec-values ((bar (values)))) ;; shadow a syntax item +(let-syntax ((m (syntax-rules ()))) (set! m 42)) +) diff --git a/tests/msgs.expected b/tests/msgs.expected new file mode 100644 index 00000000..3d77e187 --- /dev/null +++ b/tests/msgs.expected @@ -0,0 +1,6 @@ + +Warning: (msgs-test.scm:8) - assignment to syntax `bar' + +Warning: (msgs-test.scm:9) - assignment to imported value binding `var' + +Warning: (msgs-test.scm:12) - assignment to syntax `m' diff --git a/tests/runtests.sh b/tests/runtests.sh index 16fcb97f..4e7c243a 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -62,6 +62,10 @@ echo "======================================== version tests ..." $compile version-tests.scm ./a.out +echo "======================================== compiler messages tests ..." +$compile -A msgs-test.scm 2>msgs.out +diff $DIFF_OPTS msgs.expected msgs.out + echo "======================================== compiler tests ..." $compile compiler-tests.scm ./a.out diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected index 581aa45b..0641540f 100644 --- a/tests/scrutiny.expected +++ b/tests/scrutiny.expected @@ -1,5 +1,5 @@ -Note: (scrutiny-tests.scm:31) - assignment to imported value binding `car' +Warning: (scrutiny-tests.scm:31) - assignment to imported value binding `car' Note: in local procedure `c', in local procedure `b', -- 2.13.0