Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: test/mjsunit/harmony/reflect-get-prototype-of.js

Issue 1815773002: Remove runtime flags for Proxy and Reflect (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2010-2015 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Tests the Reflect.getPrototypeOf - ES6 26.1.8.
29 // This is adapted from mjsunit/get-prototype-of.js.
30
31 // Flags: --harmony-reflect
32
33
34
35 function assertPrototypeOf(func, expected) {
36 assertEquals(expected, Reflect.getPrototypeOf(func));
37 }
38
39
40 assertThrows(function() {
41 Reflect.getPrototypeOf(undefined);
42 }, TypeError);
43
44
45 assertThrows(function() {
46 Reflect.getPrototypeOf(null);
47 }, TypeError);
48
49
50 function F(){};
51 var y = new F();
52
53 assertPrototypeOf(y, F.prototype);
54 assertPrototypeOf(F, Function.prototype);
55
56 assertPrototypeOf({x: 5}, Object.prototype);
57 assertPrototypeOf({x: 5, __proto__: null}, null);
58
59 assertPrototypeOf([1, 2], Array.prototype);
60
61
62 assertThrows(function () {
63 Reflect.getPrototypeOf(1);
64 }, TypeError);
65 assertThrows(function () {
66 Reflect.getPrototypeOf(true);
67 }, TypeError);
68 assertThrows(function () {
69 Reflect.getPrototypeOf(false);
70 }, TypeError);
71 assertThrows(function () {
72 Reflect.getPrototypeOf('str');
73 }, TypeError);
74 assertThrows(function () {
75 Reflect.getPrototypeOf(Symbol());
76 }, TypeError);
77
78 assertPrototypeOf(Object(1), Number.prototype);
79 assertPrototypeOf(Object(true), Boolean.prototype);
80 assertPrototypeOf(Object(false), Boolean.prototype);
81 assertPrototypeOf(Object('str'), String.prototype);
82 assertPrototypeOf(Object(Symbol()), Symbol.prototype);
83
84
85 var errorFunctions = [
86 EvalError,
87 RangeError,
88 ReferenceError,
89 SyntaxError,
90 TypeError,
91 URIError,
92 ];
93
94 for (var f of errorFunctions) {
95 assertPrototypeOf(f, Error);
96 assertPrototypeOf(new f(), f.prototype);
97 }
98
99
100 // Builtin constructors.
101 var functions = [
102 Array,
103 ArrayBuffer,
104 Boolean,
105 // DataView,
106 Date,
107 Error,
108 // Float32Array, prototype is %TypedArray%
109 // Float64Array,
110 Function,
111 // Int16Array,
112 // Int32Array,
113 // Int8Array,
114 Map,
115 Number,
116 Object,
117 // Promise,
118 RegExp,
119 Set,
120 String,
121 // Symbol, not constructible
122 // Uint16Array,
123 // Uint32Array,
124 // Uint8Array,
125 // Uint8ClampedArray,
126 WeakMap,
127 WeakSet,
128 ];
129
130 for (var f of functions) {
131 assertPrototypeOf(f, Function.prototype);
132 assertPrototypeOf(new f(), f.prototype);
133 }
134
135 var p = new Promise(function() {});
136 assertPrototypeOf(p, Promise.prototype);
137
138 var dv = new DataView(new ArrayBuffer());
139 assertPrototypeOf(dv, DataView.prototype);
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/reflect-get-own-property-descriptor.js ('k') | test/mjsunit/harmony/reflect-own-keys.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698