| Summary: | No NumericOverflowException for SmallInt | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Kathy Carroll <carrollk> |
| Component: | EDT | Assignee: | Project Inbox <edt.javagen-inbox> |
| Status: | REOPENED --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jeffdouglas, jqian, svihovec |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
BigInt has a problem with the generated code
====== EGL Code ==========
variation string = "assigment overflow";
try
overflow bigInt = 9223372036854775810;
variation += " no exception";
syslib.writestdout("failed " + variation);
onException(oops AnyException)
if ( oops isa NumericOverflowException)
syslib.writestdout("failed " + variation);
else
variation += " wrong exception";
syslib.writestdout("failed " + variation);
end
end
===== Java code =========
long overflow = (long) 0;
overflow = EBigint.asBigint(new java.math.BigInteger( new byte[] { 0x0, (byte)0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2 } ));
===== Java error ======
The method asBigint(Short) in the type EBigint is not applicable for the arguments (BigInteger)
Fixed.
However, the testcase snippit of code has an error in it. It reports "failed" in this:
if ( oops isa NumericOverflowException)
syslib.writestdout("failed " + variation);
when that is really where it passes.
tested with build 201109161325
bigInt success
smallInt failes
program mini2 type BasicProgram {}
function main()
testBigInt();
testSmallInt();
end
function testSmallInt()
variation string = "smallInt assigment overflow";
small, small2 int;
small = 2147483600;
try
small2 = small + small;
if (small2 < small)
variation += " no exception";
syslib.writestdout("failed " + variation);
end
onException(oops AnyException)
if ( oops isa NumericOverflowException)
syslib.writestdout("success " + variation);
else
variation += " wrong exception";
syslib.writestdout("failed " + variation);
end
end
end
function testBigInt()
variation string = "bigInt assigment overflow";
try
overflow bigInt = 9223372036854775810;
variation += " no exception";
syslib.writestdout("failed " + variation);
onException(oops AnyException)
if ( oops isa NumericOverflowException)
syslib.writestdout("success " + variation);
else
variation += " wrong exception";
syslib.writestdout("failed " + variation);
end
end
end
end
Note to self: This is because there has not been any logic added to expressions to invoke a runtime routine to test for overflow. this code that was generated: small2 = (small + small); needs to be something like this: small2 = EInt.checkOverflow(small + small); And that logic can test the result. We will need that runtime method in all numeric classes. Overflow checking was deferred out of 0.7. I don't think we should be throwing those exceptions. Kathy. We are changing the behavior for 0.70 to have NO overflow checking. This means any testcases that you have will not cause overflows. We are going to add support for this in 1.0. I will be committing the runtime code changes soon, that turns off the checking that we did have, so don't be surprised. kathy, just skip these test cases with this bug number saying it's for 1.0 "bug 3566228 - EDT 1.0" Deferring to Future. This won't be done in 0.8.2. |
program mini2 type BasicProgram {} function main() small, small2 int; small = 2147483600; try small2 = small + small; if (small2 < small) syslib.writeStdout("unexpected behavior"); end onException (oops NumericOverflowException) SysLib.writeStdOut("Cool! Got overflow for SmallInt"); onException(oops AnyException) SysLib.writeStdOut("Got an exception for SmallInt"); end end end