Skip to content

Commit

Permalink
TranslatorSpec: fix tests broken in 37fd633
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Aug 27, 2024
1 parent 37fd633 commit 4cd8d59
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ class TranslatorSpec extends AnyFunSpec {
PerlCompiler -> "substr(\"foobar\", 2, 4 - 2)",
PHPCompiler -> "\\Kaitai\\Struct\\Stream::substring(\"foobar\", 2, 4)",
PythonCompiler -> "u\"foobar\"[2:4]",
RubyCompiler -> "\"foobar\"[2..4 - 1]"
RubyCompiler -> "\"foobar\"[2...4]"
))

// substring() call on concatenation of strings: for some languages, concatenation needs to be
Expand All @@ -716,7 +716,7 @@ class TranslatorSpec extends AnyFunSpec {
PerlCompiler -> "substr($self->foo() . $self->bar(), 2, 4 - 2)",
PHPCompiler -> "\\Kaitai\\Struct\\Stream::substring($this->foo() . $this->bar(), 2, 4)",
PythonCompiler -> "(self.foo + self.bar)[2:4]",
RubyCompiler -> "(foo + bar)[2..4 - 1]"
RubyCompiler -> "(foo + bar)[2...4]"
))

// substring() call with non-left-associative "from" and "to": for languages where subtraction
Expand All @@ -731,7 +731,7 @@ class TranslatorSpec extends AnyFunSpec {
PerlCompiler -> "substr($self->foo(), 10 - 7, (10 - 3) - (10 - 7))", // TODO: PerlCompiler -> "substr($self->foo(), 10 - 7, 10 - 3 - (10 - 7))",
PHPCompiler -> "\\Kaitai\\Struct\\Stream::substring($this->foo(), 10 - 7, 10 - 3)",
PythonCompiler -> "self.foo[10 - 7:10 - 3]",
RubyCompiler -> "foo[10 - 7..(10 - 3) - 1]" // TODO: RubyCompiler -> "foo[10 - 7..10 - 3 - 1]"
RubyCompiler -> "foo[10 - 7...10 - 3]"
))

// substring() call with "to" using `<<` which is lower precedence than `+` or `-`: if such
Expand All @@ -746,7 +746,7 @@ class TranslatorSpec extends AnyFunSpec {
PerlCompiler -> "substr($self->foo(), 10 - 7, (10 << 2) - (10 - 7))",
PHPCompiler -> "\\Kaitai\\Struct\\Stream::substring($this->foo(), 10 - 7, 10 << 2)",
PythonCompiler -> "self.foo[10 - 7:10 << 2]",
RubyCompiler -> "foo[10 - 7..(10 << 2) - 1]"
RubyCompiler -> "foo[10 - 7...10 << 2]"
))

// substring() call with "from" using `<<` which is lower precedence than `+` or `-`: if such
Expand All @@ -761,7 +761,7 @@ class TranslatorSpec extends AnyFunSpec {
PerlCompiler -> "substr($self->foo(), 10 << 1, 42 - (10 << 1))",
PHPCompiler -> "\\Kaitai\\Struct\\Stream::substring($this->foo(), 10 << 1, 42)",
PythonCompiler -> "self.foo[10 << 1:42]",
RubyCompiler -> "foo[10 << 1..42 - 1]"
RubyCompiler -> "foo[10 << 1...42]"
))
}
}
Expand Down

0 comments on commit 4cd8d59

Please sign in to comment.