whalesong/tests/more-tests/js-binding.rkt
2012-03-04 20:24:34 -05:00

30 lines
692 B
Racket

#lang planet dyoo/whalesong
(require (planet dyoo/whalesong/js))
(define js-plus
(js-function (js-eval "function(x, y) { return x + y; }")))
(define js-minus
(js-function (js-eval "function(x, y) { return x - y; }")))
(define sleep
(js-async-function (js-eval "function(success, fail, n) { setTimeout(success, n) }")))
"plus: " (js-plus 3 4)
"wait for one second: " (sleep 1000)
"minus:" (js-minus 239748 23)
(for-each (lambda (x)
(display x)
(sleep 1000))
'(hello world testing))
;; I need exception handling...
;;
;(define i-should-fail
; (js-async-function (js-eval "function(success, fail) { fail('I should fail'); }")))
;(i-should-fail)