File: test587.thp

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (36 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (2)
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))))