mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* bump "@babel/*" deps * bump core-js * bump @babel/core * update eslint-plugin-jest and glob * update Makefile.js * fix linting errors * remove obsolete snapshots * use inline snapshot
12 lines
643 B
JavaScript
12 lines
643 B
JavaScript
const foo = { [Symbol.toPrimitive]: () => "foo" };
|
|
|
|
expect((new class { [foo](){ return 0; } }).foo()).toBe(0);
|
|
expect((new class { get [foo](){ return 0; } }).foo).toBe(0);
|
|
expect((new class { set [foo](v){ return v; } }).foo = 0).toBe(0);
|
|
|
|
const arrayLike = { [Symbol.toPrimitive] : () => [] };
|
|
|
|
expect(() => new class { [arrayLike](){ return 0; } }).toThrow("@@toPrimitive must return a primitive value.");
|
|
expect(() => new class { get [arrayLike](){ return 0; } }).toThrow("@@toPrimitive must return a primitive value.");
|
|
expect(() => new class { set [arrayLike](v){ return v; } }).toThrow("@@toPrimitive must return a primitive value.");
|