@@ -7,6 +7,8 @@ defmodule Spitfire.ConformanceTest do
77 """
88 use ExUnit.Case , async: true
99
10+ import Spitfire.Assertions , only: [ assert_conforms: 1 ]
11+
1012 # =============================================================================
1113 # TERMINALS - Basic building blocks that are valid as standalone expressions
1214 # =============================================================================
@@ -2895,49 +2897,4 @@ defmodule Spitfire.ConformanceTest do
28952897 assert_conforms ( "^!u\n ;" )
28962898 assert_conforms ( "foo()\n ;" )
28972899 end
2898-
2899- # =============================================================================
2900- # Helper function
2901- # =============================================================================
2902-
2903- defp assert_conforms ( code , _opts \\ [ ] ) do
2904- reference = s2q ( code )
2905-
2906- case reference do
2907- { :ok , expected_ast } ->
2908- actual = spitfire_parse ( code )
2909-
2910- assert actual == reference ,
2911- """
2912- AST mismatch for: #{ inspect ( code ) }
2913-
2914- Reference:
2915- #{ inspect ( expected_ast , pretty: true ) }
2916-
2917- Actual:
2918- #{ inspect ( actual , pretty: true ) }
2919- """
2920-
2921- { :error , _ } ->
2922- # Reference parser errors - skip, nothing to validate conformance against
2923- :ok
2924- end
2925- end
2926-
2927- defp s2q ( code ) do
2928- Code . string_to_quoted (
2929- code ,
2930- columns: true ,
2931- token_metadata: true ,
2932- emit_warnings: false
2933- )
2934- end
2935-
2936- defp spitfire_parse ( code ) do
2937- case Spitfire . parse ( code ) do
2938- { :ok , ast } -> { :ok , ast }
2939- { :error , _ast , _errors } -> { :error , :parse_error }
2940- { :error , :no_fuel_remaining } -> { :error , :no_fuel_remaining }
2941- end
2942- end
29432900end
0 commit comments