-
Notifications
You must be signed in to change notification settings - Fork 1
Cobol translation demo #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./payroll temp_payroll_input_7ccdb2f020a63a7f.txt libcob: error: module 'C$GETARG' not found so need to fix this.
DEBUG: Raw record read = [E001 04000025.0000100.00] E001 ,0001000.00,0000900.00 DEBUG: Raw record read = [E002 03500030.0000150.00] E002 ,0001050.00,0000900.00 DEBUG: Raw record read = [E003 04500020.0000090.00] E003 ,0000900.00,0000810.00 DEBUG: Raw record read = [E004 05000022.5000120.00] E004 ,0001125.00,0001005.00
Python and Cobol outputs are now the same.
🧪 Benchify Analysis of PR
|
File/Function | Example Input | # Inputs Found | Description | |
---|---|---|---|---|
✅ | COBOL/script.py | num=1.5 |
100 | The function should return a 7-character string with leading zeros, representing the input number multiplied by 100 and rounded to the nearest integer. It should raise a ValueError if the input is NaN, infinite, or outside the range of 0 to 99999.99. |
✅ | COBOL/script.py | employee_records=[EmployeeRecord(emp_id='0', hours_worked=0.0, hourly_rate=0.0, tax_deduction=0.0)] |
3 | The function should produce the same results as process_payroll_cobol for the same input, including any exceptions that might be raised. |
Reproducible Unit Tests
import jsonpickle
import unittest
import time
import asyncio
import pytest
from COBOL.script import *
# Property: The function should return a 7-character string with leading zeros, representing the input number multiplied by 100 and rounded to the nearest integer. It should raise a ValueError if the input is NaN, infinite, or outside the range of 0 to 99999.99.
def benchify_test_format_pic_9_5_v_99_valid(num):
result = format_pic_9_5_v_99(num)
assert isinstance(result, str)
assert len(result) == 7
def test_format_pic_9_5_v_99_invalid(num):
with pytest.raises(ValueError):
format_pic_9_5_v_99(num)
# The next batch of tests are passing.
def test_format_pic_9_5_v_99_valid_passing_0():
num=0.0
benchify_test_format_pic_9_5_v_99_valid(num)
def test_format_pic_9_5_v_99_valid_passing_1():
num=1.0
benchify_test_format_pic_9_5_v_99_valid(num)
def test_format_pic_9_5_v_99_valid_passing_2():
num=1.5
benchify_test_format_pic_9_5_v_99_valid(num)
# Found 97 more passing tests.# Property: The function should produce the same results as process_payroll_cobol for the same input, including any exceptions that might be raised.
def benchify_test_process_payroll_matches_cobol(employee_records):
try:
result_python = process_payroll(employee_records)
result_cobol = process_payroll_cobol(employee_records)
assert result_python == result_cobol
except Exception as e:
with pytest.raises(type(e)):
process_payroll_cobol(employee_records)
# The next batch of tests are passing.
def test_process_payroll_matches_cobol_passing_0():
employee_records=[EmployeeRecord(emp_id='0', hours_worked=0.0, hourly_rate=0.0, tax_deduction=0.0)]
benchify_test_process_payroll_matches_cobol(employee_records)
def test_process_payroll_matches_cobol_passing_1():
employee_records=[EmployeeRecord(emp_id='\x9e\U000cc38c\U000c0776', hours_worked=0.0, hourly_rate=0.0, tax_deduction=0.0)]
benchify_test_process_payroll_matches_cobol(employee_records)
def test_process_payroll_matches_cobol_passing_2():
employee_records=[EmployeeRecord(emp_id='\x9e\U000cc38c\U000c0776', hours_worked=1.1754943508222875e-38, hourly_rate=1.192092896e-07, tax_deduction=9.322299188150726e-84)]
benchify_test_process_payroll_matches_cobol(employee_records)
juancastano
approved these changes
Jan 10, 2025
maxvonhippel
added a commit
that referenced
this pull request
Mar 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.