diff --git a/.formatter.exs b/.formatter.exs index d2cda26..6f9001c 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,9 @@ # Used by "mix format" [ - inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] + inputs: ["{mix,.formatter}.exs", "{config,lib,test,bench}/**/*.{ex,exs}"], + # don't add parens around assert_value arguments + import_deps: [:assert_value], + # use this line length when updating expected value + # whatever you prefer, default is 98 + line_length: 98 ] diff --git a/bench/str_split_regex.ex b/bench/str_split_regex.ex index 51bdcba..2e3f4b1 100644 --- a/bench/str_split_regex.ex +++ b/bench/str_split_regex.ex @@ -11,6 +11,7 @@ defmodule T do def plain_indent_io(str, prefix) when is_binary(prefix) do bp = :binary.compile_pattern("\n") + IO.iodata_to_binary(str) |> String.split(bp, trim: true) |> Enum.flat_map(&[prefix, &1, "\n"]) @@ -21,6 +22,7 @@ defmodule T do def plain_indent_bp_inline(str, prefix) when is_binary(prefix) do bp = :binary.compile_pattern("\n") + IO.iodata_to_binary(str) |> String.split(bp, trim: true) |> Enum.flat_map(&[prefix, &1, "\n"]) @@ -46,10 +48,13 @@ defmodule T do end r = S.text_chunk_regex(8) + inputs = %{ "no newlines, 4 chars" => String.duplicate("x", 4) |> S.text_chunk(8, false, r), - "16 newlines, 512 chars" => String.duplicate(String.duplicate("x", 31) <> "\n", 16) |> S.text_chunk(8, false, r), - "8 newlines, 1024 chars" => String.duplicate(String.duplicate("x", 127) <> "\n", 8) |> S.text_chunk(8, false, r), + "16 newlines, 512 chars" => + String.duplicate(String.duplicate("x", 31) <> "\n", 16) |> S.text_chunk(8, false, r), + "8 newlines, 1024 chars" => + String.duplicate(String.duplicate("x", 127) <> "\n", 8) |> S.text_chunk(8, false, r) } {:ok, r2} = :re.compile("\\n", [:multiline]) @@ -59,11 +64,9 @@ suites = %{ # "Split with String" => # # identical to :binary.split() # &T.plain_indent_io(&1, 2), - "Split with String compiled in function" => - &T.plain_indent_bp_inline(&1, 2), - "Split with String precompiled" => - &T.plain_indent_bp(&1, 2, bp), - #"Split with :re" => + "Split with String compiled in function" => &T.plain_indent_bp_inline(&1, 2), + "Split with String precompiled" => &T.plain_indent_bp(&1, 2, bp) + # "Split with :re" => # &T.plain_indent_re(&1, 2, r2) } diff --git a/mix.exs b/mix.exs index 79ecbd0..5bba430 100644 --- a/mix.exs +++ b/mix.exs @@ -78,7 +78,6 @@ defmodule Stampede.MixProject do # must be started before use, see test/test_helper.exs {:assert_value, "~> 0.10.4", only: [:test, :dev]}, - # RUNTIME TYPE CHECKING # https://hexdocs.pm/type_check/readme.html {:type_check, "~> 0.13.5"}, diff --git a/test/stampede_stateless_test.exs b/test/stampede_stateless_test.exs index b59496f..bbe3732 100644 --- a/test/stampede_stateless_test.exs +++ b/test/stampede_stateless_test.exs @@ -31,7 +31,7 @@ defmodule StampedeStatelessTest do describe "stateless functions" do test "split_prefix text" do assert_value S.split_prefix("!ping", "!") == {"!", "ping"} - assert_value {false, "ping"} == S.split_prefix("ping", "!") + assert_value S.split_prefix("ping", "!") == {false, "ping"} end test "SiteConfig.make_regex() test" do