@@ -12,7 +12,8 @@ defmodule Gradient.ExprData do
1212 block_test_data ( ) ,
1313 binary_test_data ( ) ,
1414 map_test_data ( ) ,
15- function_ref_test_data ( )
15+ function_ref_test_data ( ) ,
16+ sigil_test_data ( )
1617 ]
1718 |> List . flatten ( )
1819 end
@@ -108,6 +109,28 @@ defmodule Gradient.ExprData do
108109 ]
109110 end
110111
112+ def sigil_test_data ( ) do
113+ [
114+ { "regex" , elixir_to_ast ( ~r/ foo|bar/ ) , regex_exp ( ) } ,
115+ { "string ~s" , elixir_to_ast ( ~s( this is a string with "double" quotes, not 'single' ones) ) ,
116+ "\" this is a string with \" double\" quotes, not 'single' ones\" " } ,
117+ { "string ~S" , elixir_to_ast ( ~S( String without escape codes \x26 without #{interpolation}) ) ,
118+ "\" String without escape codes \\ x26 without \# {interpolation}\" " } ,
119+ { "char lists" , elixir_to_ast ( ~c( this is a char list containing 'single quotes') ) ,
120+ "'this is a char list containing \\ 'single quotes\\ ''" } ,
121+ { "word list" , elixir_to_ast ( ~w( foo bar bat) ) , "[\" foo\" , \" bar\" , \" bat\" ]" } ,
122+ { "word list atom" , elixir_to_ast ( ~w( foo bar bat) a ) , "[:foo, :bar, :bat]" } ,
123+ { "date" , elixir_to_ast ( ~D[ 2019-10-31] ) ,
124+ "%Date{calendar: Calendar.ISO, year: 2019, month: 10, day: 31}" } ,
125+ { "time" , elixir_to_ast ( ~T[ 23:00:07.0] ) ,
126+ "%Time{calendar: Calendar.ISO, hour: 23, minute: 0, second: 7, microsecond: {0, 1}}" } ,
127+ { "naive date time" , elixir_to_ast ( ~N[ 2019-10-31 23:00:07] ) ,
128+ "%NaiveDateTime{calendar: Calendar.ISO, year: 2019, month: 10, day: 31, hour: 23, minute: 0, second: 7, microsecond: {0, 0}}" } ,
129+ { "date time" , elixir_to_ast ( ~U[ 2019-10-31 19:59:03Z] ) ,
130+ "%DateTime{calendar: Calendar.ISO, year: 2019, month: 10, day: 31, hour: 19, minute: 59, second: 3, microsecond: {0, 0}, time_zone: \" Etc/UTC\" , zone_abbr: \" UTC\" , utc_offset: 0, std_offset: 0}" }
131+ ]
132+ end
133+
111134 def binary_test_data do
112135 [
113136 bin_pm_bin_var ( ) ,
@@ -170,4 +193,17 @@ defmodule Gradient.ExprData do
170193
171194 { "binary with patter matching and bitstring-size" , ast , expected }
172195 end
196+
197+ defp regex_exp ( ) do
198+ << 37 , 82 , 101 , 103 , 101 , 120 , 123 , 111 , 112 , 116 , 115 , 58 , 32 , 60 , 60 , 62 , 62 , 44 , 32 , 114 ,
199+ 101 , 95 , 112 , 97 , 116 , 116 , 101 , 114 , 110 , 58 , 32 , 123 , 58 , 114 , 101 , 95 , 112 , 97 , 116 , 116 ,
200+ 101 , 114 , 110 , 44 , 32 , 48 , 44 , 32 , 48 , 44 , 32 , 48 , 44 , 32 , 34 , 69 , 82 , 67 , 80 , 86 , 0 , 0 , 0 ,
201+ 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 195 , 191 , 195 , 191 , 195 , 191 , 195 , 191 , 195 , 191 , 195 , 191 , 195 ,
202+ 191 , 195 , 191 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
203+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 194 , 131 , 0 , 9 , 29 , 102 , 29 , 111 , 29 , 111 , 119 ,
204+ 0 , 9 , 29 , 98 , 29 , 97 , 29 , 114 , 120 , 0 , 18 , 0 , 34 , 125 , 44 , 32 , 114 , 101 , 95 , 118 , 101 , 114 ,
205+ 115 , 105 , 111 , 110 , 58 , 32 , 123 , 34 , 56 , 46 , 52 , 52 , 32 , 50 , 48 , 50 , 48 , 45 , 48 , 50 , 45 , 49 ,
206+ 50 , 34 , 44 , 32 , 58 , 108 , 105 , 116 , 116 , 108 , 101 , 125 , 44 , 32 , 115 , 111 , 117 , 114 , 99 , 101 ,
207+ 58 , 32 , 34 , 102 , 111 , 111 , 124 , 98 , 97 , 114 , 34 , 125 >>
208+ end
173209end
0 commit comments