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

Side by Side Diff: test/webkit/class-syntax-prototype.js

Issue 1109783003: Import JSC class tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 7 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 2015 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions
6 // are met:
7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24 // Flags: --harmony-sloppy
25
26 description('Tests for the descriptors of the properties implicitly defined by E S6 class syntax');
27
28 function descriptor(object, propertyName) {
29 return Object.getOwnPropertyDescriptor(object, propertyName);
30 }
31
32 function enumeratedProperties(object) {
33 var properties = [];
34 for (var propertyName in object)
35 properties.push(propertyName);
36 return properties;
37 }
38
39 Array.prototype.includes = function(element) {
40 return this.indexOf(element) !== -1;
41 };
42
43 shouldBeFalse('class A {}; descriptor(A, "prototype").writable');
44 shouldBe('class A {}; var x = A.prototype; A.prototype = 3; A.prototype', 'x');
45 shouldBeFalse('class A {}; descriptor(A, "prototype").enumerable');
46 shouldBeTrue('class A {}; A.foo = "foo"; enumeratedProperties(A).includes("foo") ');
47 shouldBeFalse('class A {}; enumeratedProperties(A).includes("prototype")');
48 shouldBeFalse('class A {}; descriptor(A, "prototype").configurable');
49 shouldThrow('class A {}; Object.defineProperty(A, "prototype", {value: "foo"})', '"TypeError: Cannot redefine property: prototype"');
50
51 shouldBeTrue('class A { static foo() {} }; descriptor(A, "foo").writable');
52 shouldBe('class A { static foo() {} }; A.foo = 3; A.foo', '3');
53 shouldBeFalse('class A { static foo() {} }; descriptor(A, "foo").enumerable');
54 shouldBeFalse('class A { static foo() {} }; enumeratedProperties(A).includes("fo o")');
55 shouldBeTrue('class A { static foo() {} }; descriptor(A, "foo").configurable');
56 shouldBe('class A { static foo() {} }; Object.defineProperty(A, "foo", {value: " bar"}); A.foo', '"bar"');
57
58 shouldBe('class A { static get foo() {} }; descriptor(A, "foo").writable', 'unde fined');
59 shouldBe('class A { static get foo() { return 5; } }; A.foo = 3; A.foo', '5');
60 shouldBeFalse('class A { static get foo() {} }; descriptor(A, "foo").enumerable' );
61 shouldBeFalse('class A { static get foo() {} }; enumeratedProperties(A).includes ("foo")');
62 shouldBeFalse('class A { static get foo() {} }; enumeratedProperties(new A).incl udes("foo")');
63 shouldBeTrue('class A { static get foo() {} }; descriptor(A, "foo").configurable ');
64 shouldBe('class A { static get foo() {} }; Object.defineProperty(A, "foo", {valu e: "bar"}); A.foo', '"bar"');
65
66 shouldBeTrue('class A { foo() {} }; descriptor(A.prototype, "foo").writable');
67 shouldBe('class A { foo() {} }; A.prototype.foo = 3; A.prototype.foo', '3');
68 shouldBeFalse('class A { foo() {} }; descriptor(A.prototype, "foo").enumerable') ;
69 shouldBeFalse('class A { foo() {} }; enumeratedProperties(A.prototype).includes( "foo")');
70 shouldBeFalse('class A { foo() {} }; enumeratedProperties(new A).includes("foo") ');
71 shouldBeTrue('class A { foo() {} }; descriptor(A.prototype, "foo").configurable' );
72 shouldBe('class A { foo() {} }; Object.defineProperty(A.prototype, "foo", {value : "bar"}); A.prototype.foo', '"bar"');
73
74 shouldBe('class A { get foo() {} }; descriptor(A.prototype, "foo").writable', 'u ndefined');
75 shouldBe('class A { get foo() { return 5; } }; A.prototype.foo = 3; A.prototype. foo', '5');
76 shouldBeFalse('class A { get foo() {} }; descriptor(A.prototype, "foo").enumerab le');
77 shouldBeFalse('class A { get foo() {} }; enumeratedProperties(A.prototype).inclu des("foo")');
78 shouldBeFalse('class A { get foo() {} }; enumeratedProperties(new A).includes("f oo")');
79 shouldBeTrue('class A { get foo() {} }; descriptor(A.prototype, "foo").configura ble');
80 shouldBe('class A { get foo() {} }; Object.defineProperty(A.prototype, "foo", {v alue: "bar"}); A.prototype.foo', '"bar"');
81
82 shouldBeTrue('class A { }; descriptor(A.prototype, "constructor").writable');
83 shouldBe('class A { }; A.prototype.constructor = 3; A.prototype.constructor', '3 ');
84 shouldBeTrue('class A { }; x = {}; A.prototype.constructor = function () { retur n x; }; (new A) instanceof A');
85 shouldBeFalse('class A { }; descriptor(A.prototype, "constructor").enumerable');
86 shouldBeFalse('class A { }; enumeratedProperties(A.prototype).includes("construc tor")');
87 shouldBeFalse('class A { }; enumeratedProperties(new A).includes("constructor")' );
88 shouldBeTrue('class A { }; descriptor(A.prototype, "constructor").configurable') ;
89 shouldBe('class A { }; Object.defineProperty(A.prototype, "constructor", {value: "bar"}); A.prototype.constructor', '"bar"');
90
91 var successfullyParsed = true;
OLDNEW
« no previous file with comments | « test/webkit/class-syntax-name-expected.txt ('k') | test/webkit/class-syntax-prototype-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698