@Test public void divideIntegers() { Number actual = evaluate(a._div(b), intPoint(23, 2)); assertThat(actual.intValue(), equalTo(11)); // Integer arithmetic drops the 0.5 }
@Test public void negIntegers() { Number actual = evaluate(a._neg(), intPoint(23, 0)); assertThat(actual.intValue(), equalTo(-23)); }
@Test public void multiplyIntegers() { Number actual = evaluate(a._mul(b), intPoint(6, 7)); assertThat(actual.intValue(), equalTo(42)); }
@Test public void addIntegers() { Number actual = evaluate(a._plus(b), intPoint(18, 5)); assertThat(actual.intValue(), equalTo(23)); }
@Test public void subtractIntegers() { Number actual = evaluate(a._minus(b), intPoint(23, 65)); assertThat(actual.intValue(), equalTo(-42)); }
@Test public void integerPolynomial() { // a**3 + a*b + 7 Number actual = evaluate(a._mul(a)._mul(a)._plus(a._mul(b))._plus(7), intPoint(3, -8)); assertThat(actual.intValue(), equalTo(10)); }
@Test public void andIntegers() { Number actual = evaluate(a._and(b), intPoint(17, 5)); assertThat(actual.intValue(), equalTo(1)); }
@Test public void shiftIntegersLogicallyRight() { Number actual = evaluate(a._shiftUR(b), intPoint(-1, 1)); assertThat(actual.intValue(), equalTo(Integer.MAX_VALUE)); }
@Test public void shiftIntegersRight() { Number actual = evaluate(a._shiftR(b), intPoint(-1, 5)); assertThat(actual.intValue(), equalTo(-1)); }
@Test public void shiftIntegersLeft() { Number actual = evaluate(a._shiftL(b), intPoint(8, 2)); assertThat(actual.intValue(), equalTo(32)); }