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

  Switch to side-by-side view

--- a
+++ b/test/trunk/ooRexx/base/class/String/round.testGroup
@@ -0,0 +1,124 @@
+#!/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_roundMethod.testGroup)
+
+  if group~isAutomatedTest then return group
+
+  testResult = group~suite~execute~~print
+
+return testResult
+
+::requires 'ooTest.frm' -- load the ooRexxUnit classes
+
+::class "String_roundMethod.testGroup" subclass ooTestCase public
+
+::method 'testzero'
+    self~assertSame(0, 0~round)
+    self~assertSame(0, '0'~round)
+    self~assertSame(0, 0.0~round)
+    self~assertSame(0, .00000000~round)
+    self~assertSame(0, '-0'~round)
+    self~assertSame(0, 0e0~round)
+
+::method 'testinteger'
+    self~assertSame('1', 000001~round)
+    self~assertSame('-1', ('-000001')~round)
+    self~assertSame('5', '5'~round)
+    self~assertSame('-5', (-5)~round)
+    self~assertSame('5', 5~round)
+    self~assertSame('-5', (-5)~round)
+    self~assertSame('5', 5.00000~round)
+    self~assertSame('-5', (-5.00000)~round)
+    self~assertSame('5', 5.000000001~round)
+    self~assertSame('-5', ('-5.000000001')~round)
+
+    self~assertSame('50', 5e1~round)
+    self~assertSame('-50', ('-5e1')~round)
+
+::method 'testnoninteger'
+    self~assertSame('1', 1.0~round)
+    self~assertSame('1', 1.1~round)
+    self~assertSame('1', 1.2~round)
+    self~assertSame('1', 1.3~round)
+    self~assertSame('1', 1.4~round)
+    self~assertSame('2', 1.5~round)
+    self~assertSame('2', 1.6~round)
+    self~assertSame('2', 1.7~round)
+    self~assertSame('2', 1.8~round)
+    self~assertSame('2', 1.9~round)
+    -- negatives
+    self~assertSame('-1', '-1.0'~round)
+    self~assertSame('-1', '-1.1'~round)
+    self~assertSame('-1', '-1.2'~round)
+    self~assertSame('-1', '-1.3'~round)
+    self~assertSame('-1', '-1.4'~round)
+    self~assertSame('-2', '-1.5'~round)
+    self~assertSame('-2', '-1.6'~round)
+    self~assertSame('-2', '-1.7'~round)
+    self~assertSame('-2', '-1.8'~round)
+    self~assertSame('-2', '-1.9'~round)
+
+    -- values that get rounded before starting the round operation because
+    -- of the digits setting
+    self~assertSame('2', '1.499999999'~round)
+    self~assertSame('-2', '-1.499999999'~round)
+
+::method 'testroundout'
+    self~assertSame('10', '9.5'~round)
+    self~assertSame('-10', '-9.5'~round)
+    self~assertSame('100000', '99999.5'~round)
+    self~assertSame('-100000', '-99999.5'~round)
+
+::method 'testnoexp'
+   self~assertSame('1000000000000', '1e12'~round)
+   self~assertSame('-1000000000000', '-1e12'~round)
+
+::method 'testnumericerror'
+    self~expectSyntax(93.943)
+    xre=nov~round
+
+::method 'testargerror'
+    self~expectSyntax(93.902)
+    xre=nov~round(2)
+