1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
;; Copyright (C) 2017, 2021 Tommi Höynälänmaa
;; Expected results: translation and running OK
(define-proper-program (tests test587)
(import (standard-library core)
(standard-library hash-table0)
(standard-library console-io))
(add-method object-hash1
(unchecked-prim-proc hashq (<object> <integer>) <integer> pure))
(define-main-proc (() <none> nonpure)
(let ((ht (static-cast
(:hash-table <object> <integer>)
(make-hash-table-with-size
(static-cast (:hash-proc <object>) object-hash)
(static-cast (:assoc-proc <object> <integer>) assoc-objects1)
10))))
(console-display-line (object-hash1 'abc 10))
(console-display-line (object-hash1 'def 10))
(console-display-line (object-hash1 'ghi 10))
(console-display-line (object-hash1 'jkl 10))
(hash-set! ht 'abc 1)
(hash-set! ht 'def 10)
(hash-set! ht 'ghi 3)
(hash-set! ht 'jkl -1)
(hash-for-each
(lambda (((x-key <object>) (i-value <integer>)) <none> nonpure)
(console-display x-key)
(console-display " ")
(console-display i-value)
(console-newline))
ht))))
|