From 51de1d8436100f725f3576aefa24a2bd2057bc28 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:36:56 +0200 Subject: Adding upstream version 0.37.0. Signed-off-by: Daniel Baumann --- TOOLS/lua/nan-test.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 TOOLS/lua/nan-test.lua (limited to 'TOOLS/lua/nan-test.lua') diff --git a/TOOLS/lua/nan-test.lua b/TOOLS/lua/nan-test.lua new file mode 100644 index 0000000..d3f1c8c --- /dev/null +++ b/TOOLS/lua/nan-test.lua @@ -0,0 +1,37 @@ +-- Test a float property which internally uses NaN. +-- Run with --no-config (or just scale-param1 not set). + +local utils = require 'mp.utils' + +prop_name = "scale-param1" + +-- internal NaN, return string "default" instead of NaN +v = mp.get_property_native(prop_name, "fail") +print("Exp:", "string", "\"default\"") +print("Got:", type(v), utils.to_string(v)) + +v = mp.get_property(prop_name) +print("Exp:", "default") +print("Got:", v) + +-- not representable -> return provided fallback value +v = mp.get_property_number(prop_name, -100) +print("Exp:", -100) +print("Got:", v) + +mp.set_property_native(prop_name, 123) +v = mp.get_property_number(prop_name, -100) +print("Exp:", "number", 123) +print("Got:", type(v), utils.to_string(v)) + +-- try to set an actual NaN +st, msg = mp.set_property_number(prop_name, 0.0/0) +print("Exp:", nil, "") +print("Got:", st, msg) + +-- set default +mp.set_property(prop_name, "default") + +v = mp.get_property(prop_name) +print("Exp:", "default") +print("Got:", v) -- cgit v1.2.3