2006-05-15 01:37:11 -04:00
|
|
|
IN: temporary
|
2006-05-19 14:59:44 -04:00
|
|
|
USING: errors interpreter io kernel math math-internals
|
2005-09-28 20:09:10 -04:00
|
|
|
namespaces prettyprint sequences test ;
|
2004-11-09 22:22:25 -05:00
|
|
|
|
2006-07-31 21:00:07 -04:00
|
|
|
: run ( -- ) done? [ step-in run ] unless ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2005-09-28 20:09:10 -04:00
|
|
|
: init-interpreter ( -- )
|
2006-08-24 02:09:54 -04:00
|
|
|
V{ } clone V{ } clone V{ } clone namestack catchstack
|
|
|
|
<continuation> meta-interp set ;
|
2005-09-28 20:09:10 -04:00
|
|
|
|
2004-11-26 22:23:57 -05:00
|
|
|
: test-interpreter
|
2006-08-24 02:09:54 -04:00
|
|
|
init-interpreter (meta-call) run meta-d ;
|
2004-11-26 22:23:57 -05:00
|
|
|
|
2006-08-15 14:56:18 -04:00
|
|
|
[ V{ } ] [
|
|
|
|
[ ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ 1 } ] [
|
|
|
|
[ 1 ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ 1 2 3 } ] [
|
2004-11-26 22:23:57 -05:00
|
|
|
[ 1 2 3 ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ "Yo" 2 } ] [
|
2004-11-26 22:23:57 -05:00
|
|
|
[ 2 >r "Yo" r> ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ 2 } ] [
|
2005-09-24 15:21:17 -04:00
|
|
|
[ t [ 2 ] [ "hi" ] if ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ "hi" } ] [
|
2005-09-24 15:21:17 -04:00
|
|
|
[ f [ 2 ] [ "hi" ] if ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ 4 } ] [
|
2004-11-26 22:23:57 -05:00
|
|
|
[ 2 2 fixnum+ ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2006-08-24 02:09:54 -04:00
|
|
|
: foo 2 2 fixnum+ ;
|
|
|
|
|
|
|
|
[ V{ 8 } ] [
|
|
|
|
[ foo 4 fixnum+ ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ C{ 1 1.5 } { } C{ 1 1.5 } { } } ] [
|
|
|
|
[ C{ 1 1.5 } { } 2dup ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ 3 4 1 2 } ] [
|
|
|
|
[ 1 2 3 4 2swap ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ t } ] [
|
2006-08-24 02:09:54 -04:00
|
|
|
[ 5 5 number= ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ f } ] [
|
2006-08-24 02:09:54 -04:00
|
|
|
[ 5 6 number= ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2006-08-24 02:09:54 -04:00
|
|
|
[ V{ -1 } ] [
|
|
|
|
[ "XYZ" "XYZ" 3 (mismatch) ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ t } ] [
|
|
|
|
[ "XYZ" "XYZ" sequence= ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ t } ] [
|
|
|
|
[ "XYZ" "XYZ" = ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ V{ f } ] [
|
|
|
|
[ "XYZ" "XuZ" = ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ 4 } ] [
|
2004-11-26 22:23:57 -05:00
|
|
|
[ 2 2 + ] test-interpreter
|
2004-11-09 22:22:25 -05:00
|
|
|
] unit-test
|
2004-11-21 19:27:18 -05:00
|
|
|
|
2005-12-03 17:34:59 -05:00
|
|
|
[ V{ } 2 ] [
|
|
|
|
2 "x" set [ [ 3 "x" set ] with-scope ] test-interpreter "x" get
|
2005-06-15 23:27:28 -04:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ 3 } ] [
|
2005-06-12 21:52:36 -04:00
|
|
|
[ 3 "x" set "x" get ] test-interpreter
|
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ "hi\n" } ] [
|
2005-06-19 18:53:58 -04:00
|
|
|
[ [ "hi" print ] string-out ] test-interpreter
|
2005-06-12 21:52:36 -04:00
|
|
|
] unit-test
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
[ V{ "4\n" } ] [
|
2006-05-15 01:49:07 -04:00
|
|
|
[ [ 2 2 + number>string print ] string-out ] test-interpreter
|
2004-11-21 19:27:18 -05:00
|
|
|
] unit-test
|