local I=script.Parent.Parent.Parent.Parent local p=require(I.Dev.JestGlobals)local l=p.expect local t=p.describe local o=p.it local b=(require(script.Parent.Parent.formatBenchmark)).formatBenchmark t("\102\111\114\109\097\116\066\101\110\099\104\109\097\114\107",function()o("\115\104\111\117\108\100 \102\111\114\109\097\116 \115\105\109\112\108\101 \098\101\110\099\104\109\097\114\107",function()(l(b({group="\084\101\115\116\071\114\111\117\112";name="\084\101\115\116\078\097\109\101";unit="\111\112\047\115";mean=123.4567;stdDev=5.67;samples=345}))).toBe("\084\101\115\116\071\114\111\117\112\035\084\101\115\116\078\097\109\101 \120 \049\050\051\046\052\053\054\055 \111\112\047\115 \194\177\053\046\054\055\037 \040\051\052\053 \114\117\110\115 \115\097\109\112\108\101\100\041\040\114\111\098\108\111\120-\099\108\105 \118\101\114\115\105\111\110 "..(version().."\041"))end)o("\115\104\111\117\108\100 \102\111\114\109\097\116 \110\117\109\098\101\114\115 \119\105\116\104 \099\111\114\114\101\099\116 \112\114\101\099\105\115\105\111\110",function()(l(b({group="\084\101\115\116\071\114\111\117\112";name="\084\101\115\116\078\097\109\101",unit="\111\112\047\115",mean=.1,stdDev=.1;samples=1}))).toBe("\084\101\115\116\071\114\111\117\112\035\084\101\115\116\078\097\109\101 \120 \048\046\049\048\048\048 \111\112\047\115 \194\177\048\046\049\048\037 \040\049 \114\117\110\115 \115\097\109\112\108\101\100\041\040\114\111\098\108\111\120-\099\108\105 \118\101\114\115\105\111\110 "..(version().."\041"));(l(b({group="\084\101\115\116\071\114\111\117\112",name="\084\101\115\116\078\097\109\101",unit="\111\112\047\115",mean=12.1,stdDev=12.1,samples=123}))).toBe("\084\101\115\116\071\114\111\117\112\035\084\101\115\116\078\097\109\101 \120 \049\050\046\049\048\048\048 \111\112\047\115 \194\177\049\050\046\049\048\037 \040\049\050\051 \114\117\110\115 \115\097\109\112\108\101\100\041\040\114\111\098\108\111\120-\099\108\105 \118\101\114\115\105\111\110 "..(version().."\041"));(l(b({group="\084\101\115\116\071\114\111\117\112";name="\084\101\115\116\078\097\109\101",unit="\111\112\047\115";mean=1234.1,stdDev=1234.1;samples=123456}))).toBe("\084\101\115\116\071\114\111\117\112\035\084\101\115\116\078\097\109\101 \120 \049\050\051\052\046\049\048\048\048 \111\112\047\115 \194\177\049\050\051\052\046\049\048\037 \040\049\050\051\052\053\054 \114\117\110\115 \115\097\109\112\108\101\100\041\040\114\111\098\108\111\120-\099\108\105 \118\101\114\115\105\111\110 "..(version().."\041"));(l(b({group="\084\101\115\116\071\114\111\117\112";name="\084\101\115\116\078\097\109\101",unit="\111\112\047\115";mean=1234.123456,stdDev=1234.123456;samples=123456.123456}))).toBe("\084\101\115\116\071\114\111\117\112\035\084\101\115\116\078\097\109\101 \120 \049\050\051\052\046\049\050\051\053 \111\112\047\115 \194\177\049\050\051\052\046\049\050\037 \040\049\050\051\052\053\054 \114\117\110\115 \115\097\109\112\108\101\100\041\040\114\111\098\108\111\120-\099\108\105 \118\101\114\115\105\111\110 "..(version().."\041"))end)end)
local rootWorkspace = script.Parent.Parent.Parent.Parent

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it

local formatBenchmark = require(script.Parent.Parent.formatBenchmark).formatBenchmark

describe("formatBenchmark", function()
	it("should format simple benchmark", function()
		jestExpect(formatBenchmark({
			group = "TestGroup",
			name = "TestName",
			unit = "op/s",
			mean = 123.4567,
			stdDev = 5.67,
			samples = 345,
		})).toBe(
			"TestGroup#TestName x 123.4567 op/s ±5.67% (345 runs sampled)(roblox-cli version " .. version() .. ")"
		)
	end)

	it("should format numbers with correct precision", function()
		jestExpect(formatBenchmark({
			group = "TestGroup",
			name = "TestName",
			unit = "op/s",
			mean = 0.1,
			stdDev = 0.1,
			samples = 1,
		})).toBe("TestGroup#TestName x 0.1000 op/s ±0.10% (1 runs sampled)(roblox-cli version " .. version() .. ")")

		jestExpect(formatBenchmark({
			group = "TestGroup",
			name = "TestName",
			unit = "op/s",
			mean = 12.1,
			stdDev = 12.1,
			samples = 123,
		})).toBe(
			"TestGroup#TestName x 12.1000 op/s ±12.10% (123 runs sampled)(roblox-cli version " .. version() .. ")"
		)

		jestExpect(formatBenchmark({
			group = "TestGroup",
			name = "TestName",
			unit = "op/s",
			mean = 1234.1,
			stdDev = 1234.1,
			samples = 123456,
		})).toBe(
			"TestGroup#TestName x 1234.1000 op/s ±1234.10% (123456 runs sampled)(roblox-cli version "
				.. version()
				.. ")"
		)

		jestExpect(formatBenchmark({
			group = "TestGroup",
			name = "TestName",
			unit = "op/s",
			mean = 1234.123456,
			stdDev = 1234.123456,
			samples = 123456.123456,
		})).toBe(
			"TestGroup#TestName x 1234.1235 op/s ±1234.12% (123456 runs sampled)(roblox-cli version "
				.. version()
				.. ")"
		)
	end)
end)
