@@ -13,11 +13,13 @@ defmodule ElixirScript.Translator.Try.Test do
1313 end
1414
1515 js_code = """
16- Bootstrap.Core.SpecialForms._try(function() {
17- return 1;
18- }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.type(ArgumentError, {})], function() {
19- return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
20- })), null, null, null)
16+ Bootstrap.Core.SpecialForms._try(function() {
17+ return 1;
18+ }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([{
19+ [Symbol.for('__struct__')]: Symbol.for('Elixir.ArgumentError')
20+ }], function() {
21+ return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
22+ })), null, null, null)
2123 """
2224
2325 assert_translation ( ex_ast , js_code )
@@ -35,11 +37,13 @@ defmodule ElixirScript.Translator.Try.Test do
3537 end
3638
3739 js_code = """
38- Bootstrap.Core.SpecialForms._try(function() {
39- return 1;
40- }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.type(ArgumentError, {})], function() {
41- return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
42- })), null, null, null)
40+ Bootstrap.Core.SpecialForms._try(function() {
41+ return 1;
42+ }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([{
43+ [Symbol.for('__struct__')]: Symbol.for('Elixir.ArgumentError')
44+ }], function() {
45+ return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
46+ })), null, null, null)
4347 """
4448
4549 assert_translation ( ex_ast , js_code )
@@ -106,13 +110,15 @@ defmodule ElixirScript.Translator.Try.Test do
106110 end
107111
108112 js_code = """
109- Bootstrap.Core.SpecialForms._try(function() {
110- return 1;
111- }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.type(ArgumentError, {})], function() {
112- return Elixir.ElixirScript.IO.__load(Elixir).puts('ArgumentError');
113- }), Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.variable()], function(x) {
114- return Elixir.ElixirScript.IO.__load(Elixir).puts('x');
115- })), null, null, null)
113+ Bootstrap.Core.SpecialForms._try(function() {
114+ return 1;
115+ }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([{
116+ [Symbol.for('__struct__')]: Symbol.for('Elixir.ArgumentError')
117+ }], function() {
118+ return Elixir.ElixirScript.IO.__load(Elixir).puts('ArgumentError');
119+ }), Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.variable()], function(x) {
120+ return Elixir.ElixirScript.IO.__load(Elixir).puts('x');
121+ })), null, null, null)
116122 """
117123
118124 assert_translation ( ex_ast , js_code )
@@ -132,13 +138,15 @@ defmodule ElixirScript.Translator.Try.Test do
132138 end
133139
134140 js_code = """
135- Bootstrap.Core.SpecialForms._try(function() {
136- return 1;
137- }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.type(ArgumentError, {})], function() {
138- return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
139- })), null, null, function() {
140- return Elixir.ElixirScript.IO.__load(Elixir).puts('This is printed regardless if it failed or succeed');
141- })
141+ Bootstrap.Core.SpecialForms._try(function() {
142+ return 1;
143+ }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([{
144+ [Symbol.for('__struct__')]: Symbol.for('Elixir.ArgumentError')
145+ }], function() {
146+ return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
147+ })), null, null, function() {
148+ return Elixir.ElixirScript.IO.__load(Elixir).puts('This is printed regardless if it failed or succeed');
149+ })
142150 """
143151
144152 assert_translation ( ex_ast , js_code )
@@ -207,13 +215,15 @@ defmodule ElixirScript.Translator.Try.Test do
207215 end
208216
209217 js_code = """
210- Bootstrap.Core.SpecialForms._try(function() {
211- return 1;
212- }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Bootstrap.Core.Patterns.type(ArgumentError, {})], function() {
213- return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
214- })), Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Symbol.for('throw'), Symbol.for('Error')], function() {
215- return Elixir.ElixirScript.IO.__load(Elixir).puts('caught error');
216- })), null, null)
218+ Bootstrap.Core.SpecialForms._try(function() {
219+ return 1;
220+ }, Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([{
221+ [Symbol.for('__struct__')]: Symbol.for('Elixir.ArgumentError')
222+ }], function() {
223+ return Elixir.ElixirScript.IO.__load(Elixir).puts('Invalid argument given');
224+ })), Bootstrap.Core.Patterns.defmatch(Bootstrap.Core.Patterns.clause([Symbol.for('throw'), Symbol.for('Error')], function() {
225+ return Elixir.ElixirScript.IO.__load(Elixir).puts('caught error');
226+ })), null, null)
217227 """
218228
219229 assert_translation ( ex_ast , js_code )
0 commit comments