Skip to content

Commit

Permalink
feature(t3.rexx): implement 'output' procedure
Browse files Browse the repository at this point in the history
The procedure is intended as a debugging tool. User calls procedure as needed,
 and output is collected in the "output" property of the generated JSON output.
  • Loading branch information
ajborla committed Aug 1, 2024
1 parent 78df985 commit 6170fe7
Show file tree
Hide file tree
Showing 65 changed files with 1,235 additions and 390 deletions.
25 changes: 19 additions & 6 deletions exercises/practice/accumulate/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* functions for the test framework */

init:
init :
parse upper arg outputType
checkNumber = 0
count = 0
Expand All @@ -32,15 +32,22 @@ init:
divider = '----------------------------------------'
spacer = ' '
EOL = "0A"X
output. = '' ; output.0 = 0
return

output : procedure expose output.
parse arg line
output.0 = output.0 + 1
n = output.0 ; output.n = line
return ''

context : procedure expose contextdesc TASK_ID
parse arg desc, task_identifier
contextdesc = desc
if task_identifier \= '' then ; TASK_ID = task_identifier
return ''

check:
check :
parse arg description, procedureCall, variableName, operation, expectedValue
checkNumber = checkNumber + 1

Expand Down Expand Up @@ -81,13 +88,18 @@ check:
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Assemble collected output */
output = ''
do i = 1 to output.0
output = output || output.i || EOL
end
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
output,,
testCode,,
TASK_ID,,
EOL)
Expand All @@ -98,7 +110,7 @@ check:

return ''

expect:
expect :
parse arg actual, variableName, op, expected

if variableName <> '' then
Expand Down Expand Up @@ -166,8 +178,9 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
message = CHANGESTR('"', CHANGESTR(eol, message, '\n'), '\"')
output = CHANGESTR('"', CHANGESTR(eol, output, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR(eol, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
25 changes: 19 additions & 6 deletions exercises/practice/acronym/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* functions for the test framework */

init:
init :
parse upper arg outputType
checkNumber = 0
count = 0
Expand All @@ -32,15 +32,22 @@ init:
divider = '----------------------------------------'
spacer = ' '
EOL = "0A"X
output. = '' ; output.0 = 0
return

output : procedure expose output.
parse arg line
output.0 = output.0 + 1
n = output.0 ; output.n = line
return ''

context : procedure expose contextdesc TASK_ID
parse arg desc, task_identifier
contextdesc = desc
if task_identifier \= '' then ; TASK_ID = task_identifier
return ''

check:
check :
parse arg description, procedureCall, variableName, operation, expectedValue
checkNumber = checkNumber + 1

Expand Down Expand Up @@ -81,13 +88,18 @@ check:
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Assemble collected output */
output = ''
do i = 1 to output.0
output = output || output.i || EOL
end
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
output,,
testCode,,
TASK_ID,,
EOL)
Expand All @@ -98,7 +110,7 @@ check:

return ''

expect:
expect :
parse arg actual, variableName, op, expected

if variableName <> '' then
Expand Down Expand Up @@ -166,8 +178,9 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
message = CHANGESTR('"', CHANGESTR(eol, message, '\n'), '\"')
output = CHANGESTR('"', CHANGESTR(eol, output, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR(eol, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
25 changes: 19 additions & 6 deletions exercises/practice/all-your-base/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* functions for the test framework */

init:
init :
parse upper arg outputType
checkNumber = 0
count = 0
Expand All @@ -32,15 +32,22 @@ init:
divider = '----------------------------------------'
spacer = ' '
EOL = "0A"X
output. = '' ; output.0 = 0
return

output : procedure expose output.
parse arg line
output.0 = output.0 + 1
n = output.0 ; output.n = line
return ''

context : procedure expose contextdesc TASK_ID
parse arg desc, task_identifier
contextdesc = desc
if task_identifier \= '' then ; TASK_ID = task_identifier
return ''

check:
check :
parse arg description, procedureCall, variableName, operation, expectedValue
checkNumber = checkNumber + 1

Expand Down Expand Up @@ -81,13 +88,18 @@ check:
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Assemble collected output */
output = ''
do i = 1 to output.0
output = output || output.i || EOL
end
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
output,,
testCode,,
TASK_ID,,
EOL)
Expand All @@ -98,7 +110,7 @@ check:

return ''

expect:
expect :
parse arg actual, variableName, op, expected

if variableName <> '' then
Expand Down Expand Up @@ -166,8 +178,9 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
message = CHANGESTR('"', CHANGESTR(eol, message, '\n'), '\"')
output = CHANGESTR('"', CHANGESTR(eol, output, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR(eol, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
25 changes: 19 additions & 6 deletions exercises/practice/anagram/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* functions for the test framework */

init:
init :
parse upper arg outputType
checkNumber = 0
count = 0
Expand All @@ -32,15 +32,22 @@ init:
divider = '----------------------------------------'
spacer = ' '
EOL = "0A"X
output. = '' ; output.0 = 0
return

output : procedure expose output.
parse arg line
output.0 = output.0 + 1
n = output.0 ; output.n = line
return ''

context : procedure expose contextdesc TASK_ID
parse arg desc, task_identifier
contextdesc = desc
if task_identifier \= '' then ; TASK_ID = task_identifier
return ''

check:
check :
parse arg description, procedureCall, variableName, operation, expectedValue
checkNumber = checkNumber + 1

Expand Down Expand Up @@ -81,13 +88,18 @@ check:
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Assemble collected output */
output = ''
do i = 1 to output.0
output = output || output.i || EOL
end
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
output,,
testCode,,
TASK_ID,,
EOL)
Expand All @@ -98,7 +110,7 @@ check:

return ''

expect:
expect :
parse arg actual, variableName, op, expected

if variableName <> '' then
Expand Down Expand Up @@ -166,8 +178,9 @@ return text

MakeJSONTestResult : procedure
parse arg name, status, message, output, test_code, task_id, eol
message = CHANGESTR('"', CHANGESTR("0A"X, message, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR("0A"X, test_code, '\n'), '\"')
message = CHANGESTR('"', CHANGESTR(eol, message, '\n'), '\"')
output = CHANGESTR('"', CHANGESTR(eol, output, '\n'), '\"')
test_code = CHANGESTR('"', CHANGESTR(eol, test_code, '\n'), '\"')
json = ,
' {' || eol || ,
' "name": "' || name || '",' || eol || ,
Expand Down
25 changes: 19 additions & 6 deletions exercises/practice/armstrong-numbers/testlib/t3.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* functions for the test framework */

init:
init :
parse upper arg outputType
checkNumber = 0
count = 0
Expand All @@ -32,15 +32,22 @@ init:
divider = '----------------------------------------'
spacer = ' '
EOL = "0A"X
output. = '' ; output.0 = 0
return

output : procedure expose output.
parse arg line
output.0 = output.0 + 1
n = output.0 ; output.n = line
return ''

context : procedure expose contextdesc TASK_ID
parse arg desc, task_identifier
contextdesc = desc
if task_identifier \= '' then ; TASK_ID = task_identifier
return ''

check:
check :
parse arg description, procedureCall, variableName, operation, expectedValue
checkNumber = checkNumber + 1

Expand Down Expand Up @@ -81,13 +88,18 @@ check:
testCode = procedureCall op expectedValue
else
testCode = procedureCall op "'"expectedValue"'"
/* Assemble collected output */
output = ''
do i = 1 to output.0
output = output || output.i || EOL
end
/* Package test results as JSON */
checkresult.count = ,
MakeJSONTestResult( ,
description,,
testStatus,,
'Expected' expectedValue conjunction 'got' returnedValue,,
'',,
output,,
testCode,,
TASK_ID,,
EOL)
Expand All @@ -98,7 +110,7 @@ check:

return ''

expect:
expect :
parse arg actual, variableName, op, expected

if variableName <> '' then
Expand Down Expand Up @@ -166,8 +178,9 @@ return text

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

0 comments on commit 6170fe7

Please sign in to comment.