]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/test/page_shared.lua
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / prometheus-cpp / 3rdparty / civetweb / test / page_shared.lua
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")
5 mg.write("\r\n")
6
7 if not shared then
8 mg.write("\"shared\" does not exist\n")
9 return
10 elseif type(shared) ~= "userdata" then
11 mg.write("\"shared\" is not userdata\n")
12 return
13 end
14
15 -- Test with number
16 mg.write("\nNumber:\n")
17 x = shared.count
18 mg.write("Previous count was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
19 x = x or 0
20 x = x + 1
21 shared.count = x
22 mg.write("Store new count " .. tostring(x) .. " (type " .. type(x) .. ")\n")
23 x = shared.count
24 mg.write("New count is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
25
26 -- Test with name
27 mg.write("\nString:\n")
28 x = shared.name
29 mg.write("Previous name was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
30 x = x or ""
31 l = string.len(x) % 26
32 x = x .. string.char(string.byte("a") + l)
33 shared.name = x
34 mg.write("Store new name " .. tostring(x) .. " (type " .. type(x) .. ")\n")
35 x = shared.name
36 mg.write("New name is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
37
38
39 -- Test with boolean
40 mg.write("\nBoolean:\n")
41 x = shared.condition
42 mg.write("Previous condition was " .. tostring(x) .. " (type " .. type(x) .. ")\n")
43 x = not x
44 shared.condition = x
45 mg.write("Store new condition " .. tostring(x) .. " (type " .. type(x) .. ")\n")
46 x = shared.condition
47 mg.write("New condition is " .. tostring(x) .. " (type " .. type(x) .. ")\n")
48
49
50 -- Test using "shared" as array
51 mg.write("\nArray element:\n")
52 mg.write("Previous array was: ")
53 for i=1,10 do
54 x = shared[i]
55 mg.write(tostring(x) .. " (" .. type(x):sub(1,1) .. ") ")
56 end
57 mg.write("\n")
58 for i=1,10 do
59 shared[i] = shared[(i + 1) % 10 + 1] or i
60 end
61 mg.write("Shifted array is: ")
62 for i=1,10 do
63 x = shared[i]
64 mg.write(tostring(x) .. " (" .. type(x):sub(1,1) .. ") ")
65 end
66 mg.write("\n")
67
68
69 -- Test using "shared" as array
70 mg.write("\nBoolean indexed element:\n")
71 x = shared[true]
72 y = shared[false]
73 mg.write("Previous elements were "
74 .. tostring(x) .. " (type " .. type(x) .. ") / "
75 .. tostring(y) .. " (type " .. type(y) .. ")\n")
76 x = not x
77 y = not x
78 shared[true] = x
79 shared[false] = y
80 mg.write("New elements are "
81 .. tostring(x) .. " (type " .. type(x) .. ") / "
82 .. tostring(y) .. " (type " .. type(y) .. ")\n")
83
84
85 -- Check if experimental functions (starting with __) are available
86 if not shared.__inc then
87 mg.write("\nExperimental functions not available\n")
88 return
89 else
90 mg.write("\nTesting experimental functions\n")
91 end
92
93
94 -- Test __inc/__dec functions
95 if not shared.x then
96 shared.x = 0
97 shared.y = 0
98 end
99 mg.write("__inc(x) = " .. shared.__inc("x") .. "\n")
100 mg.write("__dec(y) = " .. shared.__dec("y") .. "\n")
101
102
103 -- Test __add function
104 if not shared.x then
105 shared.x = 0
106 shared.y = 0
107 end
108 mg.write("__add(x, 10) = " .. shared.__add("x", 10) .. "\n")
109 mg.write("__add(y, -10) = " .. shared.__add("y", -10) .. "\n")
110
111
112 -- end