120c09252571ce36f153554265982aeebe23e6ee
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * Function expressions as variables
3  */
4
5 // Anonymous function expression without body
6 var foo = function () {};
7 var fooArg = function (a, b, c) {};
8
9 // Named function expression without body
10 var bar = function bar () {};
11 var barArg = function barArg (a, b, c) {};
12
13 // Anonymous function expression with body
14 var baz = function () {
15   something();
16 };
17 var bazArg = function (a, b, c) {
18   something();
19 };
20
21 // Named function expression with body
22 var booz = function booz (a, b, c) {
23   something();
24 };
25 var boozArg = function boozArg () {
26   something();
27 };
28
29 /**
30  * Function expression as arguments
31  */
32
33 // Named function expression with body
34 call(function test () {
35   something();
36 });
37 call(x, function test () {
38   x();
39 });
40 call(function test () {
41   x();
42 }, x);
43
44 // Named function expression with body and arguments
45 call(function testArg (a, b, c) {
46   something();
47 });
48 call(x, function testArg (a, b, c) {
49   x();
50 });
51 call(function testArg (a, b, c) {
52   x();
53 }, x)
54
55 // Named function expression without body and arguments
56 call(function test2 () {});
57 call(x, function test2 () {});
58 call(function test2 () {}, x);
59
60 // Named function expression without body and with arguments
61 call(function test2Arg (a, b, c) {});
62 call(x, function test2Arg (a, b, c) {});
63 call(function test2Arg (a, b, c) {}, x);
64
65
66 // Anonymous function expression with body
67 call(function () {
68   something();
69 });
70 call(x, function () {
71   x();
72 });
73 call(function () {
74   x();
75 }, x);
76
77 // Anonymous function expression with body and arguments
78 call(function (a, b, c) {
79   something();
80 });
81 call(x, function (a, b, c) {
82   x();
83 });
84 call(function (a, b, c) {
85   x();
86 }, x);
87
88 // Anonymous function expression without body and arguments
89 call(function () {});
90 call(x, function () {});
91 call(function () {}, x);
92
93 // Anonymous function expression without body and with arguments
94 call(function (a, b, c) {});
95 call(x, function (a, b, c) {});
96 call(function (a, b, c) {}, x);
97
98 /**
99  * Function expression as object methods
100  */
101
102 var object = {
103   // Anonymous function expression without body
104   foo: function () {},
105   fooArg: function (a, b, c) {},
106
107   // Named function expression without body
108   bar: function bar () {},
109   barArg: function barArg (a, b, c) {},
110
111   // Anonymous function expression with body
112   baz: function () {
113     something();
114   },
115   bazArg: function (a, b, c) {
116     something();
117   },
118
119   // Named function expression with body
120   booz: function booz (a, b, c) {
121     something();
122   },
123   boozArg: function boozArg () {
124     something();
125   },
126 };
127
128 /**
129  * Function expression immediate execution
130  */
131
132 // Anonymous function expression without body
133 (function () {})();
134 (function (a, b, c) {})();
135
136 // Named function expression without body
137 (function bar () {})();
138 (function barArg (a, b, c) {})();
139
140 // Anonymous function expression with body
141 (function () {
142   something();
143 })();
144 (function (a, b, c) {
145   something();
146 })();
147
148 // Named function expression with body
149 (function booz (a, b, c) {
150   something();
151 })();
152 (function boozArg () {
153   something();
154 })();
155
156
157 // Anonymous function expression without body
158 (function () {}());
159 (function (a, b, c) {}());
160
161 // Named function expression without body
162 (function bar () {}());
163 (function barArg (a, b, c) {}());
164
165 // Anonymous function expression with body
166 (function () {
167   something();
168 }());
169 (function (a, b, c) {
170   something();
171 }());
172
173 // Named function expression with body
174 (function booz (a, b, c) {
175   something();
176 }());
177 (function boozArg () {
178   something();
179 }());