! (c)Joe Groff bsd license
- USING: accessors alien alien.c-types ascii
+ USING: accessors alien alien.c-types alien.data ascii
assocs byte-arrays classes.struct classes.tuple.private
combinators compiler.tree.debugger compiler.units destructors
io.encodings.utf8 io.pathnames io.streams.string kernel libc
-literals math mirrors multiline namespaces prettyprint
+literals math mirrors namespaces prettyprint
prettyprint.config see sequences specialized-arrays system
tools.test parser lexer eval layouts ;
+ FROM: math => float ;
+ QUALIFIED-WITH: alien.c-types c
SPECIALIZED-ARRAY: char
SPECIALIZED-ARRAY: int
SPECIALIZED-ARRAY: ushort
[ {
{ "underlying" B{ 98 0 0 98 127 0 0 127 0 0 0 0 } }
- { { "x" "char" } 98 }
- { { "y" "int" } HEX: 7F00007F }
- { { "z" "bool" } f }
+ { { "x" char } 98 }
+ { { "y" int } HEX: 7F00007F }
+ { { "z" bool } f }
} ] [
B{ 98 0 0 98 127 0 0 127 0 0 0 0 } struct-test-foo memory>struct
make-mirror >alist
] unit-test
UNION-STRUCT: struct-test-float-and-bits
- { f float }
+ { f c:float }
{ bits uint } ;
[ 1.0 ] [ struct-test-float-and-bits <struct> 1.0 float>bits >>bits f>> ] unit-test
] with-scope
] unit-test
- [ "USING: classes.struct ;
-[ <" USING: alien.c-types classes.struct ;
++[ "USING: alien.c-types classes.struct ;
IN: classes.struct.tests
STRUCT: struct-test-foo
{ x char initial: 0 } { y int initial: 123 } { z bool } ;
-"> ]
+" ]
[ [ struct-test-foo see ] with-string-writer ] unit-test
- [ "USING: classes.struct ;
-[ <" USING: alien.c-types classes.struct ;
++[ "USING: alien.c-types classes.struct ;
IN: classes.struct.tests
UNION-STRUCT: struct-test-float-and-bits
{ f float initial: 0.0 } { bits uint initial: 0 } ;
-"> ]
+" ]
[ [ struct-test-float-and-bits see ] with-string-writer ] unit-test
[ {
{ offset 0 }
{ initial 0 }
{ class fixnum }
- { type "char" }
+ { type char }
}
T{ struct-slot-spec
{ name "y" }
{ offset 4 }
{ initial 123 }
{ class integer }
- { type "int" }
+ { type int }
}
T{ struct-slot-spec
{ name "z" }
{ offset 8 }
{ initial f }
- { type "bool" }
+ { type bool }
{ class object }
}
} ] [ "struct-test-foo" c-type fields>> ] unit-test
T{ struct-slot-spec
{ name "f" }
{ offset 0 }
- { type "float" }
+ { type c:float }
{ class float }
{ initial 0.0 }
}
T{ struct-slot-spec
{ name "bits" }
{ offset 0 }
- { type "uint" }
+ { type uint }
{ class integer }
{ initial 0 }
}
] unit-test
STRUCT: struct-test-optimization
- { x { "int" 3 } } { y int } ;
+ { x { int 3 } } { y int } ;
SPECIALIZED-ARRAY: struct-test-optimization
USING: classes.struct functors tools.test math words kernel
- parser io.streams.string generic ;
+ multiline parser io.streams.string generic ;
+ QUALIFIED-WITH: alien.c-types c
IN: functors.tests
<<
! Does replacing an ordinary word with a functor-generated one work?
[ [ ] ] [
- <" IN: functors.tests
+ "IN: functors.tests
TUPLE: some-tuple ;
: some-word ( -- ) ;
GENERIC: some-generic ( a -- b )
M: some-tuple some-generic ;
- SYMBOL: some-symbol
- "> <string-reader> "functors-test" parse-stream
+ SYMBOL: some-symbol" <string-reader> "functors-test" parse-stream
] unit-test
: test-redefinition ( -- )
;FUNCTOR
[ [ ] ] [
- <" IN: functors.tests
- << "some" redefine-test >>
- "> <string-reader> "functors-test" parse-stream
+ """IN: functors.tests
+ << "some" redefine-test >>""" <string-reader> "functors-test" parse-stream
] unit-test
test-redefinition
WHERE
STRUCT: T-class
- { NAME int }
+ { NAME c:int }
{ x { TYPE 4 } }
- { y { "short" N } }
+ { y { c:short N } }
{ z TYPE initial: 5 }
- { float { "float" 2 } } ;
+ { float { c:float 2 } } ;
;FUNCTOR
- "a-struct" "nemo" "char" 2 define-a-struct
+ "a-struct" "nemo" c:char 2 define-a-struct
>>
{ offset 0 }
{ class integer }
{ initial 0 }
- { type "int" }
+ { type c:int }
}
T{ struct-slot-spec
{ name "x" }
{ offset 4 }
{ class object }
{ initial f }
- { type { "char" 4 } }
+ { type { c:char 4 } }
}
T{ struct-slot-spec
{ name "y" }
{ offset 8 }
{ class object }
{ initial f }
- { type { "short" 2 } }
+ { type { c:short 2 } }
}
T{ struct-slot-spec
{ name "z" }
{ offset 12 }
{ class fixnum }
{ initial 5 }
- { type "char" }
+ { type c:char }
}
T{ struct-slot-spec
{ name "float" }
{ offset 16 }
{ class object }
{ initial f }
- { type { "float" 2 } }
+ { type { c:float 2 } }
}
}
] [ a-struct struct-slots ] unit-test
specialized-arrays.private sequences alien.c-types accessors
kernel arrays combinators compiler compiler.units classes.struct
combinators.smart compiler.tree.debugger math libc destructors
- sequences.private eval words vocabs namespaces assocs
- prettyprint ;
+ sequences.private multiline eval words vocabs namespaces
+ assocs prettyprint alien.data ;
+ FROM: alien.c-types => float ;
SPECIALIZED-ARRAY: int
SPECIALIZED-ARRAY: bool
] unit-test
[
- <"
+ """
IN: specialized-arrays.tests
USING: specialized-arrays ;
-SPECIALIZED-ARRAY: __does_not_exist__ "> eval( -- )
+SPECIALIZED-ARRAY: __does_not_exist__ """ eval( -- )
] must-fail
[ ] [
- <"
+ """
IN: specialized-arrays.tests
USING: classes.struct specialized-arrays ;
STRUCT: __does_not_exist__ { x int } ;
SPECIALIZED-ARRAY: __does_not_exist__
-"> eval( -- )
+""" eval( -- )
] unit-test
[ f ] [
HELP: "
{ $syntax "\"string...\"" }
{ $values { "string" "literal and escaped characters" } }
-{ $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", and appends the resulting string to the parse tree. String literals cannot span multiple lines. Strings containing the " { $link POSTPONE: " } " character and various other special characters can be read by inserting " { $link "escape" } "." }
+{ $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", and appends the resulting string to the parse tree. String literals can span multiple lines. Strings containing the " { $link POSTPONE: " } " character and various other special characters can be read by inserting " { $link "escape" } "." }
{ $examples
"A string with a newline in it:"
{ $example "USE: io" "\"Hello\\nworld\" print" "Hello\nworld" }
{ $description "Discards all input until the end of the line." } ;
HELP: HEX:
- { $syntax "HEX: integer" }
- { $values { "integer" "hexadecimal digits (0-9, a-f, A-F)" } }
- { $description "Adds an integer read from a hexadecimal literal to the parse tree." }
- { $examples { $example "USE: prettyprint" "HEX: ff ." "255" } } ;
+ { $syntax "HEX: NNN" "HEX: NNN.NNNpEEE" }
+ { $values { "N" "hexadecimal digit (0-9, a-f, A-F)" } { "pEEE" "decimal exponent value" } }
+ { $description "Adds an integer or floating-point value read from a hexadecimal literal to the parse tree." }
+ { $examples
+ { $example "USE: prettyprint" "HEX: ff ." "255" }
+ { $example "USE: prettyprint" "HEX: 1.8p5 ." "48.0" }
+ } ;
HELP: OCT:
{ $syntax "OCT: integer" }