Skip to content

Commit

Permalink
test(optim): add one more test case for the recalcul
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Dec 20, 2023
1 parent 369f97a commit 3093df9
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion test/optims/constantFolding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ describe('Constant folding [base]', () => {
})
})

it('should not optimize rules used in a [recalcul]', () => {
it('should not fold rules used in a [recalcul]', () => {
const rawRules = {
root: {
recalcul: {
Expand Down Expand Up @@ -575,6 +575,49 @@ describe('Constant folding [base]', () => {
})
})

it('should not fold rules used in a [recalcul] but still fold used constant in other rules', () => {
const rawRules = {
root: {
recalcul: {
règle: 'rule to recompute',
avec: {
constant: 20,
},
},
},
'rule to recompute': {
formule: 'constant * 2',
},
'rule to fold': {
formule: 'constant * 4',
},
constant: {
valeur: 10,
},
}
expect(constantFoldingWith(rawRules)).toStrictEqual({
root: {
recalcul: {
règle: 'rule to recompute',
avec: {
constant: 20,
},
},
},
'rule to recompute': {
formule: 'constant * 2',
},
'rule to fold': {
valeur: '40',
optimized: true,
},
constant: {
valeur: 10,
optimized: true,
},
})
})

it('replaceAllRefs bug #3', () => {
const rawRules = {
boisson: {
Expand Down

0 comments on commit 3093df9

Please sign in to comment.