' Enhanced assert macros with file/line reporting simulation
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL i  AS LONG
    LOCAL numTests  AS LONG
    LOCAL passed  AS LONG
    LOCAL failed  AS LONG
    LOCAL testName(20) AS STRING
    LOCAL testResult(20) AS LONG
    LOCAL fileStr AS STRING
    LOCAL lineNum  AS LONG
    LOCAL leftVal  AS LONG
    LOCAL rightVal  AS LONG
    LOCAL assertVal  AS LONG
    LOCAL assertLine  AS LONG
    LOCAL assertFileIdx  AS LONG
    LOCAL assertMsg AS STRING

    PRINT "=== Enhanced Assert Macros ==="
    PRINT

    numTests = 8
    testName(0) = "Basic equality              "
    testResult(0) = 1

    testName(1) = "String comparison           "
    testResult(1) = 1

    testName(2) = "Numeric range               "
    testResult(2) = 1

    testName(3) = "Array bounds                "
    testResult(3) = 1

    testName(4) = "Null pointer check          "
    testResult(4) = 0

    testName(5) = "Division by zero guard      "
    testResult(5) = 1

    testName(6) = "Type size check             "
    testResult(6) = 1

    testName(7) = "Boundary condition          "
    testResult(7) = 1

    PRINT "--- Running Test Suite ---"
    PRINT

    passed = 0
    failed = 0
    fileStr = "assert_macros.pb"

    FOR i = 0 TO numTests - 1
        assertVal = testResult(i)
        assertLine = i * 10 + 50
        assertMsg = TRIM$(testName(i))

        IF assertVal = 1 THEN
            PRINT "  [PASS] " & assertMsg
            passed = passed + 1
        ELSE
            PRINT "  [FAIL] " & assertMsg
            PRINT "    File: " & fileStr & ", Line: " & FORMAT$(assertLine)
            PRINT "    Expected: 1 (pass), Got: " & FORMAT$(assertVal)
            failed = failed + 1
        END IF
    NEXT i

    PRINT
    PRINT "--- Summary ---"
    PRINT "  Total: " & FORMAT$(numTests)
    PRINT "  Passed: " & FORMAT$(passed)
    PRINT "  Failed: " & FORMAT$(failed)

    IF failed = 0 THEN
        PRINT "  Result: ALL TESTS PASSED"
    ELSE
        PRINT "  Result: " & FORMAT$(failed) & " TEST(S) FAILED"
    END IF
    PRINT

    PRINT "--- Assert Types ---"
    PRINT "  ASSERT_EQ(a, b)  - check a = b"
    PRINT "  ASSERT_NE(a, b)  - check a <> b"
    PRINT "  ASSERT_GT(a, b)  - check a > b"
    PRINT "  ASSERT_LT(a, b)  - check a < b"
    PRINT "  ASSERT_TRUE(c)   - check c is true"
    PRINT "  ASSERT_FALSE(c)  - check c is false"
    PRINT "  ASSERT_NULL(p)   - check p is null"
    PRINT "  ASSERT_NOT_NULL(p) - check p not null"
    PRINT

    PRINT "--- Example: ASSERT_EQ ---"
    leftVal = 42
    rightVal = 42
    IF leftVal = rightVal THEN
        PRINT "  ASSERT_EQ(" & FORMAT$(leftVal) & ", " & FORMAT$(rightVal) & ") -> PASS"
    ELSE
        PRINT "  ASSERT_EQ(" & FORMAT$(leftVal) & ", " & FORMAT$(rightVal) & ") -> FAIL at line 99"
    END IF

    leftVal = 42
    rightVal = 43
    IF leftVal = rightVal THEN
        PRINT "  ASSERT_EQ(" & FORMAT$(leftVal) & ", " & FORMAT$(rightVal) & ") -> PASS"
    ELSE
        PRINT "  ASSERT_EQ(" & FORMAT$(leftVal) & ", " & FORMAT$(rightVal) & ") -> FAIL"
        PRINT "    Expected: " & FORMAT$(leftVal) & ", Actual: " & FORMAT$(rightVal)
    END IF

    PRINT
    PRINT "Assert macros demonstration complete."

    FUNCTION = 0
END FUNCTION
