Diff of /test/trunk/ooRexx/base/keyword/LOSTDIGITS.testGroup [000000] .. [r8668] Maximize Restore

  Switch to side-by-side view

--- a
+++ b/test/trunk/ooRexx/base/keyword/LOSTDIGITS.testGroup
@@ -0,0 +1,401 @@
+#!/usr/bin/rexx
+/*
+  SVN Revision: $Rev: 3371 $
+  Change Date:  $Date: 2008-09-21 00:33:29 -0400 (Sun, 21 Sep 2008) $
+*/
+/*----------------------------------------------------------------------------*/
+/*                                                                            */
+/* Copyright (c) 2007 Rexx Language Association. All rights reserved.         */
+/*                                                                            */
+/* This program and the accompanying materials are made available under       */
+/* the terms of the Common Public License v1.0 which accompanies this         */
+/* distribution. A copy is also available at the following address:           */
+/* http://www.oorexx.org/license.html                                         */
+/*                                                                            */
+/* Redistribution and use in source and binary forms, with or                 */
+/* without modification, are permitted provided that the following            */
+/* conditions are met:                                                        */
+/*                                                                            */
+/* Redistributions of source code must retain the above copyright             */
+/* notice, this list of conditions and the following disclaimer.              */
+/* Redistributions in binary form must reproduce the above copyright          */
+/* notice, this list of conditions and the following disclaimer in            */
+/* the documentation and/or other materials provided with the distribution.   */
+/*                                                                            */
+/* Neither the name of Rexx Language Association nor the names                */
+/* of its contributors may be used to endorse or promote products             */
+/* derived from this software without specific prior written permission.      */
+/*                                                                            */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS        */
+/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          */
+/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS          */
+/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT   */
+/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,      */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
+/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,        */
+/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY     */
+/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    */
+/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS         */
+/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.               */
+/*                                                                            */
+/*----------------------------------------------------------------------------*/
+  parse source . . s
+  group = .TestGroup~new(s)
+  group~add(.LOSTDIGITS.testGroup)
+
+  if group~isAutomatedTest then return group
+
+  testResult = group~suite~execute~~print
+
+return testResult
+
+
+
+::requires 'ooTest.frm' -- load the ooRexxUnit classes
+
+::class "LOSTDIGITS.testGroup" subclass ooTestCase public
+
+::method assertLostdigits
+  use arg expr, digits=9
+  signal on lostdigits
+  numeric digits digits
+  interpret "x="expr
+  self~fail("LOSTDIGITS not raised for" expr)
+
+lostdigits:
+  return
+
+::method assertNoLostdigits
+  use arg expr, digits=9
+  signal on lostdigits
+  numeric digits digits
+  interpret "x="expr
+  return
+
+lostdigits:
+  self~fail("LOSTDIGITS incorrectly raised for" expr)
+
+::method testAddition
+  self~assertNoLostDigits("111111111+1")
+  self~assertNoLostDigits("1+111111111")
+  self~assertNoLostDigits("11111.1111+1")
+  self~assertNoLostDigits("1+11111.1111")
+  self~assertNoLostDigits("1111111111+1", 10)
+  self~assertNoLostDigits("1+1111111111", 10)
+  self~assertNoLostDigits("'-111111111'+1")
+  self~assertNoLostDigits("1+'-111111111'")
+  self~assertNoLostDigits("'-1111111111'+1", 10)
+  self~assertNoLostDigits("1+'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111+1")
+  self~assertNoLostDigits("1+0111111111")
+  self~assertNoLostDigits("1e10+1")
+  self~assertNoLostDigits("1+1e10")
+  self~assertNoLostDigits("0.000000111111111+1")
+  self~assertNoLostDigits("1+0.00000111111111")
+
+  self~assertLostDigits("1111111111+1")
+  self~assertLostDigits("1+1111111111")
+  self~assertLostDigits("111111111+1", 8)
+  self~assertLostDigits("1+111111111", 8)
+  self~assertLostDigits("'-1111111111'+1")
+  self~assertLostDigits("1+'-1111111111'")
+  self~assertLostDigits("'-111111111'+1", 8)
+  self~assertLostDigits("1+'-111111111'", 8)
+
+  self~assertLostDigits("1000000000+1")
+  self~assertLostDigits("1+1000000000")
+  self~assertLostDigits("1.111111111+1")
+  self~assertLostDigits("1+1.111111111")
+  self~assertLostDigits("1.000000000+1")
+  self~assertLostDigits("1+1.000000000")
+  self~assertLostDigits("11111.11111+1")
+  self~assertLostDigits("1+11111.11111")
+
+::method testSubtraction
+  self~assertNoLostDigits("111111111-1")
+  self~assertNoLostDigits("1-111111111")
+  self~assertNoLostDigits("11111.1111-1")
+  self~assertNoLostDigits("1-11111.1111")
+  self~assertNoLostDigits("1111111111-1", 10)
+  self~assertNoLostDigits("1-1111111111", 10)
+  self~assertNoLostDigits("'-111111111'-1")
+  self~assertNoLostDigits("1-'-111111111'")
+  self~assertNoLostDigits("'-1111111111'-1", 10)
+  self~assertNoLostDigits("1-'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111-1")
+  self~assertNoLostDigits("1-0111111111")
+  self~assertNoLostDigits("1e10-1")
+  self~assertNoLostDigits("1-1e10")
+  self~assertNoLostDigits("0.000000111111111-1")
+  self~assertNoLostDigits("1-0.00000111111111")
+
+  self~assertLostDigits("1111111111-1")
+  self~assertLostDigits("1-1111111111")
+  self~assertLostDigits("111111111-1", 8)
+  self~assertLostDigits("1-111111111", 8)
+  self~assertLostDigits("'-1111111111'-1")
+  self~assertLostDigits("1-'-1111111111'")
+  self~assertLostDigits("'-111111111'-1", 8)
+  self~assertLostDigits("1-'-111111111'", 8)
+
+  self~assertLostDigits("1000000000-1")
+  self~assertLostDigits("1-1000000000")
+  self~assertLostDigits("1.111111111-1")
+  self~assertLostDigits("1-1.111111111")
+  self~assertLostDigits("1.000000000-1")
+  self~assertLostDigits("1-1.000000000")
+  self~assertLostDigits("11111.11111-1")
+  self~assertLostDigits("1-11111.11111")
+
+::method testMultiply
+  self~assertNoLostDigits("111111111*1")
+  self~assertNoLostDigits("1*111111111")
+  self~assertNoLostDigits("11111.1111*1")
+  self~assertNoLostDigits("1*11111.1111")
+  self~assertNoLostDigits("1111111111*1", 10)
+  self~assertNoLostDigits("1*1111111111", 10)
+  self~assertNoLostDigits("'-111111111'*1")
+  self~assertNoLostDigits("1*'-111111111'")
+  self~assertNoLostDigits("'-1111111111'*1", 10)
+  self~assertNoLostDigits("1*'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111*1")
+  self~assertNoLostDigits("1*0111111111")
+  self~assertNoLostDigits("1e10*1")
+  self~assertNoLostDigits("1*1e10")
+  self~assertNoLostDigits("0.000000111111111*1")
+  self~assertNoLostDigits("1*0.00000111111111")
+
+  self~assertLostDigits("1111111111*1")
+  self~assertLostDigits("1*1111111111")
+  self~assertLostDigits("111111111*1", 8)
+  self~assertLostDigits("1*111111111", 8)
+  self~assertLostDigits("'-1111111111'*1")
+  self~assertLostDigits("1*'-1111111111'")
+  self~assertLostDigits("'-111111111'*1", 8)
+  self~assertLostDigits("1*'-111111111'", 8)
+
+  self~assertLostDigits("1000000000*1")
+  self~assertLostDigits("1*1000000000")
+  self~assertLostDigits("1.111111111*1")
+  self~assertLostDigits("1*1.111111111")
+  self~assertLostDigits("1.000000000*1")
+  self~assertLostDigits("1*1.000000000")
+  self~assertLostDigits("11111.11111*1")
+  self~assertLostDigits("1*11111.11111")
+
+::method testDivide
+  self~assertNoLostDigits("111111111/1")
+  self~assertNoLostDigits("1/111111111")
+  self~assertNoLostDigits("11111.1111/1")
+  self~assertNoLostDigits("1/11111.1111")
+  self~assertNoLostDigits("1111111111/1", 10)
+  self~assertNoLostDigits("1/1111111111", 10)
+  self~assertNoLostDigits("'-111111111'/1")
+  self~assertNoLostDigits("1/'-111111111'")
+  self~assertNoLostDigits("'-1111111111'/1", 10)
+  self~assertNoLostDigits("1/'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111/1")
+  self~assertNoLostDigits("1/0111111111")
+  self~assertNoLostDigits("1e10/1")
+  self~assertNoLostDigits("1/1e10")
+  self~assertNoLostDigits("0.000000111111111/1")
+  self~assertNoLostDigits("1/0.00000111111111")
+
+  self~assertLostDigits("1111111111/1")
+  self~assertLostDigits("1/1111111111")
+  self~assertLostDigits("111111111/1", 8)
+  self~assertLostDigits("1/111111111", 8)
+  self~assertLostDigits("'-1111111111'/1")
+  self~assertLostDigits("1/'-1111111111'")
+  self~assertLostDigits("'-111111111'/1", 8)
+  self~assertLostDigits("1/'-111111111'", 8)
+
+  self~assertLostDigits("1000000000/1")
+  self~assertLostDigits("1/1000000000")
+  self~assertLostDigits("1.111111111/1")
+  self~assertLostDigits("1/1.111111111")
+  self~assertLostDigits("1.000000000/1")
+  self~assertLostDigits("1/1.000000000")
+  self~assertLostDigits("11111.11111/1")
+  self~assertLostDigits("1/11111.11111")
+
+::method testIntegerDivide
+  self~assertNoLostDigits("111111111%1")
+  self~assertNoLostDigits("1%111111111")
+  self~assertNoLostDigits("11111.1111%1")
+  self~assertNoLostDigits("1%11111.1111")
+  self~assertNoLostDigits("1111111111%1", 10)
+  self~assertNoLostDigits("1%1111111111", 10)
+  self~assertNoLostDigits("'-111111111'%1")
+  self~assertNoLostDigits("1%'-111111111'")
+  self~assertNoLostDigits("'-1111111111'%1", 10)
+  self~assertNoLostDigits("1%'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111%1")
+  self~assertNoLostDigits("1%0111111111")
+  self~assertNoLostDigits("1e10%1000")
+  self~assertNoLostDigits("1%1e10")
+  self~assertNoLostDigits("0.000000111111111%1")
+  self~assertNoLostDigits("1%0.00000111111111")
+
+  self~assertLostDigits("1111111111%1")
+  self~assertLostDigits("1%1111111111")
+  self~assertLostDigits("111111111%1", 8)
+  self~assertLostDigits("1%111111111", 8)
+  self~assertLostDigits("'-1111111111'%1")
+  self~assertLostDigits("1%'-1111111111'")
+  self~assertLostDigits("'-111111111'%1", 8)
+  self~assertLostDigits("1%'-111111111'", 8)
+
+  self~assertLostDigits("1000000000%1")
+  self~assertLostDigits("1%1000000000")
+  self~assertLostDigits("1.111111111%1")
+  self~assertLostDigits("1%1.111111111")
+  self~assertLostDigits("1.000000000%1")
+  self~assertLostDigits("1%1.000000000")
+  self~assertLostDigits("11111.11111%1")
+  self~assertLostDigits("1%11111.11111")
+
+::method testRemainder
+  self~assertNoLostDigits("111111111//1")
+  self~assertNoLostDigits("1//111111111")
+  self~assertNoLostDigits("11111.1111//1")
+  self~assertNoLostDigits("1//11111.1111")
+  self~assertNoLostDigits("1111111111//1", 10)
+  self~assertNoLostDigits("1//1111111111", 10)
+  self~assertNoLostDigits("'-111111111'//1")
+  self~assertNoLostDigits("1//'-111111111'")
+  self~assertNoLostDigits("'-1111111111'//1", 10)
+  self~assertNoLostDigits("1//'-1111111111'", 10)
+  self~assertNoLostDigits("0111111111//1")
+  self~assertNoLostDigits("1//0111111111")
+  self~assertNoLostDigits("1e10//10000")
+  self~assertNoLostDigits("1//1e10")
+  self~assertNoLostDigits("0.000000111111111//1")
+  self~assertNoLostDigits("1//0.00000111111111")
+
+  self~assertLostDigits("1111111111//1")
+  self~assertLostDigits("1//1111111111")
+  self~assertLostDigits("111111111//1", 8)
+  self~assertLostDigits("1//111111111", 8)
+  self~assertLostDigits("'-1111111111'//1")
+  self~assertLostDigits("1//'-1111111111'")
+  self~assertLostDigits("'-111111111'//1", 8)
+  self~assertLostDigits("1//'-111111111'", 8)
+
+  self~assertLostDigits("1000000000//1")
+  self~assertLostDigits("1//1000000000")
+  self~assertLostDigits("1.111111111//1")
+  self~assertLostDigits("1//1.111111111")
+  self~assertLostDigits("1.000000000//1")
+  self~assertLostDigits("1//1.000000000")
+  self~assertLostDigits("11111.11111//1")
+  self~assertLostDigits("1//11111.11111")
+
+::method testCompare
+  self~assertNoLostDigits("111111111=1")
+  self~assertNoLostDigits("1=111111111")
+  self~assertNoLostDigits("11111.1111=1")
+  self~assertNoLostDigits("1=11111.1111")
+  self~assertNoLostDigits("1111111111=1", 10)
+  self~assertNoLostDigits("1=1111111111", 10)
+  self~assertNoLostDigits("'-111111111'=1")
+  self~assertNoLostDigits("1='-111111111'")
+  self~assertNoLostDigits("'-1111111111'=1", 10)
+  self~assertNoLostDigits("1='-1111111111'", 10)
+  self~assertNoLostDigits("0111111111=1")
+  self~assertNoLostDigits("1=0111111111")
+  self~assertNoLostDigits("1e10=10000")
+  self~assertNoLostDigits("1=1e10")
+  self~assertNoLostDigits("0.000000111111111=1")
+  self~assertNoLostDigits("1=0.00000111111111")
+
+  self~assertLostDigits("1111111111=1")
+  self~assertLostDigits("1=1111111111")
+  self~assertLostDigits("111111111=1", 8)
+  self~assertLostDigits("1=111111111", 8)
+  self~assertLostDigits("'-1111111111'=1")
+  self~assertLostDigits("1='-1111111111'")
+  self~assertLostDigits("'-111111111'=1", 8)
+  self~assertLostDigits("1='-111111111'", 8)
+
+  self~assertLostDigits("1000000000=1")
+  self~assertLostDigits("1=1000000000")
+  self~assertLostDigits("1.111111111=1")
+  self~assertLostDigits("1=1.111111111")
+  self~assertLostDigits("1.000000000=1")
+  self~assertLostDigits("1=1.000000000")
+  self~assertLostDigits("11111.11111=1")
+  self~assertLostDigits("1=11111.11111")
+
+::method testPrefixMinus
+  self~assertNoLostDigits("-111111111")
+  self~assertNoLostDigits("-11111.1111")
+  self~assertNoLostDigits("-1111111111", 10)
+  self~assertNoLostDigits("-'-111111111'")
+  self~assertNoLostDigits("-'-1111111111'", 10)
+  self~assertNoLostDigits("-0111111111")
+  self~assertNoLostDigits("-1e10")
+  self~assertNoLostDigits("-0.000000111111111")
+
+  self~assertLostDigits("-1111111111")
+  self~assertLostDigits("-111111111", 8)
+  self~assertLostDigits("-'-1111111111'")
+  self~assertLostDigits("-'-111111111'", 8)
+
+  self~assertLostDigits("-1000000000")
+  self~assertLostDigits("-1.111111111")
+  self~assertLostDigits("-1.000000000")
+  self~assertLostDigits("-11111.11111")
+
+::method testPrefixPlus
+  self~assertNoLostDigits("+111111111")
+  self~assertNoLostDigits("+11111.1111")
+  self~assertNoLostDigits("+1111111111", 10)
+  self~assertNoLostDigits("+'-111111111'")
+  self~assertNoLostDigits("+'-1111111111'", 10)
+  self~assertNoLostDigits("+0111111111")
+  self~assertNoLostDigits("+1e10")
+  self~assertNoLostDigits("+0.000000111111111")
+
+  self~assertLostDigits("+1111111111")
+  self~assertLostDigits("+111111111", 8)
+  self~assertLostDigits("+'-1111111111'")
+  self~assertLostDigits("+'-111111111'", 8)
+
+  self~assertLostDigits("+1000000000")
+  self~assertLostDigits("+1.111111111")
+  self~assertLostDigits("+1.000000000")
+  self~assertLostDigits("+11111.11111")
+
+
+::method testPower
+  self~assertNoLostDigits("111111111**2")
+  self~assertNoLostDigits("11111.1111**2")
+  self~assertNoLostDigits("1111111111**2", 10)
+  self~assertNoLostDigits("'-111111111'**2")
+  self~assertNoLostDigits("'-1111111111'**2", 10)
+  self~assertNoLostDigits("0111111111**2")
+  self~assertNoLostDigits("1e10**2")
+  self~assertNoLostDigits("0.000000111111111**2")
+
+  self~assertLostDigits("1111111111**2")
+  self~assertLostDigits("111111111**2", 8)
+  self~assertLostDigits("'-1111111111'**2")
+  self~assertLostDigits("'-111111111'**2", 8)
+
+  self~assertLostDigits("1000000000**2")
+  self~assertLostDigits("1.111111111**2")
+  self~assertLostDigits("1.000000000**2")
+  self~assertLostDigits("11111.11111**2")
+
+::method testBifs
+  -- the arithmetic builtin functions do not honor lostdigits, since they are
+  -- defined as performing a round operation on the arguments before processing.
+
+  self~assertNoLostDigits("trunc(11111.11111, 2)")
+  self~assertNoLostDigits("11111.11111~round")
+  self~assertNoLostDigits("11111.11111~floor")
+  self~assertNoLostDigits("11111.11111~ceiling")
+  self~assertNoLostDigits("max(11111.11111, 2)")
+  self~assertNoLostDigits("min(11111.11111, 2)")
+  self~assertNoLostDigits("format(11111.11111, 6, 8)")