factor/core/vocabs/loader/loader-tests.factor

173 lines
3.9 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
USING: vocabs.loader tools.test continuations vocabs math
kernel arrays sequences namespaces io.streams.string
parser source-files words assocs classes.tuple definitions
debugger compiler.units accessors eval
2009-05-04 10:44:26 -04:00
combinators vocabs.parser grouping vocabs.files vocabs.refresh ;
IN: vocabs.loader.tests
2007-09-20 18:09:08 -04:00
! This vocab should not exist, but just in case...
[ ] [
[
"vocabs.loader.test" forget-vocab
] with-compilation-unit
] unit-test
2007-09-20 18:09:08 -04:00
[ T{ vocab-link f "vocabs.loader.test" } ]
2008-03-19 15:39:08 -04:00
[ "vocabs.loader.test" >vocab-link ] unit-test
2007-09-20 18:09:08 -04:00
[ t ]
2008-03-19 15:39:08 -04:00
[ "kernel" >vocab-link "kernel" vocab = ] unit-test
2007-09-20 18:09:08 -04:00
IN: vocabs.loader.test.2
2009-03-18 18:01:26 -04:00
: hello ( -- ) ;
2007-09-20 18:09:08 -04:00
MAIN: hello
2008-03-01 17:00:45 -05:00
IN: vocabs.loader.tests
2007-09-20 18:09:08 -04:00
2009-03-18 18:01:26 -04:00
[ ] [
2007-09-20 18:09:08 -04:00
"vocabs.loader.test.2" run
"vocabs.loader.test.2" vocab run
2008-03-19 15:39:08 -04:00
"vocabs.loader.test.2" <vocab-link> run
2007-09-20 18:09:08 -04:00
] unit-test
2008-01-09 19:13:26 -05:00
[
"resource:core/vocabs/loader/test/a/a.factor" forget-source
"vocabs.loader.test.a" forget-vocab
] with-compilation-unit
2007-09-20 18:09:08 -04:00
0 "count-me" set-global
2 [
[ "vocabs.loader.test.a" require ] must-fail
2007-09-20 18:09:08 -04:00
[ f ] [ "vocabs.loader.test.a" vocab source-loaded?>> ] unit-test
2007-09-20 18:09:08 -04:00
[ t ] [
"resource:core/vocabs/loader/test/a/a.factor"
2008-09-02 02:55:36 -04:00
source-file definitions>> dup USE: prettyprint .
2007-09-20 18:09:08 -04:00
"v-l-t-a-hello" "vocabs.loader.test.a" lookup dup .
2007-12-24 19:40:09 -05:00
swap first key?
2007-09-20 18:09:08 -04:00
] unit-test
] times
[ 2 ] [ "count-me" get-global ] unit-test
2008-02-06 16:00:10 -05:00
[
"IN: vocabs.loader.test.a v-l-t-a-hello"
<string-reader>
"resource:core/vocabs/loader/test/a/a.factor"
parse-stream
2008-06-25 05:06:18 -04:00
] [ error>> error>> error>> no-word-error? ] must-fail-with
2007-09-20 18:09:08 -04:00
0 "count-me" set-global
[ ] [
[
"vocabs.loader.test.b" forget-vocab
] with-compilation-unit
] unit-test
2007-09-20 18:09:08 -04:00
2008-03-18 21:27:09 -04:00
[ f ] [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [
2008-01-09 19:13:26 -05:00
[
"vocabs.loader.test.b" vocab-files
[ forget-source ] each
] with-compilation-unit
2007-09-20 18:09:08 -04:00
] unit-test
[ "vocabs.loader.test.b" require ] must-fail
2007-09-20 18:09:08 -04:00
[ 1 ] [ "count-me" get-global ] unit-test
[ ] [
2007-12-24 19:40:09 -05:00
[
2008-01-02 19:36:36 -05:00
"bob" "vocabs.loader.test.b" create [ ] define
2007-12-24 19:40:09 -05:00
] with-compilation-unit
2007-09-20 18:09:08 -04:00
] unit-test
[ ] [ "vocabs.loader.test.b" refresh ] unit-test
[ 2 ] [ "count-me" get-global ] unit-test
2008-01-02 19:36:36 -05:00
[ f ] [ "fred" "vocabs.loader.test.b" lookup undefined? ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [
2008-01-09 19:13:26 -05:00
[
"vocabs.loader.test.b" vocab-files
[ forget-source ] each
] with-compilation-unit
2007-09-20 18:09:08 -04:00
] unit-test
2008-04-09 20:30:54 -04:00
[ ] [ "vocabs.loader.test.b" changed-vocab ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ "vocabs.loader.test.b" refresh ] unit-test
[ 3 ] [ "count-me" get-global ] unit-test
[ { "resource:core/kernel/kernel.factor" 1 } ]
2008-03-19 15:39:08 -04:00
[ "kernel" <vocab-link> where ] unit-test
2007-09-20 18:09:08 -04:00
[ { "resource:core/kernel/kernel.factor" 1 } ]
[ "kernel" vocab where ] unit-test
2008-03-18 21:27:09 -04:00
[ ] [
[
"vocabs.loader.test.c" forget-vocab
"vocabs.loader.test.d" forget-vocab
] with-compilation-unit
] unit-test
[ +done+ ] [
2008-02-06 16:00:10 -05:00
[ "vocabs.loader.test.d" require ] [ :1 ] recover
"vocabs.loader.test.d" vocab source-loaded?>>
2007-09-20 18:09:08 -04:00
] unit-test
2009-03-23 01:34:02 -04:00
: forget-junk ( -- )
[
{ "2" "a" "b" "d" "e" "f" }
[
2008-03-19 20:15:43 -04:00
"vocabs.loader.test." prepend forget-vocab
] each
] with-compilation-unit ;
2007-09-20 18:09:08 -04:00
forget-junk
[ { } ] [
2009-04-17 16:49:21 -04:00
"IN: xabbabbja" eval( -- ) "xabbabbja" vocab-files
2007-09-20 18:09:08 -04:00
] unit-test
[ "xabbabbja" forget-vocab ] with-compilation-unit
2007-09-20 18:09:08 -04:00
forget-junk
[ ] [ [ "vocabs.loader.test.e" forget-vocab ] with-compilation-unit ] unit-test
0 "vocabs.loader.test.g" set-global
[
"vocabs.loader.test.f" forget-vocab
"vocabs.loader.test.g" forget-vocab
] with-compilation-unit
[ ] [ "vocabs.loader.test.g" require ] unit-test
[ 1 ] [ "vocabs.loader.test.g" get-global ] unit-test
[
"vocabs.loader.test.h" forget-vocab
"vocabs.loader.test.i" forget-vocab
] with-compilation-unit
[ ] [ "vocabs.loader.test.h" require ] unit-test
[
"vocabs.loader.test.j" forget-vocab
"vocabs.loader.test.k" forget-vocab
] with-compilation-unit
[ ] [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test