forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap-serialize.js
More file actions
54 lines (47 loc) · 1.36 KB
/
Copy pathmap-serialize.js
File metadata and controls
54 lines (47 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// RUN: %hermes -O -serialize-after-init-file=%t -target=HBC %s | %FileCheck --match-full-lines %s
// RUN: %hermes -O -deserialize-file=%t -target=HBC %s | %FileCheck --match-full-lines %s
// REQUIRES: serializer
print("Map prototype and constructor");
//CHECK-LABEL: Map prototype and constructor
print(Map.prototype);
//CHECK-NEXT: [object Map]
print(Map.length);
//CHECK-NEXT: 0
print(Object.getOwnPropertyNames(Map.prototype));
//CHECK-NEXT: clear,delete,entries,forEach,get,has,keys,set,size,values,constructor
print(new Map());
//CHECK-NEXT: [object Map]
var x = new Map(new Set([[1,2], [3,4]]));
print(x.get(1), x.get(3));
// CHECK-NEXT: 2 4
try {
Map();
} catch (e) {
print(e);
}
//CHECK-NEXT: TypeError: Constructor Map requires 'new'
var iterable = {};
iterable[Symbol.iterator] = function() {
return {
next: function() {
return {value: [1, 2], done: false};
},
return: function() {
print('returning');
},
};
};
var oldSet = Map.prototype.set;
Map.prototype.set = function() {
throw new Error('add error');
}
try { new Map(iterable); } catch (e) { print('caught', e.message); }
// CHECK: returning
// CHECK: caught add error
Map.prototype.set = oldSet;