diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-01-21 17:48:28 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-01-21 17:48:28 +0530 |
| commit | c9075367a178644d12a179919aa07616938b7315 (patch) | |
| tree | d3ffccc2b1db372e496016caa145f00ca7b81409 /tests/parser.spec.ts | |
| parent | c7a137861494edd65d0c8de76ab09f422ab15481 (diff) | |
| download | css-everything-c9075367a178644d12a179919aa07616938b7315.tar.gz css-everything-c9075367a178644d12a179919aa07616938b7315.zip | |
fix: fixes nested fixity issue
Diffstat (limited to '')
| -rw-r--r-- | tests/parser.spec.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/parser.spec.ts b/tests/parser.spec.ts index 16480e6..6e8431d 100644 --- a/tests/parser.spec.ts +++ b/tests/parser.spec.ts @@ -285,5 +285,62 @@ describe('parser', () => { }), ]) }) + + it('preserves order of operations (same operator)', () => { + expect(parse(`calc(30 - 5 - 3)`)).toEqual([ + Expr.Call({ + name: 'calc', + args: [ + Expr.BinOp({ + op: '-', + left: Expr.BinOp({ + op: '-', + left: Expr.LiteralNumber({ value: 30, unit: '' }), + right: Expr.LiteralNumber({ value: 5, unit: '' }), + }), + right: Expr.LiteralNumber({ value: 3, unit: '' }), + }), + ], + }), + ]) + }) + + it('preserves order of operations (different operators, same precedance)', () => { + expect(parse(`calc(30 + 5 - 3)`)).toEqual([ + Expr.Call({ + name: 'calc', + args: [ + Expr.BinOp({ + op: '-', + left: Expr.BinOp({ + op: '+', + left: Expr.LiteralNumber({ value: 30, unit: '' }), + right: Expr.LiteralNumber({ value: 5, unit: '' }), + }), + right: Expr.LiteralNumber({ value: 3, unit: '' }), + }), + ], + }), + ]) + }) + + it('preserves order of operations (different operators, different precedance)', () => { + expect(parse(`calc(30 / 5 * 3)`)).toEqual([ + Expr.Call({ + name: 'calc', + args: [ + Expr.BinOp({ + op: '*', + left: Expr.BinOp({ + op: '/', + left: Expr.LiteralNumber({ value: 30, unit: '' }), + right: Expr.LiteralNumber({ value: 5, unit: '' }), + }), + right: Expr.LiteralNumber({ value: 3, unit: '' }), + }), + ], + }), + ]) + }) }) }) |
