Skip to content

Commit

Permalink
Avoid extended array directly in tests.
Browse files Browse the repository at this point in the history
Unfortunately, `class Foo extends Array{}` doesn't work well with older
browsers (and would even require changes in our transpilation for
production builds for modern ones).

The actual test doesn't care if its running on an Array (without the
fixes in this PR this modified test still fails the same way).
  • Loading branch information
rwjblue committed Dec 15, 2018
1 parent 98afaff commit 6e74ef8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/@ember/-internals/runtime/tests/array/apply-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import { AbstractTestCase, moduleFor } from 'internal-test-helpers';

class ArrayPrototypeExtensionSelfReferenceTests extends AbstractTestCase {
'@test should not create non-Symbol, enumerable properties that refer to itself'() {
// Don't want to pollute Array.prototype so we make our own to extend
class ThrowAwayArray extends Array {}
// Don't want to pollute Array.prototype so we make a fake / simple prototype
function ThrowAwayArray() {}

// Extend our throw-away prototype (like EXTEND_PROTOTYPES.Array would)
NativeArray.apply(ThrowAwayArray.prototype);

// Create an instance to test
let obj = new ThrowAwayArray();

// Make sure we have an array-like thing & avoid the zero assertion problem is there are no enumerable properties
this.assert.strictEqual(obj.length, 0);

// Make sure that no enumerable properties refer back to the object (creating a cyclic structure)
for (let p in obj) {
this.assert.notStrictEqual(
Expand Down

0 comments on commit 6e74ef8

Please sign in to comment.