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

Side by Side Diff: test/mjsunit/function-prototype.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/function-property.js ('k') | test/mjsunit/function-source.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Test that we can set function prototypes to non-object values. The 28 // Test that we can set function prototypes to non-object values. The
29 // prototype used for instances in that case should be the initial 29 // prototype used for instances in that case should be the initial
30 // object prototype. ECMA-262 13.2.2. 30 // object prototype. ECMA-262 13.2.2.
31 function TestNonObjectPrototype(value) { 31 function TestNonObjectPrototype(value) {
32 function F() {}; 32 function F() {}
33 F.prototype = value; 33 F.prototype = value;
34 var f = new F(); 34 var f = new F();
35 assertEquals(value, F.prototype); 35 assertEquals(value, F.prototype);
36 assertEquals(Object.prototype, f.__proto__); 36 assertEquals(Object.prototype, f.__proto__);
37 } 37 }
38 38
39 var values = [123, "asdf", true]; 39 var values = [123, "asdf", true];
40 40
41 values.forEach(TestNonObjectPrototype); 41 values.forEach(TestNonObjectPrototype);
42 42
43 43
44 // Test moving between non-object and object values. 44 // Test moving between non-object and object values.
45 function F() {}; 45 function F() {}
46 var f = new F(); 46 var f = new F();
47 assertEquals(f.__proto__, F.prototype); 47 assertEquals(f.__proto__, F.prototype);
48 F.prototype = 42; 48 F.prototype = 42;
49 f = new F(); 49 f = new F();
50 assertEquals(Object.prototype, f.__proto__); 50 assertEquals(Object.prototype, f.__proto__);
51 assertEquals(42, F.prototype); 51 assertEquals(42, F.prototype);
52 F.prototype = { a: 42 }; 52 F.prototype = { a: 42 };
53 f = new F(); 53 f = new F();
54 assertEquals(42, F.prototype.a); 54 assertEquals(42, F.prototype.a);
55 assertEquals(f.__proto__, F.prototype); 55 assertEquals(f.__proto__, F.prototype);
56 56
57 57
58 // Test that the fast case optimizations can handle non-functions, 58 // Test that the fast case optimizations can handle non-functions,
59 // functions with no prototypes (yet), non-object prototypes, 59 // functions with no prototypes (yet), non-object prototypes,
60 // functions without initial maps, and the fully initialized 60 // functions without initial maps, and the fully initialized
61 // functions. 61 // functions.
62 function GetPrototypeOf(f) { 62 function GetPrototypeOf(f) {
63 return f.prototype; 63 return f.prototype;
64 }; 64 }
65 65
66 // Seed the GetPrototypeOf function to enable the fast case 66 // Seed the GetPrototypeOf function to enable the fast case
67 // optimizations. 67 // optimizations.
68 var p = GetPrototypeOf(GetPrototypeOf); 68 var p = GetPrototypeOf(GetPrototypeOf);
69 69
70 // Check that getting the prototype of a tagged integer works. 70 // Check that getting the prototype of a tagged integer works.
71 assertTrue(typeof GetPrototypeOf(1) == 'undefined'); 71 assertTrue(typeof GetPrototypeOf(1) == 'undefined');
72 72
73 function NoPrototypeYet() { } 73 function NoPrototypeYet() { }
74 var p = GetPrototypeOf(NoPrototypeYet); 74 var p = GetPrototypeOf(NoPrototypeYet);
(...skipping 11 matching lines...) Expand all
86 assertEquals(F.prototype, GetPrototypeOf(F)); 86 assertEquals(F.prototype, GetPrototypeOf(F));
87 87
88 // Check that getting the prototype of a non-function works. This must 88 // Check that getting the prototype of a non-function works. This must
89 // be the last thing we do because this will clobber the optimizations 89 // be the last thing we do because this will clobber the optimizations
90 // in GetPrototypeOf and go to a monomorphic IC load instead. 90 // in GetPrototypeOf and go to a monomorphic IC load instead.
91 assertEquals(87, GetPrototypeOf({prototype:87})); 91 assertEquals(87, GetPrototypeOf({prototype:87}));
92 92
93 // Check the prototype is not enumerable, for compatibility with 93 // Check the prototype is not enumerable, for compatibility with
94 // safari. This is deliberately incompatible with ECMA262, 15.3.5.2. 94 // safari. This is deliberately incompatible with ECMA262, 15.3.5.2.
95 var foo = new Function("return x"); 95 var foo = new Function("return x");
96 var result = "" 96 var result = "";
97 for (var n in foo) result += n; 97 for (var n in foo) result += n;
98 assertEquals(result, ""); 98 assertEquals(result, "");
OLDNEW
« no previous file with comments | « test/mjsunit/function-property.js ('k') | test/mjsunit/function-source.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698