Skip to content

Commit

Permalink
chore(t3.rexx): upgrade unit test component code (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajborla authored Jul 30, 2024
1 parent ca7a0f9 commit 6c4725d
Show file tree
Hide file tree
Showing 65 changed files with 845 additions and 520 deletions.
21 changes: 13 additions & 8 deletions exercises/practice/accumulate/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
test-script
t2.rexx
rexx-file-to-test
checkfuncs (Optional Rexx file containing custom testing routines)
t3.rexx
to create file:
Expand All @@ -14,7 +15,7 @@
2. Execute t.rexx
This file is t1.rexx
This file is t3.rexx
*/

/* functions for the test framework */
Expand All @@ -41,7 +42,6 @@ return ''

check:
parse arg description, procedureCall, variableName, operation, expectedValue

checkNumber = checkNumber + 1

/* Ensure procedureCall *is* supplied */
Expand All @@ -54,8 +54,7 @@ check:
if variableName == '' then do
if RIGHT(procedureCall, 1) = ')' then
interpret 'returnedValue = 'procedureCall
else
interpret 'call 'procedureCall
else do ; interpret 'call 'procedureCall ; returnedValue = RESULT ; end
end

assertion = expect(returnedValue, variableName, operation, expectedValue)
Expand All @@ -72,19 +71,24 @@ check:
/* Ensure conforming field values */
testStatus = 'pass' ; if testResult \= 'PASSED' then ; testStatus = 'fail'
conjunction = 'and' ; if testStatus \= 'pass' then ; conjunction = 'but'
if expectedValue == '' then ; expectedValue = "''"
if returnedValue == '' then ; returnedValue = "''"
if STRIP(expectedValue) = '' then ; expectedValue = "''"
if STRIP(returnedValue) = '' then ; returnedValue = "''"
/* Remove procedure name from description if it exists there */
delidx = POS(procedureCall, description)
if delidx > 0 then ; description = STRIP(DELSTR(description, delidx))
/* Quote code parameters if non-numeric */
if DATATYPE(expectedValue, 'N') then
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
procedureCall op expectedValue,,
testCode,,
TASK_ID,,
EOL)
end
Expand Down Expand Up @@ -162,7 +166,8 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
test_code = CHANGESTR('"', test_code, '\"')
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
21 changes: 13 additions & 8 deletions exercises/practice/acronym/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
test-script
t2.rexx
rexx-file-to-test
checkfuncs (Optional Rexx file containing custom testing routines)
t3.rexx
to create file:
Expand All @@ -14,7 +15,7 @@
2. Execute t.rexx
This file is t1.rexx
This file is t3.rexx
*/

/* functions for the test framework */
Expand All @@ -41,7 +42,6 @@ return ''

check:
parse arg description, procedureCall, variableName, operation, expectedValue

checkNumber = checkNumber + 1

/* Ensure procedureCall *is* supplied */
Expand All @@ -54,8 +54,7 @@ check:
if variableName == '' then do
if RIGHT(procedureCall, 1) = ')' then
interpret 'returnedValue = 'procedureCall
else
interpret 'call 'procedureCall
else do ; interpret 'call 'procedureCall ; returnedValue = RESULT ; end
end

assertion = expect(returnedValue, variableName, operation, expectedValue)
Expand All @@ -72,19 +71,24 @@ check:
/* Ensure conforming field values */
testStatus = 'pass' ; if testResult \= 'PASSED' then ; testStatus = 'fail'
conjunction = 'and' ; if testStatus \= 'pass' then ; conjunction = 'but'
if expectedValue == '' then ; expectedValue = "''"
if returnedValue == '' then ; returnedValue = "''"
if STRIP(expectedValue) = '' then ; expectedValue = "''"
if STRIP(returnedValue) = '' then ; returnedValue = "''"
/* Remove procedure name from description if it exists there */
delidx = POS(procedureCall, description)
if delidx > 0 then ; description = STRIP(DELSTR(description, delidx))
/* Quote code parameters if non-numeric */
if DATATYPE(expectedValue, 'N') then
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
procedureCall op expectedValue,,
testCode,,
TASK_ID,,
EOL)
end
Expand Down Expand Up @@ -162,7 +166,8 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
test_code = CHANGESTR('"', test_code, '\"')
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
21 changes: 13 additions & 8 deletions exercises/practice/all-your-base/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
test-script
t2.rexx
rexx-file-to-test
checkfuncs (Optional Rexx file containing custom testing routines)
t3.rexx
to create file:
Expand All @@ -14,7 +15,7 @@
2. Execute t.rexx
This file is t1.rexx
This file is t3.rexx
*/

/* functions for the test framework */
Expand All @@ -41,7 +42,6 @@ return ''

check:
parse arg description, procedureCall, variableName, operation, expectedValue

checkNumber = checkNumber + 1

/* Ensure procedureCall *is* supplied */
Expand All @@ -54,8 +54,7 @@ check:
if variableName == '' then do
if RIGHT(procedureCall, 1) = ')' then
interpret 'returnedValue = 'procedureCall
else
interpret 'call 'procedureCall
else do ; interpret 'call 'procedureCall ; returnedValue = RESULT ; end
end

assertion = expect(returnedValue, variableName, operation, expectedValue)
Expand All @@ -72,19 +71,24 @@ check:
/* Ensure conforming field values */
testStatus = 'pass' ; if testResult \= 'PASSED' then ; testStatus = 'fail'
conjunction = 'and' ; if testStatus \= 'pass' then ; conjunction = 'but'
if expectedValue == '' then ; expectedValue = "''"
if returnedValue == '' then ; returnedValue = "''"
if STRIP(expectedValue) = '' then ; expectedValue = "''"
if STRIP(returnedValue) = '' then ; returnedValue = "''"
/* Remove procedure name from description if it exists there */
delidx = POS(procedureCall, description)
if delidx > 0 then ; description = STRIP(DELSTR(description, delidx))
/* Quote code parameters if non-numeric */
if DATATYPE(expectedValue, 'N') then
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
procedureCall op expectedValue,,
testCode,,
TASK_ID,,
EOL)
end
Expand Down Expand Up @@ -162,7 +166,8 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
test_code = CHANGESTR('"', test_code, '\"')
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
21 changes: 13 additions & 8 deletions exercises/practice/anagram/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
test-script
t2.rexx
rexx-file-to-test
checkfuncs (Optional Rexx file containing custom testing routines)
t3.rexx
to create file:
Expand All @@ -14,7 +15,7 @@
2. Execute t.rexx
This file is t1.rexx
This file is t3.rexx
*/

/* functions for the test framework */
Expand All @@ -41,7 +42,6 @@ return ''

check:
parse arg description, procedureCall, variableName, operation, expectedValue

checkNumber = checkNumber + 1

/* Ensure procedureCall *is* supplied */
Expand All @@ -54,8 +54,7 @@ check:
if variableName == '' then do
if RIGHT(procedureCall, 1) = ')' then
interpret 'returnedValue = 'procedureCall
else
interpret 'call 'procedureCall
else do ; interpret 'call 'procedureCall ; returnedValue = RESULT ; end
end

assertion = expect(returnedValue, variableName, operation, expectedValue)
Expand All @@ -72,19 +71,24 @@ check:
/* Ensure conforming field values */
testStatus = 'pass' ; if testResult \= 'PASSED' then ; testStatus = 'fail'
conjunction = 'and' ; if testStatus \= 'pass' then ; conjunction = 'but'
if expectedValue == '' then ; expectedValue = "''"
if returnedValue == '' then ; returnedValue = "''"
if STRIP(expectedValue) = '' then ; expectedValue = "''"
if STRIP(returnedValue) = '' then ; returnedValue = "''"
/* Remove procedure name from description if it exists there */
delidx = POS(procedureCall, description)
if delidx > 0 then ; description = STRIP(DELSTR(description, delidx))
/* Quote code parameters if non-numeric */
if DATATYPE(expectedValue, 'N') then
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
procedureCall op expectedValue,,
testCode,,
TASK_ID,,
EOL)
end
Expand Down Expand Up @@ -162,7 +166,8 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
test_code = CHANGESTR('"', test_code, '\"')
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
21 changes: 13 additions & 8 deletions exercises/practice/armstrong-numbers/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
test-script
t2.rexx
rexx-file-to-test
checkfuncs (Optional Rexx file containing custom testing routines)
t3.rexx
to create file:
Expand All @@ -14,7 +15,7 @@
2. Execute t.rexx
This file is t1.rexx
This file is t3.rexx
*/

/* functions for the test framework */
Expand All @@ -41,7 +42,6 @@ return ''

check:
parse arg description, procedureCall, variableName, operation, expectedValue

checkNumber = checkNumber + 1

/* Ensure procedureCall *is* supplied */
Expand All @@ -54,8 +54,7 @@ check:
if variableName == '' then do
if RIGHT(procedureCall, 1) = ')' then
interpret 'returnedValue = 'procedureCall
else
interpret 'call 'procedureCall
else do ; interpret 'call 'procedureCall ; returnedValue = RESULT ; end
end

assertion = expect(returnedValue, variableName, operation, expectedValue)
Expand All @@ -72,19 +71,24 @@ check:
/* Ensure conforming field values */
testStatus = 'pass' ; if testResult \= 'PASSED' then ; testStatus = 'fail'
conjunction = 'and' ; if testStatus \= 'pass' then ; conjunction = 'but'
if expectedValue == '' then ; expectedValue = "''"
if returnedValue == '' then ; returnedValue = "''"
if STRIP(expectedValue) = '' then ; expectedValue = "''"
if STRIP(returnedValue) = '' then ; returnedValue = "''"
/* Remove procedure name from description if it exists there */
delidx = POS(procedureCall, description)
if delidx > 0 then ; description = STRIP(DELSTR(description, delidx))
/* Quote code parameters if non-numeric */
if DATATYPE(expectedValue, 'N') then
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
procedureCall op expectedValue,,
testCode,,
TASK_ID,,
EOL)
end
Expand Down Expand Up @@ -162,7 +166,8 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
test_code = CHANGESTR('"', test_code, '\"')
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
Loading

0 comments on commit 6c4725d

Please sign in to comment.