Added comprehensive test function with 9 sub-tests that directly match
the code examples from issue #961:
- int8 overflow wrapping
- uint32 to float64 to int32 conversion
- untyped constant with typed variable
- int8 arithmetic edge cases
- int8 multiplication overflow
- signed to unsigned conversion
- unsigned to signed conversion
- sign extension
- truncation
All tests pass with both standard Go and llgo compiler, ensuring
consistent behavior between the two implementations.
Related to #961
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <cpunion@users.noreply.github.com>
- Changed float-to-int overflow tests to use t.Logf() instead of assertions
- Go's spec defines out-of-range float-to-int conversions as undefined behavior
- All tests now pass with both standard Go and llgo compiler
- Tests properly document actual behavior without asserting specific values
Related to #961
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <cpunion@users.noreply.github.com>
This commit adds comprehensive unit tests in test/go/ directory to validate
type conversion behavior and identify bugs in LLGo's BinOp code generation.
Tests added:
1. test/go/type_conv_test.go:
- TestIntegerOverflow: Tests integer overflow wrapping behavior
- TestFloatToIntConversion: Tests float-to-int conversions with saturation
- TestUint32ToFloatToInt32: Specific test for issue #961 bug case
- TestFloatSpecialValues: Tests Inf/NaN handling
- TestSignedUnsignedConversions: Tests signed/unsigned conversions
- TestSignExtensionVsZeroExtension: Tests type extension behavior
- TestIntToFloatPrecisionLoss: Tests precision loss in conversions
2. test/go/untyped_const_test.go:
- TestUntypedConstantWithTypedVariable: Tests untyped constants with typed vars
- TestUntypedConstantArithmetic: Tests untyped constant operations
- TestUntypedConstantExpression: Tests constant expression evaluation
- TestMixedUntypedTypedExpressions: Tests mixed expressions
- TestUntypedBool/String/Rune/ZeroValues: Tests untyped constants
Test results with standard Go:
- Integer overflow tests: PASS (documents correct Go wrapping behavior)
- Untyped constant tests: PASS (validates proper type inference)
- Float-to-int tests: Some FAIL (documents that Go has undefined behavior
for out-of-range conversions, not saturation as initially expected)
These tests will help identify where LLGo differs from standard Go behavior.
Related: #961
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <cpunion@users.noreply.github.com>