factor/extra/peg/javascript/parser/parser-tests.factor

54 lines
1.1 KiB
Factor
Raw Normal View History

2008-06-18 08:42:11 -04:00
! Copyright (C) 2008 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
!
USING: kernel tools.test peg peg.javascript.ast peg.javascript.parser
2008-07-03 23:48:52 -04:00
accessors multiline sequences math peg.ebnf ;
2008-06-18 08:42:11 -04:00
IN: peg.javascript.parser.tests
{
T{
ast-begin
f
V{
T{ ast-number f 123 }
T{ ast-string f "hello" }
T{
ast-call
f
T{ ast-get f "foo" }
V{ T{ ast-get f "x" } }
}
}
}
} [
2008-07-03 23:48:52 -04:00
"123; 'hello'; foo(x);" javascript
2008-06-18 09:24:17 -04:00
] unit-test
2008-06-18 09:45:09 -04:00
{ t } [
<"
var x=5
var y=10
2008-07-03 23:48:52 -04:00
"> main \ javascript rule (parse) remaining>> length zero?
2008-06-18 09:45:09 -04:00
] unit-test
2008-06-18 09:24:17 -04:00
{ t } [
<"
function foldl(f, initial, seq) {
for(var i=0; i< seq.length; ++i)
initial = f(initial, seq[i]);
return initial;
2008-09-25 04:37:48 -04:00
}"> main \ javascript rule (parse) remaining>> length zero?
2008-06-18 09:24:17 -04:00
] unit-test
{ t } [
<"
ParseState.prototype.from = function(index) {
var r = new ParseState(this.input, this.index + index);
r.cache = this.cache;
r.length = this.length - index;
return r;
2008-09-25 04:37:48 -04:00
}"> main \ javascript rule (parse) remaining>> length zero?
] unit-test
2008-06-18 09:45:09 -04:00