public void step() {
   myPosition = myPosition.minus(IntegerValue.one());
   if (myIndex >= 0 && (myPosition.isLT(myEdges.integerVarAt(myIndex)))) {
     myIndex = myIndex - 2;
     if (myIndex >= -1) {
       myPosition = (myEdges.integerVarAt(myIndex + 1)).minus(IntegerValue.one());
     }
   }
   /*
   udanax-top.st:53451:DescendingIntegerStepper methodsFor: 'accessing'!
   {void} step
   	myPosition _ myPosition - 1.
   	(myIndex >= Int32Zero and: [myPosition < (myEdges integerVarAt: myIndex)]) ifTrue:
   		[myIndex _ myIndex - 2.
   		myIndex >= -1 ifTrue:
   			[myPosition _ (myEdges integerVarAt: myIndex + 1) - 1]]!
   */
 }
 public DescendingIntegerStepper(IntegerVarArray edges, int count) {
   super();
   myEdges = edges;
   myIndex = count - 2;
   if (myIndex >= -1) {
     myPosition = (myEdges.integerVarAt(myIndex + 1)).minus(IntegerValue.one());
   } else {
     myPosition = IntegerValue.zero();
   }
   /*
   udanax-top.st:53424:DescendingIntegerStepper methodsFor: 'protected: create'!
   create: edges {IntegerVarArray} with: count {UInt32}
   	super create.
   	myEdges _ edges.
   	myIndex _ count - 2.
   	myIndex >= -1
   		ifTrue: [myPosition _ (myEdges integerVarAt: myIndex + 1) - 1]
   		ifFalse: [myPosition _ IntegerVar0]!
   */
 }
Example #3
0
  public void testStoreMany() {
    // empty
    Int64Array array = AssertArrays.makeInt64ArrayEmpty();
    array.storeMany(0, AssertArrays.makeInt64ArrayEmpty());
    AssertArrays.assertEquals(AssertArrays.makeInt64ArrayEmpty(), array);

    // simple
    array = AssertArrays.makeInt64Array12345();
    array.storeMany(0, AssertArrays.makeInt64Array12321());
    AssertArrays.assertEquals(AssertArrays.makeInt64Array12321(), array);

    array = AssertArrays.makeInt64Array12345();
    array.storeMany(0, AssertArrays.makeInt64Array12321());
    AssertArrays.assertEquals(AssertArrays.makeInt64Array12321(), array);

    array = AssertArrays.makeInt64Array12321();
    array.storeMany(1, Int64Array.make(new long[] {8, 7, 6, 5, 4, 3, 3}), 2, 3);
    AssertArrays.assertEquals(Int64Array.make(new long[] {1, 5, 4, 2, 1}), array);

    array = AssertArrays.makeInt64Array12321();
    array.storeMany(1, Int64Array.make(new long[] {8, 7}));
    AssertArrays.assertEquals(Int64Array.make(new long[] {1, 8, 7, 2, 1}), array);

    // Store incompatible type
    array = AssertArrays.makeInt64Array12321();
    try {
      array.storeMany(1, IEEE64Array.make(new double[] {8.8, 7.7}));
      fail();
    } catch (ClassCastException e) {
      // expected
    }

    // attempt to copy beyond this extent
    array = AssertArrays.makeInt64Array12345();
    try {
      array.storeMany(1, AssertArrays.makeInt64Array12321());
      fail();
    } catch (IndexOutOfBoundsException e) {
      // expected
    }

    // insufficient source elements
    array = AssertArrays.makeInt64Array12345();
    try {
      array.storeMany(0, AssertArrays.makeInt64Array12321(), 2, 4);
      fail();
    } catch (IndexOutOfBoundsException e) {
      // expected
    }

    // Store integer values outside of spec
    array = AssertArrays.makeInt64Array12321();
    try {
      array.storeMany(
          1,
          IntegerVarArray.make(
              new IntegerValue[] {IntegerValue.make(Long.MAX_VALUE).plus(IntegerValue.one())}));
      fail("MAX_VALUE + 1");
    } catch (IllegalArgumentException e) {
      // expected
    }
  }