13514
|
1 /*
|
|
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This
|
|
3 * code is released under a tri EPL/GPL/LGPL license. You can use it,
|
|
4 * redistribute it and/or modify it under the terms of the:
|
|
5 *
|
|
6 * Eclipse Public License version 1.0
|
|
7 * GNU General Public License version 2
|
|
8 * GNU Lesser General Public License version 2.1
|
|
9 */
|
|
10 package com.oracle.truffle.ruby.test.language;
|
|
11
|
|
12 import org.junit.*;
|
|
13
|
|
14 import com.oracle.truffle.ruby.test.*;
|
|
15
|
|
16 /**
|
|
17 * Test characteristics of polymorphism.
|
|
18 */
|
|
19 public class PolymorphismTests extends RubyTests {
|
|
20
|
|
21 /**
|
|
22 * Test that a polymorphic method that will specialize to double will then not treat integers as
|
|
23 * doubles.
|
|
24 */
|
|
25 @Test
|
|
26 public void testSimpleOperatorRedefinition() {
|
|
27 assertPrints("16.759999999999998\n16\n", //
|
|
28 "def add(x, y)\n" + //
|
|
29 " x + y\n" + //
|
|
30 "end\n" + //
|
|
31 "puts add(14.5, 2.26)\n" + //
|
|
32 "puts add(14, 2)\n");
|
|
33 }
|
|
34
|
|
35 }
|