Diff of /test/trunk/ooRexx/base/class/String/ceiling.testGroup [000000] .. [r8246] Maximize Restore

  Switch to side-by-side view

--- a
+++ b/test/trunk/ooRexx/base/class/String/ceiling.testGroup
@@ -0,0 +1,115 @@
+#!/usr/bin/rexx
+/*
+  SVN Revision: $Rev: 3371 $
+  Change Date:  $Date: 2008-09-21 00:33:29 -0400 (Sun, 21 Sep 2008) $
+*/
+/*----------------------------------------------------------------------------*/
+/*                                                                            */
+/* Copyright (c) 2012 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(.String_ceilingMethod.testGroup)
+
+  if group~isAutomatedTest then return group
+
+  testResult = group~suite~execute~~print
+
+return testResult
+
+::requires 'ooTest.frm' -- load the ooRexxUnit classes
+
+::class "String_ceilingMethod.testGroup" subclass ooTestCase public
+
+::method 'testzero'
+    self~assertSame(0, 0~ceiling)
+    self~assertSame(0, '0'~ceiling)
+    self~assertSame(0, 0.0~ceiling)
+    self~assertSame(0, .00000000~ceiling)
+    self~assertSame(0, '-0'~ceiling)
+    self~assertSame(0, 0e0~ceiling)
+
+::method 'testinteger'
+    self~assertSame('1', 000001~ceiling)
+    self~assertSame('-1', ('-000001')~ceiling)
+    self~assertSame('5', '5'~ceiling)
+    self~assertSame('-5', (-5)~ceiling)
+    self~assertSame('5', 5~ceiling)
+    self~assertSame('-5', (-5)~ceiling)
+    self~assertSame('5', 5.00000~ceiling)
+    self~assertSame('-5', (-5.00000)~ceiling)
+    -- these will be truncated by rounding first, so the positive
+    -- one will not go to 6
+    self~assertSame('5', 5.000000001~ceiling)
+    self~assertSame('-5', ('-5.000000001')~ceiling)
+
+    self~assertSame('50', 5e1~ceiling)
+    self~assertSame('-50', ('-5e1')~ceiling)
+
+::method 'testnoninteger'
+    self~assertSame('6', 5.1~ceiling)
+    self~assertSame('-5', '-5.1'~ceiling)
+    -- limit of default digits, so no rounding
+    self~assertSame('6', 5.00000001~ceiling)
+    self~assertSame('-5', '-5.00000001'~ceiling)
+    -- these will round and carry into the significant
+    -- digits, so there are decimals
+    self~assertSame('6', '5.000000009'~ceiling)
+    self~assertSame('-5', '-5.000000009'~ceiling)
+    -- code has special checks for values between zero and one, so test this explicitly
+
+    self~assertSame('1', 0.1~ceiling)
+    self~assertSame('0', '-0.1'~ceiling)
+    -- limit of default digits, so no rounding
+    self~assertSame('1', 0.111111111~ceiling)
+    self~assertSame('0', '-0.111111111'~ceiling)
+
+::method 'testroundout'
+    self~assertSame('10', '9.1'~ceiling)
+    self~assertSame('-9', '-9.1'~ceiling)
+    self~assertSame('100000', '99999.1'~ceiling)
+    self~assertSame('-99999', '-99999.1'~ceiling)
+
+::method 'testnoexp'
+   self~assertSame('1000000000000', '1e12'~ceiling)
+   self~assertSame('-1000000000000', '-1e12'~ceiling)
+
+::method 'testnumericerror'
+    self~expectSyntax(93.943)
+    xre=nov~ceiling
+
+::method 'testargerror'
+    self~expectSyntax(93.902)
+    xre=nov~ceiling(2)