Skip to content

Commit

Permalink
Use #guard in String#unpack('lL')
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jul 27, 2017
1 parent 734643b commit 25d17e1
Showing 1 changed file with 97 additions and 208 deletions.
305 changes: 97 additions & 208 deletions core/string/unpack/l_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>'
end

platform_is wordsize: 32 do
guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'L<_'
it_behaves_like :string_unpack_32bit_le, 'L_<'
Expand Down Expand Up @@ -44,65 +44,33 @@
end
end

platform_is wordsize: 64 do
platform_is_not :mingw32 do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'L<_'
it_behaves_like :string_unpack_64bit_le, 'L_<'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_64bit_le, 'L<!'
it_behaves_like :string_unpack_64bit_le, 'L!<'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_64bit_be, 'L>_'
it_behaves_like :string_unpack_64bit_be, 'L_>'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_64bit_be, 'L>!'
it_behaves_like :string_unpack_64bit_be, 'L!>'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>'
end
end

platform_is :mingw32 do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'L<_'
it_behaves_like :string_unpack_32bit_le, 'L_<'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L<_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_32bit_le, 'L<!'
it_behaves_like :string_unpack_32bit_le, 'L!<'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L<!'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_32bit_be, 'L>_'
it_behaves_like :string_unpack_32bit_be, 'L_>'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_32bit_be, 'L>!'
it_behaves_like :string_unpack_32bit_be, 'L!>'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>!'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L!>'
end
guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'L<_'
it_behaves_like :string_unpack_64bit_le, 'L_<'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_64bit_le, 'L<!'
it_behaves_like :string_unpack_64bit_le, 'L!<'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_64bit_be, 'L>_'
it_behaves_like :string_unpack_64bit_be, 'L_>'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_64bit_be, 'L>!'
it_behaves_like :string_unpack_64bit_be, 'L!>'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>'
end
end
end
Expand All @@ -118,7 +86,7 @@
it_behaves_like :string_unpack_32bit_be_signed, 'l>'
end

platform_is wordsize: 32 do
guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'l<_'
it_behaves_like :string_unpack_32bit_le, 'l_<'
Expand Down Expand Up @@ -148,65 +116,33 @@
end
end

platform_is wordsize: 64 do
platform_is_not :mingw32 do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'l<_'
it_behaves_like :string_unpack_64bit_le, 'l_<'
it_behaves_like :string_unpack_64bit_le_signed, 'l<_'
it_behaves_like :string_unpack_64bit_le_signed, 'l_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_64bit_le, 'l<!'
it_behaves_like :string_unpack_64bit_le, 'l!<'
it_behaves_like :string_unpack_64bit_le_signed, 'l<!'
it_behaves_like :string_unpack_64bit_le_signed, 'l!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_64bit_be, 'l>_'
it_behaves_like :string_unpack_64bit_be, 'l_>'
it_behaves_like :string_unpack_64bit_be_signed, 'l>_'
it_behaves_like :string_unpack_64bit_be_signed, 'l_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_64bit_be, 'l>!'
it_behaves_like :string_unpack_64bit_be, 'l!>'
it_behaves_like :string_unpack_64bit_be_signed, 'l>!'
it_behaves_like :string_unpack_64bit_be_signed, 'l!>'
end
end

platform_is :mingw32 do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'l<_'
it_behaves_like :string_unpack_32bit_le, 'l_<'
it_behaves_like :string_unpack_32bit_le_signed, 'l<_'
it_behaves_like :string_unpack_32bit_le_signed, 'l_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_32bit_le, 'l<!'
it_behaves_like :string_unpack_32bit_le, 'l!<'
it_behaves_like :string_unpack_32bit_le_signed, 'l<!'
it_behaves_like :string_unpack_32bit_le_signed, 'l!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_32bit_be, 'l>_'
it_behaves_like :string_unpack_32bit_be, 'l_>'
it_behaves_like :string_unpack_32bit_be_signed, 'l>_'
it_behaves_like :string_unpack_32bit_be_signed, 'l_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_32bit_be, 'l>!'
it_behaves_like :string_unpack_32bit_be, 'l!>'
it_behaves_like :string_unpack_32bit_be_signed, 'l>!'
it_behaves_like :string_unpack_32bit_be_signed, 'l!>'
end
guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_64bit_le, 'l<_'
it_behaves_like :string_unpack_64bit_le, 'l_<'
it_behaves_like :string_unpack_64bit_le_signed, 'l<_'
it_behaves_like :string_unpack_64bit_le_signed, 'l_<'
end

describe "with modifier '<' and '!'" do
it_behaves_like :string_unpack_64bit_le, 'l<!'
it_behaves_like :string_unpack_64bit_le, 'l!<'
it_behaves_like :string_unpack_64bit_le_signed, 'l<!'
it_behaves_like :string_unpack_64bit_le_signed, 'l!<'
end

describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_64bit_be, 'l>_'
it_behaves_like :string_unpack_64bit_be, 'l_>'
it_behaves_like :string_unpack_64bit_be_signed, 'l>_'
it_behaves_like :string_unpack_64bit_be_signed, 'l_>'
end

describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_64bit_be, 'l>!'
it_behaves_like :string_unpack_64bit_be, 'l!>'
it_behaves_like :string_unpack_64bit_be_signed, 'l>!'
it_behaves_like :string_unpack_64bit_be_signed, 'l!>'
end
end
end
Expand All @@ -224,7 +160,7 @@
it_behaves_like :string_unpack_32bit_le_signed, 'l'
end

platform_is wordsize: 32 do
guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'L_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_'
Expand All @@ -246,49 +182,25 @@
end
end

platform_is wordsize: 64 do
platform_is_not :mingw32 do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_le, 'L_'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_64bit_le, 'L!'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_64bit_le, 'l_'
it_behaves_like :string_unpack_64bit_le_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_64bit_le, 'l!'
it_behaves_like :string_unpack_64bit_le_signed, 'l!'
end
end

platform_is :mingw32 do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'L_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_32bit_le, 'L!'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'l_'
it_behaves_like :string_unpack_32bit_le_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_32bit_le, 'l!'
it_behaves_like :string_unpack_32bit_le_signed, 'l!'
end
guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_le, 'L_'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_64bit_le, 'L!'
it_behaves_like :string_unpack_64bit_le_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_64bit_le, 'l_'
it_behaves_like :string_unpack_64bit_le_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_64bit_le, 'l!'
it_behaves_like :string_unpack_64bit_le_signed, 'l!'
end
end
end
Expand All @@ -306,7 +218,7 @@
it_behaves_like :string_unpack_32bit_be_signed, 'l'
end

platform_is wordsize: 32 do
guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'L_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_'
Expand All @@ -328,49 +240,26 @@
end
end

platform_is wordsize: 64 do
platform_is_not :mingw32 do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_be, 'L_'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_64bit_be, 'L!'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_64bit_be, 'l_'
it_behaves_like :string_unpack_64bit_be_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_64bit_be, 'l!'
it_behaves_like :string_unpack_64bit_be_signed, 'l!'
end
end

platform_is :mingw32 do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'L_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_32bit_be, 'L!'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'l_'
it_behaves_like :string_unpack_32bit_be_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_32bit_be, 'l!'
it_behaves_like :string_unpack_32bit_be_signed, 'l!'
end
guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_64bit_be, 'L_'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L_'
end

describe "String#unpack with format 'L' with modifier '!'" do
it_behaves_like :string_unpack_64bit_be, 'L!'
it_behaves_like :string_unpack_64bit_be_unsigned, 'L!'
end

describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_64bit_be, 'l_'
it_behaves_like :string_unpack_64bit_be_signed, 'l_'
end

describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_64bit_be, 'l!'
it_behaves_like :string_unpack_64bit_be_signed, 'l!'
end
end

end

0 comments on commit 25d17e1

Please sign in to comment.