This PR adds snapshot-based testing of the generated code and then goes to make the generated code (hopefully) a joy to read and write by formatting with conventional spacing and indentation. This helps with readability for users who may want to step into the code in the debugger and also allows changes to the generate code to be Git-tracked, fully tested and reviewable as part of future PRs. While the integration tests covered the runtime behaviour, this helps to ensure that accidental source changes don't slip by without notice.
This PR adds snapshot-based testing of the generated code and then goes to make the generated code (hopefully) a joy to read and write by formatting with conventional spacing and indentation. This helps with readability for users who may want to step into the code in the debugger and also allows changes to the generate code to be Git-tracked, fully tested and reviewable as part of future PRs. While the integration tests covered the runtime behaviour, this helps to ensure that accidental source changes don't slip by without notice.
The new tests exercise the generated code for all the Python files from the integration tests:
CSnakes.Tests
PythonStaticGeneratorTests
FormatClassFromMethods
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_args.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_basic.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_buffer.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_defaults.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_dependency.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_dicts.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_exceptions.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_false_returns.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_generators.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_keywords.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_none.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_reload.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_reserved.py")
FormatClassFromMethods(resourceName: "CSnakes.Tests.python.test_tuples.py")
The snapshot testing is leveraged from Shouldly using its
ShouldMatchApproved
.This will also eventually help with generating prettier code via a CLI (#192).