File: test461.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 (65 lines) | stat: -rw-r--r-- 1,818 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;; -*-theme-d-*-

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

;; Expected results: translation error
;;   The purpose of this test is to test the error message.


(define-proper-program (tests test461)


  (import (standard-library core)
	  (standard-library stream)
	  (standard-library promise)
	  (standard-library console-io)
	  (standard-library object-string-conversion))


  (define-param-proc my-stream-map (%type1 %type2)
		     (((proc (:procedure (%type1) %type2 pure))
		       (stm (:stream %type1)))
		      (:stream %type2)
		      pure)
    (match-type stm
      ((<null>) null)
      ((stm2 (:nonempty-stream %type1))
       (cons (proc (car stm2))
	     (delay (my-stream-map proc (stream-next stm2)))))))


  (define-param-proc my-stream-map-nonpure (%type1 %type2)
		     (((proc (:procedure (%type1) %type2 nonpure))
		       (stm (:stream %type1)))
		      (:nonpure-stream %type2)
		      nonpure)
    (match-type stm
      ((<null>) null)
      ((stm2 (:nonempty-stream %type1))
       (cons (proc (car stm2))
	     (delay-nonpure 
	      (my-stream-map-nonpure proc (stream-next stm2)))))))


  (define-main-proc (() <none> nonpure)
    (let* ((l1 '(1 2 3 4 5))
	   (stm (list->stream l1))
	   (stm2 (my-stream-map
		  (lambda (((i <integer>)) <integer> pure) (+ i 1))
		  stm))
	   (l2 (stream->list stm2))
	   (stm3 (my-stream-map
		  (lambda (((i <integer>)) <real> pure) (+ i 0.5))
		  stm))
	   (l3 (stream->list stm3))
	   (stm4 (my-stream-map-nonpure
		  (lambda (((i <integer>)) <string> nonpure)
		    (console-display-line "*")
		    (object->string i))
		  stm))
	   (l4 (nonpure-stream->list stm4)))
      (console-display-line l2)
      (console-display-line l3)
      (console-display-line l4))))