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

Side by Side Diff: test/mjsunit/compiler/short-circuit.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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 14 matching lines...) Expand all
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 some expression contexts involving short-circuit boolean 28 // Test some expression contexts involving short-circuit boolean
29 // operations that did not otherwise have test coverage. 29 // operations that did not otherwise have test coverage.
30 30
31 31
32 var x = 42; 32 var x = 42;
33 33
34 // Literals in value/test context. 34 // Literals in value/test context.
35 assertEquals(x, function () { return 0 || x }()); 35 assertEquals(x, function () { return 0 || x; }());
36 assertEquals(1, function () { return 1 || x }()); 36 assertEquals(1, function () { return 1 || x; }());
37 37
38 // Literals in test/value context. 38 // Literals in test/value context.
39 assertEquals(0, function () { return 0 && x }()); 39 assertEquals(0, function () { return 0 && x; }());
40 assertEquals(x, function () { return 1 && x }()); 40 assertEquals(x, function () { return 1 && x; }());
41 41
42 // A value on top of the stack in value/test context. 42 // A value on top of the stack in value/test context.
43 assertEquals(x, function(y) { return y++ || x }(0)); 43 assertEquals(x, function(y) { return y++ || x; }(0));
44 assertEquals(1, function(y) { return y++ || x }(1)); 44 assertEquals(1, function(y) { return y++ || x; }(1));
45 45
46 // A value on top of the stack in a test/value context. 46 // A value on top of the stack in a test/value context.
47 assertEquals(0, function(y) { return y++ && x }(0)); 47 assertEquals(0, function(y) { return y++ && x; }(0));
48 assertEquals(x, function(y) { return y++ && x }(1)); 48 assertEquals(x, function(y) { return y++ && x; }(1));
49 49
50 // An object literal in value context. 50 // An object literal in value context.
51 assertEquals(0, function () { return {x: 0}}().x); 51 assertEquals(0, function () { return {x: 0};}().x);
52 52
53 // An object literal in value/test context. 53 // An object literal in value/test context.
54 assertEquals(0, function () { return {x: 0} || this }().x); 54 assertEquals(0, function () { return {x: 0} || this; }().x);
55 55
56 // An object literal in test/value context. 56 // An object literal in test/value context.
57 assertEquals(x, function () { return {x: 0} && this }().x); 57 assertEquals(x, function () { return {x: 0} && this; }().x);
58 58
59 // An array literal in value/test context. 59 // An array literal in value/test context.
60 assertEquals(0, function () { return [0,1] || new Array(x,1) }()[0]); 60 assertEquals(0, function () { return [0,1] || new Array(x,1); }()[0]);
61 61
62 // An array literal in test/value context. 62 // An array literal in test/value context.
63 assertEquals(x, function () { return [0,1] && new Array(x,1) }()[0]); 63 assertEquals(x, function () { return [0,1] && new Array(x,1); }()[0]);
64 64
65 // Slot assignment in value/test context. 65 // Slot assignment in value/test context.
66 assertEquals(x, function (y) { return (y = 0) || x }("?")); 66 assertEquals(x, function (y) { return (y = 0) || x; }("?"));
67 assertEquals(1, function (y) { return (y = 1) || x }("?")); 67 assertEquals(1, function (y) { return (y = 1) || x; }("?"));
68 68
69 // Slot assignment in test/value context. 69 // Slot assignment in test/value context.
70 assertEquals(0, function (y) { return (y = 0) && x }("?")); 70 assertEquals(0, function (y) { return (y = 0) && x; }("?"));
71 assertEquals(x, function (y) { return (y = 1) && x }("?")); 71 assertEquals(x, function (y) { return (y = 1) && x; }("?"));
72 72
73 // void in value context. 73 // void in value context.
74 assertEquals(void 0, function () { return void x }()); 74 assertEquals(void 0, function () { return void x; }());
75 75
76 // void in value/test context. 76 // void in value/test context.
77 assertEquals(x, function () { return (void x) || x }()); 77 assertEquals(x, function () { return (void x) || x; }());
78 78
79 // void in test/value context. 79 // void in test/value context.
80 assertEquals(void 0, function () { return (void x) && x }()); 80 assertEquals(void 0, function () { return (void x) && x; }());
81 81
82 // Unary not in value context. 82 // Unary not in value context.
83 assertEquals(false, function () { return !x }()); 83 assertEquals(false, function () { return !x; }());
84 84
85 // Unary not in value/test context. 85 // Unary not in value/test context.
86 assertEquals(true, function (y) { return !y || x }(0)); 86 assertEquals(true, function (y) { return !y || x; }(0));
87 assertEquals(x, function (y) { return !y || x }(1)); 87 assertEquals(x, function (y) { return !y || x; }(1));
88 88
89 // Unary not in test/value context. 89 // Unary not in test/value context.
90 assertEquals(x, function (y) { return !y && x }(0)); 90 assertEquals(x, function (y) { return !y && x; }(0));
91 assertEquals(false, function (y) { return !y && x }(1)); 91 assertEquals(false, function (y) { return !y && x; }(1));
92 92
93 // Comparison in value context. 93 // Comparison in value context.
94 assertEquals(false, function () { return x < x; }()); 94 assertEquals(false, function () { return x < x; }());
95 95
96 // Comparison in value/test context. 96 // Comparison in value/test context.
97 assertEquals(x, function () { return x < x || x; }()); 97 assertEquals(x, function () { return x < x || x; }());
98 assertEquals(true, function () { return x <= x || x; }()); 98 assertEquals(true, function () { return x <= x || x; }());
99 99
100 // Comparison in test/value context. 100 // Comparison in test/value context.
101 assertEquals(false, function () { return x < x && x; }()); 101 assertEquals(false, function () { return x < x && x; }());
102 assertEquals(x, function () { return x <= x && x; }()); 102 assertEquals(x, function () { return x <= x && x; }());
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/regress-stacktrace-methods.js ('k') | test/mjsunit/compiler/simple-bailouts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698