@@ -105,19 +105,19 @@ func testExpressions() {
105105
106106 $0. describe ( " expression parsing " ) {
107107 $0. it ( " can parse a variable expression " ) {
108- let expression = try parseExpression ( components: [ " value " ] , tokenParser : parser )
108+ let expression = try parser . compileExpression ( components: [ " value " ] )
109109 try expect ( expression. evaluate ( context: Context ( ) ) ) . to. beFalse ( )
110110 try expect ( expression. evaluate ( context: Context ( dictionary: [ " value " : true ] ) ) ) . to. beTrue ( )
111111 }
112112
113113 $0. it ( " can parse a not expression " ) {
114- let expression = try parseExpression ( components: [ " not " , " value " ] , tokenParser : parser )
114+ let expression = try parser . compileExpression ( components: [ " not " , " value " ] )
115115 try expect ( expression. evaluate ( context: Context ( ) ) ) . to. beTrue ( )
116116 try expect ( expression. evaluate ( context: Context ( dictionary: [ " value " : true ] ) ) ) . to. beFalse ( )
117117 }
118118
119119 $0. describe ( " and expression " ) {
120- let expression = try ! parseExpression ( components: [ " lhs " , " and " , " rhs " ] , tokenParser : parser )
120+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " and " , " rhs " ] )
121121
122122 $0. it ( " evaluates to false with lhs false " ) {
123123 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : false , " rhs " : true ] ) ) ) . to. beFalse ( )
@@ -137,7 +137,7 @@ func testExpressions() {
137137 }
138138
139139 $0. describe ( " or expression " ) {
140- let expression = try ! parseExpression ( components: [ " lhs " , " or " , " rhs " ] , tokenParser : parser )
140+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " or " , " rhs " ] )
141141
142142 $0. it ( " evaluates to true with lhs true " ) {
143143 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : true , " rhs " : false ] ) ) ) . to. beTrue ( )
@@ -157,7 +157,7 @@ func testExpressions() {
157157 }
158158
159159 $0. describe ( " equality expression " ) {
160- let expression = try ! parseExpression ( components: [ " lhs " , " == " , " rhs " ] , tokenParser : parser )
160+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " == " , " rhs " ] )
161161
162162 $0. it ( " evaluates to true with equal lhs/rhs " ) {
163163 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : " a " , " rhs " : " a " ] ) ) ) . to. beTrue ( )
@@ -193,7 +193,7 @@ func testExpressions() {
193193 }
194194
195195 $0. describe ( " inequality expression " ) {
196- let expression = try ! parseExpression ( components: [ " lhs " , " != " , " rhs " ] , tokenParser : parser )
196+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " != " , " rhs " ] )
197197
198198 $0. it ( " evaluates to true with inequal lhs/rhs " ) {
199199 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : " a " , " rhs " : " b " ] ) ) ) . to. beTrue ( )
@@ -205,7 +205,7 @@ func testExpressions() {
205205 }
206206
207207 $0. describe ( " more than expression " ) {
208- let expression = try ! parseExpression ( components: [ " lhs " , " > " , " rhs " ] , tokenParser : parser )
208+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " > " , " rhs " ] )
209209
210210 $0. it ( " evaluates to true with lhs > rhs " ) {
211211 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : 5.0 , " rhs " : 4 ] ) ) ) . to. beTrue ( )
@@ -217,7 +217,7 @@ func testExpressions() {
217217 }
218218
219219 $0. describe ( " more than equal expression " ) {
220- let expression = try ! parseExpression ( components: [ " lhs " , " >= " , " rhs " ] , tokenParser : parser )
220+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " >= " , " rhs " ] )
221221
222222 $0. it ( " evaluates to true with lhs == rhs " ) {
223223 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : 5.0 , " rhs " : 5 ] ) ) ) . to. beTrue ( )
@@ -229,7 +229,7 @@ func testExpressions() {
229229 }
230230
231231 $0. describe ( " less than expression " ) {
232- let expression = try ! parseExpression ( components: [ " lhs " , " < " , " rhs " ] , tokenParser : parser )
232+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " < " , " rhs " ] )
233233
234234 $0. it ( " evaluates to true with lhs < rhs " ) {
235235 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : 4 , " rhs " : 4.5 ] ) ) ) . to. beTrue ( )
@@ -241,7 +241,7 @@ func testExpressions() {
241241 }
242242
243243 $0. describe ( " less than equal expression " ) {
244- let expression = try ! parseExpression ( components: [ " lhs " , " <= " , " rhs " ] , tokenParser : parser )
244+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " <= " , " rhs " ] )
245245
246246 $0. it ( " evaluates to true with lhs == rhs " ) {
247247 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : 5.0 , " rhs " : 5 ] ) ) ) . to. beTrue ( )
@@ -253,7 +253,7 @@ func testExpressions() {
253253 }
254254
255255 $0. describe ( " multiple expression " ) {
256- let expression = try ! parseExpression ( components: [ " one " , " or " , " two " , " and " , " not " , " three " ] , tokenParser : parser )
256+ let expression = try ! parser . compileExpression ( components: [ " one " , " or " , " two " , " and " , " not " , " three " ] )
257257
258258 $0. it ( " evaluates to true with one " ) {
259259 try expect ( expression. evaluate ( context: Context ( dictionary: [ " one " : true ] ) ) ) . to. beTrue ( )
@@ -281,7 +281,7 @@ func testExpressions() {
281281 }
282282
283283 $0. describe ( " in expression " ) {
284- let expression = try ! parseExpression ( components: [ " lhs " , " in " , " rhs " ] , tokenParser : parser )
284+ let expression = try ! parser . compileExpression ( components: [ " lhs " , " in " , " rhs " ] )
285285
286286 $0. it ( " evaluates to true when rhs contains lhs " ) {
287287 try expect ( expression. evaluate ( context: Context ( dictionary: [ " lhs " : 1 , " rhs " : [ 1 , 2 , 3 ] ] ) ) ) . to. beTrue ( )
0 commit comments