Optional Libraries Supported
The Swift interpreter has automated tests which run against real compiled Swift. You can see those test results in the generated MD file called TEST_RESULTS.md.
run_tests.sh is run while on the "staging" or "main" branch, this md
TEST_RESULTS.md is automatically updated.
You can add a new test by adding a folder under CodeTests with the desired test suite name with swift files for each test you would like to run.
Some example test files:
// assert matching_return_value var arr =  arr.append(10) return arr
// assert matching_stack_value_x var x = 5 x += 10
// assert does_not_compile let x = 5 let y = 5.0 let z = x + y // error, you cannot sum an Int and Double
These will automatically produce a test to compare the result of running the interpreted Swift against the result of running compiled Swift.
There are three assertions currently supported.
// assert matching_return_value
returnstatement at the end of your program
// assert matching_stack_value_x
xcan be any global variable name
// assert does_not_compile
Note: The Swift Interpreter is provided as a prebuilt binary, if you would like to have access to source, contact Joe Hinkle.
To build from source, first clone SwiftInterpreterSource in the same directory as this repo.
swift package generate-xcodeproj to produce
Then drag the
SwiftInterpreterSource folder into the navigation panel of SwiftInterpreter. This should prompt asking to create a workspace. Create the workspace under the
SwiftInterpreter folder and call it
Rewrite the target
SwiftInterpreterSource to have the name
SwiftInterpreterBinary in order to trick this repo into using the source instead of the binary target.
Now when you build, it will automatically build the Swift Interpreter from source and use that in your tests.
|Last commit: 4 weeks ago|