1 mg.write("HTTP/1.0 200 OK\r\n")
2 mg.write("Connection: close\r\n")
3 mg.write("Cache-Control: no-cache, no-store, must-revalidate, max-age=0\r\n")
4 mg.write("Content-Type: text/plain\r\n")
8 mg.write("\"shared\" does not exist\n")
10 elseif type(shared) ~= "userdata" then
11 mg.write("\"shared\" is not userdata\n")
16 mg.write("\nNumber:\n")
18 mg.write("Previous count was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
22 mg.write("Store new count " .. tostring(x) .. " (type " .. type(x) .. ")\n")
24 mg.write("New count is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
27 mg.write("\nString:\n")
29 mg.write("Previous name was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
31 l = string.len(x) % 26
32 x = x .. string.char(string.byte("a") + l)
34 mg.write("Store new name " .. tostring(x) .. " (type " .. type(x) .. ")\n")
36 mg.write("New name is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
40 mg.write("\nBoolean:\n")
42 mg.write("Previous condition was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
45 mg.write("Store new condition " .. tostring(x) .. " (type " .. type(x) .. ")\n")
47 mg.write("New condition is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
50 -- Test using "shared" as array
51 mg.write("\nArray element:\n")
52 mg.write("Previous array was: ")
55 mg.write(tostring(x) .. " (" .. type(x):sub(1,1) .. ") ")
59 shared[i] = shared[(i + 1) % 10 + 1] or i
61 mg.write("Shifted array is: ")
64 mg.write(tostring(x) .. " (" .. type(x):sub(1,1) .. ") ")
69 -- Test using "shared" as array
70 mg.write("\nBoolean indexed element:\n")
73 mg.write("Previous elements were "
74 .. tostring(x) .. " (type " .. type(x) .. ") / "
75 .. tostring(y) .. " (type " .. type(y) .. ")\n")
80 mg.write("New elements are "
81 .. tostring(x) .. " (type " .. type(x) .. ") / "
82 .. tostring(y) .. " (type " .. type(y) .. ")\n")
85 -- Check if experimental functions (starting with __) are available
86 if not shared.__inc then
87 mg.write("\nExperimental functions not available\n")
90 mg.write("\nTesting experimental functions\n")
94 -- Test __inc/__dec functions
99 mg.write("__inc(x) = " .. shared.__inc("x") .. "\n")
100 mg.write("__dec(y) = " .. shared.__dec("y") .. "\n")
103 -- Test __add function
108 mg.write("__add(x, 10) = " .. shared.__add("x", 10) .. "\n")
109 mg.write("__add(y, -10) = " .. shared.__add("y", -10) .. "\n")