compiler.cfg.optimizer compiler.cfg.predecessors compiler.cfg.checker
compiler.cfg arrays locals byte-arrays kernel.private math
slots.private vectors sbufs strings math.partial-dispatch
-strings.private ;
+strings.private accessors compiler.cfg.instructions ;
IN: compiler.cfg.builder.tests
! Just ensure that various CFGs build correctly.
{ pinned-c-ptr class } \ set-alien-cell '[ _ declare 10 _ execute ] unit-test-cfg
{ pinned-c-ptr class fixnum } \ set-alien-cell '[ _ declare _ execute ] unit-test-cfg
] each
+
+: contains-insn? ( quot insn-check -- ? )
+ [ test-mr [ instructions>> ] map ] dip
+ '[ _ any? ] any? ; inline
+
+[ t ] [ [ swap ] [ ##replace? ] contains-insn? ] unit-test
+
+[ f ] [ [ swap swap ] [ ##replace? ] contains-insn? ] unit-test
+
+[ t ] [
+ [ { fixnum byte-array fixnum } declare set-alien-unsigned-1 ]
+ [ ##set-alien-integer-1? ] contains-insn?
+] unit-test
+
+[ t ] [
+ [ { fixnum byte-array fixnum } declare [ dup * dup * ] 2dip set-alien-unsigned-1 ]
+ [ ##set-alien-integer-1? ] contains-insn?
+] unit-test
+
+[ f ] [
+ [ { byte-array fixnum } declare set-alien-unsigned-1 ]
+ [ ##set-alien-integer-1? ] contains-insn?
+] unit-test
\ No newline at end of file
quotations classes classes.algebra classes.tuple.private
continuations growable namespaces hints alien.accessors
compiler.tree.builder compiler.tree.optimizer sequences.deep
-compiler definitions ;
+compiler definitions generic.single ;
IN: compiler.tests.optimizer
GENERIC: xyz ( obj -- obj )
\ bad-dispatch-position-test* forget
] with-compilation-unit
] unit-test
+
+[ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with
\ No newline at end of file