diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-07 17:44:59 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-07 17:44:59 +0100 |
commit | aaef96a2faeb761b2a8b893158899f48c39cbf4b (patch) | |
tree | b500548e19ce09e1695598af21d486765cc6441a /unit_tests | |
parent | b92dbd75b1c9988dcc83e5876e1ce2815145fa30 (diff) | |
download | lanes-aaef96a2faeb761b2a8b893158899f48c39cbf4b.tar.gz lanes-aaef96a2faeb761b2a8b893158899f48c39cbf4b.tar.bz2 lanes-aaef96a2faeb761b2a8b893158899f48c39cbf4b.zip |
Revamped lanes.nameof
Diffstat (limited to 'unit_tests')
-rw-r--r-- | unit_tests/lane_tests.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/unit_tests/lane_tests.cpp b/unit_tests/lane_tests.cpp index 77c7f61..63626ae 100644 --- a/unit_tests/lane_tests.cpp +++ b/unit_tests/lane_tests.cpp | |||
@@ -8,16 +8,25 @@ TEST_CASE("lanes.nameof") | |||
8 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; | 8 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; |
9 | S.requireSuccess("lanes = require 'lanes'.configure()"); | 9 | S.requireSuccess("lanes = require 'lanes'.configure()"); |
10 | 10 | ||
11 | // no argument is not good | ||
12 | S.requireFailure("local t, n = lanes.nameof()"); | ||
13 | |||
14 | // more than one argument is not good | ||
15 | S.requireFailure("local t, n = lanes.nameof(true, false)"); | ||
16 | |||
11 | // a constant is itself, stringified | 17 | // a constant is itself, stringified |
12 | S.requireReturnedString("local t, n = lanes.nameof('bob'); return t .. ': ' .. tostring(n)", "string: bob"); | 18 | S.requireReturnedString("local t, n = lanes.nameof('bob'); return t .. ': ' .. tostring(n)", "string: bob"); |
13 | S.requireReturnedString("local t, n = lanes.nameof(true); return t .. ': ' .. tostring(n)", "boolean: true"); | 19 | S.requireReturnedString("local t, n = lanes.nameof(true); return t .. ': ' .. tostring(n)", "boolean: true"); |
14 | S.requireReturnedString("local t, n = lanes.nameof(42); return t .. ': ' .. tostring(n)", "number: 42"); | 20 | S.requireReturnedString("local t, n = lanes.nameof(42); return t .. ': ' .. tostring(n)", "number: 42"); |
21 | |||
22 | // a temporary object has no name | ||
15 | S.requireReturnedString("local t, n = lanes.nameof({}); return t .. ': ' .. tostring(n)", "table: nil"); | 23 | S.requireReturnedString("local t, n = lanes.nameof({}); return t .. ': ' .. tostring(n)", "table: nil"); |
24 | S.requireReturnedString("local t, n = lanes.nameof(function() end); return t .. ': ' .. tostring(n)", "function: nil"); | ||
16 | 25 | ||
17 | // look for something in _G | 26 | // look for something in _G |
18 | S.requireReturnedString("local t, n = lanes.nameof(print); return t .. ': ' .. tostring(n)", "function: _G/print"); | 27 | S.requireReturnedString("local t, n = lanes.nameof(print); return t .. ': ' .. tostring(n)", "function: _G/print()"); |
19 | S.requireReturnedString("local t, n = lanes.nameof(string); return t .. ': ' .. tostring(n)", "table: _G/string"); | 28 | S.requireReturnedString("local t, n = lanes.nameof(string); return t .. ': ' .. tostring(n)", "table: _G/string[]"); |
20 | S.requireReturnedString("local t, n = lanes.nameof(string.sub); return t .. ': ' .. tostring(n)", "function: _G/string/sub"); | 29 | S.requireReturnedString("local t, n = lanes.nameof(string.sub); return t .. ': ' .. tostring(n)", "function: _G/string[]/sub()"); |
21 | } | 30 | } |
22 | 31 | ||
23 | // ################################################################################################# | 32 | // ################################################################################################# |