File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -349,7 +349,8 @@ export function handleActions<Context>(
349349 }
350350
351351 if ( has ( "$mul" ) ) {
352- let reference = input [ "$mul" ] [ 2 ]
352+ // $mul can have 2 or 3 operands, 2 means multiply the context variable (1st operand) by the 2nd operand
353+ let reference = input [ "$mul" ] [ input [ "$mul" ] . length === 3 ? 2 : 0 ]
353354
354355 const variableValue1 = findNamedChild ( input [ "$mul" ] [ 0 ] , context )
355356 const variableValue2 = findNamedChild ( input [ "$mul" ] [ 1 ] , context )
Original file line number Diff line number Diff line change @@ -73,14 +73,24 @@ const data = {
7373 ] ,
7474 Mul1 : [
7575 {
76- $mul : [ "Context.Object" , 5 , "Context.Object " ] ,
76+ $mul : [ "Context.Object" , 5 , "Context.Output " ] ,
7777 } ,
7878 {
7979 Context : {
8080 Object : 18 ,
8181 } ,
8282 } ,
8383 ] ,
84+ Mul2 : [
85+ {
86+ $mul : [ "Context.Object" , 10 ]
87+ } ,
88+ {
89+ Context : {
90+ Object : 42
91+ }
92+ }
93+ ]
8494}
8595
8696describe ( "$inc" , ( ) => {
@@ -118,9 +128,15 @@ describe("$dec", () => {
118128} )
119129
120130describe ( "$mul" , ( ) => {
121- it ( "can multiply a context object" , ( ) => {
131+ it ( "can multiply a context object and store it in another " , ( ) => {
122132 const [ sm , vars ] = data . Mul1
123133 const r = handleActions ( sm , vars )
124- assert . strictEqual ( r . Context . Object , 90 )
134+ assert . strictEqual ( r . Context . Output , 90 )
135+ } )
136+
137+ it ( "can multiply a context object and store it in that object" , ( ) => {
138+ const [ sm , vars ] = data . Mul2
139+ const r = handleActions ( sm , vars )
140+ assert . strictEqual ( r . Context . Object , 420 )
125141 } )
126142} )
You can’t perform that action at this time.
0 commit comments