File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,9 @@ class Runner {
9090 else if ( statement . type === PARSER_TYPE_BRANCH ) {
9191 this . invokeBranch ( statement ) ;
9292 }
93- throw new RuntimeError ( `Unexpected statement: ${ statement } ` ) ;
93+ else {
94+ throw new RuntimeError ( `Unexpected statement: ${ statement } ` ) ;
95+ }
9496 }
9597 }
9698
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+ const nb = require ( '../nodeBuilder' ) ;
6+
7+ describe ( 'Runtime.invokeBranch' , function ( ) {
8+ let runtime ;
9+
10+ beforeEach ( function ( ) {
11+ runtime = new Runtime ( ) ;
12+ } ) ;
13+
14+ it ( 'should invoke on true condition' , function ( ) {
15+ runtime . invokeBranch (
16+ nb . branch ( [
17+ nb . conditional ( nb . value ( false ) , nb . root ( nb . literal ( 'aaa' ) ) ) ,
18+ nb . conditional ( nb . value ( true ) , nb . root ( nb . literal ( 'bbb' ) ) )
19+ ] )
20+ ) ;
21+ expect ( runtime . result ) . to . deep . equal ( [ 'bbb' ] ) ;
22+ } ) ;
23+
24+ it ( 'should invoke else' , function ( ) {
25+ runtime . invokeBranch (
26+ nb . branch ( [
27+ nb . conditional ( nb . value ( false ) , nb . root ( nb . literal ( 'aaa' ) ) ) ,
28+ nb . constantConditional ( nb . root ( nb . literal ( 'bbb' ) ) )
29+ ] )
30+ ) ;
31+ expect ( runtime . result ) . to . deep . equal ( [ 'bbb' ] ) ;
32+ } ) ;
33+
34+
35+ it ( 'should not invoke on false condition' , function ( ) {
36+ runtime . invokeBranch (
37+ nb . branch (
38+ nb . conditional ( nb . value ( false ) , nb . root ( nb . literal ( 'foo' ) ) )
39+ )
40+ ) ;
41+ expect ( runtime . result ) . to . deep . equal ( [ ] ) ;
42+ } ) ;
43+ } ) ;
You can’t perform that action at this time.
0 commit comments