USING: compiler.test compiler.units tools.test kernel kernel.private
sequences.private math.private math combinators strings alien
arrays memory vocabs parser eval quotations compiler.errors
-definitions ;
+definitions generic.single ;
IN: compiler.tests.simple
! Test empty word
! Don't want compiler error to stick around
[ ] [ [ M\ quotation bad-effect-test forget ] with-compilation-unit ] unit-test
+
+! Make sure time bombs literalize
+[ [ \ + call ] compile-call ] [ no-method? ] must-fail-with
[ T{ color f f f f } ]
[ [ color new ] compile-call ] unit-test
+
+SYMBOL: foo
+
+[ [ foo new ] compile-call ] must-fail
+
+[ [ foo boa ] compile-call ] must-fail
infer-quot-here
] dip recursive-state set ;
-: time-bomb ( error -- )
- '[ _ throw ] infer-quot-here ;
+: time-bomb-quot ( obj generic -- quot )
+ [ literalize ] [ "default-method" word-prop ] bi* [ ] 2sequence ;
-ERROR: bad-call obj ;
-
-M: bad-call summary
- drop "call must be given a callable" ;
+: time-bomb ( obj generic -- )
+ time-bomb-quot infer-quot-here ;
: infer-literal-quot ( literal -- )
dup recursive-quotation? [
[ [ recursion>> ] keep add-local-quotation ]
bi infer-quot
] [
- value>> \ bad-call boa time-bomb
+ value>> \ call time-bomb
] if
] if ;
\ compose [ infer-compose ] "special" set-word-prop
-ERROR: bad-executable obj ;
-
-M: bad-executable summary
- drop "execute must be given a word" ;
-
: infer-execute ( -- )
pop-literal nip
dup word? [
apply-object
] [
- \ bad-executable boa time-bomb
+ \ execute time-bomb
] if ;
\ execute [ infer-execute ] "special" set-word-prop
[ depends-on-tuple-layout ]
[ [ "boa-check" word-prop [ ] or ] dip ] 2bi
'[ @ _ <tuple-boa> ]
- ] [ drop f ] if
+ ] [
+ \ boa time-bomb
+ ] if
] 1 define-transform
\ boa t "no-compile" set-word-prop
[ T{ rgba f 1.0 1.0 1.0 1.0 } ] if ;
GENERIC# apply-world-attributes 1 ( world attributes -- world )
+
M: world apply-world-attributes
{
[ title>> >>title ]
GENERIC: begin-world ( world -- )
GENERIC: end-world ( world -- )
-
GENERIC: resize-world ( world -- )
-M: world begin-world
- drop ;
-M: world end-world
- drop ;
-M: world resize-world
- drop ;
+M: world begin-world drop ;
+M: world end-world drop ;
+M: world resize-world drop ;
M: world dim<<
[ call-next-method ]
[ [ clean-up-broken-window ] [ ui-error ] bi* ] recover
] bi ;
+: dispose-window-resources ( world -- )
+ [ <reversed> [ [ dispose ] when* ] each V{ } clone ] change-window-resources drop ;
+
M: world ungraft*
{
[ set-gl-context ]
[ hand-clicked close-global ]
[ hand-gadget close-global ]
[ end-world ]
- [ [ <reversed> [ [ dispose ] when* ] each V{ } clone ] change-window-resources drop ]
- [ [ (close-window) f ] change-handle drop ]
+ [ dispose-window-resources ]
[ unfocus-world ]
+ [ [ (close-window) f ] change-handle drop ]
[ promise>> t swap fulfill ]
} cleave ;