Skip to content

Commit

Permalink
Clean up stdlib tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Apr 30, 2023
1 parent dc15ea8 commit b44967a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/stdlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v1
uses: actions/checkout@v3

- name: Install Erlang/OTP
uses: erlef/setup-beam@v1
Expand All @@ -44,15 +44,15 @@ jobs:
echo ::set-output name=sha::$( curl -u "u:${{ github.token }}" https://api.github.com/repos/elixir-lang/elixir/git/ref/heads/main | jq .object.sha | tr -d '"' )
- name: Check out latest Elixir
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: elixir-lang/elixir
ref: ${{ steps.get-elixir-sha.outputs.sha }}
path: elixir_src

- name: Cache compiled Elixir
id: cache-compiled-elixir
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: elixir_src
key: ${{ runner.os }}-elixir-${{ steps.get-elixir-sha.outputs.sha }}
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/enum_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ defmodule StreamData.EnumTest do
defp enum_count do
# Creating arbitrary big enums will make tests needlessly slow.
# Finding edge cases doesn't require big sizes.
integer() |> filter(&(&1 >= 0)) |> resize(100)
non_negative_integer() |> resize(100)
end
end
end
53 changes: 23 additions & 30 deletions test/stdlib/kernel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,33 @@ defmodule StreamData.KernelTest do

@moduletag :stdlib

if Version.match?(System.version(), "~> 1.14") do
# From https://github.com/elixir-lang/elixir/pull/12045.
property "binary_slice/2 is always consistent with Enum.slice/2" do
check all(
binary <- binary(),
start <- integer(),
stop <- integer(),
step <- positive_integer()
) do
expected =
binary
|> :binary.bin_to_list()
|> Enum.slice(start..stop//step)
|> :binary.list_to_bin()
# From https://github.com/elixir-lang/elixir/pull/12045.
property "binary_slice/2 is always consistent with Enum.slice/2" do
check all(
binary <- binary(),
start <- integer(),
stop <- integer(),
step <- positive_integer()
) do
expected =
binary
|> :binary.bin_to_list()
|> Enum.slice(start..stop//step)
|> :binary.list_to_bin()

assert binary_slice(binary, start..stop//step) == expected
end
assert binary_slice(binary, start..stop//step) == expected
end
end

property "binary_slice/3 is always consistent with Enum.slice/3" do
check all(
binary <- binary(),
start <- integer(),
amount <- integer(),
amount >= 0
) do
expected =
binary
|> :binary.bin_to_list()
|> Enum.slice(start, amount)
|> :binary.list_to_bin()
property "binary_slice/3 is always consistent with Enum.slice/3" do
check all binary <- binary(), start <- integer(), amount <- non_negative_integer() do
expected =
binary
|> :binary.bin_to_list()
|> Enum.slice(start, amount)
|> :binary.list_to_bin()

assert binary_slice(binary, start, amount) == expected
end
assert binary_slice(binary, start, amount) == expected
end
end
end

0 comments on commit b44967a

Please sign in to comment.