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

Side by Side Diff: test/mjsunit/harmony/super.js

Issue 923443003: new classes: no longer experimental. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: One more rebase? Created 5 years, 10 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
« no previous file with comments | « test/mjsunit/harmony/classes-experimental.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-classes --allow-natives-syntax 5 // Flags: --harmony-classes --allow-natives-syntax
6 6
7 (function TestSuperNamedLoads() { 7 (function TestSuperNamedLoads() {
8 function Base() { } 8 function Base() { }
9 function fBase() { } 9 function fBase() { }
10 Base.prototype = { 10 Base.prototype = {
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 constructor(v1, v2) { 1811 constructor(v1, v2) {
1812 super(v1); 1812 super(v1);
1813 this.fromDerived = v2; 1813 this.fromDerived = v2;
1814 } 1814 }
1815 } 1815 }
1816 1816
1817 var d = new Derived2("base", "derived"); 1817 var d = new Derived2("base", "derived");
1818 assertEquals("base", d.fromBase); 1818 assertEquals("base", d.fromBase);
1819 assertEquals("derived", d.fromDerived); 1819 assertEquals("derived", d.fromDerived);
1820 1820
1821 class ImplicitSubclassOfFunction {
1822 constructor() {
1823 super();
1824 this.x = 123;
1825 }
1826 }
1827
1828 var o = new ImplicitSubclassOfFunction();
1829 assertEquals(123, o.x);
1830
1831 var calls = 0; 1821 var calls = 0;
1832 class G { 1822 class G {
1833 constructor() { 1823 constructor() {
1834 calls++; 1824 calls++;
1835 } 1825 }
1836 } 1826 }
1837 class F { 1827
1828 class F extends Object {
1838 constructor() { 1829 constructor() {
1839 super(); 1830 super();
1840 } 1831 }
1841 } 1832 }
1842 F.__proto__ = G; 1833 F.__proto__ = G;
1843 new F(); 1834 new F();
1844 assertEquals(1, calls); 1835 assertEquals(1, calls);
1845 F.__proto__ = function() {}; 1836 F.__proto__ = function() {};
1846 new F(); 1837 new F();
1847 assertEquals(1, calls); 1838 assertEquals(1, calls);
1848 }()); 1839 }());
1849 1840
1850 1841
1842 (function TestExtendsObject() {
1843 'use strict';
1844 class F extends Object { }
1845 var f = new F(42);
1846
1847 // TODO(dslomov,arv): Fix this. BUG=v8:3886.
1848 assertTrue(f instanceof Number);
1849 }());
1850
1851 (function TestSuperCallErrorCases() { 1851 (function TestSuperCallErrorCases() {
1852 'use strict'; 1852 'use strict';
1853 class T { 1853 class T extends Object {
1854 constructor() { 1854 constructor() {
1855 super(); 1855 super();
1856 } 1856 }
1857 } 1857 }
1858 1858
1859 T.__proto__ = null; 1859 T.__proto__ = null;
1860 assertThrows(function() { new T(); }, TypeError); 1860 assertThrows(function() { new T(); }, TypeError);
1861 }()); 1861 }());
1862
1863
1864 (function TestSuperCallSyntacticRestriction() {
1865 'use strict';
1866 assertThrows(function() {
1867 class C {
1868 constructor() {
1869 super(this.x);
1870 }
1871 }
1872 new C();
1873 }, TypeError);
1874 assertThrows(function() {
1875 class C {
1876 constructor() {
1877 super(this);
1878 }
1879 }
1880 new C();
1881 }, TypeError);
1882 assertThrows(function() {
1883 class C {
1884 constructor() {
1885 super(1, 2, Object.getPrototypeOf(this));
1886 }
1887 }
1888 new C();
1889 }, TypeError);
1890 assertThrows(function() {
1891 class C {
1892 constructor() {
1893 { super(1, 2); }
1894 }
1895 }
1896 new C();
1897 }, TypeError);
1898 assertThrows(function() {
1899 class C {
1900 constructor() {
1901 if (1) super();
1902 }
1903 }
1904 new C();
1905 }, TypeError);
1906
1907 class C1 {
1908 constructor() {
1909 'use strict';
1910 super();
1911 }
1912 }
1913 new C1();
1914
1915 class C2 {
1916 constructor() {
1917 ; 'use strict';;;;;
1918 super();
1919 }
1920 }
1921 new C2();
1922
1923 class C3 {
1924 constructor() {
1925 ; 'use strict';;;;;
1926 // This is a comment.
1927 super();
1928 }
1929 }
1930 new C3();
1931 }());
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/classes-experimental.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698