2009-01-22 22:22:28 -05:00
|
|
|
USING: definitions compiler.units tools.test arrays sequences words kernel
|
2009-04-15 01:27:02 -04:00
|
|
|
accessors namespaces fry eval ;
|
2009-03-28 05:19:02 -04:00
|
|
|
IN: compiler.units.tests
|
2008-08-30 03:31:27 -04:00
|
|
|
|
2009-03-13 20:39:32 -04:00
|
|
|
[ [ [ ] define-temp ] with-compilation-unit ] must-infer
|
|
|
|
[ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer
|
|
|
|
|
2008-08-30 03:31:27 -04:00
|
|
|
[ flushed-dependency ] [ f flushed-dependency strongest-dependency ] unit-test
|
|
|
|
[ flushed-dependency ] [ flushed-dependency f strongest-dependency ] unit-test
|
|
|
|
[ inlined-dependency ] [ flushed-dependency inlined-dependency strongest-dependency ] unit-test
|
|
|
|
[ inlined-dependency ] [ called-dependency inlined-dependency strongest-dependency ] unit-test
|
|
|
|
[ flushed-dependency ] [ called-dependency flushed-dependency strongest-dependency ] unit-test
|
|
|
|
[ called-dependency ] [ called-dependency f strongest-dependency ] unit-test
|
2009-01-22 22:22:28 -05:00
|
|
|
|
2009-01-23 19:20:47 -05:00
|
|
|
! Non-optimizing compiler bugs
|
2009-01-22 22:22:28 -05:00
|
|
|
[ 1 1 ] [
|
2009-01-24 21:17:11 -05:00
|
|
|
"A" "B" <word> [ [ 1 ] dip ] >>def dup f 2array 1array modify-code-heap
|
2009-01-22 22:22:28 -05:00
|
|
|
1 swap execute
|
2009-01-23 19:20:47 -05:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ "A" "B" ] [
|
|
|
|
gensym "a" set
|
|
|
|
gensym "b" set
|
|
|
|
[
|
|
|
|
"a" get [ "A" ] define
|
|
|
|
"b" get "a" get '[ _ execute ] define
|
|
|
|
] with-compilation-unit
|
|
|
|
"b" get execute
|
|
|
|
[
|
|
|
|
"a" get [ "B" ] define
|
|
|
|
] with-compilation-unit
|
|
|
|
"b" get execute
|
2009-03-28 05:19:02 -04:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
! Notify observers even if compilation unit did nothing
|
|
|
|
SINGLETON: observer
|
|
|
|
|
|
|
|
observer add-definition-observer
|
|
|
|
|
|
|
|
SYMBOL: counter
|
|
|
|
|
|
|
|
0 counter set-global
|
|
|
|
|
|
|
|
M: observer definitions-changed 2drop global [ counter inc ] bind ;
|
|
|
|
|
|
|
|
[ ] with-compilation-unit
|
|
|
|
|
2009-04-15 01:27:02 -04:00
|
|
|
[ 1 ] [ counter get-global ] unit-test
|
|
|
|
|
|
|
|
observer remove-definition-observer
|
|
|
|
|
|
|
|
! Notify observers with nested compilation units
|
|
|
|
observer add-definition-observer
|
|
|
|
|
|
|
|
0 counter set-global
|
|
|
|
|
|
|
|
DEFER: nesting-test
|
|
|
|
|
2009-04-17 13:45:57 -04:00
|
|
|
[ ] [ "IN: compiler.units.tests << : nesting-test ( -- ) ; >>" (( -- )) eval ] unit-test
|
2009-04-15 01:27:02 -04:00
|
|
|
|
2009-04-17 13:45:57 -04:00
|
|
|
observer remove-definition-observer
|