11defmodule Gradient.TestHelpers do
22 alias Gradient.Types , as: T
33
4- @ examples_path "test/examples/"
4+ @ examples_path "test/examples"
5+ @ examples_build_path "test/examples/_build"
56
67 @ spec load ( String . t ( ) ) :: T . forms ( )
78 def load ( beam_file ) do
8- beam_file = String . to_charlist ( @ examples_path <> beam_file )
9+ beam_file = String . to_charlist ( Path . join ( @ examples_build_path , beam_file ) )
910
1011 { :ok , { _ , [ abstract_code: { :raw_abstract_v1 , ast } ] } } =
1112 :beam_lib . chunks ( beam_file , [ :abstract_code ] )
@@ -15,8 +16,8 @@ defmodule Gradient.TestHelpers do
1516
1617 @ spec load ( String . t ( ) , String . t ( ) ) :: { T . tokens ( ) , T . forms ( ) }
1718 def load ( beam_file , ex_file ) do
18- beam_file = String . to_charlist ( @ examples_path <> beam_file )
19- ex_file = @ examples_path <> ex_file
19+ beam_file = String . to_charlist ( Path . join ( @ examples_build_path , beam_file ) )
20+ ex_file = Path . join ( @ examples_path , ex_file )
2021
2122 { :ok , { _ , [ abstract_code: { :raw_abstract_v1 , ast } ] } } =
2223 :beam_lib . chunks ( beam_file , [ :abstract_code ] )
@@ -30,8 +31,8 @@ defmodule Gradient.TestHelpers do
3031
3132 @ spec example_data ( ) :: { T . tokens ( ) , T . forms ( ) }
3233 def example_data ( ) do
33- beam_path = ( @ examples_path <> "Elixir.SimpleApp.beam" ) |> String . to_charlist ( )
34- file_path = @ examples_path <> "simple_app.ex"
34+ beam_path = Path . join ( @ examples_build_path , "Elixir.SimpleApp.beam" ) |> String . to_charlist ( )
35+ file_path = Path . join ( @ examples_path , "simple_app.ex" )
3536
3637 code =
3738 File . read! ( file_path )
@@ -50,7 +51,7 @@ defmodule Gradient.TestHelpers do
5051
5152 @ spec example_tokens ( ) :: T . tokens ( )
5253 def example_tokens ( ) do
53- file_path = @ examples_path <> "conditional/cond.ex"
54+ file_path = Path . join ( @ examples_path , "conditional/cond.ex" )
5455
5556 code =
5657 File . read! ( file_path )
@@ -65,7 +66,7 @@ defmodule Gradient.TestHelpers do
6566
6667 @ spec example_string_tokens ( ) :: T . tokens ( )
6768 def example_string_tokens ( ) do
68- file_path = @ examples_path <> "string_example.ex"
69+ file_path = Path . join ( @ examples_path , "string_example.ex" )
6970
7071 code =
7172 File . read! ( file_path )
0 commit comments