Debian Codegraph @

packages/babel-plugin-transform-block-scoping/test/fixtures/const-violations/update-expression/exec.js

raw symbols SCIP
1 const state1 = {};
2 expect(function() {
3 const foo = 1;
4 state1.getFoo = () => foo;
5
6 foo++;
7 }).toThrow('"foo" is read-only');
8 expect(state1.getFoo()).toBe(1); // Assignment did not succeed
9
10 const state2 = {};
11 expect(function() {
12 const bar = {
13 valueOf() {
14 state2.valueOfIsCalled = true;
15 }
16 };
17 state2.bar = bar;
18 state2.getBar = () => bar;
19
20 bar++;
21 }).toThrow('"bar" is read-only');
22 expect(state2.getBar()).toBe(state2.bar); // Assignment did not succeed
23 expect(state2.valueOfIsCalled).toBe(true); // `bar` was read before error thrown