Files
TransPyC/Test/TestProject/App/main.py
2026-07-18 19:25:40 +08:00

221 lines
8.0 KiB
Python

import stdio
import stdint
import zc.config as config
import zc.test as test
import zc.logic_test as logic
import zc.class_test as class_test
import testcheck
import test_numpy
def main() -> stdint.INT:
testcheck.begin("Hello World!")
testcheck.section("Cross-module macros")
stdio.printf(" POSMAX: %d\n", config.POSMAX)
stdio.printf(" MATH_SCALE: %d\n", config.MATH_SCALE)
stdio.printf(" THRESHOLD: %d\n", config.THRESHOLD)
stdio.printf(" SHIFT_AMOUNT: %d\n", config.SHIFT_AMOUNT)
stdio.printf(" MASK_VALUE: 0x%x\n", config.MASK_VALUE)
testcheck.ok("config macros accessible")
testcheck.section("While Loop Test")
test.AboutSizeTWhileTest(10)
testcheck.ok("While Loop Test (10)")
testcheck.section("Math Basic Test (20, 6)")
test.MathBasicTest(20, 6)
testcheck.ok("Math Basic Test (20, 6)")
testcheck.section("Math Advanced Test (value=15)")
test.MathAdvancedTest(15)
testcheck.ok("Math Advanced Test (value=15)")
testcheck.section("While with Elif-Else Test (-2 to 12)")
test.WhileWithElifElseTest(-2, 12)
testcheck.ok("While with Elif-Else Test (-2 to 12)")
testcheck.section("Nested While with Macros Test")
test.NestedWhileWithMacrosTest(3, 4)
testcheck.ok("Nested While with Macros Test (3, 4)")
testcheck.section("Complex Condition Test (1, 2, 3)")
test.ComplexConditionTest(1, 2, 3)
testcheck.ok("Complex Condition Test (1, 2, 3)")
testcheck.section("Retry Loop Test (8)")
test.RetryLoopTest(8)
testcheck.ok("Retry Loop Test (8)")
testcheck.section("Bitwise Operations Test (0b1101101)")
test.BitwiseOperationsTest(109)
testcheck.ok("Bitwise Operations Test (109)")
testcheck.section("Compound Assignment Math Test (15, 4)")
test.CompoundAssignmentMathTest(15, 4)
testcheck.ok("Compound Assignment Math Test (15, 4)")
testcheck.section("Power and Modulo Test (2, 8)")
test.PowerAndModuloTest(2, 8)
testcheck.ok("Power and Modulo Test (2, 8)")
testcheck.section("Mixed Arithmetic Test (5, 3, 4)")
test.MixedArithmeticTest(5, 3, 4)
testcheck.ok("Mixed Arithmetic Test (5, 3, 4)")
testcheck.section("Math with While Loop Test (start=1, count=5)")
test.MathWithWhileLoopTest(1, 5)
testcheck.ok("Math with While Loop Test (1, 5)")
testcheck.section("Complex Nested Math Test (7, 3)")
test.ComplexNestedMathTest(7, 3)
testcheck.ok("Complex Nested Math Test (7, 3)")
testcheck.section("Conditional Math Chain Test (value=10)")
test.ConditionalMathChainTest(10)
testcheck.ok("Conditional Math Chain Test (value=10)")
testcheck.section("Bit Manipulation Math Test (0xABCD)")
test.BitManipulationMathTest(0xABCD)
testcheck.ok("Bit Manipulation Math Test (0xABCD)")
testcheck.section("COMPLEX LOGIC TESTS")
testcheck.section("For Range Basic Test (stop=5)")
logic.ForRangeBasicTest(5)
testcheck.ok("For Range Basic Test (5)")
testcheck.section("For Range With Start Stop Step (start=1, stop=10, step=2)")
logic.ForRangeWithStartStop(1, 10, 2)
testcheck.ok("For Range With Start Stop (1, 10, 2)")
testcheck.section("Nested For Range Test (rows=2, cols=3)")
logic.NestedForRangeTest(2, 3)
testcheck.ok("Nested For Range Test (2, 3)")
testcheck.section("For With If Break Test (size=8)")
logic.ForWithIfBreakTest(8)
testcheck.ok("For With If Break Test (8)")
testcheck.section("For With If Continue Test (n=10)")
logic.ForWithIfContinueTest(10)
testcheck.ok("For With If Continue Test (10)")
testcheck.section("For With Elif Branch Test (value=10)")
logic.ForWithElifBranchTest(10)
testcheck.ok("For With Elif Branch Test (10)")
testcheck.section("While With If Elif Else Test (iterations=7)")
logic.WhileWithIfElifElseTest(7)
testcheck.ok("While With If Elif Else Test (7)")
testcheck.section("While With Nested If Test (limit=4)")
logic.WhileWithNestedIfTest(4)
testcheck.ok("While With Nested If Test (4)")
testcheck.section("While With Match Case Test (value=2)")
logic.WhileWithMatchCaseTest(2)
testcheck.ok("While With Match Case Test (2)")
testcheck.section("While With Match Case Test (value=99)")
logic.WhileWithMatchCaseTest(99)
testcheck.ok("While With Match Case Test (99)")
testcheck.section("While With Match Case NoBreak Test (value=3)")
logic.WhileWithMatchCaseNoBreakTest(3)
testcheck.ok("While With Match Case NoBreak Test (3)")
testcheck.section("Complex For While Match Test (outer=3, inner=3)")
logic.ComplexForWhileMatchTest(3, 3)
testcheck.ok("Complex For While Match Test (3, 3)")
testcheck.section("For With Case And NoBreak Test (n=5)")
logic.ForWithCaseAndNoBreakTest(5)
testcheck.ok("For With Case And NoBreak Test (5)")
testcheck.section("While With Break Condition Test (limit=6)")
logic.WhileWithBreakConditionTest(6)
testcheck.ok("While With Break Condition Test (6)")
testcheck.section("Nested While With Multiple BreakPoints (depth=3, width=4)")
logic.NestedWhileWithMultipleBreakPoints(3, 4)
testcheck.ok("Nested While With Multiple BreakPoints (3, 4)")
testcheck.section("For With Match Case In Loop Test (iterations=9)")
logic.ForWithMatchCaseInLoopTest(9)
testcheck.ok("For With Match Case In Loop Test (9)")
testcheck.section("Complex Logic With Elif Chains (a=3, b=5, c=7)")
logic.ComplexLogicWithElifChains(3, 5, 7)
testcheck.ok("Complex Logic With Elif Chains (3, 5, 7)")
testcheck.section("For Range With Step And Condition (n=12, step=2)")
logic.ForRangeWithStepAndCondition(12, 2)
testcheck.ok("For Range With Step And Condition (12, 2)")
testcheck.section("Match Case With Guard Conditions (value=1)")
logic.MatchCaseWithGuardConditions(1)
testcheck.ok("Match Case With Guard Conditions (1)")
testcheck.section("While With Multiple Match Cases (iterations=12)")
logic.WhileWithMultipleMatchCases(12)
testcheck.ok("While With Multiple Match Cases (12)")
testcheck.section("For While Mix With Break And Continue (n=5)")
logic.ForWhileMixWithBreakAndContinue(5)
testcheck.ok("For While Mix With Break And Continue (5)")
testcheck.section("Complex Case Matching With Ranges (start=0, end=35)")
logic.ComplexCaseMatchingWithRanges(0, 35)
testcheck.ok("Complex Case Matching With Ranges (0, 35)")
testcheck.section("While With Elif In Elif Chain (limit=7)")
logic.WhileWithElifInElifChain(7)
testcheck.ok("While With Elif In Elif Chain (7)")
testcheck.section("For With Case NoBreak Nested (inner_limit=4)")
logic.ForWithCaseNoBreakNested(4)
testcheck.ok("For With Case NoBreak Nested (4)")
testcheck.section("CLASS TESTS")
class_test.TestBasicDataClass()
testcheck.ok("TestBasicDataClass")
class_test.TestPoint3DClass()
testcheck.ok("TestPoint3DClass")
class_test.TestStudentClass()
testcheck.ok("TestStudentClass")
class_test.TestCounterClass()
testcheck.ok("TestCounterClass")
class_test.TestStackAllocation()
testcheck.ok("TestStackAllocation")
class_test.TestHeapAllocation()
testcheck.ok("TestHeapAllocation")
class_test.TestHeapObjectWithInit()
testcheck.ok("TestHeapObjectWithInit")
class_test.TestMultipleStackObjects()
testcheck.ok("TestMultipleStackObjects")
class_test.TestImplicitInitCall()
testcheck.ok("TestImplicitInitCall")
class_test.TestClassWithBitFields()
testcheck.ok("TestClassWithBitFields")
testcheck.section("ARRAY TESTS")
class_test.TestIntArray()
testcheck.ok("TestIntArray")
class_test.TestFloatArray()
testcheck.ok("TestFloatArray")
class_test.TestCharArray()
testcheck.ok("TestCharArray")
class_test.TestNestedArray()
testcheck.ok("TestNestedArray")
class_test.TestArrayWithStruct()
testcheck.ok("TestArrayWithStruct")
class_test.TestArrayPointer()
testcheck.ok("TestArrayPointer")
class_test.TestDynamicString()
testcheck.ok("TestDynamicString")
testcheck.section("numpy Correctness Tests")
test_numpy.test_numpy_correct()
return testcheck.end()