Browse Source

Testcase for Reflect.ownKeys() order

Doesn't implement Symbol order now.
pull/1460/head
Sami Vaarala 8 years ago
parent
commit
2b58de5927
  1. 37
      tests/ecmascript/test-bi-reflect-ownkeys-symbol-order-2.js
  2. 27
      tests/ecmascript/test-bi-reflect-ownkeys-symbol-order-3.js
  3. 28
      tests/ecmascript/test-bi-reflect-ownkeys-symbol-order.js

37
tests/ecmascript/test-bi-reflect-ownkeys-symbol-order-2.js

@ -0,0 +1,37 @@
/*===
0
1
2
3
7
foo
bar
quux
S2
S3
S1
===*/
var S1 = Symbol('s1');
var S2 = Symbol('s2');
var S3 = Symbol('s3');
var obj = {};
obj[1] = 'one';
obj['foo'] = 'foo';
obj[0] = 'zero';
obj[3] = 'three';
obj[S2] = 's2';
obj[2] = 'two';
obj[S3] = 's3';
obj['bar'] = 'bar';
obj[S1] = 's1';
obj['quux'] = 'quux';
obj[7] = 'seven';
Reflect.ownKeys(obj).forEach(function (v) {
if (v === S1) { print('S1'); }
else if (v === S2) { print('S2'); }
else if (v === S3) { print('S3'); }
else { print(v); }
});

27
tests/ecmascript/test-bi-reflect-ownkeys-symbol-order-3.js

@ -0,0 +1,27 @@
/*===
foo
bar
quux
S2
S3
S1
===*/
var S1 = Symbol('s1');
var S2 = Symbol('s2');
var S3 = Symbol('s3');
var obj = {};
obj['foo'] = 'foo';
obj[S2] = 's2';
obj[S3] = 's3';
obj['bar'] = 'bar';
obj[S1] = 's1';
obj['quux'] = 'quux';
Reflect.ownKeys(obj).forEach(function (v) {
if (v === S1) { print('S1'); }
else if (v === S2) { print('S2'); }
else if (v === S3) { print('S3'); }
else { print(v); }
});

28
tests/ecmascript/test-bi-reflect-ownkeys-symbol-order.js

@ -0,0 +1,28 @@
/*===
7
300
100
500
700
200
400
600
===*/
var sym1 = Symbol();
var sym2 = Symbol();
var sym3 = Symbol();
var obj = {};
obj.foo = 100;
obj[sym1] = 200;
obj[3] = 300;
obj[sym2] = 400;
obj.quux = 500;
obj[sym3] = 600;
obj.baz = 700;
var keys = Reflect.ownKeys(obj);
print(keys.length);
keys.forEach(function (v) {
print(obj[v]);
});
Loading…
Cancel
Save