From: <mie...@us...> - 2007-12-01 06:16:56
|
Revision: 1361 http://oorexx.svn.sourceforge.net/oorexx/?rev=1361&view=rev Author: miesfeld Date: 2007-11-30 22:17:00 -0800 (Fri, 30 Nov 2007) Log Message: ----------- ooRexxUnit - Port the file rename from the 3.2.0 branch to the trunk Added Paths: ----------- test/trunk/ooRexx/base/Assignments.testGroup test/trunk/ooRexx/base/BIF.testGroup test/trunk/ooRexx/base/DO.testGroup test/trunk/ooRexx/base/LOOP.testGroup test/trunk/ooRexx/base/LabelOption.testGroup test/trunk/ooRexx/base/PARSE.testGroup test/trunk/ooRexx/base/RAISE.testGroup test/trunk/ooRexx/base/RESULT_RC_SIGL.testGroup test/trunk/ooRexx/base/SAY.testGroup test/trunk/ooRexx/base/ShortCircuitAnd.testGroup test/trunk/ooRexx/base/SourceFile.testGroup test/trunk/ooRexx/base/USE.testGroup test/trunk/ooRexx/base/bif/LINES.testUnit test/trunk/ooRexx/base/class/Array.testGroup test/trunk/ooRexx/base/class/Bag.testGroup test/trunk/ooRexx/base/class/CircularQueue.testGroup test/trunk/ooRexx/base/class/Class.testGroup test/trunk/ooRexx/base/class/CollectionSetlikeMethods.testGroup test/trunk/ooRexx/base/class/DateTime.testGroup test/trunk/ooRexx/base/class/Directory.testGroup test/trunk/ooRexx/base/class/List.testGroup test/trunk/ooRexx/base/class/Method.testGroup test/trunk/ooRexx/base/class/Monitor.testGroup test/trunk/ooRexx/base/class/MutableBuffer.testGroup test/trunk/ooRexx/base/class/Properties.testGroup test/trunk/ooRexx/base/class/Queue.testGroup test/trunk/ooRexx/base/class/QueueRGF.testGroup test/trunk/ooRexx/base/class/Relation.testGroup test/trunk/ooRexx/base/class/Set.testGroup test/trunk/ooRexx/base/class/Stem.testGroup test/trunk/ooRexx/base/class/String.testGroup test/trunk/ooRexx/base/class/Table.testGroup test/trunk/ooRexx/base/class/TimeSpan.testGroup test/trunk/ooRexx/base/environmentEntries.testGroup test/trunk/ooRexx/base/generated/Date-generate.rex test/trunk/ooRexx/base/generated/Date.testGroup test/trunk/ooRexx/base/generated/Time.testGroup test/trunk/ooRexx/doc/chapter5/Chapter5Section1.testGroup Removed Paths: ------------- test/trunk/ooRexx/base/bif/ooRexx.Base.BIF.LINES.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Array.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Bag.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.CircularQueue.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Class.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.CollectionSetlikeMethods.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.DateTime.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Directory.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.List.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Method.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Monitor.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.MutableBuffer.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Properties.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Queue.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.QueueRGF.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Relation.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Set.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Stem.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.String.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.Table.testUnit test/trunk/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit test/trunk/ooRexx/base/generated/ooRexx.Base.Date-generate.rex test/trunk/ooRexx/base/generated/ooRexx.Base.Date.testUnit test/trunk/ooRexx/base/generated/ooRexx.Base.Time.testUnit test/trunk/ooRexx/base/ooRexx.Base.Assignments.testUnit test/trunk/ooRexx/base/ooRexx.Base.BIF.testUnit test/trunk/ooRexx/base/ooRexx.Base.DO.testUnit test/trunk/ooRexx/base/ooRexx.Base.LOOP.testUnit test/trunk/ooRexx/base/ooRexx.Base.LabelOption.testUnit test/trunk/ooRexx/base/ooRexx.Base.PARSE.testUnit test/trunk/ooRexx/base/ooRexx.Base.RAISE.testUnit test/trunk/ooRexx/base/ooRexx.Base.RESULT_RC_SIGL.testUnit test/trunk/ooRexx/base/ooRexx.Base.SAY.testUnit test/trunk/ooRexx/base/ooRexx.Base.ShortCircuitAnd.testUnit test/trunk/ooRexx/base/ooRexx.Base.SourceFile.testUnit test/trunk/ooRexx/base/ooRexx.Base.USE.testUnit test/trunk/ooRexx/base/ooRexx.Base.environmentEntries.testUnit test/trunk/ooRexx/doc/chapter5/ooRexx.doc.chapter5.section1.testUnit Copied: test/trunk/ooRexx/base/Assignments.testGroup (from rev 1360, test/trunk/ooRexx/base/ooRexx.Base.Assignments.testUnit) =================================================================== --- test/trunk/ooRexx/base/Assignments.testGroup (rev 0) +++ test/trunk/ooRexx/base/Assignments.testGroup 2007-12-01 06:17:00 UTC (rev 1361) @@ -0,0 +1,262 @@ +#!/usr/bin/rexx +/* + name: ooRexx.Base.Assignments.testUnit + author: Rony G. Flatscher + date: 2007-06-16 + version: 1.0.0 + changed: --- + +-- line commented lines are ignored, when building the directory of infos from this header + + languageLevel: 6.0 + purpose: Test assignments + remark: Initially uses documentation examples only + + + license: CPL 1.0 (Common Public License v1.0, see below) + link: + + category1: ooRexx + category2: Base + category3: Assignments +*/ +/*----------------------------------------------------------------------------*/ +/* */ +/* 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.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* 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. */ +/* */ +/*----------------------------------------------------------------------------*/ + + + +------------------------------------------------------------------------------------------- +-- ===> adapt the "testUnitList" to your testCase classes; each element in the list is <=== +-- ===> an array object, the first element containing the testCase class object, the <=== +-- ===> second element is a list of test method names which are regarded to be <=== +-- ===> mandatory (if the list remains empty all test methods are mandatory) <=== + + /* list of array objects, each containing the testUnit class object and an + optional list of mandatory test case methods name */ + +mandatoryTestMethods=.list~new -- no mandatory tests for this testCase class +testUnitList=.list~of( .array~of(.ooRexx.Base.Assignments.testUnit, mandatoryTestMethods) ) + + +------------------------------------------------------------------------------------------- +-- ===> the following code needs not to be individualized <=== + + -- read top comment, containing infos about this program +arrLines=.array~new +do i=1 to 150 until arrLines[i]="*/" + arrLines[i]=sourceline(i) +end + -- supply information for the testClass(es) in this file; the class attribute + -- "TestCaseInfo" (a directory object, index points to a queue) will store + -- the parsed infos +aTestUnitClass=testUnitList~at(testUnitList~first)[1] -- get first testClass + + -- will parse the array lines and store result in class object +call makeDirTestInfo aTestUnitClass, arrLines +tmpDir=aTestUnitClass~TestCaseInfo +parse source s -- op_sys invocationType fullPathToThisFile +tmpDir~setentry("test_Case-source", s) + + -- now add this directory to other testCase classes, if any left +do arr over testUnitList + if arr[1]=aTestUnitClass then iterate -- already handled + arr[1]~TestCaseInfo=tmpDir -- save info in class object +end + +-- if this file is CALLed or REQUIRED then define an entry "bRunTestLocally" in .local +-- and set it to .false; this way the independent local invocation of the tests is inhibited +if .local~hasentry("bRunTestsLocally")=.false then + .local~bRunTestsLocally=.true -- if this file is executed directly, then run tests for debugging + +if .bRunTestsLocally=.true then -- run ALL tests in this test unit +do + ts=.testSuite~new -- create a testSuite + do arr over testUnitList + -- create a testSuite for the given test case class, use all its testmethods + ts~addTest( .testSuite~new(arr[1])) + end + -- testResult=.testSuite~new(testUnitClass)~run + testResult=ts~run -- now run all the tests + + call simpleDumpTestResults testResult +end + + /* return list of array objects containing test case classes and + optionally list of mandatory test methods */ +return testUnitList + + + +::requires ooRexxUnit.cls -- load the ooRexxUnit classes + +::class "ooRexx.Base.Assignments.testUnit" subclass TestCase public + + + +::method "test_+=" + + i1=0 + i2=0 + do i=-5 to +5 by 0.1 + i1 =i1+1.01+i + i2+= 1.01+i + end + self~assertEquals("subtest_01", i1, i2) + + i3=0 + i3+=10 + self~assertEquals("subtest_02", 10, i3) + + +::method "test_-=" + + i1=0 + i2=0 + do i=-5 to +5 by 0.1 + i1 =i1-1.01-i + i2-= 1.01-i + end + self~assertEquals("subtest_01", i1, i2) + + i3=0 + i3-=10 + self~assertEquals("subtest_02", -10, i3) + + +::method "test_/=" + + i1=1 + i2=1 + do i=-5 to +5 by 0.1 + i1 =i1/(1.01+i) + i2/= (1.01+i) + end + self~assertEquals("subtest_01", i1, i2) + + i3=13 + i3/=10 + self~assertEquals("subtest_02", 1.3, i3) + + +::method "test_//=" + + i1=13 + i2=13 + i1 =i1//(1.01+2) + i2//= (1.01+2) + self~assertEquals("subtest_01", i1, i2) + + i3=13 + i3//=10 + self~assertEquals("subtest_02", 3, i3) + + + +::method "test_%=" + + i1=13 + i2=13 + i1 =i1%(1.01+2) + i2%= (1.01+2) + self~assertEquals("subtest_01", i1, i2) + + i3=13 + i3%=10 + self~assertEquals("subtest_02", 1, i3) + + +::method "test_*=" + + i1=13 + i2=13 + i1 =i1*(1.01+2) + i2*= (1.01+2) + self~assertEquals("subtest_01", i1, i2) + + i3=13 + i3*=10 + self~assertEquals("subtest_02", 130, i3) + + +::method "test_**=" + + i1=13 + i2=13 + i1 =i1**(1+2) + i2**= (1+2) + self~assertEquals("subtest_01", i1, i2) + + i3=3 + i3**=4 + self~assertEquals("subtest_02", 81, i3) + + +::method "test_|=" + + i1=.false + i2=.false + i1 =i1|.true + i2|= .true + self~assertEquals("subtest_01", i1, i2) + + +::method "test_&=" + + i1=.false + i2=.false + i1 =i1&.true + i2&= .true + self~assertEquals("subtest_01", i1, i2) + + +::method "test_&&=" + + i1=.false + i2=.false + i1 =i1&&.true + i2&&= .true + self~assertEquals("subtest_01", i1, i2) + + +::method "test_||=" + + i1=.false + i2=.false + i1 =i1||.true + i2||= .true + self~assertEquals("subtest_01", i1, i2) + Copied: test/trunk/ooRexx/base/BIF.testGroup (from rev 1360, test/trunk/ooRexx/base/ooRexx.Base.BIF.testUnit) =================================================================== --- test/trunk/ooRexx/base/BIF.testGroup (rev 0) +++ test/trunk/ooRexx/base/BIF.testGroup 2007-12-01 06:17:00 UTC (rev 1361) @@ -0,0 +1,1562 @@ +#!/usr/bin/rexx +/* + name: ooRexx.Base.String.testUnit + author: Rony G. Flatscher + date: 2005-08-07 + version: 1.0.5 + +-- line commented lines are ignored, when building the directory of infos from this header + changed: 2005-08-21, ---rgf, renamed the testUnit-class to match exactly the + file name, i.e. a dot (.) between class name and "TestUnit"; + added convention to return a list of arrays containing the + test case class object and an optional list of mandatory test + case methods from it + 2005-10-09, ---rgf, renamed from ".String." to ".BIF." to reflect the testing area + "BIF": "built in function" + 2005-10-11, ---rgf, finished first round of testing the documentation + BIF examples + 2005-10-17, ---rgf, added Walter Pachl's Errornumber()-tests + 2006-11-12, ---rgf, removed a wrong comment + 2007-01-20, ---rgf, adapted "test_SOURCELINE" to cater for hash-bang processing + 2007-03-21, ---rgf, added 6.01 datatype(value, 'O') test + 2007-03-26, ---rgf, finally corrected the sequence of "expected" and "actual" value + for assert[Not]Equals() and assert[Not]Same() + 2007-05-30, ---rgf, in language level 6.02 error text number 89 gets a text, adjusted + 2007-06-10, ---rgf, added test cases for lower() and upper() BIFs; + added test cases to test whether TAB and blank chars are + really treated equal in all related BIFs + 2007-06-11, ---rgf, added TAB=blank test case for PARSE + 2007-09-16, ---rgf, added tests for new 'count' argument in [caseless]changeStr() + 2007-10-10, ---rgf, cater for new errortext # 88 + + languageLevel: 6.02 + purpose: Test the String functions. + remark: Initial test unit for demonstration purposes, needs to be completed. + + Following BIFs are missing: CHARIN, CHAROUT, CHARS, CONDITION, DIRECTORY, + ENDLOCAL, FILESPEC, LINEIN, LINEOUT, LINES, + QUEUED, RXFUNCADD, RXFUNCDROP, RXFUNCQUERY, + RXQUEUE, SETLOCAL, STREAM, TRACE, USERID + + + license: CPL 1.0 (Common Public License v1.0, see below) + link: + + category1: ooRexx + category2: Base + category3: BIF +*/ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 2005-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.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* 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. */ +/* */ +/*----------------------------------------------------------------------------*/ + + + +------------------------------------------------------------------------------------------- +-- ===> adapt the "testUnitList" to your testCase classes; each element in the list is <=== +-- ===> an array object, the first element containing the testCase class object, the <=== +-- ===> second element is a list of test method names which are regarded to be <=== +-- ===> mandatory (if the list remains empty all test methods are mandatory) <=== + + /* list of array objects, each containing the testUnit class object and an + optional list of mandatory test case methods name */ + +mandatoryTestMethods=.list~new -- no mandatory tests for this testCase class +testUnitList=.list~of( .array~of(.ooRexx.Base.BIF.testUnit, mandatoryTestMethods) ) + + +------------------------------------------------------------------------------------------- +-- ===> the following code needs not to be individualized <=== + + -- read top comment, containing infos about this program +arrLines=.array~new +do i=1 to 150 until arrLines[i]="*/" + arrLines[i]=sourceline(i) +end + -- supply information for the testClass(es) in this file; the class attribute + -- "TestCaseInfo" (a directory object, index points to a queue) will store + -- the parsed infos +aTestUnitClass=testUnitList~at(testUnitList~first)[1] -- get first testClass + + -- will parse the array lines and store result in class object +call makeDirTestInfo aTestUnitClass, arrLines +tmpDir=aTestUnitClass~TestCaseInfo +parse source s -- op_sys invocationType fullPathToThisFile +tmpDir~setentry("test_Case-source", s) + + -- now add this directory to other testCase classes, if any left +do arr over testUnitList + if arr[1]=aTestUnitClass then iterate -- already handled + arr[1]~TestCaseInfo=tmpDir -- save info in class object +end + +-- if this file is CALLed or REQUIRED then define an entry "bRunTestLocally" in .local +-- and set it to .false; this way the independent local invocation of the tests is inhibited +if .local~hasentry("bRunTestsLocally")=.false then + .local~bRunTestsLocally=.true -- if this file is executed directly, then run tests for debugging + +if .bRunTestsLocally=.true then -- run ALL tests in this test unit +do + ts=.testSuite~new -- create a testSuite + do arr over testUnitList + -- create a testSuite for the given test case class, use all its testmethods + ts~addTest( .testSuite~new(arr[1])) + end + -- testResult=.testSuite~new(testUnitClass)~run + testResult=ts~run -- now run all the tests + + call simpleDumpTestResults testResult +end + + /* return list of array objects containing test case classes and + optionally list of mandatory test methods */ +return testUnitList + + + +::requires ooRexxUnit.cls -- load the ooRexxUnit classes + +::class "ooRexx.Base.BIF.testUnit" subclass TestCase public + + -- test the ABBREV BIF, using examples from the documentation +::method "test_ABBREV" + + word="Print" + self~assertSame("subTest1", .true , ABBREV(word, "Pri") ) + + word="PRINT" + self~assertSame("subTest2", .false, ABBREV(word, "Pri") ) + self~assertSame("subTest3", .false, ABBREV(word, "PRI", 4) ) + self~assertSame("subTest4", .false, ABBREV(word, "PRY") ) + self~assertSame("subTest5", .true , ABBREV(word, "") ) + self~assertSame("subTest6", .false, ABBREV(word, "", 1) ) + + + -- test the BIF, using examples from the documentation +::method "test_ABS" + + self~assertSame("subTest1", 12.3 , ABS('12.3'), ) + self~assertSame("subTest2", 0.307, ABS(' -0.307'),) + + -- new tests + self~assertSame("subTest3", 0 , ABS(' -0'), ) + self~assertSame("subTest4", 0 , ABS(' +0'), ) + self~assertSame("subTest5", 0 , ABS(' - 0 '), ) + self~assertSame("subTest6", 0 , ABS(' + 0 '), ) + self~assertSame("subTest7", 1 , ABS(' -1'), ) + self~assertSame("subTest8", 1 , ABS(' +1'), ) + self~assertSame("subTest9", 1 , ABS(' - 1 '), ) + self~assertSame("subTest10", 1 , ABS(' + 1 '), ) + + + -- test the BIF +::method "test_ADDRESS" + + addr=address() -- get default address environment (e.g. cmd.exe, bash, etc.) + self~assertNotSame("subTest1", addr~string~strip, "") -- make sure something is returned + self~assertNotSame("subTest2", addr, .nil) -- make sure something is returned + + -- test for default command processor + parse source os . -- get name of operating system + os1=os~left(1)~translate -- get first character in uppercase + if pos(os1, "O W") > 0 then -- OS2, Windows ? + do + self~assertSame("subTest3 - default address environment for" pp(os)"="pp(addr) "not" pp("CMD"), "CMD", addr) + end + else if os1=="L" then -- Linux + do + self~assertSame("subTest3 - default address environment for" pp(os)"="pp(addr) "not" pp("bash"), "bash", addr) + end + + + -- test the BIF, using examples from the documentation +::method "test_ARG" + call name1 -- call procedure without arguments + call name2 'a', , 'b' -- call procedure with arguments + + exit + + name1: + self~assertSame("subTest1", 0 , arg() ) + self~assertSame("subTest2", "" , arg(1) ) + self~assertSame("subTest3", "" , arg(2) ) + self~assertSame("subTest4", .false, arg(1, 'e') ) + self~assertSame("subTest5", .true , arg(1, 'o') ) + self~assertSame("subTest6", 0 , arg(1, 'a')~items ) + return + + name2: + self~assertSame("subTest7", 3 , arg() ) + self~assertSame("subTest8", "a" , arg(1) ) + self~assertSame("subTest9", "" , arg(2) ) + self~assertSame("subTest10", "b" , arg(3) ) + self~assertSame("subTest11", "" , arg(4) ) + self~assertSame("subTest12", .true , arg(1, 'e') ) + self~assertSame("subTest13", .false, arg(2, 'e') ) + self~assertSame("subTest14", .true , arg(3, 'e') ) + self~assertSame("subTest15", .false, arg(1, 'o') ) + self~assertSame("subTest16", .true , arg(2, 'o') ) + self~assertSame("subTest17", .false, arg(3, 'o') ) + return + + + + -- test the BIF +::method "test_BEEP" + + call beep 262 /* middle C */, 1 /* 1/1000 second or standard beep */ + self~assertTrue(.true) -- o.k., test went o.k. count assertion + + + -- test the BIF, using examples from the documentation +::method "test_BITAND" + self~assertSame("subTest1", '12'x , BITAND('12'x) ) + self~assertSame("subTest2", '23'x , BITAND('73'x,'27'x) ) + self~assertSame("subTest3", '1155'x , BITAND('13'x,'5555'x) ) + self~assertSame("subTest4", '1154'x , BITAND('13'x,'5555'x,'74'x) ) + self~assertSame("subTest5", 'PQRS' , BITAND('pQrS', ,'DF'x) ) + + + -- test the BIF, using examples from the documentation +::method "test_BITOR" + self~assertSame("subTest1", '12'x , BITOR('12'x) ) + self~assertSame("subTest2", '35'x , BITOR('15'x,'24'x) ) + self~assertSame("subTest3", '3556'x , BITOR('15'x,'2456'x) ) + self~assertSame("subTest4", '35F6'x , BITOR('15'x,'2456'x,'F0'x) ) + self~assertSame("subTest5", '5D5D'x , BITOR('1111'x, ,'4D'x) ) + self~assertSame("subTest6", 'pqrs' , BITOR('pQrS', ,'20'x) ) + + + -- test the BIF, using examples from the documentation +::method "test_BITXOR" + self~assertSame("subTest1", '12'x , BITXOR('12'x) ) + self~assertSame("subTest2", '30'x , BITXOR('12'x,'22'x) ) + self~assertSame("subTest3", '3011'x , BITXOR('1211'x,'22'x) ) + self~assertSame("subTest4", '555544'x , BITXOR('1111'x,'444444'x) ) + self~assertSame("subTest5", '555504'x , BITXOR('1111'x,'444444'x,'40'x)) + self~assertSame("subTest6", '5C5C'x , BITXOR('1111'x, ,'4D'x) ) + self~assertSame("subTest7", 'E53302'x , BITXOR('C711'x,'222222'x,' ') ) + + + -- test the BIF, using examples from the documentation +::method "test_C2D" + self~assertSame("subTest1" , 0 , C2D('') ) + + self~assertSame("subTest2" , 9 , C2D('09'X) ) + self~assertSame("subTest3" , 129 , C2D('81'X) ) + self~assertSame("subTest4" , 65409 , C2D('FF81'X) ) + self~assertSame("subTest5" , 0 , C2D("") ) + self~assertSame("subTest6" , 97 , C2D('a') ) + + self~assertSame("subTest7" , -127 , C2D('81'X,1) ) + self~assertSame("subTest8" , 129 , C2D('81'X,2) ) + self~assertSame("subTest9" , -127 , C2D('FF81'X,2)) + self~assertSame("subTest10", -127 , C2D('FF81'X,1) ) + self~assertSame("subTest11", 127 , C2D('FF7F'X,1) ) + self~assertSame("subTest12", -3967 , C2D('F081'X,2) ) + self~assertSame("subTest13", -127 , C2D('F081'X,1) ) + self~assertSame("subTest14", 0 , C2D('0031'X,0) ) + + + + -- test the BIF, using examples from the documentation +::method "test_C2X" + self~assertSame("subTest1", "" , C2X('') ) + + self~assertSame("subTest2", '0123' , C2X('0123'X)) /* '30313233'X in ASCII */ + self~assertSame("subTest3", '5A4438' , C2X('ZD8') ) /* '354134343338'X in ASCII */ + + + + -- test the BIF, using examples from the documentation +::method "test_CENTER" + self~assertSame("subTest1", ' ABC ' , CENTER(abc,7) ) + self~assertSame("subTest2", '--ABC---' , CENTER(abc,8,'-') ) + self~assertSame("subTest3", 'e blue s' , CENTRE('The blue sky',8) ) + self~assertSame("subTest4", 'e blue ' , CENTRE('The blue sky',7) ) + + + -- test the BIF, using examples from the documentation +::method "test_CHANGESTR" + self~assertSame("subTest1", '000' , CHANGESTR('1','101100',"") ) + self~assertSame("subTest2", 'X0XX00' , CHANGESTR('1','101100','X') ) + + -- new tests + self~assertSame("subTest3", '101100' , CHANGESTR('','101100','X') ) + self~assertSame("subTest4", '' , CHANGESTR('1','' ,'X') ) + + -- new tests: optional, trailing "count" argument + self~assertSame("subTest5", 'ha-lo' , CHANGESTR('l','hallo','-',1) ) + self~assertSame("subTest6", 'ha--o' , CHANGESTR('l','hallo','-',2) ) + self~assertSame("subTest7", 'ha--o' , CHANGESTR('l','hallo','-',3) ) + +::method "test_changeStr_error_93.907" + self~expectSyntax(93.907) + a=changestr('a','aha','A',0) + + -- test the BIF, using examples from the documentation +::method "test_COMPARE" + self~assertSame("subTest1", 0 , COMPARE('abc','abc') ) + self~assertSame("subTest2", 2 , COMPARE('abc','ak') ) + self~assertSame("subTest3", 0 , COMPARE('ab ','ab') ) + self~assertSame("subTest4", 0 , COMPARE('ab ','ab',' ') ) + self~assertSame("subTest5", 3 , COMPARE('ab ','ab','x') ) + self~assertSame("subTest6", 5 , COMPARE('ab-- ','ab','-')) + + -- new tests + self~assertSame("subTest7", 0 , COMPARE('' ,'' ,'-')) + self~assertSame("subTest8", 2 , COMPARE(' ' ,' ','-')) + self~assertSame("subTest9", 2 , COMPARE(' ' ,' ' ,'-')) + self~assertSame("subTest10", 0 , COMPARE(' ' ,' ' ,'-')) + + + -- test the BIF, using examples from the documentation +::method "test_COPIES" + self~assertSame("subTest1", 'abcabcabc' , COPIES('abc',3)) + self~assertSame("subTest2", "" , COPIES('abc',0)) + + + -- test the BIF, using examples from the documentation +::method "test_COUNTSTR" + self~assertSame("subTest1", 4 , COUNTSTR('1','101101') ) + self~assertSame("subTest2", 1 , COUNTSTR('KK','J0KKK0')) + + -- new tests + self~assertSame("subTest3", 0 , COUNTSTR('','J0KKK0') ) + self~assertSame("subTest4", 0 , COUNTSTR(' ','J0KKK0') ) + + + -- test the BIF, using examples from the documentation +::method "test_D2C" + self~assertSame("subTest1", 'A' , D2C(65) ) + self~assertSame("subTest2", 'A' , D2C(65,1) ) + self~assertSame("subTest3", right('A', 2, "00"x) , D2C(65,2) ) + self~assertSame("subTest4", right('A', 5, "00"x) , D2C(65,5) ) + self~assertSame("subTest5", 'm' , D2C(109) ) /* '6D'x is an ASCII 'm' */ + self~assertSame("subTest6", '93'x , D2C(-109,1)) /* '93'x is an ASCII '\xF4' */ + self~assertSame("subTest7", right('L', 2, "00"x) , D2C(76,2) ) /* '4C'x is an ASCII ' L' */ + self~assertSame("subTest8", right('L', 2, "FF"x) , D2C(-180,2)) + + -- new tests + self~assertSame("subTest9", "" , D2C(-180,0)) + + + -- test the BIF, using examples from the documentation +::method "test_D2X" + self~assertSame("subTest1", '9' , D2X(9) ) + self~assertSame("subTest2", '81' , D2X(129) ) + self~assertSame("subTest3", '1' , D2X(129,1) ) + self~assertSame("subTest4", '81' , D2X(129,2) ) + self~assertSame("subTest5", '0081' , D2X(129,4) ) + self~assertSame("subTest6", '01' , D2X(257,2) ) + self~assertSame("subTest7", '81' , D2X(-127,2)) + self~assertSame("subTest8", 'FF81' , D2X(-127,4)) + self~assertSame("subTest9", "" , D2X(12,0) ) + + + -- test the BIF, using examples from the documentation +::method "test_DATATYPE" + self~assertEquals("subTest1" , 'NUM' , DATATYPE(' 12 ') ) + self~assertEquals("subTest2" , 'CHAR' , DATATYPE("") ) + self~assertEquals("subTest3" , 'CHAR' , DATATYPE('123*') ) + + self~assertTrue("subTest4" , DATATYPE('12.3','N') ) + self~assertFalse("subTest5" , DATATYPE('12.3','W') ) + self~assertTrue("subTest6" , DATATYPE('Fred','M') ) + self~assertFalse("subTest7" , DATATYPE('Fred','U') ) -- changed, syntax error in documentation ! + self~assertFalse("subTest8" , DATATYPE('Fred','L') ) + self~assertTrue("subTest9" , DATATYPE('?20K','s') ) + self~assertTrue("subTest10" , DATATYPE('BCd3','X') ) + self~assertTrue("subTest11" , DATATYPE('BC d3','X') ) + + -- new tests + self~assertTrue("subTest12" , DATATYPE('', 'X') ) + + self~assertTrue("subTest13" , DATATYPE('BCd3' ,'A') ) -- alphanumeric + self~assertFalse("subTest14", DATATYPE('BC-d3','A') ) + + self~assertTrue("subTest15" , DATATYPE('a1' ,'s') ) -- symbol + self~assertTrue("subTest16" , DATATYPE('.a1' ,'s') ) + self~assertTrue("subTest17" , DATATYPE('_' ,'s') ) + self~assertTrue("subTest18" , DATATYPE('!' ,'s') ) + self~assertTrue("subTest19" , DATATYPE('?' ,'s') ) + self~assertTrue("subTest20" , DATATYPE('.' ,'s') ) + self~assertTrue("subTest21" , DATATYPE('1' ,'s') ) + self~assertTrue("subTest22" , DATATYPE('1b_!?','s') ) + self~assertFalse("subTest23", DATATYPE('. .' ,'s') ) + + self~assertTrue("subTest24" , DATATYPE('abc' ,'v') ) -- variable + self~assertTrue("subTest25" , DATATYPE('?' ,'v') ) + self~assertTrue("subTest26" , DATATYPE('_' ,'v') ) + self~assertTrue("subTest27" , DATATYPE('!' ,'v') ) + self~assertTrue("subTest28" , DATATYPE('a1!_?','v') ) + self~assertFalse("subTest29", DATATYPE('.' ,'v') ) + self~assertFalse("subTest30", DATATYPE('.a' ,'v') ) + self~assertFalse("subTest31", DATATYPE('1' ,'v') ) + + + a=digits() -- get digits + numeric digits 9 + self~assertTrue( "subTest32", DATATYPE('0' ,'W') ) -- whole number + self~assertTrue( "subTest33", DATATYPE('1' ,'W') ) + self~assertTrue( "subTest34", DATATYPE('-1' ,'W') ) + self~assertTrue( "subTest35", DATATYPE('12345','W') ) + self~assertTrue( "subTest36", DATATYPE('1E3' ,'W') ) + self~assertFalse("subTest37", DATATYPE('1E9' ,'W') ) + + numeric digits a + + self~assertFalse("subTest44", DATATYPE('z' ,'X') ) -- heX-digits + self~assertTrue( "subTest45", DATATYPE('' ,'X') ) + + self~assertFalse("subTest46", DATATYPE('z' ,'B') ) -- binary digits + self~assertTrue( "subTest47", DATATYPE('' ,'B') ) + self~assertTrue( "subTest48", DATATYPE('01' ,'B') ) + self~assertTrue( "subTest49", DATATYPE('01101001' ,'B') ) + self~assertTrue( "subTest50", DATATYPE('0110 1001' ,'B') ) + self~assertFalse("subTest51", DATATYPE('011 01001' ,'B') ) + + numeric digits 9 + self~assertEquals("subTest52", 'NUM' , DATATYPE(' 1e3 ') ) + self~assertEquals("subTest53", 'NUM' , DATATYPE(' 123456789 ') ) + self~assertEquals("subTest54", 'NUM' , DATATYPE(' 1234567891 ') ) + self~assertEquals("subTest55", 'CHAR' , DATATYPE("") ) + self~assertEquals("subTest56", 'CHAR' , DATATYPE("a") ) + self~assertEquals("subTest57", 'CHAR' , DATATYPE("abc") ) + self~assertEquals("subTest58", 'CHAR' , DATATYPE("1A0") ) + + self~assertTrue("subTest59" , DATATYPE("123456789012345", "N" ) ) -- Numeric + self~assertTrue("subTest60" , DATATYPE("0" , "N" ) ) -- Numeric + self~assertTrue("subTest61" , DATATYPE("1234567890.1234", "N" ) ) -- Numeric + self~assertFalse("subTest61" , DATATYPE("" , "N" ) ) -- Numeric + numeric digits a + + self~assertTrue("subtest62", DATATYPE(0, "O") ) -- Logical (Boolean) + self~assertTrue("subtest63", DATATYPE(1, "O") ) -- Logical (Boolean) + self~assertFalse("subtest64", DATATYPE(2, "O") ) -- Logical (Boolean) + self~assertFalse("subtest65", DATATYPE(-1, "O") ) -- Logical (Boolean) + self~assertFalse("subtest66", DATATYPE("", "O") ) -- Logical (Boolean) + + + -- test the BIF, using examples from the documentation +::method "test_DATATYPE_WITH_OPTION_9" + a=digits() -- get digits + + numeric digits 1 -- make sure that numeric digits is not set to 9 + self~assertTrue( "subTest38", DATATYPE('0' ,'9') ) -- whole number under 9 digits (?) + self~assertTrue( "subTest39", DATATYPE('1' ,'9') ) + self~assertTrue( "subTest40", DATATYPE('-1' ,'9') ) + self~assertTrue( "subTest41", DATATYPE('12345' ,'9') ) -- ? + self~assertTrue( "subTest42", DATATYPE('1E3' ,'9') ) -- ? + self~assertFalse( "subTest43", DATATYPE('1E9' ,'9') ) -- ? + numeric digits a + + + -- test the BIF, using examples from the documentation +::method "test_DATE" + tmpD='13 Nov 1996' + + self~assertSame("subTest1" , '13 Nov 1996' , DATE( , tmpD )) + self~assertSame("subTest2" , 728975 , DATE('B', tmpD )) -- error: 728609 ) + self~assertSame("subTest3" , 318 , DATE('D', tmpD )) -- error: 317 ) + self~assertSame("subTest4" , '13/11/96' , DATE('E', tmpD )) + self~assertSame("subTest5" , '13 November 1996' , DATE('L', tmpD )) + self~assertSame("subTest6" , 'November' , DATE('M', tmpD )) + self~assertSame("subTest7" , '13 Nov 1996' , DATE('N', tmpD )) + self~assertSame("subTest8" , '96/11/13' , DATE('O', tmpD )) + self~assertSame("subTest9" , '19961113' , DATE('S', tmpD )) + self~assertSame("subTest10", '11/13/96' , DATE('U', tmpD )) + self~assertSame("subTest11", 'Wednesday' , DATE('W', tmpD )) -- error: 'Monday' ) + + self~assertSame("subTest12", '23/02/13' , DATE('O','13 Feb 1923') ) + self~assertSame("subTest13", '50/06/01' , DATE('O','06/01/50','U')) + + self~assertSame("subTest14", '1996-02-13' , DATE('S','13 Feb 1996','N','-')) + self~assertSame("subTest15", '13Feb1996' , DATE('N','13 Feb 1996','N',"") ) + self~assertSame("subTest16", '13-Feb-1996' , DATE('N','13 Feb 1996','N','-')) + self~assertSame("subTest17", '500601' , DATE('O','06/01/50','U',"") ) + self~assertSame("subTest18", '13.02.96' , DATE('E','02/13/96','U','.') ) + self~assertSame("subTest19", '26_Mar_1998' , DATE('N', '26 Mar 1998', ,'_') ) + + -- self~assertSame("subTest20", DATE('S','1996-11-13','S', ,"",'-'), '19961113' ) -- error: more than 5 arg() ! + self~assertSame("subTest20", '19961113' , DATE('S','1996-11-13','S',"",'-') ) + + self~assertSame("subTest21", '19961113' , DATE('S','13-Nov-1996','N',"",'-') ) + self~assertSame("subTest22", '500601' , DATE('O','06*01*50','U',"",'*') ) + self~assertSame("subTest23", '02/13/96' , DATE('U','13.Feb.1996','N', ,'.') ) + + + -- test the BIF, using examples from the documentation +::method "test_DELSTR" + self~assertSame("subTest1" , 'ab' , DELSTR('abcd',3) ) + self~assertSame("subTest2" , 'abe' , DELSTR('abcde',3,2)) + self~assertSame("subTest3" , 'abcde' , DELSTR('abcde',6) ) + + -- new tests + self~assertSame("subTest4" , '' , DELSTR('abcde',1) ) + self~assertSame("subTest5" , 'bcde' , DELSTR('abcde',1,1)) + self~assertSame("subTest6" , 'abcde' , DELSTR('abcde',1,0)) + self~assertSame("subTest7" , 'abcde' , DELSTR('abcde',3,0)) + self~assertSame("subTest8" , 'abde' , DELSTR('abcde',3,1)) + self~assertSame("subTest9" , 'abcde' , DELSTR('abcde',9) ) + + + -- test the BIF, using examples from the documentation +::method "test_DELWORD" + self~assertSame("subTest1" , 'Now time' , DELWORD('Now is the time',2,2)) + self~assertSame("subTest2" , 'Now is ' , DELWORD('Now is the time ',3) ) + self~assertSame("subTest3" , 'Now is the time' , DELWORD('Now is the time',5) ) + self~assertSame("subTest4" , 'Now is time' , DELWORD('Now is the time',3,1)) + self~assertSame("subTest5" , 'Now time' , DELWORD('Now is the time',2,2)) + + -- new tests + self~assertSame("subTest4" , 'Now is the time' , DELWORD('Now is the time',3,0)) + self~assertSame("subTest4" , 'Now is the time' , DELWORD('Now is the time',1,0)) + + + -- test the BIF +::method "test_DIGITS" + self~assertTrue("subTest1", datatype(digits(),"N")) -- make sure a number is returned + self~assertTrue("subTest2", digits()>0 ) -- make sure a number is returned + + + -- test the BIF, using examples from the documentation +::method "test_ERRORTEXT" + self~assertSame("subTest-2" , 'Label not found' , ERRORTEXT(16)) + self~assertSame("subTest-1" , "" , ERRORTEXT(60)) + + -- additional tests by Walter Pachl (2005-10-14) + self~assertSame('subTest1' , '' , ERRORTEXT(1) ) + self~assertSame('subTest2' , '' , ERRORTEXT(2) ) + self~assertSame('subTest3' , 'Failure during initialization' , ERRORTEXT(3) ) + self~assertSame('subTest4' , 'Program interrupted' , ERRORTEXT(4) ) + self~assertSame('subTest5' , 'System resources exhausted' , ERRORTEXT(5) ) + self~assertSame('subTest6' , 'Unmatched "/*" or quote' , ERRORTEXT(6) ) + self~assertSame('subTest7' , 'WHEN or OTHERWISE expected' , ERRORTEXT(7) ) + self~assertSame('subTest8' , 'Unexpected THEN or ELSE' , ERRORTEXT(8) ) + self~assertSame('subTest9' , 'Unexpected WHEN or OTHERWISE' , ERRORTEXT(9) ) + self~assertSame('subTest10', 'Unexpected or unmatched END' , ERRORTEXT(10)) + self~assertSame('subTest11', 'Control stack full' , ERRORTEXT(11)) + self~assertSame('subTest12', '' , ERRORTEXT(12)) + self~assertSame('subTest13', 'Invalid character in program' , ERRORTEXT(13)) + self~assertSame('subTest14', 'Incomplete DO/SELECT/IF' , ERRORTEXT(14)) + self~assertSame('subTest15', 'Invalid hexadecimal or binary string' , ERRORTEXT(15)) + self~assertSame('subTest16', 'Label not found' , ERRORTEXT(16)) + self~assertSame('subTest17', 'Unexpected PROCEDURE' , ERRORTEXT(17)) + self~assertSame('subTest18', 'THEN expected' , ERRORTEXT(18)) + self~assertSame('subTest19', 'String or symbol expected' , ERRORTEXT(19)) + self~assertSame('subTest20', 'Symbol expected' , ERRORTEXT(20)) + self~assertSame('subTest21', 'Invalid data on end of clause' , ERRORTEXT(21)) + self~assertSame('subTest22', 'Invalid character string' , ERRORTEXT(22)) + self~assertSame('subTest23', 'Invalid data string' , ERRORTEXT(23)) + self~assertSame('subTest24', 'Invalid TRACE request' , ERRORTEXT(24)) + self~assertSame('subTest25', 'Invalid subkeyword found' , ERRORTEXT(25)) + self~assertSame('subTest26', 'Invalid whole number' , ERRORTEXT(26)) + self~assertSame('subTest27', 'Invalid DO syntax' , ERRORTEXT(27)) + self~assertSame('subTest28', 'Invalid LEAVE or ITERATE' , ERRORTEXT(28)) + self~assertSame('subTest29', 'Environment name too long' , ERRORTEXT(29)) + self~assertSame('subTest30', 'Name or string too long' , ERRORTEXT(30)) + self~assertSame('subTest31', 'Name starts with number or "."' , ERRORTEXT(31)) + self~assertSame('subTest32', '' , ERRORTEXT(32)) + self~assertSame('subTest33', 'Invalid expression result' , ERRORTEXT(33)) + self~assertSame('subTest34', 'Logical value not 0 or 1' , ERRORTEXT(34)) + self~assertSame('subTest35', 'Invalid expression' , ERRORTEXT(35)) + self~assertSame('subTest36', 'Unmatched "(" or "[" in expression' , ERRORTEXT(36)) + self~assertSame('subTest37', 'Unexpected ",", ")", or "]"' , ERRORTEXT(37)) + self~assertSame('subTest38', 'Invalid template or pattern' , ERRORTEXT(38)) + self~assertSame('subTest39', 'Evaluation stack overflow' , ERRORTEXT(39)) + self~assertSame('subTest40', 'Incorrect call to routine' , ERRORTEXT(40)) + self~assertSame('subTest41', 'Bad arithmetic conversion' , ERRORTEXT(41)) + self~assertSame('subTest42', 'Arithmetic overflow/underflow' , ERRORTEXT(42)) + self~assertSame('subTest43', 'Routine not found' , ERRORTEXT(43)) + self~assertSame('subTest44', 'Function or message did not return data' , ERRORTEXT(44)) + self~assertSame('subTest45', 'No data specified on function RETURN' , ERRORTEXT(45)) + self~assertSame('subTest46', 'Invalid variable reference' , ERRORTEXT(46)) + self~assertSame('subTest47', 'Unexpected label' , ERRORTEXT(47)) + self~assertSame('subTest48', 'Failure in system service' , ERRORTEXT(48)) + self~assertSame('subTest49', 'Interpretation error' , ERRORTEXT(49)) + self~assertSame('subTest50', '' , ERRORTEXT(50)) + self~assertSame('subTest51', '' , ERRORTEXT(51)) + self~assertSame('subTest52', '' , ERRORTEXT(52)) + self~assertSame('subTest53', '' , ERRORTEXT(53)) + self~assertSame('subTest54', '' , ERRORTEXT(54)) + self~assertSame('subTest55', '' , ERRORTEXT(55)) + self~assertSame('subTest56', '' , ERRORTEXT(56)) + self~assertSame('subTest57', '' , ERRORTEXT(57)) + self~assertSame('subTest58', '' , ERRORTEXT(58)) + self~assertSame('subTest59', '' , ERRORTEXT(59)) + self~assertSame('subTest60', '' , ERRORTEXT(60)) + self~assertSame('subTest61', '' , ERRORTEXT(61)) + self~assertSame('subTest62', '' , ERRORTEXT(62)) + self~assertSame('subTest63', '' , ERRORTEXT(63)) + self~assertSame('subTest64', '' , ERRORTEXT(64)) + self~assertSame('subTest65', '' , ERRORTEXT(65)) + self~assertSame('subTest66', '' , ERRORTEXT(66)) + self~assertSame('subTest67', '' , ERRORTEXT(67)) + self~assertSame('subTest68', '' , ERRORTEXT(68)) + self~assertSame('subTest69', '' , ERRORTEXT(69)) + self~assertSame('subTest70', '' , ERRORTEXT(70)) + self~assertSame('subTest71', '' , ERRORTEXT(71)) + self~assertSame('subTest72', '' , ERRORTEXT(72)) + self~assertSame('subTest73', '' , ERRORTEXT(73)) + self~assertSame('subTest74', '' , ERRORTEXT(74)) + self~assertSame('subTest75', '' , ERRORTEXT(75)) + self~assertSame('subTest76', '' , ERRORTEXT(76)) + self~assertSame('subTest77', '' , ERRORTEXT(77)) + self~assertSame('subTest78', '' , ERRORTEXT(78)) + self~assertSame('subTest79', '' , ERRORTEXT(79)) + self~assertSame('subTest80', '' , ERRORTEXT(80)) + self~assertSame('subTest81', '' , ERRORTEXT(81)) + self~assertSame('subTest82', '' , ERRORTEXT(82)) + self~assertSame('subTest83', '' , ERRORTEXT(83)) + self~assertSame('subTest84', '' , ERRORTEXT(84)) + self~assertSame('subTest85', '' , ERRORTEXT(85)) + self~assertSame('subTest86', '' , ERRORTEXT(86)) + self~assertSame('subTest87', '' , ERRORTEXT(87)) + self~assertSame('subTest88', 'Invalid argument' , ERRORTEXT(88)) + self~assertSame('subTest89', 'Variable or message term expected' , ERRORTEXT(89)) + self~assertSame('subTest90', 'External name not found' , ERRORTEXT(90)) + self~assertSame('subTest91', 'No result object' , ERRORTEXT(91)) + self~assertSame('subTest92', 'OLE error' , ERRORTEXT(92)) + self~assertSame('subTest93', 'Incorrect call to method' , ERRORTEXT(93)) + self~assertSame('subTest94', '' , ERRORTEXT(94)) + self~assertSame('subTest95', '' , ERRORTEXT(95)) + self~assertSame('subTest96', '' , ERRORTEXT(96)) + self~assertSame('subTest97', 'Object method not found' , ERRORTEXT(97)) + self~assertSame('subTest98', 'Execution error' , ERRORTEXT(98)) + self~assertSame('subTest99', 'Translation error' , ERRORTEXT(99)) + + self~assertTrue("subTest100", test100()) + self~assertTrue("subTest101", test101()) + + return + + ---------------------------------------------------------------------- + + test100: procedure -- nonexisting error text number + signal on syntax name test100syntax + call errortext(100) -- should invoke a syntax error + return .false -- arriving here is an error! + test100syntax: -- syntax error # 40.903 + return condition("o")~code=40.903 + + ---------------------------------------------------------------------- + + test101: procedure -- not using a whole number as index + signal on syntax name test101syntax + a='blabla'; + errortext(a) -- should invoke a syntax error + return .false + test101syntax: -- syntax error # 40.12 + return condition("o")~code=40.12 + + + + + + + -- test the BIF +::method "test_FORM" + numeric form scientific + self~assertSame("subTest1", "SCIENTIFIC", form()) + + numeric form engineering + self~assertSame("subTest2", "ENGINEERING", form()) + + numeric form -- reset to default, which is scientific + self~assertSame("subTest1", "SCIENTIFIC", form()) + + + + -- test the BIF, using examples from the documentation +::method "test_FORMAT" + self~assertSame("subTest1" , ' 3' , FORMAT('3',4) ) + self~assertSame("subTest2" , ' 2' , FORMAT('1.73',4,0) ) + self~assertSame("subTest3" , ' 1.730' , FORMAT('1.73',4,3) ) + self~assertSame("subTest4" , ' -0.8' , FORMAT('-.76',4,1) ) + self~assertSame("subTest5" , ' 3.03' , FORMAT('3.03',4) ) + self~assertSame("subTest6" , '-12.7300' , FORMAT(' - 12.73', ,4) ) + self~assertSame("subTest7" , '-12.73' , FORMAT(' - 12.73') ) + self~assertSame("subTest8" , '0' , FORMAT('0.000') ) + + self~assertSame("subTest9" , '1.234573E+04' , FORMAT('12345.73', , ,2,2) ) -- + self~assertSame("subTest10", '1.235E+4' , FORMAT('12345.73', ,3, ,0) ) + self~assertSame("subTest11", '1.235' , FORMAT('1.234573', ,3, ,0) ) + self~assertSame("subTest12", '12345.73' , FORMAT('12345.73', , ,3,6) ) + self~assertSame("subTest13", '123456700000.000' , FORMAT('1234567e5', ,3,0) ) + + + + -- test the BIF +::method "test_FUZZ" + numeric fuzz 0 + self~assertEquals("subTest1", 0, fuzz()) + + numeric fuzz 1 + self~assertEquals("subTest2", 1, fuzz()) + + numeric fuzz + self~assertEquals("subTest3", 0, fuzz()) + + + + -- test the BIF, using examples from the documentation +::method "test_INSERT" + self~assertSame("subTest1" , 'abc def' , INSERT(' ','abcdef',3) ) + self~assertSame("subTest2" , 'abc 123 ' , INSERT('123','abc',5,6) ) + self~assertSame("subTest3" , 'abc++123+++' , INSERT('123','abc',5,6,'+')) + self~assertSame("subTest4" , '123abc' , INSERT('123','abc') ) + self~assertSame("subTest5" , '123--abc' , INSERT('123','abc', ,5,'-')) + + -- new tests + self~assertSame("subTest6" , 'abcdef' , INSERT('','abcdef',3) ) + self~assertSame("subTest7" , 'abcdef' , INSERT(' ','abcdef',3, 0) ) + self~assertSame("subTest8" , '' , INSERT('','') ) + self~assertSame("subTest9" , ' ' , INSERT('','', 3, 0) ) + self~assertSame("subTest10", ' ' , INSERT('','', 3, 1) ) + + + + -- test the BIF, using examples from the documentation +::method "test_LASTPOS" + self~assertEquals("subTest1" , 8 , LASTPOS(' ','abc def ghi') ) + self~assertEquals("subTest2" , 0 , LASTPOS(' ','abcdefghi') ) + self~assertEquals("subTest3" , 4 , LASTPOS('xy','efgxyz') ) + self~assertEquals("subTest4" , 4 , LASTPOS(' ','abc def ghi',7)) + + -- new tests + self~assertEquals("subTest5" , 0 , LASTPOS('','abc def ghi',7)) + self~assertEquals("subTest6" , 0 , LASTPOS('','') ) + + + -- test the BIF, using examples from the documentation +::method "test_LEFT" + self~assertSame("subTest1" , 'abc d ' , LEFT('abc d',8) ) + self~assertSame("subTest2" , 'abc d...' , LEFT('abc d',8,'.')) + self~assertSame("subTest3" , 'abc de' , LEFT('abc def',7) ) + + -- new tests + self~assertSame("subTest4" , 'a' , LEFT('abc def',1) ) + self~assertSame("subTest5" , '' , LEFT('abc def',0) ) + + + + -- test the BIF, using examples from the documentation +::method "test_LENGTH" + self~assertSame("subTest1" , 8 , LENGTH('abcdefgh')) + self~assertSame("subTest2" , 8 , LENGTH('abc defg')) + self~assertSame("subTest3" , 0 , LENGTH("") ) + + +::method "test_LOWER" + self~assertSame("subTest_01" , 'AbCdeFGH', lower('ABCdeFGH', 2, 1 )) + self~assertSame("subTest_02" , 'ABCdeFGH', lower('ABCdeFGH', 1, 0 )) + self~assertSame("subTest_03" , 'ABCdeFGH', lower('ABCdeFGH', 99, 2 )) + self~assertSame("subTest_04" , 'Abcdefgh', lower('ABCdeFGH', 2 )) + self~assertSame("subTest_05" , 'abcdefgh', lower('ABCdeFGH' )) + + + + -- test the BIF, using examples from the documentation +::method "test_MAX" + self~assertEquals("subTest1" , 12 , MAX(12,6,7,9) ) + self~assertEquals("subTest2" , 19 , MAX(17.3,19,17.03) ) + self~assertEquals("subTest3" , -3 , MAX(-7,-3,-4.3) ) + self~assertEquals("subTest4" , 21 , MAX(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)) + + + + -- test the BIF, using examples from the documentation +::method "test_MIN" + self~assertEquals("subTest1" , 6 , MIN(12,6,7,9) ) + self~assertEquals("subTest2" , 17.03 , MIN(17.3,19,17.03) ) + self~assertEquals("subTest3" , -7 , MIN(-7,-3,-4.3) ) + self~assertEquals("subTest4" , 1 , MIN(21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1)) + + + -- test the BIF, using examples from the documentation +::method "test_OVERLAY" + self~assertSame("subTest1" , 'ab def' , OVERLAY(' ','abcdef',3) ) + self~assertSame("subTest2" , 'ab. ef' , OVERLAY('.','abcdef',3,2) ) + self~assertSame("subTest3" , 'qqcd' , OVERLAY('qq','abcd') ) + self~assertSame("subTest4" , 'abcqq' , OVERLAY('qq','abcd',4) ) + self~assertSame("subTest5" , 'abc+123+++', OVERLAY('123','abc',5,6,'+') ) + + -- new tests + self~assertSame("subTest6" , 'abc' , OVERLAY('','abc',3) ) + self~assertSame("subTest7" , 'abc' , OVERLAY('','abc',3, 0) ) + self~assertSame("subTest8" , 'ab ' , OVERLAY('','abc',3, 1) ) + self~assertSame("subTest9" , 'abc ' , OVERLAY('','abc',6, 1) ) + + self~assertSame("subTest10", 'abc' , OVERLAY(' ','abc',3, 0) ) + self~assertSame("subTest11", 'ab ' , OVERLAY(' ','abc',3, 1) ) + self~assertSame("subTest12", 'abc ' , OVERLAY(' ','abc',6, 1) ) + + self~assertSame("subTest13", 'abc' , OVERLAY('12','abc',3, 0) ) + self~assertSame("subTest14", 'ab3' , OVERLAY('34','abc',3, 1) ) + self~assertSame("subTest15", 'abc 5' , OVERLAY('56','abc',6, 1) ) + + + + + -- test the BIF, using examples from the documentation +::method "test_POS" + self~assertEquals("subTest1" , 6, POS('day','Saturday') ) + self~assertEquals("subTest2" , 0, POS('x','abc def ghi') ) + self~assertEquals("subTest3" , 4, POS(' ','abc def ghi') ) + self~assertEquals("subTest4" , 8, POS(' ','abc def ghi',5)) + + -- new test + self~assertEquals("subTest5" , 0, POS('','abc def ghi',5) ) + + + -- test the BIF, using examples from the documentation +::method "test_RANDOM" + + min="0 0 1 9999" + max="1 +1 9 99999" + seed="0 179 34 99999" + reps=100 + + do i=1 to words(min) + mi=word(min, i) + ma=word(max, i) + do reps + x=random(mi, ma) + if x<mi | x>ma then + self~fail(x "not in range: min="mi", max="ma) + end + self~assertTrue(.true) -- indicate that this run holds + end + + -- now collect first 100 random numbers per seed, repeat generation and compare with stored ones + do i=1 to words(min) + mi=word(min, i) + ma=word(max, i) + se=word(seed, i) + + x.1=random(mi, ma, se) -- define a seed to start the generator test + do i1=2 to reps + x.i1=random(mi, ma) + if x.i1<mi | x.i1>ma then + self~fail(x.i1 "not in range: min="mi", max="ma) + end + + -- now re-run with same seed + y.1=random(mi, ma, se) + do i1=2 to reps + y.i1=random(mi, ma) + if y.i1<mi | y.i1>ma then + self~fail(y.i1 "not in range: min="mi", max="ma) + end + + -- now compare both runs + do i1=1 to reps + if x.i1<>y.i1 then + self~fail("i1="i1"," x.i1 "<>" y.i1) + end + self~assertTrue(.true) -- indicate that this run holds + drop x. y. + end + + + + -- test the BIF, using examples from t... [truncated message content] |