Skip to content

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 20 commits into from
Jan 11, 2025
Merged

Cobol translation demo #134

merged 20 commits into from
Jan 11, 2025

Conversation

maxvonhippel
Copy link
Collaborator

No description provided.

maxvonhippel and others added 19 commits January 9, 2025 13:45
./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.
Copy link

benchify bot commented Jan 10, 2025

🧪 Benchify Analysis of PR 134

The property-based tests for the functions in COBOL/script.py passed (✅) for two properties:

  1. Converting a number to a 7-character string with leading zeros, and
  2. Producing the same results as process_payroll_cobol for payroll processing.
    This suggests that these functions are working as expected for the given inputs.
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)

Copy link
Collaborator Author

maxvonhippel commented Jan 11, 2025

Merge activity

  • Jan 11, 10:48 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 11, 10:48 AM EST: A user merged this pull request with Graphite.

@maxvonhippel maxvonhippel merged commit aaa15e6 into main Jan 11, 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants