blob: c32fda6dfaaa4ceb3efbde99b61fab6f038d6cad [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7function test(expected, f) {
8 assertEquals(expected, f());
9 assertEquals(expected, f());
10 %OptimizeFunctionOnNextCall(f);
11 assertEquals(expected, f());
12 assertEquals(expected, f());
13}
14
15function testThrows(f) {
16 assertThrows(f);
17 assertThrows(f);
18 %OptimizeFunctionOnNextCall(f);
19 assertThrows(f);
20 assertThrows(f);
21}
22
23// --- Constant case.
24a = 11;
25
26function f1() { return a; }
27test(11, f1);
28
29delete a;
30
31testThrows(f1);
32
33
34// --- SMI case.
35
36b = 11;
37b = 12;
38b = 13;
39
40function f2() { return b; }
41test(13, f2);
42
43delete b;
44
45testThrows(f2);
46
47
48// --- double case.
49
50c = 11;
51c = 12.25;
52c = 13.25;
53
54function f3() { return c; }
55test(13.25, f3);
56
57delete c;
58
59testThrows(f3);
60
61
62// --- tagged case.
63
64d = 11;
65d = 12.25;
66d = "hello";
67
68function f4() { return d; }
69test("hello", f4);
70
71delete d;
72
73testThrows(f4);