forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-serialize.js
More file actions
54 lines (47 loc) · 1.32 KB
/
error-serialize.js
File metadata and controls
54 lines (47 loc) · 1.32 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
// Test Error
var e = new Error();
print(e);
//CHECK: Error
print(e.hasOwnProperty(e, 'name'));
//CHECK: false
print(e.hasOwnProperty(e, 'message'));
//CHECK: false
print(e.__proto__.hasOwnProperty('name'));
//CHECK: true
print(e.__proto__.hasOwnProperty('message'));
//CHECK: true
e.name = 'RandomError';
print(e);
//CHECK: RandomError
e.message = 'random-message';
print(e);
//CHECK: RandomError: random-message
// Test Native error types
print(EvalError.__proto__ === Error);
//CHECK: true
print(RangeError.__proto__ === Error);
//CHECK: true
print(ReferenceError.__proto__ === Error);
//CHECK: true
print(SyntaxError.__proto__ === Error);
//CHECK: true
print(TypeError.__proto__ === Error);
//CHECK: true
print(URIError.__proto__ === Error);
//CHECK: true
// Check exception case of accessing Error.stack from a different 'this'
try {
new Error().__lookupGetter__("stack").call({});
} catch (e) {
print(e.name);
}
//CHECK: TypeError