summaryrefslogtreecommitdiff
path: root/Resources/Libraries/luaunit/test/check_lua_calc_error.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-26 11:32:46 +0800
committerchai <chaifix@163.com>2021-10-26 11:32:46 +0800
commit0549b1e5a8a3132005e275d6026db8003cb067d2 (patch)
treef0d7751ec32ecf5c4d23997fa0ffd3450a5a755a /Resources/Libraries/luaunit/test/check_lua_calc_error.lua
parent32345800737b668011a87328cd3dcce59ec2934c (diff)
*rename folder
Diffstat (limited to 'Resources/Libraries/luaunit/test/check_lua_calc_error.lua')
-rw-r--r--Resources/Libraries/luaunit/test/check_lua_calc_error.lua23
1 files changed, 0 insertions, 23 deletions
diff --git a/Resources/Libraries/luaunit/test/check_lua_calc_error.lua b/Resources/Libraries/luaunit/test/check_lua_calc_error.lua
deleted file mode 100644
index 448be72..0000000
--- a/Resources/Libraries/luaunit/test/check_lua_calc_error.lua
+++ /dev/null
@@ -1,23 +0,0 @@
-
-local lu = require('luaunit')
-
-print( lu.EPS )
-
-local pi_div_6_deg_expected, pi_div_6_deg_calculated, pi_div_3_deg_expected, pi_div_3_deg_calculated
-
-pi_div_6_deg_calculated = math.deg(math.pi/6)
-pi_div_6_deg_expected = 30
-
-pi_div_3_deg_calculated = math.deg(math.pi/3)
-pi_div_3_deg_expected = 60
-
-print( (pi_div_6_deg_expected - pi_div_6_deg_calculated) / lu.EPS ) -- prints: 16
-print( (pi_div_3_deg_expected - pi_div_3_deg_calculated) / lu.EPS ) -- prints: 32
-
--- Better use relative error:
-print( ( (pi_div_6_deg_expected - pi_div_6_deg_calculated) / pi_div_6_deg_expected) / lu.EPS ) -- prints: 0.53333
-print( ( (pi_div_3_deg_expected - pi_div_3_deg_calculated) / pi_div_3_deg_expected) / lu.EPS ) -- prints: 0.53333
-
--- relative error is constant. Assertion can take the form of:
-lu.assertAlmostEquals( (pi_div_6_deg_expected - pi_div_6_deg_calculated) / pi_div_6_deg_expected, 0, lu.EPS )
-lu.assertAlmostEquals( (pi_div_3_deg_expected - pi_div_3_deg_calculated) / pi_div_3_deg_expected, 0, lu.EPS ) \ No newline at end of file