1 USING: compiler definitions compiler.units tools.test arrays sequences words kernel
2 accessors namespaces fry eval quotations math ;
3 IN: compiler.units.tests
5 [ [ [ ] define-temp ] with-compilation-unit ] must-infer
6 [ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer
8 ! Non-optimizing compiler bugs
10 "A" <uninterned-word> [ [ [ 1 ] dip ] 2array 1array t t modify-code-heap ] keep
20 "a" get [ "A" ] define
21 "b" get "a" get '[ _ execute ] define
22 ] with-compilation-unit
25 "a" get [ "B" ] define
26 ] with-compilation-unit
32 ! Check that we notify observers
35 observer add-definition-observer
41 M: observer definitions-changed
42 2drop [ counter inc ] with-global ;
44 [ gensym [ ] ( -- ) define-declared ] with-compilation-unit
46 [ 1 ] [ counter get-global ] unit-test
48 observer remove-definition-observer
50 ! Notify observers with nested compilation units
51 observer add-definition-observer
57 [ ] [ "IN: compiler.units.tests << : nesting-test ( -- ) ; >>" eval( -- ) ] unit-test
59 observer remove-definition-observer
61 ! Make sure that non-optimized calls to a generic word which
62 ! hasn't been compiled yet work properly
63 GENERIC: uncompiled-generic-test ( a -- b )
65 M: integer uncompiled-generic-test 1 + ;
67 << [ uncompiled-generic-test ] [ jit-compile ] [ suffix! ] bi >>
70 [ 4 ] [ 3 "q" get call ] unit-test
72 [ ] [ [ \ uncompiled-generic-test forget ] with-compilation-unit ] unit-test