1
- const parser = require ( ' ../main' ) ;
1
+ const parser = require ( " ../main" ) ;
2
2
3
3
describe ( "encapsed" , function ( ) {
4
4
it ( "variable (simple syntax)" , function ( ) {
@@ -14,13 +14,17 @@ describe("encapsed", function() {
14
14
expect ( parser . parseEval ( '"string $array[0] string";' ) ) . toMatchSnapshot ( ) ;
15
15
} ) ;
16
16
it ( "offsetlookup (2) (simple syntax)" , function ( ) {
17
- expect ( parser . parseEval ( '"string $array[koolaid1] string";' ) ) . toMatchSnapshot ( ) ;
17
+ expect (
18
+ parser . parseEval ( '"string $array[koolaid1] string";' )
19
+ ) . toMatchSnapshot ( ) ;
18
20
} ) ;
19
21
it ( "offsetlookup (3) (simple syntax)" , function ( ) {
20
22
expect ( parser . parseEval ( '"string $array[0][0] string";' ) ) . toMatchSnapshot ( ) ;
21
23
} ) ;
22
24
it ( "propertylookup (simple syntax)" , function ( ) {
23
- expect ( parser . parseEval ( '"string $obj->property string";' ) ) . toMatchSnapshot ( ) ;
25
+ expect (
26
+ parser . parseEval ( '"string $obj->property string";' )
27
+ ) . toMatchSnapshot ( ) ;
24
28
} ) ;
25
29
it ( "variable with space opening before curly" , function ( ) {
26
30
expect ( parser . parseEval ( '"string { $var} string";' ) ) . toMatchSnapshot ( ) ;
@@ -32,22 +36,34 @@ describe("encapsed", function() {
32
36
expect ( parser . parseEval ( '"string {$var} string";' ) ) . toMatchSnapshot ( ) ;
33
37
} ) ;
34
38
it ( "propertylookup (complex syntax)" , function ( ) {
35
- expect ( parser . parseEval ( '"string {$obj->property} string";' ) ) . toMatchSnapshot ( ) ;
39
+ expect (
40
+ parser . parseEval ( '"string {$obj->property} string";' )
41
+ ) . toMatchSnapshot ( ) ;
36
42
} ) ;
37
43
it ( "offsetlookup (complex syntax)" , function ( ) {
38
- expect ( parser . parseEval ( '"string {$array["key"]} string";' ) ) . toMatchSnapshot ( ) ;
44
+ expect (
45
+ parser . parseEval ( '"string {$array["key"]} string";' )
46
+ ) . toMatchSnapshot ( ) ;
39
47
} ) ;
40
48
it ( "offsetlookup 2 (complex syntax)" , function ( ) {
41
- expect ( parser . parseEval ( '"string {$array[4][3]} string";' ) ) . toMatchSnapshot ( ) ;
49
+ expect (
50
+ parser . parseEval ( '"string {$array[4][3]} string";' )
51
+ ) . toMatchSnapshot ( ) ;
42
52
} ) ;
43
53
it ( "offsetlookup 3 (complex syntax)" , function ( ) {
44
- expect ( parser . parseEval ( '"string {$arr[foo][3]} string";' ) ) . toMatchSnapshot ( ) ;
54
+ expect (
55
+ parser . parseEval ( '"string {$arr[foo][3]} string";' )
56
+ ) . toMatchSnapshot ( ) ;
45
57
} ) ;
46
58
it ( "offsetlookup 4 (complex syntax)" , function ( ) {
47
- expect ( parser . parseEval ( '"string {$arr["foo"][3]} string";' ) ) . toMatchSnapshot ( ) ;
59
+ expect (
60
+ parser . parseEval ( '"string {$arr["foo"][3]} string";' )
61
+ ) . toMatchSnapshot ( ) ;
48
62
} ) ;
49
63
it ( "propertylookup and offsetlookup (complex syntax)" , function ( ) {
50
- expect ( parser . parseEval ( '"string {$obj->values[3]->name} string";' ) ) . toMatchSnapshot ( ) ;
64
+ expect (
65
+ parser . parseEval ( '"string {$obj->values[3]->name} string";' )
66
+ ) . toMatchSnapshot ( ) ;
51
67
} ) ;
52
68
it ( "value of the var (complex syntax)" , function ( ) {
53
69
expect ( parser . parseEval ( '"string {${$name}} string";' ) ) . toMatchSnapshot ( ) ;
@@ -59,31 +75,47 @@ describe("encapsed", function() {
59
75
expect ( parser . parseEval ( '"string {${call()}} string";' ) ) . toMatchSnapshot ( ) ;
60
76
} ) ;
61
77
it ( "value of the var named by the return value (3) (complex syntax)" , function ( ) {
62
- expect ( parser . parseEval ( '"string {${$obj->property}} string";' ) ) . toMatchSnapshot ( ) ;
78
+ expect (
79
+ parser . parseEval ( '"string {${$obj->property}} string";' )
80
+ ) . toMatchSnapshot ( ) ;
63
81
} ) ;
64
82
it ( "value of the var named by the return value (4) (complex syntax)" , function ( ) {
65
- expect ( parser . parseEval ( '"string {${$obj->call()}} string";' ) ) . toMatchSnapshot ( ) ;
83
+ expect (
84
+ parser . parseEval ( '"string {${$obj->call()}} string";' )
85
+ ) . toMatchSnapshot ( ) ;
66
86
} ) ;
67
87
it ( "value of the var named by the return value (5) (complex syntax)" , function ( ) {
68
- expect ( parser . parseEval ( '"string {${$obj::$var}} string";' ) ) . toMatchSnapshot ( ) ;
88
+ expect (
89
+ parser . parseEval ( '"string {${$obj::$var}} string";' )
90
+ ) . toMatchSnapshot ( ) ;
69
91
} ) ;
70
92
it ( "value of the var named by the return value (6) (complex syntax)" , function ( ) {
71
- expect ( parser . parseEval ( '"string {${$obj::call()}} string";' ) ) . toMatchSnapshot ( ) ;
93
+ expect (
94
+ parser . parseEval ( '"string {${$obj::call()}} string";' )
95
+ ) . toMatchSnapshot ( ) ;
72
96
} ) ;
73
97
it ( "propertylookup by variable (complex syntax)" , function ( ) {
74
98
expect ( parser . parseEval ( '"string {$obj->$var} string";' ) ) . toMatchSnapshot ( ) ;
75
99
} ) ;
76
100
it ( "propertylookup by variable (2) (complex syntax)" , function ( ) {
77
- expect ( parser . parseEval ( '"string {$obj->{$array[1]}} string";' ) ) . toMatchSnapshot ( ) ;
101
+ expect (
102
+ parser . parseEval ( '"string {$obj->{$array[1]}} string";' )
103
+ ) . toMatchSnapshot ( ) ;
78
104
} ) ;
79
105
it ( "propertylookup with multiple call (complex syntax)" , function ( ) {
80
- expect ( parser . parseEval ( '"string {$obj->call()->call()} string";' ) ) . toMatchSnapshot ( ) ;
106
+ expect (
107
+ parser . parseEval ( '"string {$obj->call()->call()} string";' )
108
+ ) . toMatchSnapshot ( ) ;
81
109
} ) ;
82
110
it ( "multiple propertylookup (complex syntax)" , function ( ) {
83
- expect ( parser . parseEval ( '"string {$obj->property->property} string";' ) ) . toMatchSnapshot ( ) ;
111
+ expect (
112
+ parser . parseEval ( '"string {$obj->property->property} string";' )
113
+ ) . toMatchSnapshot ( ) ;
84
114
} ) ;
85
115
it ( "propertylookup with comments (complex syntax)" , function ( ) {
86
- expect ( parser . parseEval ( '"string {$var->foo->bar /* Comment */ } string";' ) ) . toMatchSnapshot ( ) ;
116
+ expect (
117
+ parser . parseEval ( '"string {$var->foo->bar /* Comment */ } string";' )
118
+ ) . toMatchSnapshot ( ) ;
87
119
} ) ;
88
120
it ( "newline before closing curly (complex syntax)" , function ( ) {
89
121
expect ( parser . parseEval ( '"string {$var\n} string";' ) ) . toMatchSnapshot ( ) ;
@@ -92,12 +124,32 @@ describe("encapsed", function() {
92
124
expect ( parser . parseEval ( '"string {$obj::$var} string";' ) ) . toMatchSnapshot ( ) ;
93
125
} ) ;
94
126
it ( "staticlookup (2) (complex syntax)" , function ( ) {
95
- expect ( parser . parseEval ( '"string {$obj::call()} string";' ) ) . toMatchSnapshot ( ) ;
127
+ expect (
128
+ parser . parseEval ( '"string {$obj::call()} string";' )
129
+ ) . toMatchSnapshot ( ) ;
96
130
} ) ;
97
131
it ( "staticlookup (3) (complex syntax)" , function ( ) {
98
- expect ( parser . parseEval ( '"string {$obj::$var::$var} string";' ) ) . toMatchSnapshot ( ) ;
132
+ expect (
133
+ parser . parseEval ( '"string {$obj::$var::$var} string";' )
134
+ ) . toMatchSnapshot ( ) ;
99
135
} ) ;
100
136
it ( "staticlookup (4) (complex syntax)" , function ( ) {
101
- expect ( parser . parseEval ( '"string {$var::$target::$resource::$binary::$foo::$bar::$foobar::$bar::$foo::$foobar::$bar::$foo} string";' ) ) . toMatchSnapshot ( ) ;
137
+ expect (
138
+ parser . parseEval (
139
+ '"string {$var::$target::$resource::$binary::$foo::$bar::$foobar::$bar::$foo::$foobar::$bar::$foo} string";'
140
+ )
141
+ ) . toMatchSnapshot ( ) ;
142
+ } ) ;
143
+ it ( "string offset in encapsed var offset" , ( ) => {
144
+ expect ( parser . parseEval ( `"$var[var]";` ) ) . toMatchSnapshot ( ) ;
145
+ } ) ;
146
+ it ( "positive offset in encapsed var offset" , ( ) => {
147
+ expect ( parser . parseEval ( `"$var[1]";` ) ) . toMatchSnapshot ( ) ;
148
+ } ) ;
149
+ it ( "negative offset in encapsed var offset" , ( ) => {
150
+ expect ( parser . parseEval ( `"$var[-1]";` ) ) . toMatchSnapshot ( ) ;
151
+ } ) ;
152
+ it ( "string offset in encapsed var offset" , ( ) => {
153
+ expect ( parser . parseEval ( `"$var[$var]";` ) ) . toMatchSnapshot ( ) ;
102
154
} ) ;
103
155
} ) ;
0 commit comments