diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-07-18 11:51:39 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-07-18 11:51:39 +0800 |
| commit | 9d3d8ef2be15dfbf279de71241ff747a568e2c49 (patch) | |
| tree | 53f88fa8a0e64dfa2262898312c9b4d988876fe8 /spec/outputs/string.lua | |
| parent | 51a74726e6f68851bafccba0fe69900274a81d59 (diff) | |
| download | yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.tar.gz yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.tar.bz2 yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.zip | |
Added specs, tests and docs.
Diffstat (limited to 'spec/outputs/string.lua')
| -rw-r--r-- | spec/outputs/string.lua | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/spec/outputs/string.lua b/spec/outputs/string.lua index febea62..b536e6d 100644 --- a/spec/outputs/string.lua +++ b/spec/outputs/string.lua | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | local _module_0 = { } | ||
| 1 | local hi = "hello" | 2 | local hi = "hello" |
| 2 | local hello = "what the heckyes" | 3 | local hello = "what the heckyes" |
| 3 | print(hi) | 4 | print(hi) |
| @@ -41,4 +42,42 @@ local _ = "hello"; | |||
| 41 | ("hello"):format().hello(1, 2, 3); | 42 | ("hello"):format().hello(1, 2, 3); |
| 42 | ("hello"):format(1, 2, 3) | 43 | ("hello"):format(1, 2, 3) |
| 43 | something("hello"):world() | 44 | something("hello"):world() |
| 44 | return something(("hello"):world()) | 45 | something(("hello"):world()) |
| 46 | do | ||
| 47 | local str = "key: value" | ||
| 48 | str = "config:\n\tenabled: true\n\tlevel: 5" | ||
| 49 | str = "header: start\nfooter: end" | ||
| 50 | str = "name: " .. tostring(username) | ||
| 51 | str = "count: " .. tostring(total) .. " items" | ||
| 52 | str = "user: " .. tostring(name) .. "\nid: " .. tostring(id) | ||
| 53 | str = "path: \"C:\\\\Program Files\\\\App\"\ndesc: 'single \"quote\" test'" | ||
| 54 | str = "key: value \nnext: 123 " | ||
| 55 | str = "list:\n - \"one\"\n - \"two\"" | ||
| 56 | str = "-- comment\ncontent text\n-- comment" | ||
| 57 | str = tostring(1 + 2) .. '\n' .. tostring(2 + 3) .. '\n' .. tostring("a" .. "b") | ||
| 58 | local obj = { | ||
| 59 | settings = "mode: " .. tostring(mode) .. "\nflags:\n\t- " .. tostring(flag1) .. "\n\t- default" | ||
| 60 | } | ||
| 61 | local fn | ||
| 62 | fn = function() | ||
| 63 | return "Hello\nname: " .. tostring(userName) | ||
| 64 | end | ||
| 65 | str = "result:\n\tstatus: " .. tostring((function() | ||
| 66 | if ok then | ||
| 67 | return "pass" | ||
| 68 | else | ||
| 69 | return "fail" | ||
| 70 | end | ||
| 71 | end)()) .. "\n\tcode: " .. tostring(code) | ||
| 72 | local summary = "date: " .. tostring(os.date()) .. "\nvalues:\n\t-\n\t\ta: " .. tostring(aVal) .. "\n\t\tb: " .. tostring(bVal or defaultB) | ||
| 73 | local msg = send("Hello, " .. tostring(user) .. "!\nToday is " .. tostring(os.date("%A")) .. ".") | ||
| 74 | local desc | ||
| 75 | do | ||
| 76 | local prefix = "Result" | ||
| 77 | desc = tostring(prefix) .. ":\nvalue: " .. tostring(compute()) | ||
| 78 | end | ||
| 79 | print(("1\n2\n3")) | ||
| 80 | end | ||
| 81 | local yaml = "version: " .. tostring(ver) .. "\nok: true" | ||
| 82 | _module_0["yaml"] = yaml | ||
| 83 | return _module_0 | ||
