summaryrefslogtreecommitdiff
path: root/test-suite/tests/load-lang.test
blob: 9f1c8e5921b51e7fd63cf4f0bd93a1ba4cc5bab8 (plain)
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
;;;; load-lang.test - test loading extension languages	-*- scheme -*-
;;;;

;; these always fail for some reason:
;;
;; $ ./check-guile load-lang.test
;; ...
;; ERROR: load-lang.test: load-lang: using #lang - arguments: 
;;    ((read-error #f "/home/mwette/repo/sv/build/guile/load1js:1:3: 
;;       Unknown # object: ~S" ("#l") #f))
;; ...
;; ERROR: load-lang.test: load-lang: using dot-js - arguments: 
;;    ((unbound-variable #f "Unbound variable: ~S" (function) #f))
;;
;; but works this way
;; $ meta/guile
;; ...
;; scheme@(guile-user)> (load "load1js")
;; scheme@(guile-user)> (js_1pl 1)
;; $1 = 2
;; scheme@(guile-user)> (load "load2.js")
;; ...
;; scheme@(guile-user)> (js_2pl 2)
;; $2 = 4

(define-module (test-suite test-load-lang)
  #:use-module (test-suite lib)
  #:declarative? #f)

(define tmp-dir (getcwd))

(define (data-file-name filename)
  (in-vicinity tmp-dir filename))

(with-test-prefix "load-lang"

  (pass-if "using #lang"
    (let ((src-file (data-file-name "load1js")))
      (with-output-to-file src-file
	(lambda ()
	  (display "#lang ecmascript\n")
	  (display "function js_1pl(b) { return 1 + b; }\n")))
      (load src-file)
      ;;(delete-file src-file)
      (= (js_1pl 2) 3)))

  (pass-if "using dot-js"
    (let ((src-file (data-file-name "load2.js")))
      (with-output-to-file src-file
	(lambda ()
	  (display "function js_2pl(b) { return 2 + b; }\n")))
      (load src-file)
      ;;(delete-file src-file)
      (= (js_2pl 2) 4)))

  )

;; --- last line ---