Skip to content

Commit

Permalink
Fix some Perl array tests (#259)
Browse files Browse the repository at this point in the history
* Perl allow several pairs of brackets to define arrays: (), [] and several others

Since 7ff2eda Perl expression translator uses [] instead of ().
Fix tests to reflect that

* Fix Perl tests after changes in d9ae2b9

* Fix Perl tests after ba114f2

* Fix Perl array subscript translation tests

.first and .last and subscript was implemented initially in c20661a
  • Loading branch information
Mingun committed Oct 24, 2023
1 parent 9247f44 commit d370048
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "new ArrayList<Integer>(Arrays.asList(0, 1, 100500))",
JavaScriptCompiler -> "[0, 1, 100500]",
LuaCompiler -> "{0, 1, 100500}",
PerlCompiler -> "(0, 1, 100500)",
PerlCompiler -> "[0, 1, 100500]",
PHPCompiler -> "[0, 1, 100500]",
PythonCompiler -> "[0, 1, 100500]",
RubyCompiler -> "[0, 1, 100500]"
Expand Down Expand Up @@ -347,6 +347,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "a().get((int) 42)",
JavaScriptCompiler -> "this.a[42]",
LuaCompiler -> "self.a[43]",
PerlCompiler -> "@{$self->a()}[42]",
PHPCompiler -> "$this->a()[42]",
PythonCompiler -> "self.a[42]",
RubyCompiler -> "a[42]"
Expand All @@ -359,6 +360,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "a().get((42 - 2))",
JavaScriptCompiler -> "this.a[(42 - 2)]",
LuaCompiler -> "self.a[(43 - 2)]",
PerlCompiler -> "@{$self->a()}[(42 - 2)]",
PHPCompiler -> "$this->a()[(42 - 2)]",
PythonCompiler -> "self.a[(42 - 2)]",
RubyCompiler -> "a[(42 - 2)]"
Expand All @@ -371,6 +373,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "a().get(0)",
JavaScriptCompiler -> "this.a[0]",
LuaCompiler -> "self.a[1]",
PerlCompiler -> "@{$self->a()}[0]",
PHPCompiler -> "$this->a()[0]",
PythonCompiler -> "self.a[0]",
RubyCompiler -> "a.first"
Expand All @@ -383,6 +386,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "a().get(a().size() - 1)",
JavaScriptCompiler -> "this.a[this.a.length - 1]",
LuaCompiler -> "self.a[#self.a]",
PerlCompiler -> "@{$self->a()}[-1]",
PHPCompiler -> "$this->a()[count($this->a()) - 1]",
PythonCompiler -> "self.a[-1]",
RubyCompiler -> "a.last"
Expand All @@ -396,7 +400,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaScriptCompiler -> "this.a.length",
LuaCompiler -> "#self.a",
PHPCompiler -> "count($this->a())",
PerlCompiler -> "scalar($self->a())",
PerlCompiler -> "scalar(@{$self->a()})",
PythonCompiler -> "len(self.a)",
RubyCompiler -> "a.length"
))
Expand Down Expand Up @@ -520,7 +524,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "Long.parseLong(\"12345\", 10)",
JavaScriptCompiler -> "Number.parseInt(\"12345\", 10)",
LuaCompiler -> "tonumber(\"12345\")",
PerlCompiler -> "\"12345\"",
PerlCompiler -> "\"12345\" + 0",
PHPCompiler -> "intval(\"12345\", 10)",
PythonCompiler -> "int(u\"12345\")",
RubyCompiler -> "\"12345\".to_i"
Expand Down Expand Up @@ -601,7 +605,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "new ArrayList<Integer>(Arrays.asList())",
JavaScriptCompiler -> "[]",
LuaCompiler -> "{}",
PerlCompiler -> "()",
PerlCompiler -> "[]",
PHPCompiler -> "[]",
PythonCompiler -> "[]",
RubyCompiler -> "[]"
Expand All @@ -614,7 +618,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "new ArrayList<Double>(Arrays.asList())",
JavaScriptCompiler -> "[]",
LuaCompiler -> "{}",
PerlCompiler -> "()",
PerlCompiler -> "[]",
PHPCompiler -> "[]",
PythonCompiler -> "[]",
RubyCompiler -> "[]"
Expand All @@ -641,7 +645,7 @@ class TranslatorSpec extends AnyFunSuite {
JavaCompiler -> "new ArrayList<Integer>(Arrays.asList(0, 1, 2))",
JavaScriptCompiler -> "[0, 1, 2]",
LuaCompiler -> "{0, 1, 2}",
PerlCompiler -> "(0, 1, 2)",
PerlCompiler -> "[0, 1, 2]",
PHPCompiler -> "[0, 1, 2]",
PythonCompiler -> "[0, 1, 2]",
RubyCompiler -> "[0, 1, 2]"
Expand Down

0 comments on commit d370048

Please sign in to comment.