]> gitweb.factorcode.org Git - factor.git/blob - extra/peg/javascript/parser/parser-tests.factor
factor: clean up spaces in -tests files
[factor.git] / extra / peg / javascript / parser / parser-tests.factor
1 ! Copyright (C) 2008 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 USING: kernel tools.test peg peg.javascript.ast peg.javascript.parser 
5        accessors sequences math peg.ebnf peg.ebnf.private ;
6 IN: peg.javascript.parser.tests
7
8 {
9   T{
10       ast-begin
11       f
12       V{
13           T{ ast-number f 123 }
14           T{ ast-string f "hello" }
15           T{
16               ast-call
17               f
18               T{ ast-get f "foo" }
19               V{ T{ ast-get f "x" } }
20           }
21       }
22   }
23 } [
24   "123; 'hello'; foo(x);" javascript
25 ] unit-test
26
27 { t } [
28 """
29 var x=5
30 var y=10
31 """ main \ javascript rule (parse) remaining>> length zero?
32 ] unit-test
33
34
35 { t } [
36 """
37 function foldl(f, initial, seq) {
38    for(var i=0; i< seq.length; ++i)
39      initial = f(initial, seq[i]);
40    return initial;
41 }""" main \ javascript rule (parse) remaining>> length zero?
42 ] unit-test
43
44 { t } [
45 """
46 ParseState.prototype.from = function(index) {
47     var r = new ParseState(this.input, this.index + index);
48     r.cache = this.cache;
49     r.length = this.length - index;
50     return r;
51 }""" main \ javascript rule (parse) remaining>> length zero?
52 ] unit-test