Skip to content

Commit

Permalink
Use ordinal/1 in build_argument_error_msg/2
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Nov 12, 2024
1 parent 886ba1f commit 0ec8706
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/elixir/support/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Hologram.Test.Helpers do

alias Hologram.Commons.ETS
alias Hologram.Commons.FileUtils
alias Hologram.Commons.IntegerUtils
alias Hologram.Commons.KernelUtils
alias Hologram.Commons.ProcessUtils
alias Hologram.Compiler.AST
Expand Down Expand Up @@ -72,14 +73,10 @@ defmodule Hologram.Test.Helpers do
"""
@spec build_argument_error_msg(integer(), String.t()) :: String.t()
def build_argument_error_msg(arg_idx, blame) do
# Based on: https://stackoverflow.com/a/39466341/13040586
suffix_idx = rem(rem(arg_idx + 90, 100) - 10, 10) - 1
suffix = Enum.at(["st", "nd", "rd"], suffix_idx, "th")

"""
errors were found at the given arguments:
* #{arg_idx}#{suffix} argument: #{blame}
* #{IntegerUtils.ordinal(arg_idx)} argument: #{blame}
"""
end

Expand Down

0 comments on commit 0ec8706

Please sign in to comment.