Lua: huge API breaking change: converted all snake_case APIs to camelCase

This commit is contained in:
Zef Hemel
2025-02-06 10:04:45 +01:00
parent 0635faabfc
commit a169406d37
42 changed files with 377 additions and 599 deletions
+29 -29
View File
@@ -1,48 +1,48 @@
local function assert_equal(a, b)
local function assertEqual(a, b)
if a ~= b then
error("Assertion failed: " .. a .. " is not equal to " .. b)
error("Assertion failed: " .. a .. " is not equal to " .. b)
end
end
-- Trigonometric functions
assert_equal(math.cos(0), 1)
assert_equal(math.sin(0), 0)
assert_equal(math.tan(0), 0)
assert_equal(math.acos(1), 0)
assert_equal(math.asin(0), 0)
assert_equal(math.atan(0), 0)
assertEqual(math.cos(0), 1)
assertEqual(math.sin(0), 0)
assertEqual(math.tan(0), 0)
assertEqual(math.acos(1), 0)
assertEqual(math.asin(0), 0)
assertEqual(math.atan(0), 0)
-- Hyperbolic functions
assert_equal(math.cosh(0), 1)
assert_equal(math.sinh(0), 0)
assert_equal(math.tanh(0), 0)
assertEqual(math.cosh(0), 1)
assertEqual(math.sinh(0), 0)
assertEqual(math.tanh(0), 0)
-- Basic functions
assert_equal(math.abs(-5), 5)
assert_equal(math.ceil(3.3), 4)
assert_equal(math.floor(3.7), 3)
assert_equal(math.max(1, 2, 3, 4), 4)
assert_equal(math.min(1, 2, 3, 4), 1)
assertEqual(math.abs(-5), 5)
assertEqual(math.ceil(3.3), 4)
assertEqual(math.floor(3.7), 3)
assertEqual(math.max(1, 2, 3, 4), 4)
assertEqual(math.min(1, 2, 3, 4), 1)
-- Rounding and remainder
assert_equal(math.fmod(7, 3), 1)
assertEqual(math.fmod(7, 3), 1)
-- Power and logarithms
assert_equal(math.exp(0), 1)
assert_equal(math.log(math.exp(1)), 1)
assert_equal(math.log(8, 2), 3) -- log base 2 of 8
assert_equal(math.pow(2, 3), 8)
assert_equal(math.sqrt(9), 3)
assertEqual(math.exp(0), 1)
assertEqual(math.log(math.exp(1)), 1)
assertEqual(math.log(8, 2), 3) -- log base 2 of 8
assertEqual(math.pow(2, 3), 8)
assertEqual(math.sqrt(9), 3)
-- Random number tests (basic range checks)
local rand = math.random()
assert_equal(rand >= 0 and rand < 1, true)
local rand_n = math.random(10)
assert_equal(rand_n >= 1 and rand_n <= 10, true)
local rand_range = math.random(5, 10)
assert_equal(rand_range >= 5 and rand_range <= 10, true)
assertEqual(rand >= 0 and rand < 1, true)
local randN = math.random(10)
assertEqual(randN >= 1 and randN <= 10, true)
local randRange = math.random(5, 10)
assertEqual(randRange >= 5 and randRange <= 10, true)
-- Unsigned less than comparison
assert_equal(math.ult(1, 2), true)
assert_equal(math.ult(2, 1), false)
assertEqual(math.ult(1, 2), true)
assertEqual(math.ult(2, 1), false)