;; -*-theme-d-*-

;; Copyright (C) 2014  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 test186)


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


  (define-param-proc my-proc1 (%type)
		     (((a %type) (b <integer>)) (:vector %type) pure)
    (make-vector %type b a))


  (define-param-proc my-proc2 (%type)
		     (((a %type) (b <integer>)) (:mutable-vector %type) pure)
    (make-mutable-vector %type b a))


  (define-param-proc my-proc3 (%type)
		     (((a %type) (b <integer>)) (:value-vector %type) pure)
    (make-value-vector %type b a))


  (define-param-proc my-proc4 (%type)
		     (((a %type) (b <integer>)) (:mutable-value-vector %type) pure)
    (make-mutable-value-vector %type b a))


  (define-param-proc-alt display-vector (%type)
    (lambda (((v (:vector %type))) <none> nonpure)
      (let ((len (vector-length v)))
	(let-mutable ((j <integer> 0))
	  (until ((>= j len))
	    (console-display (vector-ref v j))
	    (console-newline)
	    (set! j (+ j 1)))))))


  (define-param-proc-alt display-value-vector (%type)
    (lambda (((v (:value-vector %type))) <none> nonpure)
      (let ((len (value-vector-length v)))
	(let-mutable ((j <integer> 0))
	  (until ((>= j len))
	    (console-display (value-vector-ref v j))
	    (console-newline)
	    (set! j (+ j 1)))))))


  (define-param-proc-alt display-mutable-vector (%type)
    (lambda (((v (:mutable-vector %type))) <none> nonpure)
      (let ((len (mutable-vector-length v)))
	(let-mutable ((j <integer> 0))
	  (until ((>= j len))
	    (console-display (mutable-vector-ref v j))
	    (console-newline)
	    (set! j (+ j 1)))))))


  (define-param-proc-alt display-mutable-value-vector (%type)
    (lambda (((v (:mutable-value-vector %type))) <none> nonpure)
      (let ((len (mutable-value-vector-length v)))
	(let-mutable ((j <integer> 0))
	  (until ((>= j len))
	    (console-display (mutable-value-vector-ref v j))
	    (console-newline)
	    (set! j (+ j 1)))))))


  (define main
    (lambda (() <none> nonpure)
      (let ((vec1 (my-proc1 'abc 2))
	    (vec2 (my-proc2 1 3))
	    (vec3 (my-proc3 1.5 4))
	    (vec4 (my-proc4 #t 5)))
	(display-vector vec1)
	(display-mutable-vector vec2)
	(display-value-vector vec3)
	(display-mutable-value-vector vec4)
	(console-newline)))))
