roblox-opencode 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/commands/setup-game.md +108 -0
- package/commands/sync-check.md +53 -0
- package/core/roblox-core.md +93 -0
- package/dist/server.js +167 -0
- package/package.json +35 -0
- package/skills/roblox-analytics/SKILL.md +277 -0
- package/skills/roblox-analytics/references/event-batcher.luau +75 -0
- package/skills/roblox-animation-vfx/SKILL.md +1325 -0
- package/skills/roblox-architecture/SKILL.md +863 -0
- package/skills/roblox-architecture/references/combat-systems.md +1381 -0
- package/skills/roblox-code-review/SKILL.md +687 -0
- package/skills/roblox-data/SKILL.md +889 -0
- package/skills/roblox-data/references/inventory-systems.md +1729 -0
- package/skills/roblox-debug/SKILL.md +99 -0
- package/skills/roblox-gui/SKILL.md +1103 -0
- package/skills/roblox-gui-fusion/SKILL.md +150 -0
- package/skills/roblox-gui-fusion/references/inventory.luau +427 -0
- package/skills/roblox-gui-fusion/references/settings-menu.luau +579 -0
- package/skills/roblox-gui-fusion/references/shop.luau +411 -0
- package/skills/roblox-luau-mastery/SKILL.md +1519 -0
- package/skills/roblox-monetization/SKILL.md +1084 -0
- package/skills/roblox-monetization/references/process-receipt.luau +131 -0
- package/skills/roblox-networking/SKILL.md +669 -0
- package/skills/roblox-networking/references/remote-validator.luau +193 -0
- package/skills/roblox-publish-checklist/SKILL.md +128 -0
- package/skills/roblox-runtime/SKILL.md +753 -0
- package/skills/roblox-sharp-edges/SKILL.md +295 -0
- package/skills/roblox-sync/SKILL.md +126 -0
- package/skills/roblox-testing/SKILL.md +943 -0
- package/skills/roblox-tooling/SKILL.md +150 -0
- package/vendor/LICENSES/ProfileStore-LICENSE +201 -0
- package/vendor/LICENSES/RbxUtil-LICENSE +7 -0
- package/vendor/LICENSES/promise-LICENSE +21 -0
- package/vendor/LICENSES/t-LICENSE +21 -0
- package/vendor/LICENSES/testez-LICENSE +201 -0
- package/vendor/README.md +84 -0
- package/vendor/fusion/Animation/ExternalTime.luau +84 -0
- package/vendor/fusion/Animation/Spring.luau +322 -0
- package/vendor/fusion/Animation/Stopwatch.luau +128 -0
- package/vendor/fusion/Animation/Tween.luau +187 -0
- package/vendor/fusion/Animation/getTweenDuration.luau +27 -0
- package/vendor/fusion/Animation/getTweenRatio.luau +47 -0
- package/vendor/fusion/Animation/lerpType.luau +164 -0
- package/vendor/fusion/Animation/packType.luau +100 -0
- package/vendor/fusion/Animation/springCoefficients.luau +80 -0
- package/vendor/fusion/Animation/unpackType.luau +103 -0
- package/vendor/fusion/Colour/Oklab.luau +70 -0
- package/vendor/fusion/Colour/sRGB.luau +55 -0
- package/vendor/fusion/External.luau +168 -0
- package/vendor/fusion/ExternalDebug.luau +70 -0
- package/vendor/fusion/Graph/Observer.luau +114 -0
- package/vendor/fusion/Graph/castToGraph.luau +29 -0
- package/vendor/fusion/Graph/change.luau +81 -0
- package/vendor/fusion/Graph/depend.luau +33 -0
- package/vendor/fusion/Graph/evaluate.luau +56 -0
- package/vendor/fusion/Instances/Attribute.luau +58 -0
- package/vendor/fusion/Instances/AttributeChange.luau +47 -0
- package/vendor/fusion/Instances/AttributeOut.luau +63 -0
- package/vendor/fusion/Instances/Child.luau +21 -0
- package/vendor/fusion/Instances/Children.luau +148 -0
- package/vendor/fusion/Instances/Hydrate.luau +33 -0
- package/vendor/fusion/Instances/New.luau +53 -0
- package/vendor/fusion/Instances/OnChange.luau +50 -0
- package/vendor/fusion/Instances/OnEvent.luau +54 -0
- package/vendor/fusion/Instances/Out.luau +69 -0
- package/vendor/fusion/Instances/applyInstanceProps.luau +149 -0
- package/vendor/fusion/Instances/defaultProps.luau +194 -0
- package/vendor/fusion/LICENSE +21 -0
- package/vendor/fusion/Logging/formatError.luau +49 -0
- package/vendor/fusion/Logging/messages.luau +52 -0
- package/vendor/fusion/Logging/parseError.luau +25 -0
- package/vendor/fusion/Memory/checkLifetime.luau +134 -0
- package/vendor/fusion/Memory/deriveScope.luau +24 -0
- package/vendor/fusion/Memory/deriveScopeImpl.luau +45 -0
- package/vendor/fusion/Memory/doCleanup.luau +79 -0
- package/vendor/fusion/Memory/innerScope.luau +34 -0
- package/vendor/fusion/Memory/legacyCleanup.luau +18 -0
- package/vendor/fusion/Memory/needsDestruction.luau +17 -0
- package/vendor/fusion/Memory/poisonScope.luau +34 -0
- package/vendor/fusion/Memory/scopePool.luau +55 -0
- package/vendor/fusion/Memory/scoped.luau +27 -0
- package/vendor/fusion/Memory/whichLivesLonger.luau +75 -0
- package/vendor/fusion/RobloxExternal.luau +98 -0
- package/vendor/fusion/State/Computed.luau +139 -0
- package/vendor/fusion/State/For/Disassembly.luau +211 -0
- package/vendor/fusion/State/For/ForTypes.luau +30 -0
- package/vendor/fusion/State/For/init.luau +110 -0
- package/vendor/fusion/State/ForKeys.luau +94 -0
- package/vendor/fusion/State/ForPairs.luau +97 -0
- package/vendor/fusion/State/ForValues.luau +94 -0
- package/vendor/fusion/State/Value.luau +88 -0
- package/vendor/fusion/State/castToState.luau +26 -0
- package/vendor/fusion/State/peek.luau +31 -0
- package/vendor/fusion/State/updateAll.luau +1 -0
- package/vendor/fusion/Types.luau +314 -0
- package/vendor/fusion/Utility/Contextual.luau +91 -0
- package/vendor/fusion/Utility/Safe.luau +23 -0
- package/vendor/fusion/Utility/isSimilar.luau +29 -0
- package/vendor/fusion/Utility/merge.luau +35 -0
- package/vendor/fusion/Utility/nameOf.luau +35 -0
- package/vendor/fusion/Utility/never.luau +14 -0
- package/vendor/fusion/Utility/nicknames.luau +11 -0
- package/vendor/fusion/Utility/xtypeof.luau +27 -0
- package/vendor/fusion/init.luau +82 -0
- package/vendor/profilestore/init.luau +2243 -0
- package/vendor/promise/init.luau +1982 -0
- package/vendor/rbxutil/buffer-util/Buffer.test.luau +25 -0
- package/vendor/rbxutil/buffer-util/BufferReader.luau +228 -0
- package/vendor/rbxutil/buffer-util/BufferWriter.luau +269 -0
- package/vendor/rbxutil/buffer-util/DataTypeBuffer.luau +223 -0
- package/vendor/rbxutil/buffer-util/Types.luau +60 -0
- package/vendor/rbxutil/buffer-util/index.d.ts +153 -0
- package/vendor/rbxutil/buffer-util/init.luau +41 -0
- package/vendor/rbxutil/buffer-util/package.json +16 -0
- package/vendor/rbxutil/buffer-util/wally.toml +9 -0
- package/vendor/rbxutil/comm/Client/ClientComm.luau +232 -0
- package/vendor/rbxutil/comm/Client/ClientRemoteProperty.luau +156 -0
- package/vendor/rbxutil/comm/Client/ClientRemoteSignal.luau +109 -0
- package/vendor/rbxutil/comm/Client/init.luau +135 -0
- package/vendor/rbxutil/comm/Server/RemoteProperty.luau +295 -0
- package/vendor/rbxutil/comm/Server/RemoteSignal.luau +211 -0
- package/vendor/rbxutil/comm/Server/ServerComm.luau +211 -0
- package/vendor/rbxutil/comm/Server/init.luau +140 -0
- package/vendor/rbxutil/comm/Types.luau +18 -0
- package/vendor/rbxutil/comm/Util.luau +27 -0
- package/vendor/rbxutil/comm/init.luau +35 -0
- package/vendor/rbxutil/comm/wally.toml +13 -0
- package/vendor/rbxutil/component/init.luau +759 -0
- package/vendor/rbxutil/component/init.test.luau +311 -0
- package/vendor/rbxutil/component/wally.toml +14 -0
- package/vendor/rbxutil/concur/init.luau +542 -0
- package/vendor/rbxutil/concur/init.test.luau +364 -0
- package/vendor/rbxutil/concur/wally.toml +8 -0
- package/vendor/rbxutil/enum-list/init.luau +101 -0
- package/vendor/rbxutil/enum-list/init.test.luau +91 -0
- package/vendor/rbxutil/enum-list/wally.toml +8 -0
- package/vendor/rbxutil/find/index.d.ts +20 -0
- package/vendor/rbxutil/find/init.luau +44 -0
- package/vendor/rbxutil/find/package.json +17 -0
- package/vendor/rbxutil/find/wally.toml +8 -0
- package/vendor/rbxutil/input/Gamepad.luau +559 -0
- package/vendor/rbxutil/input/Keyboard.luau +124 -0
- package/vendor/rbxutil/input/Mouse.luau +278 -0
- package/vendor/rbxutil/input/PreferredInput.luau +91 -0
- package/vendor/rbxutil/input/Touch.luau +120 -0
- package/vendor/rbxutil/input/init.luau +33 -0
- package/vendor/rbxutil/input/wally.toml +12 -0
- package/vendor/rbxutil/loader/index.d.ts +15 -0
- package/vendor/rbxutil/loader/init.luau +137 -0
- package/vendor/rbxutil/loader/wally.toml +8 -0
- package/vendor/rbxutil/log/index.d.ts +38 -0
- package/vendor/rbxutil/log/init.luau +746 -0
- package/vendor/rbxutil/log/wally.toml +8 -0
- package/vendor/rbxutil/net/init.luau +190 -0
- package/vendor/rbxutil/net/wally.toml +8 -0
- package/vendor/rbxutil/option/index.d.ts +44 -0
- package/vendor/rbxutil/option/init.luau +489 -0
- package/vendor/rbxutil/option/init.test.luau +342 -0
- package/vendor/rbxutil/option/wally.toml +8 -0
- package/vendor/rbxutil/pid/index.d.ts +53 -0
- package/vendor/rbxutil/pid/init.luau +195 -0
- package/vendor/rbxutil/pid/package.json +16 -0
- package/vendor/rbxutil/pid/wally.toml +9 -0
- package/vendor/rbxutil/quaternion/index.d.ts +117 -0
- package/vendor/rbxutil/quaternion/init.luau +570 -0
- package/vendor/rbxutil/quaternion/package.json +16 -0
- package/vendor/rbxutil/quaternion/wally.toml +9 -0
- package/vendor/rbxutil/query/index.d.ts +43 -0
- package/vendor/rbxutil/query/init.luau +117 -0
- package/vendor/rbxutil/query/package.json +18 -0
- package/vendor/rbxutil/query/wally.toml +9 -0
- package/vendor/rbxutil/sequent/index.d.ts +28 -0
- package/vendor/rbxutil/sequent/init.luau +340 -0
- package/vendor/rbxutil/sequent/package.json +16 -0
- package/vendor/rbxutil/sequent/wally.toml +9 -0
- package/vendor/rbxutil/ser/init.luau +175 -0
- package/vendor/rbxutil/ser/init.test.luau +50 -0
- package/vendor/rbxutil/ser/wally.toml +11 -0
- package/vendor/rbxutil/shake/index.d.ts +36 -0
- package/vendor/rbxutil/shake/init.luau +532 -0
- package/vendor/rbxutil/shake/init.test.luau +267 -0
- package/vendor/rbxutil/shake/package.json +16 -0
- package/vendor/rbxutil/shake/wally.toml +9 -0
- package/vendor/rbxutil/signal/index.d.ts +100 -0
- package/vendor/rbxutil/signal/init.luau +432 -0
- package/vendor/rbxutil/signal/init.test.luau +190 -0
- package/vendor/rbxutil/signal/package.json +17 -0
- package/vendor/rbxutil/signal/wally.toml +9 -0
- package/vendor/rbxutil/silo/TableWatcher.luau +65 -0
- package/vendor/rbxutil/silo/Util.luau +55 -0
- package/vendor/rbxutil/silo/init.luau +338 -0
- package/vendor/rbxutil/silo/init.test.luau +215 -0
- package/vendor/rbxutil/silo/wally.toml +8 -0
- package/vendor/rbxutil/spring/index.d.ts +40 -0
- package/vendor/rbxutil/spring/init.luau +97 -0
- package/vendor/rbxutil/spring/package.json +17 -0
- package/vendor/rbxutil/spring/wally.toml +8 -0
- package/vendor/rbxutil/stream/index.d.ts +88 -0
- package/vendor/rbxutil/stream/init.luau +597 -0
- package/vendor/rbxutil/stream/package.json +18 -0
- package/vendor/rbxutil/stream/wally.toml +9 -0
- package/vendor/rbxutil/streamable/Streamable.luau +202 -0
- package/vendor/rbxutil/streamable/StreamableUtil.luau +80 -0
- package/vendor/rbxutil/streamable/init.luau +8 -0
- package/vendor/rbxutil/streamable/wally.toml +12 -0
- package/vendor/rbxutil/symbol/init.luau +56 -0
- package/vendor/rbxutil/symbol/init.test.luau +37 -0
- package/vendor/rbxutil/symbol/wally.toml +8 -0
- package/vendor/rbxutil/table-util/init.luau +938 -0
- package/vendor/rbxutil/table-util/init.test.luau +439 -0
- package/vendor/rbxutil/table-util/wally.toml +8 -0
- package/vendor/rbxutil/task-queue/index.d.ts +27 -0
- package/vendor/rbxutil/task-queue/init.luau +97 -0
- package/vendor/rbxutil/task-queue/wally.toml +8 -0
- package/vendor/rbxutil/timer/index.d.ts +81 -0
- package/vendor/rbxutil/timer/init.luau +249 -0
- package/vendor/rbxutil/timer/init.test.luau +73 -0
- package/vendor/rbxutil/timer/wally.toml +11 -0
- package/vendor/rbxutil/tree/index.d.ts +15 -0
- package/vendor/rbxutil/tree/init.luau +137 -0
- package/vendor/rbxutil/tree/wally.toml +8 -0
- package/vendor/rbxutil/trove/index.d.ts +46 -0
- package/vendor/rbxutil/trove/init.luau +787 -0
- package/vendor/rbxutil/trove/init.test.luau +203 -0
- package/vendor/rbxutil/trove/wally.toml +8 -0
- package/vendor/rbxutil/typed-remote/init.luau +196 -0
- package/vendor/rbxutil/typed-remote/wally.toml +8 -0
- package/vendor/rbxutil/wait-for/index.d.ts +17 -0
- package/vendor/rbxutil/wait-for/init.luau +257 -0
- package/vendor/rbxutil/wait-for/init.test.luau +182 -0
- package/vendor/rbxutil/wait-for/wally.toml +11 -0
- package/vendor/t/t.lua +1350 -0
- package/vendor/testez/Context.lua +26 -0
- package/vendor/testez/Expectation.lua +311 -0
- package/vendor/testez/ExpectationContext.lua +38 -0
- package/vendor/testez/LifecycleHooks.lua +89 -0
- package/vendor/testez/Reporters/TeamCityReporter.lua +102 -0
- package/vendor/testez/Reporters/TextReporter.lua +106 -0
- package/vendor/testez/Reporters/TextReporterQuiet.lua +97 -0
- package/vendor/testez/TestBootstrap.lua +147 -0
- package/vendor/testez/TestEnum.lua +28 -0
- package/vendor/testez/TestPlan.lua +304 -0
- package/vendor/testez/TestPlanner.lua +40 -0
- package/vendor/testez/TestResults.lua +112 -0
- package/vendor/testez/TestRunner.lua +188 -0
- package/vendor/testez/TestSession.lua +243 -0
- package/vendor/testez/init.lua +40 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
The Context object implements a write-once key-value store. It also allows
|
|
3
|
+
for a new Context object to inherit the entries from an existing one.
|
|
4
|
+
]]
|
|
5
|
+
local Context = {}
|
|
6
|
+
|
|
7
|
+
function Context.new(parent)
|
|
8
|
+
local meta = {}
|
|
9
|
+
local index = {}
|
|
10
|
+
meta.__index = index
|
|
11
|
+
|
|
12
|
+
if parent then
|
|
13
|
+
for key, value in pairs(getmetatable(parent).__index) do
|
|
14
|
+
index[key] = value
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
function meta.__newindex(_obj, key, value)
|
|
19
|
+
assert(index[key] == nil, string.format("Cannot reassign %s in context", tostring(key)))
|
|
20
|
+
index[key] = value
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
return setmetatable({}, meta)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return Context
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Allows creation of expectation statements designed for behavior-driven
|
|
3
|
+
testing (BDD). See Chai (JS) or RSpec (Ruby) for examples of other BDD
|
|
4
|
+
frameworks.
|
|
5
|
+
|
|
6
|
+
The Expectation class is exposed to tests as a function called `expect`:
|
|
7
|
+
|
|
8
|
+
expect(5).to.equal(5)
|
|
9
|
+
expect(foo()).to.be.ok()
|
|
10
|
+
|
|
11
|
+
Expectations can be negated using .never:
|
|
12
|
+
|
|
13
|
+
expect(true).never.to.equal(false)
|
|
14
|
+
|
|
15
|
+
Expectations throw errors when their conditions are not met.
|
|
16
|
+
]]
|
|
17
|
+
|
|
18
|
+
local Expectation = {}
|
|
19
|
+
|
|
20
|
+
--[[
|
|
21
|
+
These keys don't do anything except make expectations read more cleanly
|
|
22
|
+
]]
|
|
23
|
+
local SELF_KEYS = {
|
|
24
|
+
to = true,
|
|
25
|
+
be = true,
|
|
26
|
+
been = true,
|
|
27
|
+
have = true,
|
|
28
|
+
was = true,
|
|
29
|
+
at = true,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
--[[
|
|
33
|
+
These keys invert the condition expressed by the Expectation.
|
|
34
|
+
]]
|
|
35
|
+
local NEGATION_KEYS = {
|
|
36
|
+
never = true,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
--[[
|
|
40
|
+
Extension of Lua's 'assert' that lets you specify an error level.
|
|
41
|
+
]]
|
|
42
|
+
local function assertLevel(condition, message, level)
|
|
43
|
+
message = message or "Assertion failed!"
|
|
44
|
+
level = level or 1
|
|
45
|
+
|
|
46
|
+
if not condition then
|
|
47
|
+
error(message, level + 1)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
--[[
|
|
52
|
+
Returns a version of the given method that can be called with either . or :
|
|
53
|
+
]]
|
|
54
|
+
local function bindSelf(self, method)
|
|
55
|
+
return function(firstArg, ...)
|
|
56
|
+
if firstArg == self then
|
|
57
|
+
return method(self, ...)
|
|
58
|
+
else
|
|
59
|
+
return method(self, firstArg, ...)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local function formatMessage(result, trueMessage, falseMessage)
|
|
65
|
+
if result then
|
|
66
|
+
return trueMessage
|
|
67
|
+
else
|
|
68
|
+
return falseMessage
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
--[[
|
|
73
|
+
Create a new expectation
|
|
74
|
+
]]
|
|
75
|
+
function Expectation.new(value)
|
|
76
|
+
local self = {
|
|
77
|
+
value = value,
|
|
78
|
+
successCondition = true,
|
|
79
|
+
condition = false,
|
|
80
|
+
matchers = {},
|
|
81
|
+
_boundMatchers = {},
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setmetatable(self, Expectation)
|
|
85
|
+
|
|
86
|
+
self.a = bindSelf(self, self.a)
|
|
87
|
+
self.an = self.a
|
|
88
|
+
self.ok = bindSelf(self, self.ok)
|
|
89
|
+
self.equal = bindSelf(self, self.equal)
|
|
90
|
+
self.throw = bindSelf(self, self.throw)
|
|
91
|
+
self.near = bindSelf(self, self.near)
|
|
92
|
+
|
|
93
|
+
return self
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
function Expectation.checkMatcherNameCollisions(name)
|
|
97
|
+
if SELF_KEYS[name] or NEGATION_KEYS[name] or Expectation[name] then
|
|
98
|
+
return false
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
return true
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
function Expectation:extend(matchers)
|
|
105
|
+
self.matchers = matchers or {}
|
|
106
|
+
|
|
107
|
+
for name, implementation in pairs(self.matchers) do
|
|
108
|
+
self._boundMatchers[name] = bindSelf(self, function(_self, ...)
|
|
109
|
+
local result = implementation(self.value, ...)
|
|
110
|
+
local pass = result.pass == self.successCondition
|
|
111
|
+
|
|
112
|
+
assertLevel(pass, result.message, 3)
|
|
113
|
+
self:_resetModifiers()
|
|
114
|
+
return self
|
|
115
|
+
end)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
return self
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
function Expectation.__index(self, key)
|
|
122
|
+
-- Keys that don't do anything except improve readability
|
|
123
|
+
if SELF_KEYS[key] then
|
|
124
|
+
return self
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
-- Invert your assertion
|
|
128
|
+
if NEGATION_KEYS[key] then
|
|
129
|
+
local newExpectation = Expectation.new(self.value):extend(self.matchers)
|
|
130
|
+
newExpectation.successCondition = not self.successCondition
|
|
131
|
+
|
|
132
|
+
return newExpectation
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if self._boundMatchers[key] then
|
|
136
|
+
return self._boundMatchers[key]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
-- Fall back to methods provided by Expectation
|
|
140
|
+
return Expectation[key]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
--[[
|
|
144
|
+
Called by expectation terminators to reset modifiers in a statement.
|
|
145
|
+
|
|
146
|
+
This makes chains like:
|
|
147
|
+
|
|
148
|
+
expect(5)
|
|
149
|
+
.never.to.equal(6)
|
|
150
|
+
.to.equal(5)
|
|
151
|
+
|
|
152
|
+
Work as expected.
|
|
153
|
+
]]
|
|
154
|
+
function Expectation:_resetModifiers()
|
|
155
|
+
self.successCondition = true
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
--[[
|
|
159
|
+
Assert that the expectation value is the given type.
|
|
160
|
+
|
|
161
|
+
expect(5).to.be.a("number")
|
|
162
|
+
]]
|
|
163
|
+
function Expectation:a(typeName)
|
|
164
|
+
local result = (type(self.value) == typeName) == self.successCondition
|
|
165
|
+
|
|
166
|
+
local message = formatMessage(self.successCondition,
|
|
167
|
+
("Expected value of type %q, got value %q of type %s"):format(
|
|
168
|
+
typeName,
|
|
169
|
+
tostring(self.value),
|
|
170
|
+
type(self.value)
|
|
171
|
+
),
|
|
172
|
+
("Expected value not of type %q, got value %q of type %s"):format(
|
|
173
|
+
typeName,
|
|
174
|
+
tostring(self.value),
|
|
175
|
+
type(self.value)
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
assertLevel(result, message, 3)
|
|
180
|
+
self:_resetModifiers()
|
|
181
|
+
|
|
182
|
+
return self
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
-- Make alias public on class
|
|
186
|
+
Expectation.an = Expectation.a
|
|
187
|
+
|
|
188
|
+
--[[
|
|
189
|
+
Assert that our expectation value is truthy
|
|
190
|
+
]]
|
|
191
|
+
function Expectation:ok()
|
|
192
|
+
local result = (self.value ~= nil) == self.successCondition
|
|
193
|
+
|
|
194
|
+
local message = formatMessage(self.successCondition,
|
|
195
|
+
("Expected value %q to be non-nil"):format(
|
|
196
|
+
tostring(self.value)
|
|
197
|
+
),
|
|
198
|
+
("Expected value %q to be nil"):format(
|
|
199
|
+
tostring(self.value)
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
assertLevel(result, message, 3)
|
|
204
|
+
self:_resetModifiers()
|
|
205
|
+
|
|
206
|
+
return self
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
--[[
|
|
210
|
+
Assert that our expectation value is equal to another value
|
|
211
|
+
]]
|
|
212
|
+
function Expectation:equal(otherValue)
|
|
213
|
+
local result = (self.value == otherValue) == self.successCondition
|
|
214
|
+
|
|
215
|
+
local message = formatMessage(self.successCondition,
|
|
216
|
+
("Expected value %q (%s), got %q (%s) instead"):format(
|
|
217
|
+
tostring(otherValue),
|
|
218
|
+
type(otherValue),
|
|
219
|
+
tostring(self.value),
|
|
220
|
+
type(self.value)
|
|
221
|
+
),
|
|
222
|
+
("Expected anything but value %q (%s)"):format(
|
|
223
|
+
tostring(otherValue),
|
|
224
|
+
type(otherValue)
|
|
225
|
+
)
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
assertLevel(result, message, 3)
|
|
229
|
+
self:_resetModifiers()
|
|
230
|
+
|
|
231
|
+
return self
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
--[[
|
|
235
|
+
Assert that our expectation value is equal to another value within some
|
|
236
|
+
inclusive limit.
|
|
237
|
+
]]
|
|
238
|
+
function Expectation:near(otherValue, limit)
|
|
239
|
+
assert(type(self.value) == "number", "Expectation value must be a number to use 'near'")
|
|
240
|
+
assert(type(otherValue) == "number", "otherValue must be a number")
|
|
241
|
+
assert(type(limit) == "number" or limit == nil, "limit must be a number or nil")
|
|
242
|
+
|
|
243
|
+
limit = limit or 1e-7
|
|
244
|
+
|
|
245
|
+
local result = (math.abs(self.value - otherValue) <= limit) == self.successCondition
|
|
246
|
+
|
|
247
|
+
local message = formatMessage(self.successCondition,
|
|
248
|
+
("Expected value to be near %f (within %f) but got %f instead"):format(
|
|
249
|
+
otherValue,
|
|
250
|
+
limit,
|
|
251
|
+
self.value
|
|
252
|
+
),
|
|
253
|
+
("Expected value to not be near %f (within %f) but got %f instead"):format(
|
|
254
|
+
otherValue,
|
|
255
|
+
limit,
|
|
256
|
+
self.value
|
|
257
|
+
)
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
assertLevel(result, message, 3)
|
|
261
|
+
self:_resetModifiers()
|
|
262
|
+
|
|
263
|
+
return self
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
--[[
|
|
267
|
+
Assert that our functoid expectation value throws an error when called.
|
|
268
|
+
An optional error message can be passed to assert that the error message
|
|
269
|
+
contains the given value.
|
|
270
|
+
]]
|
|
271
|
+
function Expectation:throw(messageSubstring)
|
|
272
|
+
local ok, err = pcall(self.value)
|
|
273
|
+
local result = ok ~= self.successCondition
|
|
274
|
+
|
|
275
|
+
if messageSubstring and not ok then
|
|
276
|
+
if self.successCondition then
|
|
277
|
+
result = err:find(messageSubstring, 1, true) ~= nil
|
|
278
|
+
else
|
|
279
|
+
result = err:find(messageSubstring, 1, true) == nil
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
local message
|
|
284
|
+
|
|
285
|
+
if messageSubstring then
|
|
286
|
+
message = formatMessage(self.successCondition,
|
|
287
|
+
("Expected function to throw an error containing %q, but it %s"):format(
|
|
288
|
+
messageSubstring,
|
|
289
|
+
err and ("threw: %s"):format(err) or "did not throw."
|
|
290
|
+
),
|
|
291
|
+
("Expected function to never throw an error containing %q, but it threw: %s"):format(
|
|
292
|
+
messageSubstring,
|
|
293
|
+
tostring(err)
|
|
294
|
+
)
|
|
295
|
+
)
|
|
296
|
+
else
|
|
297
|
+
message = formatMessage(self.successCondition,
|
|
298
|
+
"Expected function to throw an error, but it did not throw.",
|
|
299
|
+
("Expected function to succeed, but it threw an error: %s"):format(
|
|
300
|
+
tostring(err)
|
|
301
|
+
)
|
|
302
|
+
)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
assertLevel(result, message, 3)
|
|
306
|
+
self:_resetModifiers()
|
|
307
|
+
|
|
308
|
+
return self
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
return Expectation
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
local Expectation = require(script.Parent.Expectation)
|
|
2
|
+
local checkMatcherNameCollisions = Expectation.checkMatcherNameCollisions
|
|
3
|
+
|
|
4
|
+
local function copy(t)
|
|
5
|
+
local result = {}
|
|
6
|
+
|
|
7
|
+
for key, value in pairs(t) do
|
|
8
|
+
result[key] = value
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
return result
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
local ExpectationContext = {}
|
|
15
|
+
ExpectationContext.__index = ExpectationContext
|
|
16
|
+
|
|
17
|
+
function ExpectationContext.new(parent)
|
|
18
|
+
local self = {
|
|
19
|
+
_extensions = parent and copy(parent._extensions) or {},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return setmetatable(self, ExpectationContext)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
function ExpectationContext:startExpectationChain(...)
|
|
26
|
+
return Expectation.new(...):extend(self._extensions)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
function ExpectationContext:extend(config)
|
|
30
|
+
for key, value in pairs(config) do
|
|
31
|
+
assert(self._extensions[key] == nil, string.format("Cannot reassign %q in expect.extend", key))
|
|
32
|
+
assert(checkMatcherNameCollisions(key), string.format("Cannot overwrite matcher %q; it already exists", key))
|
|
33
|
+
|
|
34
|
+
self._extensions[key] = value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
return ExpectationContext
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
local TestEnum = require(script.Parent.TestEnum)
|
|
2
|
+
|
|
3
|
+
local LifecycleHooks = {}
|
|
4
|
+
LifecycleHooks.__index = LifecycleHooks
|
|
5
|
+
|
|
6
|
+
function LifecycleHooks.new()
|
|
7
|
+
local self = {
|
|
8
|
+
_stack = {},
|
|
9
|
+
}
|
|
10
|
+
return setmetatable(self, LifecycleHooks)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
--[[
|
|
14
|
+
Returns an array of `beforeEach` hooks in FIFO order
|
|
15
|
+
]]
|
|
16
|
+
function LifecycleHooks:getBeforeEachHooks()
|
|
17
|
+
local key = TestEnum.NodeType.BeforeEach
|
|
18
|
+
local hooks = {}
|
|
19
|
+
|
|
20
|
+
for _, level in ipairs(self._stack) do
|
|
21
|
+
for _, hook in ipairs(level[key]) do
|
|
22
|
+
table.insert(hooks, hook)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return hooks
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
--[[
|
|
30
|
+
Returns an array of `afterEach` hooks in FILO order
|
|
31
|
+
]]
|
|
32
|
+
function LifecycleHooks:getAfterEachHooks()
|
|
33
|
+
local key = TestEnum.NodeType.AfterEach
|
|
34
|
+
local hooks = {}
|
|
35
|
+
|
|
36
|
+
for _, level in ipairs(self._stack) do
|
|
37
|
+
for _, hook in ipairs(level[key]) do
|
|
38
|
+
table.insert(hooks, 1, hook)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
return hooks
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
--[[
|
|
46
|
+
Pushes uncalled beforeAll and afterAll hooks back up the stack
|
|
47
|
+
]]
|
|
48
|
+
function LifecycleHooks:popHooks()
|
|
49
|
+
table.remove(self._stack, #self._stack)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
function LifecycleHooks:pushHooksFrom(planNode)
|
|
53
|
+
assert(planNode ~= nil)
|
|
54
|
+
|
|
55
|
+
table.insert(self._stack, {
|
|
56
|
+
[TestEnum.NodeType.BeforeAll] = self:_getHooksOfType(planNode.children, TestEnum.NodeType.BeforeAll),
|
|
57
|
+
[TestEnum.NodeType.AfterAll] = self:_getHooksOfType(planNode.children, TestEnum.NodeType.AfterAll),
|
|
58
|
+
[TestEnum.NodeType.BeforeEach] = self:_getHooksOfType(planNode.children, TestEnum.NodeType.BeforeEach),
|
|
59
|
+
[TestEnum.NodeType.AfterEach] = self:_getHooksOfType(planNode.children, TestEnum.NodeType.AfterEach),
|
|
60
|
+
})
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
--[[
|
|
64
|
+
Get the beforeAll hooks from the current level.
|
|
65
|
+
]]
|
|
66
|
+
function LifecycleHooks:getBeforeAllHooks()
|
|
67
|
+
return self._stack[#self._stack][TestEnum.NodeType.BeforeAll]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
--[[
|
|
71
|
+
Get the afterAll hooks from the current level.
|
|
72
|
+
]]
|
|
73
|
+
function LifecycleHooks:getAfterAllHooks()
|
|
74
|
+
return self._stack[#self._stack][TestEnum.NodeType.AfterAll]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
function LifecycleHooks:_getHooksOfType(nodes, key)
|
|
78
|
+
local hooks = {}
|
|
79
|
+
|
|
80
|
+
for _, node in ipairs(nodes) do
|
|
81
|
+
if node.type == key then
|
|
82
|
+
table.insert(hooks, node.callback)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
return hooks
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
return LifecycleHooks
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
local TestService = game:GetService("TestService")
|
|
2
|
+
|
|
3
|
+
local TestEnum = require(script.Parent.Parent.TestEnum)
|
|
4
|
+
|
|
5
|
+
local TeamCityReporter = {}
|
|
6
|
+
|
|
7
|
+
local function teamCityEscape(str)
|
|
8
|
+
str = string.gsub(str, "([]|'[])","|%1")
|
|
9
|
+
str = string.gsub(str, "\r", "|r")
|
|
10
|
+
str = string.gsub(str, "\n", "|n")
|
|
11
|
+
return str
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
local function teamCityEnterSuite(suiteName)
|
|
15
|
+
return string.format("##teamcity[testSuiteStarted name='%s']", teamCityEscape(suiteName))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
local function teamCityLeaveSuite(suiteName)
|
|
19
|
+
return string.format("##teamcity[testSuiteFinished name='%s']", teamCityEscape(suiteName))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
local function teamCityEnterCase(caseName)
|
|
23
|
+
return string.format("##teamcity[testStarted name='%s']", teamCityEscape(caseName))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
local function teamCityLeaveCase(caseName)
|
|
27
|
+
return string.format("##teamcity[testFinished name='%s']", teamCityEscape(caseName))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
local function teamCityFailCase(caseName, errorMessage)
|
|
31
|
+
return string.format("##teamcity[testFailed name='%s' message='%s']",
|
|
32
|
+
teamCityEscape(caseName), teamCityEscape(errorMessage))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
local function reportNode(node, buffer, level)
|
|
36
|
+
buffer = buffer or {}
|
|
37
|
+
level = level or 0
|
|
38
|
+
if node.status == TestEnum.TestStatus.Skipped then
|
|
39
|
+
return buffer
|
|
40
|
+
end
|
|
41
|
+
if node.planNode.type == TestEnum.NodeType.Describe then
|
|
42
|
+
table.insert(buffer, teamCityEnterSuite(node.planNode.phrase))
|
|
43
|
+
for _, child in ipairs(node.children) do
|
|
44
|
+
reportNode(child, buffer, level + 1)
|
|
45
|
+
end
|
|
46
|
+
table.insert(buffer, teamCityLeaveSuite(node.planNode.phrase))
|
|
47
|
+
else
|
|
48
|
+
table.insert(buffer, teamCityEnterCase(node.planNode.phrase))
|
|
49
|
+
if node.status == TestEnum.TestStatus.Failure then
|
|
50
|
+
table.insert(buffer, teamCityFailCase(node.planNode.phrase, table.concat(node.errors,"\n")))
|
|
51
|
+
end
|
|
52
|
+
table.insert(buffer, teamCityLeaveCase(node.planNode.phrase))
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
local function reportRoot(node)
|
|
57
|
+
local buffer = {}
|
|
58
|
+
|
|
59
|
+
for _, child in ipairs(node.children) do
|
|
60
|
+
reportNode(child, buffer, 0)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
return buffer
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
local function report(root)
|
|
67
|
+
local buffer = reportRoot(root)
|
|
68
|
+
|
|
69
|
+
return table.concat(buffer, "\n")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
function TeamCityReporter.report(results)
|
|
73
|
+
local resultBuffer = {
|
|
74
|
+
"Test results:",
|
|
75
|
+
report(results),
|
|
76
|
+
("%d passed, %d failed, %d skipped"):format(
|
|
77
|
+
results.successCount,
|
|
78
|
+
results.failureCount,
|
|
79
|
+
results.skippedCount
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
print(table.concat(resultBuffer, "\n"))
|
|
84
|
+
|
|
85
|
+
if results.failureCount > 0 then
|
|
86
|
+
print(("%d test nodes reported failures."):format(results.failureCount))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
if #results.errors > 0 then
|
|
90
|
+
print("Errors reported by tests:")
|
|
91
|
+
print("")
|
|
92
|
+
|
|
93
|
+
for _, message in ipairs(results.errors) do
|
|
94
|
+
TestService:Error(message)
|
|
95
|
+
|
|
96
|
+
-- Insert a blank line after each error
|
|
97
|
+
print("")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
return TeamCityReporter
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
The TextReporter uses the results from a completed test to output text to
|
|
3
|
+
standard output and TestService.
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local TestService = game:GetService("TestService")
|
|
7
|
+
|
|
8
|
+
local TestEnum = require(script.Parent.Parent.TestEnum)
|
|
9
|
+
|
|
10
|
+
local INDENT = (" "):rep(3)
|
|
11
|
+
local STATUS_SYMBOLS = {
|
|
12
|
+
[TestEnum.TestStatus.Success] = "+",
|
|
13
|
+
[TestEnum.TestStatus.Failure] = "-",
|
|
14
|
+
[TestEnum.TestStatus.Skipped] = "~"
|
|
15
|
+
}
|
|
16
|
+
local UNKNOWN_STATUS_SYMBOL = "?"
|
|
17
|
+
|
|
18
|
+
local TextReporter = {}
|
|
19
|
+
|
|
20
|
+
local function compareNodes(a, b)
|
|
21
|
+
return a.planNode.phrase:lower() < b.planNode.phrase:lower()
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
local function reportNode(node, buffer, level)
|
|
25
|
+
buffer = buffer or {}
|
|
26
|
+
level = level or 0
|
|
27
|
+
|
|
28
|
+
if node.status == TestEnum.TestStatus.Skipped then
|
|
29
|
+
return buffer
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
local line
|
|
33
|
+
|
|
34
|
+
if node.status then
|
|
35
|
+
local symbol = STATUS_SYMBOLS[node.status] or UNKNOWN_STATUS_SYMBOL
|
|
36
|
+
|
|
37
|
+
line = ("%s[%s] %s"):format(
|
|
38
|
+
INDENT:rep(level),
|
|
39
|
+
symbol,
|
|
40
|
+
node.planNode.phrase
|
|
41
|
+
)
|
|
42
|
+
else
|
|
43
|
+
line = ("%s%s"):format(
|
|
44
|
+
INDENT:rep(level),
|
|
45
|
+
node.planNode.phrase
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
table.insert(buffer, line)
|
|
50
|
+
table.sort(node.children, compareNodes)
|
|
51
|
+
|
|
52
|
+
for _, child in ipairs(node.children) do
|
|
53
|
+
reportNode(child, buffer, level + 1)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return buffer
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
local function reportRoot(node)
|
|
60
|
+
local buffer = {}
|
|
61
|
+
table.sort(node.children, compareNodes)
|
|
62
|
+
|
|
63
|
+
for _, child in ipairs(node.children) do
|
|
64
|
+
reportNode(child, buffer, 0)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return buffer
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
local function report(root)
|
|
71
|
+
local buffer = reportRoot(root)
|
|
72
|
+
|
|
73
|
+
return table.concat(buffer, "\n")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
function TextReporter.report(results)
|
|
77
|
+
local resultBuffer = {
|
|
78
|
+
"Test results:",
|
|
79
|
+
report(results),
|
|
80
|
+
("%d passed, %d failed, %d skipped"):format(
|
|
81
|
+
results.successCount,
|
|
82
|
+
results.failureCount,
|
|
83
|
+
results.skippedCount
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
print(table.concat(resultBuffer, "\n"))
|
|
88
|
+
|
|
89
|
+
if results.failureCount > 0 then
|
|
90
|
+
print(("%d test nodes reported failures."):format(results.failureCount))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
if #results.errors > 0 then
|
|
94
|
+
print("Errors reported by tests:")
|
|
95
|
+
print("")
|
|
96
|
+
|
|
97
|
+
for _, message in ipairs(results.errors) do
|
|
98
|
+
TestService:Error(message)
|
|
99
|
+
|
|
100
|
+
-- Insert a blank line after each error
|
|
101
|
+
print("")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
return TextReporter
|