1- const parser = require ( ' ../main' ) ;
1+ const parser = require ( " ../main" ) ;
22
33describe ( "encapsed" , function ( ) {
44 it ( "variable (simple syntax)" , function ( ) {
@@ -14,13 +14,17 @@ describe("encapsed", function() {
1414 expect ( parser . parseEval ( '"string $array[0] string";' ) ) . toMatchSnapshot ( ) ;
1515 } ) ;
1616 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 ( ) ;
1820 } ) ;
1921 it ( "offsetlookup (3) (simple syntax)" , function ( ) {
2022 expect ( parser . parseEval ( '"string $array[0][0] string";' ) ) . toMatchSnapshot ( ) ;
2123 } ) ;
2224 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 ( ) ;
2428 } ) ;
2529 it ( "variable with space opening before curly" , function ( ) {
2630 expect ( parser . parseEval ( '"string { $var} string";' ) ) . toMatchSnapshot ( ) ;
@@ -32,22 +36,34 @@ describe("encapsed", function() {
3236 expect ( parser . parseEval ( '"string {$var} string";' ) ) . toMatchSnapshot ( ) ;
3337 } ) ;
3438 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 ( ) ;
3642 } ) ;
3743 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 ( ) ;
3947 } ) ;
4048 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 ( ) ;
4252 } ) ;
4353 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 ( ) ;
4557 } ) ;
4658 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 ( ) ;
4862 } ) ;
4963 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 ( ) ;
5167 } ) ;
5268 it ( "value of the var (complex syntax)" , function ( ) {
5369 expect ( parser . parseEval ( '"string {${$name}} string";' ) ) . toMatchSnapshot ( ) ;
@@ -59,31 +75,47 @@ describe("encapsed", function() {
5975 expect ( parser . parseEval ( '"string {${call()}} string";' ) ) . toMatchSnapshot ( ) ;
6076 } ) ;
6177 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 ( ) ;
6381 } ) ;
6482 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 ( ) ;
6686 } ) ;
6787 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 ( ) ;
6991 } ) ;
7092 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 ( ) ;
7296 } ) ;
7397 it ( "propertylookup by variable (complex syntax)" , function ( ) {
7498 expect ( parser . parseEval ( '"string {$obj->$var} string";' ) ) . toMatchSnapshot ( ) ;
7599 } ) ;
76100 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 ( ) ;
78104 } ) ;
79105 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 ( ) ;
81109 } ) ;
82110 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 ( ) ;
84114 } ) ;
85115 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 ( ) ;
87119 } ) ;
88120 it ( "newline before closing curly (complex syntax)" , function ( ) {
89121 expect ( parser . parseEval ( '"string {$var\n} string";' ) ) . toMatchSnapshot ( ) ;
@@ -92,12 +124,32 @@ describe("encapsed", function() {
92124 expect ( parser . parseEval ( '"string {$obj::$var} string";' ) ) . toMatchSnapshot ( ) ;
93125 } ) ;
94126 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 ( ) ;
96130 } ) ;
97131 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 ( ) ;
99135 } ) ;
100136 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 ( ) ;
102154 } ) ;
103155} ) ;
0 commit comments