factor: more IN: -> in:
parent
b885dd195c
commit
cda8f73022
|
@ -9,7 +9,7 @@ HELP: change:
|
|||
"Change a tuple slot:"
|
||||
{ $example
|
||||
"USING: prettyprint changer kernel math ;"
|
||||
"IN: changer"
|
||||
"in: changer"
|
||||
"TUPLE: nightclub count ;"
|
||||
"T{ nightclub f 0 } [ 3 + ] change: count ."
|
||||
"T{ nightclub { count 3 } }"
|
||||
|
|
|
@ -332,27 +332,27 @@ STRUCT: struct-that's-a-word { x int } ;
|
|||
|
||||
! Interactive parsing of struct slot definitions
|
||||
[
|
||||
"USE: classes.struct IN: classes.struct.tests STRUCT: unexpected-eof-test" <string-reader>
|
||||
"USE: classes.struct in: classes.struct.tests STRUCT: unexpected-eof-test" <string-reader>
|
||||
"struct-class-test-1" parse-stream
|
||||
] [ error>> error>> unexpected-eof? ] must-fail-with
|
||||
|
||||
[
|
||||
"USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x uint } ;" eval( -- )
|
||||
"USING: alien.c-types classes.struct ; in: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x uint } ;" eval( -- )
|
||||
] [ error>> duplicate-slot-names? ] must-fail-with
|
||||
|
||||
[
|
||||
"USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x float } ;" eval( -- )
|
||||
"USING: alien.c-types classes.struct ; in: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x float } ;" eval( -- )
|
||||
] [ error>> duplicate-slot-names? ] must-fail-with
|
||||
|
||||
! S{ with non-struct type
|
||||
[
|
||||
"USE: classes.struct IN: classes.struct.tests TUPLE: not-a-struct ; S{ not-a-struct }"
|
||||
"USE: classes.struct in: classes.struct.tests TUPLE: not-a-struct ; S{ not-a-struct }"
|
||||
eval( -- value )
|
||||
] [ error>> no-method? ] must-fail-with
|
||||
|
||||
! Subclassing a struct class should not be allowed
|
||||
[
|
||||
"USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: a-struct { x int } ; TUPLE: not-a-struct < a-struct ;"
|
||||
"USING: alien.c-types classes.struct ; in: classes.struct.tests STRUCT: a-struct { x int } ; TUPLE: not-a-struct < a-struct ;"
|
||||
eval( -- )
|
||||
] [ error>> bad-superclass? ] must-fail-with
|
||||
|
||||
|
@ -365,7 +365,7 @@ TUPLE: a-subclass < will-become-struct ;
|
|||
|
||||
{ will-become-struct } [ a-subclass superclass-of ] unit-test
|
||||
|
||||
{ } [ "IN: classes.struct.tests USING: classes.struct alien.c-types ; STRUCT: will-become-struct { x int } ;" eval( -- ) ] unit-test
|
||||
{ } [ "in: classes.struct.tests USING: classes.struct alien.c-types ; STRUCT: will-become-struct { x int } ;" eval( -- ) ] unit-test
|
||||
|
||||
{ t } [ will-become-struct struct-class? ] unit-test
|
||||
|
||||
|
@ -517,7 +517,7 @@ STRUCT: struct-1-union { a int initial: 0 } ;
|
|||
! Bug #206
|
||||
STRUCT: going-to-redefine { a uint } ;
|
||||
{ } [
|
||||
"IN: classes.struct.tests TUPLE: going-to-redefine b ;" eval( -- )
|
||||
"in: classes.struct.tests TUPLE: going-to-redefine b ;" eval( -- )
|
||||
] unit-test
|
||||
{ f } [ \ going-to-redefine \ clone ?lookup-method ] unit-test
|
||||
{ f } [ \ going-to-redefine \ struct-slot-values ?lookup-method ] unit-test
|
||||
|
|
|
@ -14,7 +14,7 @@ in: compiler.tests.callback-error
|
|||
|
||||
[ ] [
|
||||
" USING: alien alien.c-types alien.syntax kernel ;
|
||||
IN: scratchpad
|
||||
in: scratchpad
|
||||
|
||||
: callback-death ( -- callback )
|
||||
void { } cdecl [ \"Error!\" throw ] alien-callback ;
|
||||
|
@ -31,7 +31,7 @@ in: compiler.tests.callback-error
|
|||
|
||||
[ ] [
|
||||
"USING: alien alien.c-types alien.syntax kernel threads ;
|
||||
IN: scratchpad
|
||||
in: scratchpad
|
||||
|
||||
: callback-death ( -- callback )
|
||||
void { } cdecl [ \"Error!\" throw ] alien-callback ;
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.folding
|
|||
|
||||
[ ] [
|
||||
"USING: math arrays ;
|
||||
IN: compiler.tests.folding
|
||||
in: compiler.tests.folding
|
||||
GENERIC: foldable-generic ( a -- b ) ; foldable
|
||||
M: integer foldable-generic f <array> ;"
|
||||
eval( -- )
|
||||
|
@ -16,7 +16,7 @@ in: compiler.tests.folding
|
|||
|
||||
[ ] [
|
||||
"USING: math arrays ;
|
||||
IN: compiler.tests.folding
|
||||
in: compiler.tests.folding
|
||||
: fold-test ( -- x ) 10 foldable-generic ;"
|
||||
eval( -- )
|
||||
] unit-test
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine0
|
|||
|
||||
[ test-2 ] [ not-compiled? ] must-fail-with
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 : test-1 ( -- ) ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 : test-1 ( -- ) ;" eval( -- ) ] unit-test
|
||||
|
||||
{ 0 0 } [ test-1 ] must-infer-as
|
||||
|
||||
|
@ -26,7 +26,7 @@ in: compiler.tests.redefine0
|
|||
|
||||
[ ] [ test-4 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 USE: kernel : test-3 ( a -- ) call ; inline" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 USE: kernel : test-3 ( a -- ) call ; inline" eval( -- ) ] unit-test
|
||||
|
||||
[ test-4 ] [ not-compiled? ] must-fail-with
|
||||
|
||||
|
@ -42,7 +42,7 @@ in: compiler.tests.redefine0
|
|||
|
||||
[ 31337 ] [ 31337 test-6 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 USING: macros kernel ; MACRO: test-5 ( a -- quot ) drop [ ] ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 USING: macros kernel ; MACRO: test-5 ( a -- quot ) drop [ ] ;" eval( -- ) ] unit-test
|
||||
|
||||
[ 31337 test-6 ] [ not-compiled? ] must-fail-with
|
||||
|
||||
|
@ -83,15 +83,15 @@ MACRO: test-10 ( -- quot ) quot get ; >>
|
|||
|
||||
[ ] [ test-11 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 : test-9 ( -- ) 1 ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 : test-9 ( -- ) 1 ;" eval( -- ) ] unit-test
|
||||
|
||||
! test-11 should get recompiled now
|
||||
|
||||
[ test-11 ] [ not-compiled? ] must-fail-with
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 : test-9 ( -- a ) 1 ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 : test-9 ( -- a ) 1 ;" eval( -- ) ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine0 : test-9 ( -- ) ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine0 : test-9 ( -- ) ;" eval( -- ) ] unit-test
|
||||
|
||||
[ ] [ test-11 ] unit-test
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ M: integer method-redefine-generic-1 3 + ;
|
|||
|
||||
[ 6 ] [ method-redefine-test-1 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine1 USE: math M: fixnum method-redefine-generic-1 4 + ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine1 USE: math M: fixnum method-redefine-generic-1 4 + ;" eval( -- ) ] unit-test
|
||||
|
||||
[ 7 ] [ method-redefine-test-1 ] unit-test
|
||||
|
||||
|
@ -27,7 +27,7 @@ M: integer method-redefine-generic-2 3 + ;
|
|||
|
||||
[ 6 ] [ method-redefine-test-2 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine1 USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine1 USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" eval( -- ) ] unit-test
|
||||
|
||||
[ 7 ] [ method-redefine-test-2 ] unit-test
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine11
|
|||
|
||||
[ ] [
|
||||
"USING: kernel math classes arrays ;
|
||||
IN: compiler.tests.redefine11
|
||||
in: compiler.tests.redefine11
|
||||
MIXIN: my-mixin
|
||||
INSTANCE: array my-mixin
|
||||
INSTANCE: fixnum my-mixin
|
||||
|
|
|
@ -15,6 +15,6 @@ M: object g drop t ;
|
|||
|
||||
TUPLE: jeah ;
|
||||
|
||||
[ ] [ "USE: kernel IN: compiler.tests.redefine12 M: jeah g drop f ;" eval( -- ) ] unit-test
|
||||
[ ] [ "USE: kernel in: compiler.tests.redefine12 M: jeah g drop f ;" eval( -- ) ] unit-test
|
||||
|
||||
[ f ] [ T{ jeah } h ] unit-test
|
||||
|
|
|
@ -11,4 +11,4 @@ M: fixnum breakage-caller 2 breakage-macro ;
|
|||
|
||||
: breakage ( -- obj ) 2 breakage-caller ;
|
||||
|
||||
! [ ] [ "IN: compiler.tests.redefine13 : breakage-word ( a b -- c ) ;" eval ] unit-test
|
||||
! [ ] [ "in: compiler.tests.redefine13 : breakage-word ( a b -- c ) ;" eval ] unit-test
|
||||
|
|
|
@ -18,8 +18,8 @@ INSTANCE: d c
|
|||
|
||||
M: d g2 drop d ;
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine18 SINGLETON: b INSTANCE: b d" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine18 SINGLETON: b INSTANCE: b d" eval( -- ) ] unit-test
|
||||
|
||||
[ d ] [ "b" "compiler.tests.redefine18" lookup-word g1 ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine18 FORGET: b" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine18 FORGET: b" eval( -- ) ] unit-test
|
||||
|
|
|
@ -5,7 +5,7 @@ in: compiler.tests.redefine2
|
|||
|
||||
DEFER: redefine2-test
|
||||
|
||||
[ ] [ "USE: sequences USE: kernel IN: compiler.tests.redefine2 TUPLE: redefine2-test ; M: redefine2-test nth 2drop 3 ; INSTANCE: redefine2-test sequence" eval( -- ) ] unit-test
|
||||
[ ] [ "USE: sequences USE: kernel in: compiler.tests.redefine2 TUPLE: redefine2-test ; M: redefine2-test nth 2drop 3 ; INSTANCE: redefine2-test sequence" eval( -- ) ] unit-test
|
||||
|
||||
[ t ] [ \ redefine2-test symbol? ] unit-test
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ TYPEDEF: alien.c-types:float type-2
|
|||
|
||||
[ ] [
|
||||
"USING: alien.c-types alien.syntax ;
|
||||
IN: compiler.tests.redefine24 TYPEDEF: int type-2" eval( -- )
|
||||
in: compiler.tests.redefine24 TYPEDEF: int type-2" eval( -- )
|
||||
] unit-test
|
||||
|
||||
[ 3 ] [ 1 2 callback indirect ] unit-test
|
||||
|
||||
[ ] [
|
||||
"USING: alien.c-types alien.syntax ;
|
||||
IN: compiler.tests.redefine24
|
||||
in: compiler.tests.redefine24
|
||||
TYPEDEF: float type-1
|
||||
TYPEDEF: float type-2" eval( -- )
|
||||
] unit-test
|
||||
|
@ -32,7 +32,7 @@ TYPEDEF: alien.c-types:float type-2
|
|||
|
||||
[ ] [
|
||||
"USING: alien.c-types alien.syntax ;
|
||||
IN: compiler.tests.redefine24
|
||||
in: compiler.tests.redefine24
|
||||
TYPEDEF: float type-3" eval( -- )
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ M: empty-mixin sheeple drop "wake up" ; inline
|
|||
[ t ] [ object \ sheeple lookup-method \ sheeple-test compiled-use? ] unit-test
|
||||
[ f ] [ empty-mixin \ sheeple lookup-method \ sheeple-test compiled-use? ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine3 USE: arrays INSTANCE: array empty-mixin" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine3 USE: arrays INSTANCE: array empty-mixin" eval( -- ) ] unit-test
|
||||
|
||||
[ "wake up" ] [ sheeple-test ] unit-test
|
||||
[ f ] [ object \ sheeple lookup-method \ sheeple-test compiled-use? ] unit-test
|
||||
|
|
|
@ -7,6 +7,6 @@ in: compiler.tests.redefine4
|
|||
|
||||
[ "" ] [ [ declaration-test ] with-string-writer ] unit-test
|
||||
|
||||
[ ] [ "IN: compiler.tests.redefine4 USE: io : declaration-test-1 ( -- a ) \"X\" write f ;" eval( -- ) ] unit-test
|
||||
[ ] [ "in: compiler.tests.redefine4 USE: io : declaration-test-1 ( -- a ) \"X\" write f ;" eval( -- ) ] unit-test
|
||||
|
||||
[ "X" ] [ [ declaration-test ] with-string-writer ] unit-test
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine5
|
|||
|
||||
[ ] [
|
||||
"USING: sorting kernel math.order ;
|
||||
IN: compiler.tests.redefine5
|
||||
in: compiler.tests.redefine5
|
||||
GENERIC: my-generic ( a -- b ) ;
|
||||
M: object my-generic [ <=> ] sort ;
|
||||
: my-inline ( a -- b ) my-generic ;"
|
||||
|
@ -17,7 +17,7 @@ in: compiler.tests.redefine5
|
|||
|
||||
[ ] [
|
||||
"USE: kernel
|
||||
IN: compiler.tests.redefine5
|
||||
in: compiler.tests.redefine5
|
||||
TUPLE: my-tuple ;
|
||||
M: my-tuple my-generic drop 0 ;" eval( -- )
|
||||
] unit-test
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine6
|
|||
|
||||
[ ] [
|
||||
"USING: kernel kernel.private ;
|
||||
IN: compiler.tests.redefine6
|
||||
in: compiler.tests.redefine6
|
||||
GENERIC: my-generic ( a -- b ) ;
|
||||
MIXIN: my-mixin
|
||||
M: my-mixin my-generic drop 0 ;
|
||||
|
@ -18,7 +18,7 @@ in: compiler.tests.redefine6
|
|||
|
||||
[ ] [
|
||||
"USING: kernel ;
|
||||
IN: compiler.tests.redefine6
|
||||
in: compiler.tests.redefine6
|
||||
TUPLE: my-tuple ;
|
||||
M: my-tuple my-generic drop 1 ;
|
||||
INSTANCE: my-tuple my-mixin"
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine7
|
|||
|
||||
[ ] [
|
||||
"USING: kernel math ;
|
||||
IN: compiler.tests.redefine7
|
||||
in: compiler.tests.redefine7
|
||||
MIXIN: my-mixin
|
||||
INSTANCE: fixnum my-mixin
|
||||
: my-inline ( a -- b ) dup my-mixin? [ 1 + ] when ;"
|
||||
|
@ -17,7 +17,7 @@ in: compiler.tests.redefine7
|
|||
|
||||
[ ] [
|
||||
"USE: math
|
||||
IN: compiler.tests.redefine7
|
||||
in: compiler.tests.redefine7
|
||||
INSTANCE: float my-mixin"
|
||||
eval( -- )
|
||||
] unit-test
|
||||
|
|
|
@ -8,7 +8,7 @@ in: compiler.tests.redefine8
|
|||
|
||||
[ ] [
|
||||
"USING: kernel math math.order sorting ;
|
||||
IN: compiler.tests.redefine8
|
||||
in: compiler.tests.redefine8
|
||||
MIXIN: my-mixin
|
||||
INSTANCE: fixnum my-mixin
|
||||
GENERIC: my-generic ( a -- b ) ;
|
||||
|
@ -20,7 +20,7 @@ in: compiler.tests.redefine8
|
|||
|
||||
[ ] [
|
||||
"USE: math
|
||||
IN: compiler.tests.redefine8
|
||||
in: compiler.tests.redefine8
|
||||
INSTANCE: float my-mixin"
|
||||
eval( -- )
|
||||
] unit-test
|
||||
|
|
|
@ -237,7 +237,7 @@ M: f single-combination-test-2 single-combination-test-4 ;
|
|||
[ "compiler.tests.foo" forget-vocab ] with-compilation-unit
|
||||
[ t ] [
|
||||
"USING: prettyprint words accessors ;
|
||||
IN: compiler.tests.foo
|
||||
in: compiler.tests.foo
|
||||
: (recursive) ( -- ) (recursive) (recursive) ; inline recursive
|
||||
: recursive ( -- ) (recursive) ;
|
||||
\\ (recursive) word-optimized?" eval( -- obj )
|
||||
|
|
|
@ -132,7 +132,7 @@ TUPLE: a-tuple x ;
|
|||
|
||||
{ t } [ test-quotatation cached-effect ( a -- b ) effect<= ] unit-test
|
||||
|
||||
{ } [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a b -- c ) + ;" eval( -- ) ] unit-test
|
||||
{ } [ "in: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a b -- c ) + ;" eval( -- ) ] unit-test
|
||||
|
||||
{ t } [ test-quotatation cached-effect ( a b -- c ) effect<= ] unit-test
|
||||
|
||||
|
@ -140,7 +140,7 @@ TUPLE: a-tuple x ;
|
|||
|
||||
{ 4 } [ 1 3 test-quotatation inline-cache-invalidation-test ] unit-test
|
||||
|
||||
{ } [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a -- c ) 1 + ;" eval( -- ) ] unit-test
|
||||
{ } [ "in: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a -- c ) 1 + ;" eval( -- ) ] unit-test
|
||||
|
||||
[ 1 3 test-quotatation inline-cache-invalidation-test ] [ T{ wrong-values f [ call(-redefine-test ] ( a b -- c ) } = ] must-fail-with
|
||||
|
||||
|
@ -153,6 +153,6 @@ TUPLE: my-tuple a b c ;
|
|||
|
||||
{ T{ my-tuple f 1 2 3 } } [ 1 2 3 my-quot my-word ] unit-test
|
||||
|
||||
{ } [ "IN: compiler.tree.propagation.call-effect.tests TUPLE: my-tuple a b ;" eval( -- ) ] unit-test
|
||||
{ } [ "in: compiler.tree.propagation.call-effect.tests TUPLE: my-tuple a b ;" eval( -- ) ] unit-test
|
||||
|
||||
[ 1 2 3 my-quot my-word ] [ wrong-values? ] must-fail-with
|
||||
|
|
|
@ -294,7 +294,7 @@ M: attempt-all-error summary drop "Nothing to attempt" ;
|
|||
M: already-disposed summary drop "Attempting to operate on disposed object" ;
|
||||
|
||||
M: no-current-vocab-error summary
|
||||
drop "Not in a vocabulary; IN: form required" ;
|
||||
drop "Not in a vocabulary; in: form required" ;
|
||||
|
||||
M: no-word-error summary
|
||||
name>>
|
||||
|
|
|
@ -16,7 +16,7 @@ DESCRIPTIVE: divide ( num denom -- fraction ) / ;
|
|||
[ 3 0 divide ] [ ] recover
|
||||
] unit-test
|
||||
|
||||
{ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE: divide ( num denom -- fraction ) / ;\n" }
|
||||
{ "USING: descriptive math ;\nin: descriptive.tests\nDESCRIPTIVE: divide ( num denom -- fraction ) / ;\n" }
|
||||
[ \ divide [ see ] with-string-writer ] unit-test
|
||||
|
||||
DESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;
|
||||
|
@ -31,4 +31,4 @@ DESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;
|
|||
}
|
||||
} [ [ 3 0 divide* ] [ ] recover ] unit-test
|
||||
|
||||
{ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;\n" } [ \ divide* [ see ] with-string-writer ] unit-test
|
||||
{ "USING: descriptive math ;\nin: descriptive.tests\nDESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;\n" } [ \ divide* [ see ] with-string-writer ] unit-test
|
||||
|
|
|
@ -105,7 +105,7 @@ M: integer W 1 + ;
|
|||
|
||||
! Does replacing an ordinary word with a functor-generated one work?
|
||||
[ [ ] ] [
|
||||
"IN: functors.tests
|
||||
"in: functors.tests
|
||||
|
||||
TUPLE: some-tuple ;
|
||||
: some-word ( -- ) ;
|
||||
|
@ -144,7 +144,7 @@ SYMBOL: W-symbol
|
|||
;FUNCTOR
|
||||
|
||||
[ [ ] ] [
|
||||
"IN: functors.tests
|
||||
"in: functors.tests
|
||||
<< \"some\" redefine-test >>" <string-reader> "functors-test" parse-stream
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ HELP: file-system-info
|
|||
{ $examples
|
||||
{ $unchecked-example
|
||||
"USING: io.files.info io.pathnames math prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
": gb ( m -- n ) 30 2^ * ;"
|
||||
""
|
||||
|
|
|
@ -91,7 +91,7 @@ SYMBOLS: out-path err-path ;
|
|||
out-path get-global ascii file-lines first
|
||||
] unit-test
|
||||
|
||||
[ "IN: scratchpad " ] [
|
||||
[ "in: scratchpad " ] [
|
||||
<process>
|
||||
console-vm-path "-run=listener" 2array >>command
|
||||
+closed+ >>stdin
|
||||
|
@ -224,7 +224,7 @@ SYMBOLS: out-path err-path ;
|
|||
out-path get-global utf8 file-contents
|
||||
] unit-test
|
||||
|
||||
[ "IN: scratchpad " ] [
|
||||
[ "in: scratchpad " ] [
|
||||
console-vm-path "-run=listener" 2array
|
||||
ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream
|
||||
] unit-test
|
||||
|
|
|
@ -10,7 +10,7 @@ HELP: $
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: kernel literals prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
"CONSTANT: five 5"
|
||||
"{ $ five } ."
|
||||
|
@ -18,7 +18,7 @@ HELP: $
|
|||
}
|
||||
{ $example
|
||||
"USING: kernel literals prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
": seven-eleven ( -- a b ) 7 11 ;"
|
||||
"{ $ seven-eleven } ."
|
||||
|
@ -33,7 +33,7 @@ HELP: $[
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: kernel literals math prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
"<< CONSTANT: five 5 >>"
|
||||
"{ $[ five dup 1 + dup 2 + ] } ."
|
||||
|
@ -48,7 +48,7 @@ HELP: ${
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: kernel literals math prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
"CONSTANT: five 5"
|
||||
"CONSTANT: six 6"
|
||||
|
@ -65,7 +65,7 @@ HELP: flags{
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: literals kernel prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"CONSTANT: x 0x1"
|
||||
"flags{ 0x20 x 0b100 } .h"
|
||||
"0x25"
|
||||
|
@ -77,7 +77,7 @@ ARTICLE: "literals" "Interpolating code results into literal values"
|
|||
"The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
|
||||
{ $example
|
||||
"USING: kernel literals math prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
"<< CONSTANT: five 5 >>"
|
||||
"{ $ five $[ five dup 1 + dup 2 + ] } ."
|
||||
|
|
|
@ -43,7 +43,7 @@ HELP: match-replace
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: match prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"MATCH-VARS: ?a ?b ;"
|
||||
"{ 1 2 } { ?a ?b } { ?b ?a } match-replace ."
|
||||
"{ 2 1 }"
|
||||
|
|
|
@ -28,7 +28,7 @@ HELP: <mirror>
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: assocs mirrors prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"TUPLE: circle center radius ;"
|
||||
"C: <circle> circle"
|
||||
"{ 100 50 } 15 <circle> <mirror> >alist ."
|
||||
|
|
|
@ -56,7 +56,7 @@ TUPLE: color
|
|||
! Test reshaping with a mirror
|
||||
1 2 3 color boa <mirror> "mirror" set
|
||||
|
||||
{ } [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test
|
||||
{ } [ "in: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test
|
||||
|
||||
{ 1 } [ "red" "mirror" get at ] unit-test
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ HELP: EBNF:
|
|||
{ $examples
|
||||
{ $example
|
||||
"USING: prettyprint peg.ebnf ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"EBNF: foo rule=\"a\" \"b\" ;EBNF"
|
||||
"\"ab\" foo ."
|
||||
"V{ \"a\" \"b\" }"
|
||||
|
@ -413,7 +413,7 @@ $nl
|
|||
{ $example
|
||||
"USING: prettyprint peg peg.ebnf kernel math.parser strings"
|
||||
"accessors math arrays ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
""
|
||||
"TUPLE: ast-number value ;"
|
||||
"TUPLE: ast-string value ;"
|
||||
|
|
|
@ -69,12 +69,12 @@ unit-test
|
|||
|
||||
: foo ( a -- b ) dup * ; inline
|
||||
|
||||
{ "USING: kernel math ;\nIN: prettyprint.tests\n: foo ( a -- b ) dup * ; inline\n" }
|
||||
{ "USING: kernel math ;\nin: prettyprint.tests\n: foo ( a -- b ) dup * ; inline\n" }
|
||||
[ [ \ foo see ] with-string-writer ] unit-test
|
||||
|
||||
: bar ( x -- y ) 2 + ;
|
||||
|
||||
{ "USING: math ;\nIN: prettyprint.tests\n: bar ( x -- y ) 2 + ;\n" }
|
||||
{ "USING: math ;\nin: prettyprint.tests\n: bar ( x -- y ) 2 + ;\n" }
|
||||
[ [ \ bar see ] with-string-writer ] unit-test
|
||||
|
||||
: blah ( a a a a a a a a a a a a a a a a a a a a -- )
|
||||
|
@ -151,7 +151,7 @@ M: object method-layout ;
|
|||
: soft-break-test ( -- str )
|
||||
{
|
||||
"USING: kernel math sequences strings ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
": soft-break-layout ( x y -- ? )"
|
||||
" over string? ["
|
||||
" over hashcode over hashcode number="
|
||||
|
@ -168,7 +168,7 @@ DEFER: parse-error-file
|
|||
: another-soft-break-test ( -- str )
|
||||
{
|
||||
"USING: make sequences ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
": another-soft-break-layout ( node -- quot )"
|
||||
" parse-error-file"
|
||||
" [ <reversed> \"hello world foo\" suffix ] [ ] make ;"
|
||||
|
@ -182,7 +182,7 @@ DEFER: parse-error-file
|
|||
: string-layout ( -- str )
|
||||
{
|
||||
"USING: accessors debugger io kernel ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
": string-layout-test ( error -- )"
|
||||
" \"Expected \" write dup want>> expected>string write"
|
||||
" \" but got \" write got>> expected>string print ;"
|
||||
|
@ -196,7 +196,7 @@ DEFER: parse-error-file
|
|||
: narrow-test ( -- array )
|
||||
{
|
||||
"USING: arrays combinators continuations kernel sequences ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
": narrow-layout ( obj1 obj2 -- obj3 )"
|
||||
" {"
|
||||
" { [ dup continuation? ] [ append ] }"
|
||||
|
@ -211,7 +211,7 @@ DEFER: parse-error-file
|
|||
|
||||
: another-narrow-test ( -- array )
|
||||
{
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
": another-narrow-layout ( -- obj )"
|
||||
" H{"
|
||||
" { 1 2 }"
|
||||
|
@ -239,10 +239,10 @@ M: class-see-layout class-see-layout ;
|
|||
|
||||
{
|
||||
{
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: class-see-layout ;"
|
||||
""
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"GENERIC: class-see-layout ( x -- y ) ;"
|
||||
""
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ M: class-see-layout class-see-layout ;
|
|||
|
||||
! Regression
|
||||
{ t } [
|
||||
"IN: prettyprint.tests\nGENERIC: generic-decl-test ( a -- b ) ; flushable\n"
|
||||
"in: prettyprint.tests\nGENERIC: generic-decl-test ( a -- b ) ; flushable\n"
|
||||
dup eval( -- )
|
||||
"generic-decl-test" "prettyprint.tests" lookup-word
|
||||
[ see ] with-string-writer =
|
||||
|
@ -292,13 +292,13 @@ M: f generic-see-test-with-f ;
|
|||
|
||||
PREDICATE: predicate-see-test < integer even? ;
|
||||
|
||||
{ "USING: math ;\nIN: prettyprint.tests\nPREDICATE: predicate-see-test < integer even? ;\n" } [
|
||||
{ "USING: math ;\nin: prettyprint.tests\nPREDICATE: predicate-see-test < integer even? ;\n" } [
|
||||
[ \ predicate-see-test see ] with-string-writer
|
||||
] unit-test
|
||||
|
||||
INTERSECTION: intersection-see-test sequence number ;
|
||||
|
||||
{ "USING: math sequences ;\nIN: prettyprint.tests\nINTERSECTION: intersection-see-test sequence number ;\n" } [
|
||||
{ "USING: math sequences ;\nin: prettyprint.tests\nINTERSECTION: intersection-see-test sequence number ;\n" } [
|
||||
[ \ intersection-see-test see ] with-string-writer
|
||||
] unit-test
|
||||
|
||||
|
@ -322,7 +322,7 @@ TUPLE: tuple-with-declared-slot { x integer } ;
|
|||
{
|
||||
{
|
||||
"USING: math ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: tuple-with-declared-slot { x integer initial: 0 } ;"
|
||||
""
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ TUPLE: tuple-with-read-only-slot { x read-only } ;
|
|||
|
||||
{
|
||||
{
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: tuple-with-read-only-slot { x read-only } ;"
|
||||
""
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ TUPLE: tuple-with-initial-slot { x initial: 123 } ;
|
|||
|
||||
{
|
||||
{
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: tuple-with-initial-slot { x initial: 123 } ;"
|
||||
""
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ TUPLE: tuple-with-initial-declared-slot { x integer initial: 123 } ;
|
|||
{
|
||||
{
|
||||
"USING: math ;"
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: tuple-with-initial-declared-slot"
|
||||
" { x integer initial: 123 } ;"
|
||||
""
|
||||
|
@ -372,7 +372,7 @@ TUPLE: final-tuple ; final
|
|||
|
||||
{
|
||||
{
|
||||
"IN: prettyprint.tests"
|
||||
"in: prettyprint.tests"
|
||||
"TUPLE: final-tuple ; final"
|
||||
""
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ in: prettyprint.stylesheet
|
|||
|
||||
<PRIVATE
|
||||
|
||||
{ POSTPONE: USING: POSTPONE: USE: POSTPONE: IN: }
|
||||
{ postpone: USING: postpone: use: postpone: in: }
|
||||
[
|
||||
{ { foreground COLOR: gray35 } }
|
||||
"word-style" set-word-prop
|
||||
|
|
|
@ -16,5 +16,5 @@ HELP: LAZY:
|
|||
{ $values { "word" "a new word to define" } { "definition" "a word definition" } }
|
||||
{ $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." }
|
||||
{ $examples
|
||||
{ $example "USING: arrays sequences prettyprint promises ;" "IN: scratchpad" "LAZY: zeroes ( -- pair ) 0 zeroes 2array ;" "zeroes force second force first ." "0" }
|
||||
{ $example "USING: arrays sequences prettyprint promises ;" "in: scratchpad" "LAZY: zeroes ( -- pair ) 0 zeroes 2array ;" "zeroes force second force first ." "0" }
|
||||
} ;
|
||||
|
|
|
@ -29,12 +29,12 @@ HELP: definer
|
|||
{ $contract "Outputs the parsing words which delimit the definition." }
|
||||
{ $examples
|
||||
{ $example "USING: definitions prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
": foo ( -- ) ; \\ foo definer . ."
|
||||
";\nPOSTPONE: :"
|
||||
}
|
||||
{ $example "USING: definitions prettyprint ;"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"SYMBOL: foo \\ foo definer . ."
|
||||
"f\nPOSTPONE: SYMBOL:"
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@ in: see.tests
|
|||
|
||||
CONSTANT: test-const 10
|
||||
|
||||
{ "IN: see.tests\nCONSTANT: test-const 10 inline\n" }
|
||||
{ "in: see.tests\nCONSTANT: test-const 10 inline\n" }
|
||||
[ [ \ test-const see ] with-string-writer ] unit-test
|
||||
|
||||
{ "IN: sequences\nERROR: non-negative-integer-expected n ;\n" }
|
||||
{ "in: sequences\nERROR: non-negative-integer-expected n ;\n" }
|
||||
[ [ \ non-negative-integer-expected see ] with-string-writer ] unit-test
|
||||
|
||||
ALIAS: test-alias +
|
||||
|
||||
{ "USING: math ;\nIN: see.tests\nALIAS: test-alias + inline\n" }
|
||||
{ "USING: math ;\nin: see.tests\nALIAS: test-alias + inline\n" }
|
||||
[ [ \ test-alias see ] with-string-writer ] unit-test
|
||||
|
||||
{ "IN: see.tests ALIAS: test-alias ( x y -- z )" }
|
||||
{ "in: see.tests ALIAS: test-alias ( x y -- z )" }
|
||||
[ \ test-alias summary ] unit-test
|
||||
|
||||
{ } [ gensym see ] unit-test
|
||||
|
|
|
@ -116,12 +116,12 @@ M: object declarations. drop ;
|
|||
|
||||
M: word declarations.
|
||||
{
|
||||
POSTPONE: delimiter
|
||||
POSTPONE: deprecated
|
||||
POSTPONE: inline
|
||||
POSTPONE: recursive
|
||||
POSTPONE: foldable
|
||||
POSTPONE: flushable
|
||||
postpone: delimiter
|
||||
postpone: deprecated
|
||||
postpone: inline
|
||||
postpone: recursive
|
||||
postpone: foldable
|
||||
postpone: flushable
|
||||
} [ declaration. ] with each ;
|
||||
|
||||
: pprint-; ( -- ) \ ; pprint-word ;
|
||||
|
|
|
@ -6,7 +6,7 @@ in: slots.syntax
|
|||
HELP: slots[
|
||||
{ $description "Outputs several slot values to the stack." }
|
||||
{ $example "USING: kernel prettyprint slots.syntax ;"
|
||||
"IN: slots.syntax.example"
|
||||
"in: slots.syntax.example"
|
||||
"TUPLE: rectangle width height ;"
|
||||
"T{ rectangle { width 3 } { height 5 } } slots[ width height ] [ . ] bi@"
|
||||
"3
|
||||
|
@ -16,7 +16,7 @@ HELP: slots[
|
|||
HELP: slots{
|
||||
{ $description "Outputs an array of slot values from a tuple." }
|
||||
{ $example "USING: prettyprint slots.syntax ;"
|
||||
"IN: slots.syntax.example"
|
||||
"in: slots.syntax.example"
|
||||
"TUPLE: rectangle width height ;"
|
||||
"T{ rectangle { width 3 } { height 5 } } slots{ width height } ."
|
||||
"{ 3 5 }"
|
||||
|
@ -25,7 +25,7 @@ HELP: slots{
|
|||
HELP: set-slots{
|
||||
{ $description "Sets slot values in a tuple from an array." }
|
||||
{ $example "USING: prettyprint slots.syntax kernel ;"
|
||||
"IN: slots.syntax.example"
|
||||
"in: slots.syntax.example"
|
||||
"TUPLE: rectangle width height ;"
|
||||
"rectangle new { 3 5 } set-slots{ width height } ."
|
||||
"T{ rectangle { width 3 } { height 5 } }"
|
||||
|
@ -34,7 +34,7 @@ HELP: set-slots{
|
|||
HELP: set-slots[
|
||||
{ $description "Sets slot values in a tuple from the stack." }
|
||||
{ $example "USING: prettyprint slots.syntax kernel ;"
|
||||
"IN: slots.syntax.example"
|
||||
"in: slots.syntax.example"
|
||||
"TUPLE: rectangle width height ;"
|
||||
"rectangle new 3 5 set-slots[ width height ] ."
|
||||
"T{ rectangle { width 3 } { height 5 } }"
|
||||
|
@ -43,7 +43,7 @@ HELP: set-slots[
|
|||
HELP: copy-slots{
|
||||
{ $description "Copy slots from the first object to the second and return the second object." }
|
||||
{ $example "USING: prettyprint slots.syntax kernel ;"
|
||||
"IN: slots.syntax.example"
|
||||
"in: slots.syntax.example"
|
||||
"TUPLE: thing1 a b ;"
|
||||
"TUPLE: thing2 a b c ;"
|
||||
"1 2 thing1 boa 11 22 33 thing2 boa copy-slots{ a b } ."
|
||||
|
|
|
@ -19,7 +19,7 @@ $nl
|
|||
"An example:"
|
||||
{ $example
|
||||
"USE: tuple-arrays"
|
||||
"IN: scratchpad"
|
||||
"in: scratchpad"
|
||||
"TUPLE: point x y ; final"
|
||||
"TUPLE-ARRAY: point"
|
||||
"{ T{ point f 1 2 } T{ point f 1 3 } T{ point f 2 3 } } >point-array first short."
|
||||
|
|
|
@ -32,14 +32,14 @@ TUPLE-ARRAY: broken
|
|||
{ 100 } [ 100 <broken-array> length ] unit-test
|
||||
|
||||
! Can't define a tuple array for a non-tuple class
|
||||
[ "IN: tuple-arrays.tests USING: tuple-arrays words ; TUPLE-ARRAY: word" eval( -- ) ]
|
||||
[ "in: tuple-arrays.tests USING: tuple-arrays words ; TUPLE-ARRAY: word" eval( -- ) ]
|
||||
[ error>> not-a-tuple? ]
|
||||
must-fail-with
|
||||
|
||||
! Can't define a tuple array for a non-final class
|
||||
TUPLE: non-final x ;
|
||||
|
||||
[ "IN: tuple-arrays.tests USE: tuple-arrays TUPLE-ARRAY: non-final" eval( -- ) ]
|
||||
[ "in: tuple-arrays.tests USE: tuple-arrays TUPLE-ARRAY: non-final" eval( -- ) ]
|
||||
[ error>> not-final? ]
|
||||
must-fail-with
|
||||
|
||||
|
@ -62,7 +62,7 @@ TUPLE-ARRAY: tuple-to-struct
|
|||
|
||||
! This shouldn't crash
|
||||
{ } [
|
||||
"IN: tuple-arrays.tests
|
||||
"in: tuple-arrays.tests
|
||||
USING: alien.c-types classes.struct ;
|
||||
STRUCT: tuple-to-struct { x int } ;"
|
||||
eval( -- )
|
||||
|
|
|
@ -14,7 +14,7 @@ in: vocabs.prettyprint.tests
|
|||
|
||||
: manifest-test-2 ( -- string )
|
||||
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
|
||||
IN: vocabs.prettyprint.tests
|
||||
in: vocabs.prettyprint.tests
|
||||
|
||||
<< manifest get pprint-manifest >>" ;
|
||||
|
||||
|
@ -30,7 +30,7 @@ in: vocabs.prettyprint.tests"
|
|||
QUALIFIED: system
|
||||
QUALIFIED-WITH: assocs a
|
||||
EXCLUDE: parser => run-file ;
|
||||
IN: vocabs.prettyprint.tests
|
||||
in: vocabs.prettyprint.tests
|
||||
|
||||
<< manifest get pprint-manifest >>" ;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ in: vocabs.prettyprint
|
|||
[ vocab-name ] [ lookup-vocab vocab-style ] bi styled-text ;
|
||||
|
||||
: pprint-in ( vocab -- )
|
||||
[ \ IN: pprint-word pprint-vocab ] with-pprint ;
|
||||
[ \ in: pprint-word pprint-vocab ] with-pprint ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
Loading…
Reference in New Issue