File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,14 +98,10 @@ class Runner {
9898 }
9999
100100 invokeInclude ( statement ) {
101- let path ;
101+ const path = statement . value . type === PARSER_TYPE_VARIABLE
102+ ? this . getValueFromVariable ( statement . value . name )
103+ : statement . value . value ;
102104
103- if ( statement . value . type === PARSER_TYPE_VARIABLE ) {
104- path = this . getValueFromVariable ( statement . value . name ) ;
105- }
106- else {
107- path = statement . value . value ;
108- }
109105 if ( this . astCache [ path ] ) {
110106 this . invokeStatements ( this . astCache [ path ] . statements ) ;
111107 }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const expect = require ( 'chai' ) . expect ;
4+ const Runtime = require ( '../../src/Runtime' ) ;
5+
6+ describe ( 'Runtime.evaluateEquals' , function ( ) {
7+ it ( 'should get matching input data' , function ( ) {
8+ const runtime = new Runtime ( ) ;
9+
10+ runtime . input = { foo : 'bar' } ;
11+ expect ( runtime . getValueFromVariable ( 'foo' ) ) . to . equal ( 'bar' ) ;
12+ } ) ;
13+
14+ it ( 'should error on missing input data' , function ( ) {
15+ const runtime = new Runtime ( ) ;
16+
17+ runtime . input = { } ;
18+ expect ( ( ) => runtime . getValueFromVariable ( 'foo' ) ) . to . throw ( / U n s e t v a r i a b l e / ) ;
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 22
33const expect = require ( 'chai' ) . expect ;
44const Runtime = require ( '../../src/Runtime' ) ;
5+ const nb = require ( '../nodeBuilder' ) ;
56
67describe ( 'Runtime.getValueFromVariable' , function ( ) {
7- it ( 'should get matching input data ' , function ( ) {
8+ it ( 'should return on not operator ' , function ( ) {
89 const runtime = new Runtime ( ) ;
10+ const expression = nb . notConditional ( nb . value ( true ) ) ;
911
10- runtime . input = { foo : 'bar' } ;
11- expect ( runtime . getValueFromVariable ( 'foo' ) ) . to . equal ( 'bar' ) ;
12+ expect ( runtime . evaluateUnaryExpression ( expression ) ) . to . be . false ;
1213 } ) ;
1314
14- it ( 'should error on missing input data ' , function ( ) {
15+ it ( 'should error on unknown operator ' , function ( ) {
1516 const runtime = new Runtime ( ) ;
17+ const expression = nb . invalidExpression ( ) ;
1618
17- runtime . input = { } ;
18- expect ( ( ) => runtime . getValueFromVariable ( 'foo' ) ) . to . throw ( / U n s e t v a r i a b l e / ) ;
19+ expect ( ( ) => runtime . evaluateUnaryExpression ( expression ) ) . to . throw ( / U n k n o w n o p e r a t o r / ) ;
1920 } ) ;
2021} ) ;
Original file line number Diff line number Diff line change @@ -82,5 +82,13 @@ module.exports = {
8282 condition,
8383 consequent
8484 } ;
85+ } ,
86+ invalidExpression ( ) {
87+ return {
88+ type : 'INVALID_EXPRESSION' ,
89+ left : 'left' ,
90+ right : 'right' ,
91+ operator : 'INVALID'
92+ } ;
8593 }
8694} ;
You can’t perform that action at this time.
0 commit comments