[FOray-commit] SF.net SVN: foray: [10599] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2008-05-30 04:43:22
|
Revision: 10599
http://foray.svn.sourceforge.net/foray/?rev=10599&view=rev
Author: victormote
Date: 2008-05-29 21:43:29 -0700 (Thu, 29 May 2008)
Log Message:
-----------
Change PsInteger to wrap a BigDecimal instead of int.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsInteger.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsNumber.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsReal.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsSystemDict.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/TestPsSystemDict.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -184,7 +184,7 @@
final Object arrayItem = psarray.get(i);
if (arrayItem instanceof PsInteger) {
final PsInteger psInteger = (PsInteger) arrayItem;
- final int itemValue = psInteger.getValue();
+ final int itemValue = psInteger.intValue();
this.fontBBox[i] = itemValue;
} else {
return null;
@@ -211,7 +211,7 @@
if (! (item instanceof PsInteger)) {
return 0;
}
- return ((PsInteger) item).getValue();
+ return ((PsInteger) item).intValue();
}
/**
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -180,7 +180,7 @@
if (getItem("FontMatrix") == null) {
return false;
}
- if (fontType.getValue() != 0) {
+ if (fontType.intValue() != 0) {
if (getItem("Encoding") == null) {
return false;
}
@@ -188,7 +188,7 @@
return false;
}
}
- if (fontType.getValue() == 1) {
+ if (fontType.intValue() == 1) {
if (getItem("PaintType") == null) {
return false;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsInteger.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsInteger.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsInteger.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -30,10 +30,12 @@
import org.foray.common.WKConstants;
+import java.math.BigDecimal;
+
/**
* Class representing a numeric PostScript object.
*/
-public class PsInteger extends PsNumber implements Comparable<Object> {
+public class PsInteger extends PsNumber {
/** Constant indicating the smallest PostScript integer value. */
public static final int PS_SMALLEST_INTEGER = -2147483648;
@@ -49,19 +51,27 @@
* an integer in the PostScript language (base-36). */
private static final int MAXIMUM_RADIX = 36;
- /** The encapsulated value for this object. */
- private int value;
-
/**
- * Constructor.
+ * Constructor for an int parameter.
* @param value The value to encapsulate.
*/
public PsInteger(final int value) {
- super();
- this.value = value;
+ super(new BigDecimal(value));
}
/**
+ * Constructor for a BigDecimal parameter.
+ * @param value The value to encapsulate. This must be a BigDecimal that has no fractional
+ * part, that is, it must be an integer.
+ */
+ public PsInteger(final BigDecimal value) {
+ super(value);
+ /* Extract the value. The only purpose in doing this is to get the ArithmeticException
+ * thrown if the value is not an integer. */
+ value.intValueExact();
+ }
+
+ /**
* Creates a PSInteger if value is within the PostScript architectural
* limits for an integer.
* @param value The value to be encapsulated.
@@ -71,7 +81,7 @@
public static PsNumber makePSNumber(final long value) {
if (value > PsInteger.PS_LARGEST_INTEGER
|| value < PsInteger.PS_SMALLEST_INTEGER) {
- return new PsReal(value);
+ return new PsReal(new BigDecimal(value));
}
return new PsInteger((int) value);
}
@@ -80,7 +90,7 @@
* {@inheritDoc}
*/
public PsInteger clone() {
- final PsInteger clone = new PsInteger(this.value);
+ final PsInteger clone = new PsInteger(this.getValue());
return clone;
}
@@ -241,7 +251,7 @@
* {@inheritDoc}
*/
public PsInteger duplicate() {
- return new PsInteger(this.value);
+ return new PsInteger(this.getValue());
}
/**
@@ -254,114 +264,30 @@
/**
* {@inheritDoc}
*/
- public boolean isComparable(final PsObject object) {
- if (object instanceof PsInteger || object instanceof PsReal) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int compareTo(final Object object) {
- PsObject psobject = null;
- if (object instanceof PsObject) {
- psobject = (PsObject) object;
- } else {
- return Byte.MIN_VALUE;
- }
- if (! isComparable(psobject)) {
- return Byte.MIN_VALUE;
- }
- if (psobject instanceof PsInteger) {
- final PsInteger psinteger = (PsInteger) psobject;
- if (this.value == psinteger.value) {
- return 0;
- } else if (this.value < psinteger.value) {
- return -1;
- } else {
- return 1;
- }
- }
- if (psobject instanceof PsReal) {
- final PsReal psreal = (PsReal) psobject;
- if (this.value == psreal.getDoubleValue()) {
- return 0;
- } else if (this.value < psreal.getDoubleValue()) {
- return -1;
- } else {
- return 1;
- }
- }
- return Byte.MIN_VALUE;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(final Object object) {
- if (this.compareTo(object) == 0) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
public PsName getTypeName() {
return new PsName("integertype", true, false);
}
/**
- * Return the encapsulated value.
- * @return The encapsulated value.
- */
- public int getValue() {
- return this.value;
- }
-
- /**
* {@inheritDoc}
*/
- public double getDoubleValue() {
- return this.value;
- }
-
- /**
- * {@inheritDoc}
- */
- public void round() {
- /* Do nothing. This is already an integer. */
- return;
- }
-
- /**
- * {@inheritDoc}
- */
public String toString() {
- return "Integer: " + Integer.toString(this.value);
+ return "Integer: " + this.getValue().toString();
}
/**
* {@inheritDoc}
*/
- public PsNumber add(final PsNumber amount) {
- if (amount instanceof PsInteger) {
- final PsInteger psInteger = (PsInteger) amount;
- this.value += psInteger.value;
- return this;
- }
- final double newValue = this.value + amount.getDoubleValue();
- return new PsReal(newValue);
+ public boolean isComposite() {
+ return false;
}
/**
- * {@inheritDoc}
+ * Returns the integer value of this instance.
+ * @return The integer value.
*/
- public boolean isComposite() {
- return false;
+ public int intValue() {
+ return this.getValue().intValueExact();
}
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsNumber.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsNumber.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsNumber.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -28,18 +28,25 @@
package org.foray.ps;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
/**
* Superclass for numeric Postscript data types.
* @see PsInteger
* @see PsReal
*/
-public abstract class PsNumber implements PsObjectSimple, Cloneable {
+public abstract class PsNumber implements PsObjectSimple, Cloneable, Comparable<PsNumber> {
+ /** The encapsulated value for this object. */
+ private BigDecimal value;
+
/**
* Constructor.
+ * @param value The encapsulated value for this object.
*/
- public PsNumber() {
- super();
+ public PsNumber(final BigDecimal value) {
+ this.value = value;
}
/**
@@ -51,21 +58,21 @@
* Return the value of this numeric item cast as a double.
* @return The value of this number as a double.
*/
- public abstract double getDoubleValue();
+ public double getDoubleValue() {
+ return this.getValue().doubleValue();
+ }
/**
* Rounds the value.
*/
- public abstract void round();
+ public void round() {
+ if (this instanceof PsInteger) {
+ /* Do nothing. The value is already an integer. */
+ return;
+ }
+ this.value = this.value.setScale(0, RoundingMode.HALF_UP);
+ }
- /**
- * Adds a given amount to the value of this object, returning either this object with its value
- * adjusted, or, if this object is unable to represent the value properly, a new object which
- * can.
- * @param amount The amount which should be added to the value of this number.
- * @return A PSNumber that contains the new value.
- */
- public abstract PsNumber add(PsNumber amount);
/**
* Tests whether the input byte is a numeral.
@@ -114,4 +121,63 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isComparable(final PsObject object) {
+ if (object instanceof PsNumber) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(final Object object) {
+ if (object instanceof PsNumber) {
+ final PsNumber psNumber = (PsNumber) object;
+ return this.compareTo(psNumber) == 0;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo(final PsNumber object) {
+ return this.getValue().compareTo(object.getValue());
+ }
+
+ /**
+ * Adds a given amount to the value of this object, returning either this object with its value
+ * adjusted, or, if this object is unable to represent the value properly, a new object which
+ * can.
+ * @param amount The amount which should be added to the value of this number.
+ * @return A PSNumber that contains the new value.
+ */
+ public PsNumber add(final PsNumber amount) {
+ /* Avoid unnecessary creation of objects if possible. */
+ if (this.getValue().compareTo(BigDecimal.ZERO) == 0) {
+ return amount;
+ }
+ if (amount.getValue().compareTo(BigDecimal.ZERO) == 0) {
+ return this;
+ }
+ final BigDecimal sum = this.getValue().add(amount.getValue());
+ if (this instanceof PsInteger
+ && amount instanceof PsInteger) {
+ return new PsInteger(sum);
+ }
+ return new PsReal(sum);
+ }
+
+ /**
+ * Return the encapsulated value.
+ * @return The encapsulated value.
+ */
+ public BigDecimal getValue() {
+ return this.value;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsReal.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsReal.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsReal.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -29,23 +29,18 @@
package org.foray.ps;
import java.math.BigDecimal;
-import java.math.RoundingMode;
/**
* Class representing PostScript object that is a real number.
*/
-public class PsReal extends PsNumber implements Comparable<Object> {
+public class PsReal extends PsNumber {
- /** The encapsulated value for this object. */
- private BigDecimal value;
-
/**
* Constructor for a double value.
* @param value The value to encapsulate.
*/
public PsReal(final double value) {
- super();
- this.value = new BigDecimal(value);
+ super(new BigDecimal(value));
}
/**
@@ -53,15 +48,14 @@
* @param value The value to encapsulate.
*/
public PsReal(final BigDecimal value) {
- super();
- this.value = value;
+ super(value);
}
/**
* {@inheritDoc}
*/
public PsReal clone() {
- final PsReal clone = new PsReal(this.value);
+ final PsReal clone = new PsReal(this.getValue());
return clone;
}
@@ -80,22 +74,23 @@
if (!isNumeral(input[i])
&& !isMember(PsInterpreter.SIGN_INDICATOR, input[i])
&& input[i] != '.'
- && input[i] != 'E' // E (for exponent)
- && input[i] != 'e' // e (for exponent)
- ) {
+ /* E (for exponent). */
+ && input[i] != 'E'
+ /* e (for exponent). */
+ && input[i] != 'e') {
return null;
}
}
- // An e or E by itself won't be a number.
- if (input.length == 1 && (input[0] == 'e' || input[0] == 'E')) {
+ /* An e or E by itself won't be a number. */
+ if (input.length == 1
+ && (input[0] == 'e'
+ || input[0] == 'E')) {
return null;
}
- // It looks like the java methods might be sufficient here
- final StringBuilder sb = new StringBuilder();
- for (int i = 0; i < input.length; i++) {
- sb.append((char) input[i]);
- }
- final double value = Double.valueOf(sb.toString()).doubleValue();
+ final String sb = new String(input);
+ /* Use the String constructor to get better precision than can be had with a float or
+ * double. */
+ final BigDecimal value = new BigDecimal(sb);
return new PsReal(value);
}
@@ -103,7 +98,7 @@
* {@inheritDoc}
*/
public PsReal duplicate() {
- return new PsReal(this.value);
+ return new PsReal(this.getValue());
}
/**
@@ -116,106 +111,20 @@
/**
* {@inheritDoc}
*/
- public boolean isComparable(final PsObject object) {
- if (object instanceof PsInteger || object instanceof PsReal) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int compareTo(final Object object) {
- PsObject psobject = null;
- if (object instanceof PsObject) {
- psobject = (PsObject) object;
- } else {
- return Byte.MIN_VALUE;
- }
- if (! isComparable(psobject)) {
- return Byte.MIN_VALUE;
- }
- if (psobject instanceof PsInteger) {
- final PsInteger psinteger = (PsInteger) psobject;
- if (this.value.doubleValue() == psinteger.getValue()) {
- return 0;
- } else if (this.value.doubleValue() < psinteger.getValue()) {
- return -1;
- } else {
- return 1;
- }
- }
- if (psobject instanceof PsReal) {
- final PsReal psreal = (PsReal) psobject;
- if (this.value == psreal.value) {
- return 0;
- } else if (this.value.doubleValue() < psreal.value.doubleValue()) {
- return -1;
- } else {
- return 1;
- }
- }
- return Byte.MIN_VALUE;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(final Object object) {
- if (this.compareTo(object) == 0) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
public PsName getTypeName() {
return new PsName("realtype", true, false);
}
/**
- * Return the encapsulated value.
- * @return The encapsulated value.
- */
- public BigDecimal getValue() {
- return this.value;
- }
-
- /**
* {@inheritDoc}
*/
- public double getDoubleValue() {
- return this.value.doubleValue();
- }
-
- /**
- * {@inheritDoc}
- */
- public void round() {
- this.value = this.value.setScale(0, RoundingMode.HALF_UP);
- }
-
- /**
- * {@inheritDoc}
- */
public String toString() {
- return "Real: " + this.value.toString();
+ return "Real: " + this.getValue().toString();
}
/**
* {@inheritDoc}
*/
- public PsNumber add(final PsNumber amount) {
- final double doubleValue = this.getDoubleValue() + amount.getDoubleValue();
- return new PsReal(doubleValue);
- }
-
- /**
- * {@inheritDoc}
- */
public boolean isComposite() {
return false;
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsSystemDict.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsSystemDict.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsSystemDict.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -872,12 +872,7 @@
*/
private double popDouble(final PsOperator operation) throws PsOperatorException {
final PsNumber psn = popPSNumber(operation);
- if (psn instanceof PsInteger) {
- return ((PsInteger) psn).getValue();
- } else if (psn instanceof PsReal) {
- return ((PsReal) psn).getDoubleValue();
- }
- return 0;
+ return psn.getDoubleValue();
}
/**
@@ -898,7 +893,7 @@
*/
private int popInt(final PsOperator operation) throws PsOperatorException {
final PsInteger psi = popPSInteger(operation);
- return psi.getValue();
+ return psi.intValue();
}
/**
@@ -1097,7 +1092,7 @@
if (! (object instanceof PsInteger)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.DICT);
}
- int initialSize = ((PsInteger) object).getValue();
+ int initialSize = ((PsInteger) object).intValue();
if (initialSize < -1) {
initialSize = 1;
}
@@ -1170,7 +1165,7 @@
*/
private void addAsIntegers(final PsInteger num1, final PsInteger num2)
throws PsOperatorException {
- final long sum = num1.getValue() + num2.getValue();
+ final long sum = num1.intValue() + num2.intValue();
final PsNumber number = PsInteger.makePSNumber(sum);
pushOperand(number);
}
@@ -1186,7 +1181,7 @@
&& num2 instanceof PsInteger) {
final PsInteger integer1 = (PsInteger) num1;
final PsInteger integer2 = (PsInteger) num2;
- final long difference = integer1.getValue() - integer2.getValue();
+ final long difference = integer1.intValue() - integer2.intValue();
final PsNumber number = PsInteger.makePSNumber(difference);
pushOperand(number);
} else {
@@ -1206,7 +1201,7 @@
&& num2 instanceof PsInteger) {
final PsInteger integer1 = (PsInteger) num1;
final PsInteger integer2 = (PsInteger) num2;
- final long product = integer1.getValue() * integer2.getValue();
+ final long product = integer1.intValue() * integer2.intValue();
final PsNumber number = PsInteger.makePSNumber(product);
pushOperand(number);
} else {
@@ -1395,7 +1390,7 @@
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.STRING);
}
final PsInteger psinteger = (PsInteger) object;
- final int size = psinteger.getValue();
+ final int size = psinteger.intValue();
final StringBuilder sb = new StringBuilder(size);
for (int i = 1; i <= size; i++) {
sb.append('0');
@@ -1455,10 +1450,8 @@
*/
private void roll() throws PsOperatorException, PsException {
try {
- final int j = ((PsInteger) popOperand(PsOperator.ROLL))
- .getValue();
- final int n = ((PsInteger) popOperand(PsOperator.ROLL))
- .getValue();
+ final int j = ((PsInteger) popOperand(PsOperator.ROLL)).intValue();
+ final int n = ((PsInteger) popOperand(PsOperator.ROLL)).intValue();
if (n <= 0) {
throw new PsOperatorException(PsError.RANGECHECK,
PsOperator.ROLL, "n must be non-negative");
@@ -1558,7 +1551,7 @@
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.PUT);
}
final PsInteger psinteger = (PsInteger) where;
- final int index = psinteger.getValue();
+ final int index = psinteger.intValue();
if (index < 0 || index > array.size() - 1) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.PUT);
}
@@ -1593,7 +1586,7 @@
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.PUT);
}
PsInteger psinteger = (PsInteger) where;
- final int index = psinteger.getValue();
+ final int index = psinteger.intValue();
if (index < 0 || index > string.getValue().length() - 1) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.PUT);
}
@@ -1601,7 +1594,7 @@
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.PUT);
}
psinteger = (PsInteger) what;
- final char replacementChar = (char) psinteger.getValue();
+ final char replacementChar = (char) psinteger.intValue();
final char[] charArray = new char[string.getValue().length()];
string.getValue().getChars(0, string.getValue().length(), charArray, 0);
charArray[index] = replacementChar;
@@ -1617,7 +1610,7 @@
if (! (object instanceof PsInteger)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.ARRAY);
}
- final int size = ((PsInteger) object).getValue();
+ final int size = ((PsInteger) object).intValue();
if (size < 0 || size > PsInterpreter.MAX_ARRAY_SIZE) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.ARRAY);
}
@@ -1648,7 +1641,7 @@
if (! (object instanceof PsInteger)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.INDEX);
}
- final int index = ((PsInteger) object).getValue();
+ final int index = ((PsInteger) object).intValue();
if (index < 0) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.INDEX);
}
@@ -1693,7 +1686,7 @@
if (! (where instanceof PsInteger)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.GET);
}
- final int index = ((PsInteger) where).getValue();
+ final int index = ((PsInteger) where).intValue();
if (index < 0 || index > array.size() - 1) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.GET);
}
@@ -1725,7 +1718,7 @@
if (! (where instanceof PsInteger)) {
throw new PsOperatorException(PsError.TYPECHECK, PsOperator.GET);
}
- final int index = ((PsInteger) where).getValue();
+ final int index = ((PsInteger) where).intValue();
if (index < 0 || index > string.getValue().length() - 1) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.GET);
}
@@ -1795,7 +1788,7 @@
final PsObject object = popOperand(PsOperator.NEG);
if (object instanceof PsInteger) {
final PsInteger psint = (PsInteger) object;
- final int value = psint.getValue();
+ final int value = psint.intValue();
pushOperand(new PsInteger(-1 * value));
return;
}
@@ -1825,7 +1818,7 @@
}
if (object instanceof PsInteger) {
PsInteger psinteger = (PsInteger) object;
- final int value = psinteger.getValue();
+ final int value = psinteger.intValue();
psinteger = new PsInteger(~value);
pushOperand(psinteger);
return;
@@ -1847,7 +1840,7 @@
return;
}
if (item2 instanceof PsInteger) {
- final int int2 = ((PsInteger) item2).getValue();
+ final int int2 = ((PsInteger) item2).intValue();
final int int1 = popInt(PsOperator.OR);
final PsInteger int3 = new PsInteger(int1 | int2);
pushOperand(int3);
@@ -1870,7 +1863,7 @@
return;
}
if (item2 instanceof PsInteger) {
- final int int2 = ((PsInteger) item2).getValue();
+ final int int2 = ((PsInteger) item2).intValue();
final int int1 = popInt(PsOperator.OR);
final PsInteger int3 = new PsInteger(int1 ^ int2);
pushOperand(int3);
@@ -1893,7 +1886,7 @@
return;
}
if (item2 instanceof PsInteger) {
- final int int2 = ((PsInteger) item2).getValue();
+ final int int2 = ((PsInteger) item2).intValue();
final int int1 = popInt(PsOperator.OR);
final PsInteger int3 = new PsInteger(int1 & int2);
pushOperand(int3);
@@ -2558,7 +2551,7 @@
*/
private void copyStack() throws PsOperatorException {
final PsInteger integer = popPSInteger(PsOperator.COPY);
- final int count = integer.getValue();
+ final int count = integer.intValue();
if (count < 0) {
throw new PsOperatorException(PsError.RANGECHECK, PsOperator.COPY);
}
Modified: trunk/foray/foray-ps/src/javatest/org/foray/ps/TestPsSystemDict.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/TestPsSystemDict.java 2008-05-30 03:06:17 UTC (rev 10598)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/TestPsSystemDict.java 2008-05-30 04:43:29 UTC (rev 10599)
@@ -66,12 +66,12 @@
PsObject object = interpreter.getOperandStack().peek(0);
assertTrue(object instanceof PsInteger);
PsInteger integer = (PsInteger) object;
- assertEquals(2, integer.getValue());
+ assertEquals(2, integer.intValue());
/* The next-to-top item should be the integer 1. */
object = interpreter.getOperandStack().peek(1);
assertTrue(object instanceof PsInteger);
integer = (PsInteger) object;
- assertEquals(1, integer.getValue());
+ assertEquals(1, integer.intValue());
/* Second example from the PSLRM, 2nd ed. */
input = new PsStringInput("1 2 3 pop pop");
@@ -83,7 +83,7 @@
object = interpreter.getOperandStack().peek(0);
assertTrue(object instanceof PsInteger);
integer = (PsInteger) object;
- assertEquals(1, integer.getValue());
+ assertEquals(1, integer.intValue());
}
/**
@@ -141,7 +141,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
PsInteger integer = (PsInteger) object;
- assertEquals(1, integer.getValue());
+ assertEquals(1, integer.intValue());
/* Second example from the PSLRM, 2nd ed. */
input = new PsStringInput("4 2 idiv");
@@ -151,7 +151,7 @@
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
integer = (PsInteger) object;
- assertEquals(2, integer.getValue());
+ assertEquals(2, integer.intValue());
/* Third example from the PSLRM, 2nd ed. */
input = new PsStringInput("-5 2 idiv");
@@ -161,7 +161,7 @@
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
integer = (PsInteger) object;
- assertEquals(-2, integer.getValue());
+ assertEquals(-2, integer.intValue());
}
/**
@@ -177,7 +177,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
final PsInteger integer = (PsInteger) object;
- assertEquals(7, integer.getValue());
+ assertEquals(7, integer.intValue());
/* Second example from the PSLRM, 2nd ed. */
input = new PsStringInput("9.9 1.1 add");
@@ -202,7 +202,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
final PsInteger integer = (PsInteger) object;
- assertEquals(4, integer.getValue());
+ assertEquals(4, integer.intValue());
/* Inverse of the second example for "add" from the PSLRM, 2nd ed. */
input = new PsStringInput("11.0 9.9 sub");
@@ -228,7 +228,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
final PsInteger integer = (PsInteger) object;
- assertEquals(12, integer.getValue());
+ assertEquals(12, integer.intValue());
/* Second example from the PSLRM, 2nd ed. */
input = new PsStringInput("9.9 1.1 mul");
@@ -604,7 +604,7 @@
PsObject object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
PsInteger psInteger = (PsInteger) object;
- assertEquals(5, psInteger.getValue());
+ assertEquals(5, psInteger.intValue());
assertEquals(0, interpreter.getOperandStack().size());
assertEquals(0, interpreter.getExecutionStack().size());
@@ -622,12 +622,12 @@
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
psInteger = (PsInteger) object;
- assertEquals(2, psInteger.getValue());
+ assertEquals(2, psInteger.intValue());
/* Test third operand on stack. */
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
psInteger = (PsInteger) object;
- assertEquals(3, psInteger.getValue());
+ assertEquals(3, psInteger.intValue());
/* Make sure that the execution stack is now empty. */
assertEquals(0, interpreter.getExecutionStack().size());
@@ -638,7 +638,7 @@
object = interpreter.getOperandStack().pop();
assertTrue(object instanceof PsInteger);
psInteger = (PsInteger) object;
- assertEquals(5, psInteger.getValue());
+ assertEquals(5, psInteger.intValue());
assertEquals(0, interpreter.getOperandStack().size());
assertEquals(0, interpreter.getExecutionStack().size());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|