UNPKG

1.24 kBtext/coffeescriptView Raw
1test_scan = ->
2 if DEBUG then console.log "test_scan ----------------------------"
3
4 run_test [
5
6 "a^^b",
7 "a^^ ? b\nStop: syntax error",
8
9 "(a+b",
10 "(a+b ? \nStop: ) expected",
11
12 "quote(1/(x*log(a*x)))", # test case A
13 "1/(x*log(a*x))",
14
15 "\"hello",
16 "\"hello ? \nStop: runaway string",
17
18 # make sure question mark can appear after newlines
19
20 "a+\nb+\nc+",
21 "a+\nb+\nc+ ? \nStop: syntax error",
22
23 # this bug fixed in version 30 (used to give one result, 14)
24
25 "(1+1)",
26 "2",
27
28 "2+2\n(3+3)",
29 "4\n6",
30
31 # plus and minus cannot cross newline
32
33 "1\n-1",
34 "1\n-1",
35
36 "1\n+1",
37 "1\n1",
38
39 # implicit multiplication is parsed fine in
40 # in the obvious cases where the first factor
41 # is a "naked" number. Note that
42 # (2)(a) doesn't work (yet) instead.
43 # In many other cases such as a(b) it's in
44 # principle impossible at parse time to turn that
45 # into a multiplication because the first factor
46 # could be a function, so that'd be a function
47 # call.
48
49 "2(a) * 2a",
50 "4*a^2",
51
52 "2a3b",
53 "2*a3b",
54
55 "2a 3b",
56 "6*a*b",
57
58 "2 a 3b",
59 "6*a*b",
60
61 "2 a 3 b",
62 "6*a*b",
63
64 "2(a)3(b)",
65 "6*a*b",
66
67 "2(a)b*3",
68 "6*a*b",
69
70 "(a)2 * 2a",
71 "4*a^2",
72
73 "3 (2 x^3 + x^2 - 23 x + 20)",
74 "6*x^3+3*x^2-69*x+60",
75
76 ]
77