test demo languages
parent
b16e11a8a2
commit
3cf4fe260e
@ -1,4 +1,4 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
||||
(define compile-omit-paths '("private"))
|
||||
(define test-omit-paths '("private" "sample-input.rkt"))
|
@ -1,4 +0,0 @@
|
||||
#lang basic-demo-2
|
||||
10 rem all results should be 1
|
||||
20 def f(x) = x * x
|
||||
30 print f((1+2)*3) = 81
|
@ -1,3 +0,0 @@
|
||||
#lang br
|
||||
(require basic-demo-2/sample-var)
|
||||
(* a a)
|
@ -0,0 +1,34 @@
|
||||
#lang at-exp br
|
||||
(require br/test rackunit)
|
||||
|
||||
(check-equal? (run-source "sample.rkt") "one
|
||||
|
||||
three
|
||||
4
|
||||
")
|
||||
(check-equal? (run-source "sample-var.rkt") "15
|
||||
75
|
||||
")
|
||||
(check-equal? (run-source "sample-math.rkt") "1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
")
|
||||
(check-equal? (run-source "sample-gosub.rkt") "hello
|
||||
world
|
||||
third
|
||||
hi
|
||||
")
|
||||
(check-equal? (run-source "sample-for.rkt") "19
|
||||
18
|
||||
17
|
||||
29
|
||||
28
|
||||
27
|
||||
39
|
||||
38
|
||||
37
|
||||
")
|
@ -1,4 +1 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
@ -0,0 +1,8 @@
|
||||
#lang at-exp br
|
||||
(require br/test rackunit)
|
||||
|
||||
(check-equal? (run-source "sample.rkt") "one
|
||||
|
||||
three
|
||||
4
|
||||
")
|
@ -1,4 +1,4 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
||||
(define compile-omit-paths '("private"))
|
||||
(define test-omit-paths '("private" "sample-input.rkt"))
|
@ -1,6 +1,6 @@
|
||||
#lang br
|
||||
(require "sample-export.rkt")
|
||||
(provide (all-from-out "sample-export.rkt"))
|
||||
(require "sample-exporter.rkt")
|
||||
(provide (all-from-out "sample-exporter.rkt"))
|
||||
div
|
||||
x
|
||||
(div x 10)
|
@ -0,0 +1,72 @@
|
||||
#lang at-exp br
|
||||
(require br/test rackunit)
|
||||
|
||||
(check-equal? (run-source "sample.rkt") "one
|
||||
|
||||
three
|
||||
4
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-cond.rkt") "1
|
||||
1
|
||||
1
|
||||
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-def.rkt") "60
|
||||
600
|
||||
3
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-exporter.rkt") "1
|
||||
2
|
||||
3
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-for.rkt") "1
|
||||
9
|
||||
1
|
||||
8
|
||||
1
|
||||
7
|
||||
2
|
||||
9
|
||||
2
|
||||
8
|
||||
2
|
||||
7
|
||||
3
|
||||
9
|
||||
3
|
||||
8
|
||||
3
|
||||
7
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-gosub.rkt") "first
|
||||
second
|
||||
third
|
||||
fourth
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-import.rkt") "53
|
||||
0
|
||||
10
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-importer.rkt") "#<procedure:div>
|
||||
20
|
||||
2
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-math.rkt") "1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
")
|
||||
|
||||
(check-equal? (run-source "sample-shell.rkt") "got shell args: 000\n")
|
||||
|
@ -1,61 +0,0 @@
|
||||
#lang br/quicklang
|
||||
(provide (rename-out [b-module-begin #%module-begin])
|
||||
(matching-identifiers-out #rx"^b-" (all-defined-out)))
|
||||
|
||||
(define-macro (b-module-begin (b-program LINE ...))
|
||||
(with-pattern
|
||||
([(LINE-NUM ...)
|
||||
(filter-stx-prop 'b-line-num
|
||||
(stx-flatten #'(LINE ...)))]
|
||||
[(LINE-ID ...) (prefix-ids "line-" #'(LINE-NUM ...))])
|
||||
#'(#%module-begin
|
||||
LINE ...
|
||||
(define line-table
|
||||
(apply hasheqv (append (list LINE-NUM LINE-ID) ...)))
|
||||
(run line-table))))
|
||||
|
||||
(define-macro (b-line LINE-NUMBER STATEMENT ...)
|
||||
(with-pattern
|
||||
([LINE-NUMBER-ID (prefix-id "line-" #'LINE-NUMBER
|
||||
#:source #'LINE-NUMBER)]
|
||||
[ORIG-LOC caller-stx])
|
||||
(syntax/loc caller-stx
|
||||
(define (LINE-NUMBER-ID #:srcloc? [loc #f])
|
||||
(if loc
|
||||
(syntax-srcloc #'ORIG-LOC)
|
||||
(begin (void) STATEMENT ...))))))
|
||||
|
||||
(define b-rem void)
|
||||
(define (b-print [val ""]) (displayln val))
|
||||
(define (b-sum . nums) (apply + nums))
|
||||
(define (b-num-expr expr)
|
||||
(if (integer? expr) (inexact->exact expr) expr))
|
||||
|
||||
(struct $program-end-signal ())
|
||||
(define (b-end) (raise ($program-end-signal)))
|
||||
|
||||
(struct $change-line-signal (val))
|
||||
(define (b-goto expr) (raise ($change-line-signal expr)))
|
||||
|
||||
(define-exn line-not-found exn:fail)
|
||||
|
||||
(define (run line-table)
|
||||
(define line-vec
|
||||
(list->vector (sort (hash-keys line-table) <)))
|
||||
(with-handlers ([$program-end-signal? void])
|
||||
(for/fold ([line-idx 0])
|
||||
([i (in-naturals)])
|
||||
(unless (< line-idx (vector-length line-vec)) (b-end))
|
||||
(define line-num (vector-ref line-vec line-idx))
|
||||
(define line-proc (hash-ref line-table line-num))
|
||||
(with-handlers
|
||||
([$change-line-signal?
|
||||
(λ (cls)
|
||||
(define clsv ($change-line-signal-val cls))
|
||||
(or
|
||||
(and (exact-positive-integer? clsv)
|
||||
(vector-member clsv line-vec))
|
||||
(raise-line-not-found
|
||||
(line-proc #:srcloc? #t))))])
|
||||
(line-proc)
|
||||
(add1 line-idx)))))
|
@ -1,4 +1,4 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
||||
(define test-omit-paths '("private"))
|
||||
(define compile-omit-paths '("private"))
|
@ -0,0 +1,8 @@
|
||||
#lang at-exp br
|
||||
(require br/test rackunit)
|
||||
|
||||
(check-equal? (run-source "sample.rkt") "one
|
||||
|
||||
three
|
||||
4
|
||||
")
|
@ -1,3 +1,3 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths '("factorial.rkt" "test-reader.rkt"))
|
@ -1,3 +1,42 @@
|
||||
#lang br
|
||||
(require "parser.rkt")
|
||||
(parse-to-datum "++++-+++-++-++[>++++-+++-++-++<-]>.")
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
(check-equal? (parse-to-datum "++++-+++-++-++[>++++-+++-++-++<-]>.")
|
||||
'(bf-program
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-loop
|
||||
"["
|
||||
(bf-op ">")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "-")
|
||||
(bf-op "+")
|
||||
(bf-op "+")
|
||||
(bf-op "<")
|
||||
(bf-op "-")
|
||||
"]")
|
||||
(bf-op ">")
|
||||
(bf-op "."))))
|
||||
|
@ -0,0 +1,4 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
@ -0,0 +1,3 @@
|
||||
#lang info
|
||||
|
||||
(define test-omit-paths 'all)
|
@ -0,0 +1,4 @@
|
||||
#lang info
|
||||
|
||||
(define compile-omit-paths 'all)
|
||||
(define test-omit-paths 'all)
|
@ -0,0 +1 @@
|
||||
#lang info
|
@ -0,0 +1,2 @@
|
||||
#lang info
|
||||
|
@ -0,0 +1 @@
|
||||
#lang info
|
@ -0,0 +1 @@
|
||||
#lang info
|
@ -0,0 +1 @@
|
||||
#lang info
|
Loading…
Reference in New Issue