File: test929.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 (47 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
;; -*-theme-d-*-

;; Copyright (C) 2025  Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK

(define-proper-program (tests test929)


  (import (standard-library core)
          (standard-library list-utilities)
          (standard-library console-io))

  (define <pure-myproc> (:procedure ((rest <object>)) <object> pure))

  (define <nonpure-myproc> (:simple-proc ((rest <object>)) <object> nonpure))

  (define-simple-proc myproc1 (((l (rest <object>))) <boolean> pure)
    #t)

  (define-simple-proc myproc2 (((l (rest <object>))) <boolean> nonpure)
    (console-display-line "*2*")
    (for-each1 console-display-line l)
    #f)

  (define-simple-proc myproc3 (((x <object>)) <none> nonpure)
    (match-type x
      ((proc1 <pure-myproc>) (console-display-line (proc1 'a 'b 'c)))
      ((proc2 <nonpure-myproc>) (proc2 1 2 3))
      (else (console-display-line "no match"))))

  (define-simple-proc myproc4 (((x <object>)) <none> nonpure)
    (console-display-line (is-instance? x <list>))
    (match-type x
      ((l <list>) (console-display-line #t))
      (else (console-display-line #f))))

  (define-main-proc (() <none> nonpure)
    (myproc3 myproc1)
    (myproc3 myproc2)
    (myproc3 console-display-line)
    (myproc4 '(1 2 3))
    (myproc4 '(1 2 3 . 4))))