#lang racket/base (require rackunit "main.rkt") (define ordinary (js (define (ordinary-let x) (let ([x 1] [y x]) (return y))))) (define sequential (js (define (sequential-let x) (let* ([x 1] [y x]) (return y))))) (define looped (js (define (sum-to n) (let loop ([i 0] [acc 0]) (if (> i n) (return acc) (loop (+ i 1) (+ acc i))))))) (check-regexp-match #rx"function ordinary_let" ordinary) (check-regexp-match #rx"const [A-Za-z0-9_]+ = x;" ordinary) (check-regexp-match #rx"let y = [A-Za-z0-9_]+;" ordinary) (check-regexp-match #rx"let y = x;" sequential) (check-regexp-match #rx"while \\(true\\)" looped) (check-regexp-match #rx"continue;" looped) (check-equal? (js1 (+ 1 2)) "1 + 2")