From bcbfa5f10ec3f601d2afda0e814c160a9be980e2 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Wed, 9 Nov 2011 11:56:38 -0500 Subject: [PATCH] exercising hash-values, hash-keys, hash-map, hash-for-each --- .../runtime-src/baselib-primitives.js | 12 ++++++++ lang/kernel.rkt | 6 ++-- tests/more-tests/hashes.expected | 9 ++++++ tests/more-tests/hashes.rkt | 29 +++++++++++++++++++ version.rkt | 2 +- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/js-assembler/runtime-src/baselib-primitives.js b/js-assembler/runtime-src/baselib-primitives.js index a6f848d..6366743 100644 --- a/js-assembler/runtime-src/baselib-primitives.js +++ b/js-assembler/runtime-src/baselib-primitives.js @@ -195,6 +195,18 @@ return VOID; }); + installPrimitiveProcedure( + 'write', + makeList(1, 2), + function (M) { + var firstArg = M.e[M.e.length - 1]; + var outputPort = M.params.currentOutputPort; + if (M.a === 2) { + outputPort = checkOutputPort(M, 'write', 1); + } + outputPort.writeDomNode(M, toDomNode(firstArg, 'write')); + return VOID; + }); installPrimitiveProcedure( 'write-byte', diff --git a/lang/kernel.rkt b/lang/kernel.rkt index e2cd247..3af3789 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -438,9 +438,9 @@ box? string-append string->list list->string -;; string-copy -string->symbol -symbol->string + string->symbol + symbol->string + format printf fprintf diff --git a/tests/more-tests/hashes.expected b/tests/more-tests/hashes.expected index 923a3cc..a5090c2 100644 --- a/tests/more-tests/hashes.expected +++ b/tests/more-tests/hashes.expected @@ -71,3 +71,12 @@ false false false true + +(author name) +(author name) +(graham-knuth-patashnik concrete-mathematics) +(graham-knuth-patashnik concrete-mathematics) +"author" +"name" +"graham-knuth-patashnik" +"concrete-mathematics" diff --git a/tests/more-tests/hashes.rkt b/tests/more-tests/hashes.rkt index b2935b3..1a31e53 100644 --- a/tests/more-tests/hashes.rkt +++ b/tests/more-tests/hashes.rkt @@ -152,3 +152,32 @@ (hash-eqv? (make-hash)) (hash-eqv? (make-hasheq)) (hash-eqv? (make-hasheqv)) + + +(newline) +(hash-keys (make-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik)))) +(hash-keys (make-immutable-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik)))) +(hash-values (make-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik)))) +(hash-values (make-immutable-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik)))) +(hash-map (make-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik))) + (lambda (k v) (list v k))) +(hash-map (make-immutable-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik))) + (lambda (k v) (list v k))) + +(hash-for-each (make-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik))) + (lambda (k v) + (write (symbol->string k)) + (newline))) + +(hash-for-each (make-immutable-hash '((name . concrete-mathematics) + (author . graham-knuth-patashnik))) + (lambda (k v) + (write (symbol->string v)) + (newline))) diff --git a/version.rkt b/version.rkt index 53a9f21..d9fa156 100644 --- a/version.rkt +++ b/version.rkt @@ -6,4 +6,4 @@ (provide version) (: version String) -(define version "1.71") +(define version "1.72")