tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / script-tests / mod-crash.js
1 description(
2 "This test checks that n % 0 doesn't crash with a floating-point exception."
3 );
4
5 shouldBe("2 % 0", "NaN");
6
7 var n = 2;
8 shouldBe("n % 0", "NaN");
9
10 function f()
11 {
12     return 2 % 0;
13 }
14
15 shouldBe("f()", "NaN");
16
17 function g()
18 {
19     var n = 2;
20     return n % 0;
21 }
22
23 shouldBe("g()", "NaN");
24
25 // Test that reusing a floating point value after use in a modulus works correctly.
26 function nonSpeculativeModReuseInner(argument, o1, o2)
27 {
28         // The + operator on objects is a reliable way to avoid the speculative JIT path for now at least.
29     o1 + o2;
30
31     var knownDouble = argument - 0;
32     return knownDouble % 1 + knownDouble;
33 }
34 function nonSpeculativeModReuse(argument)
35 {
36     return nonSpeculativeModReuseInner(argument, {}, {});
37 }
38
39 shouldBe("nonSpeculativeModReuse(0.5)", "1");