comparison graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/BignumTests.java @ 13514:0fbee3eb71f0

Ruby: import project.
author Chris Seaton <chris.seaton@oracle.com>
date Mon, 06 Jan 2014 17:12:09 +0000
parents
children
comparison
equal deleted inserted replaced
13513:64a23ce736a0 13514:0fbee3eb71f0
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.core;
11
12 import org.junit.*;
13
14 import com.oracle.truffle.ruby.test.*;
15
16 /**
17 * Test the {@code Bignum} class.
18 */
19 public class BignumTests extends RubyTests {
20
21 @Test
22 public void testImmediate() {
23 assertPrints("123456789123456789\n", "puts 123456789123456789");
24 assertPrints("574658776654483828\n", "puts 574658776654483828");
25 }
26
27 @Test
28 public void testAddImmediate() {
29 assertPrints("821572354901397406\n", "puts 123456789123456789+698115565777940617");
30 assertPrints("7675735362615108\n", "puts 867676857675 + 7674867685757433");
31 assertPrints("8792416214481\n", "puts 8785647643454 + (6768571027)");
32 assertPrints("8089240320234\n", "puts (7132953783486) + ((956286536748))");
33 }
34
35 @Test
36 public void testSubImmediate() {
37 assertPrints("574658776654483828\n", "puts 698115565777940617-123456789123456789");
38 assertPrints("7674000008899758\n", "puts 7674867685757433 - 867676857675");
39 assertPrints("8778879072427\n", "puts 8785647643454 - (6768571027)");
40 assertPrints("6176667246738\n", "puts (7132953783486) - ((956286536748))");
41 }
42
43 @Test
44 public void testLessImmediate() {
45 assertPrints("false\n", "puts 698115565777940617 < 123456789123456789");
46 assertPrints("true\n", "puts 867676857675 < 7674867685757433");
47 assertPrints("false\n", "puts 8785647643454 < (6768571027)");
48 assertPrints("true\n", "puts (956286536748) < ((7132953783486))");
49 }
50
51 @Test
52 public void testDivmod() {
53 assertPrints("100\n2342\n", "puts 1000000000000000000000002342.divmod(10000000000000000000000000)");
54 assertPrints("Fixnum\n", "puts 1000000000000000000000002342.divmod(10000000000000000000000000)[0].class");
55 assertPrints("Fixnum\n", "puts 1000000000000000000000002342.divmod(10000000000000000000000000)[1].class");
56 }
57 }