klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 522c7efcbec5a3e3602620fe4d47f18194928276
parent 2680a2f652f80156f2c3baf1ecaf4d6306e1c1b7
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed,  7 Dec 2011 03:32:15 -0300

Added tests for keywords and conversion between string, symbol and keyword objects.

Diffstat:
Msrc/tests/combiners.k | 24++++++++++++------------
Asrc/tests/keywords.k | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/tests/symbols.k | 24++++++++++++++++++++----
Msrc/tests/test-all.k | 1+
4 files changed, 94 insertions(+), 16 deletions(-)

diff --git a/src/tests/combiners.k b/src/tests/combiners.k @@ -39,11 +39,11 @@ (enc #inert)))) ($check-not-predicate (operative? (memoize #inert))) ($check-not-predicate (operative? 1)) -;($check-not-predicate (operative? 1.0)) +($check-not-predicate (operative? 1.0)) ($check-not-predicate (operative? #e+infinity)) -;($check-not-predicate (operative? #i+infinity)) -;($check-not-predicate (operative? #undefined)) -;($check-not-predicate (operative? #real-with-no-primary-value)) +($check-not-predicate (operative? #i+infinity)) +($check-not-predicate (operative? #undefined)) +($check-not-predicate (operative? #real)) ($check-not-predicate (operative? "string")) ($check-not-predicate (operative? #\a)) ($check-not-predicate (operative? (get-current-input-port))) @@ -63,11 +63,11 @@ (enc #inert)))) ($check-not-predicate (applicative? (memoize #inert))) ($check-not-predicate (applicative? 1)) -;($check-not-predicate (applicative? 1.0)) +($check-not-predicate (applicative? 1.0)) ($check-not-predicate (applicative? #e+infinity)) -;($check-not-predicate (applicative? #i+infinity)) -;($check-not-predicate (applicative? #undefined)) -;($check-not-predicate (applicative? #real-with-no-primary-value)) +($check-not-predicate (applicative? #i+infinity)) +($check-not-predicate (applicative? #undefined)) +($check-not-predicate (applicative? #real)) ($check-not-predicate (applicative? "string")) ($check-not-predicate (applicative? #\a)) ($check-not-predicate (applicative? (get-current-input-port))) @@ -86,11 +86,11 @@ (enc #inert)))) ($check-not-predicate (combiner? (memoize #inert))) ($check-not-predicate (combiner? 1)) -;($check-not-predicate (combiner? 1.0)) +($check-not-predicate (combiner? 1.0)) ($check-not-predicate (combiner? #e+infinity)) -;($check-not-predicate (combiner? #i+infinity)) -;($check-not-predicate (combiner? #undefined)) -;($check-not-predicate (combiner? #real-with-no-primary-value)) +($check-not-predicate (combiner? #i+infinity)) +($check-not-predicate (combiner? #undefined)) +($check-not-predicate (combiner? #real)) ($check-not-predicate (combiner? "string")) ($check-not-predicate (combiner? #\a)) ($check-not-predicate (combiner? (get-current-input-port))) diff --git a/src/tests/keywords.k b/src/tests/keywords.k @@ -0,0 +1,60 @@ +;; check.k & test-helpers.k should be loaded + +;;; +;;; Basic Functionality +;;; + +;; keyword? +($check-predicate (applicative? keyword?)) + +($check-predicate (keyword?)) +($check-predicate (keyword? #:s1)) +($check-predicate (keyword? #:s1 #:s2 #:s3)) +($check-predicate (keyword? #:s1 . #0=(#:s2 . #0#))) + +($check-not-predicate (keyword? ())) +($check-not-predicate (keyword? (cons () ()))) +($check-not-predicate (keyword? #ignore)) +($check-not-predicate (keyword? (make-environment))) +($check-not-predicate (keyword? #inert)) +($check-not-predicate (keyword? wrap)) +($check-not-predicate (keyword? (call/cc ($lambda (c) c)))) +($check-not-predicate (keyword? ($let (((enc . #ignore) + (make-encapsulation-type))) + (enc #inert)))) +($check-not-predicate (keyword? (memoize #inert))) +($check-not-predicate (keyword? 1)) +($check-not-predicate (keyword? 1.0)) +($check-not-predicate (keyword? #e+infinity)) +($check-not-predicate (keyword? #i+infinity)) +($check-not-predicate (keyword? #undefined)) +($check-not-predicate (keyword? #real)) +($check-not-predicate (keyword? "string")) +($check-not-predicate (keyword? #\a)) +($check-not-predicate (keyword? (get-current-input-port))) +($check-not-predicate (keyword? ((unwrap list) . symbol))) + +;; keyword->string +($check-predicate (applicative? keyword->string)) +($check equal? (keyword->string #:keyword) "keyword") + +;; string->keyword +($check-predicate (applicative? string->keyword)) +($check equal? (string->keyword "keyword") #:keyword) +($check equal? (keyword->string (string->keyword "keyword")) "keyword") + +;; keyword->symbol +($check-predicate (applicative? keyword->symbol)) +($check equal? (keyword->symbol #:keyword) ((unwrap list) . keyword)) + +;; symbol->keyword +($check-predicate (applicative? symbol->keyword)) +($check equal? (symbol->keyword ((unwrap list) . keyword)) #:keyword) +($check equal? (keyword->symbol (symbol->keyword ((unwrap list) . keyword))) + ((unwrap list) . keyword)) + +;;; +;;; Eq?-ness & Equal?-ness +;;; +($check-predicate (eq? #:keyword #:keyword)) +($check-predicate (equal? #:keyword #:keyword)) +\ No newline at end of file diff --git a/src/tests/symbols.k b/src/tests/symbols.k @@ -28,11 +28,26 @@ (enc #inert)))) ($check-not-predicate (symbol? (memoize #inert))) ($check-not-predicate (symbol? 1)) -;($check-not-predicate (symbol? 1.0)) +($check-not-predicate (symbol? 1.0)) ($check-not-predicate (symbol? #e+infinity)) -;($check-not-predicate (symbol? #i+infinity)) -;($check-not-predicate (symbol? #undefined)) -;($check-not-predicate (symbol? #real-with-no-primary-value)) +($check-not-predicate (symbol? #i+infinity)) +($check-not-predicate (symbol? #undefined)) +($check-not-predicate (symbol? #real)) ($check-not-predicate (symbol? "string")) ($check-not-predicate (symbol? #\a)) ($check-not-predicate (symbol? (get-current-input-port))) + +;; symbol->string +($check-predicate (applicative? symbol->string)) +($check equal? (symbol->string ((unwrap list) . symbol)) "symbol") + +;; string->symbol +($check-predicate (applicative? string->symbol)) +($check equal? (string->symbol "symbol") ((unwrap list) . symbol)) +($check equal? (symbol->string (string->symbol "symbol")) "symbol") + +;;; +;;; Eq?-ness & Equal?-ness +;;; +($check-predicate (eq? ((unwrap list) . symbol) ((unwrap list) . symbol))) +($check-predicate (equal? ((unwrap list) . symbol) ((unwrap list) . symbol))) +\ No newline at end of file diff --git a/src/tests/test-all.k b/src/tests/test-all.k @@ -26,5 +26,6 @@ (load "tests/bytevectors.k") (load "tests/vectors.k") (load "tests/system.k") +(load "tests/keywords.k") (check-report)