-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.lua
3341 lines (3030 loc) · 126 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- $Id$
--[=[
TODO:
More comments
More documentation
]=]
--local path = (... .. "/"):gsub("\\", "/") -- Needed for Cybeloras to run this properly
local path = ""
local function escape_char(c)
return ("\\%03d"):format(c:byte())
end
local function table_len(t)
for i = 1, #t do
if t[i] == nil then
return i-1
end
end
return #t
end
function pprint(...)
print(ptostring(...))
end
local function key_sort(alpha, bravo)
local type_alpha, type_bravo = type(alpha), type(bravo)
if type_alpha ~= type_bravo then
return type_alpha < type_bravo
end
if type_alpha == "string" then
return alpha:lower() < bravo:lower()
elseif type_alpha == "number" then
return alpha < bravo
elseif type_alpha == "table" then
return tostring(alpha) < tostring(bravo)
else
return false
end
end
local preserved = {
["nil"] = true,
["true"] = true,
["false"] = true,
}
local first_ptostring = true
function ptostring(...)
local t = {}
for i = 1, select('#', ...) do
if i > 1 then
t[#t+1] = ",\t"
end
local v = select(i, ...)
if type(v) == "string" then
t[#t+1] = (("%q"):format(v):gsub("\\\010", "\\n"):gsub("[\001-\031\128-\255]", escape_char))
elseif type(v) == "table" then
t[#t+1] = "{ "
local keys = {}
for a in pairs(v) do
keys[#keys+1] = a
end
table.sort(keys, key_sort)
local first = true
for _,a in ipairs(keys) do
local b = v[a]
if first then
first = nil
else
t[#t+1] = ", "
end
if type(a) ~= "number" or a < 1 or a > table_len(v) then
if type(a) == "string" and a:match("^[a-zA-Z_][a-zA-Z_0-9]*$") and not preserved[a] then
t[#t+1] = a
t[#t+1] = " = "
else
t[#t+1] = "["
t[#t+1] = ptostring(a)
t[#t+1] = "] = "
end
end
t[#t+1] = ptostring(b)
end
if first then
t[#t] = "{}"
else
t[#t+1] = " }"
end
else
t[#t+1] = tostring(v)
end
end
return table.concat(t)
end
local function is_equal(alpha, bravo)
if type(alpha) ~= type(bravo) then
return false
end
if type(alpha) == "number" then
return alpha == bravo or tostring(alpha) == tostring(bravo) or math.abs(alpha - bravo) < 1e-15
elseif type(alpha) ~= "table" then
return alpha == bravo
end
local num = 0
for k,v in pairs(alpha) do
num = num + 1
if not is_equal(v, bravo[k]) then
return false
end
end
for k,v in pairs(bravo) do
num = num - 1
end
if num ~= 0 then
return false
end
return true
end
local errors_raised = 0
function geterrorhandler()
return function(err)
errors_raised = errors_raised + 1
print(debug.traceback(err, 2))
os.exit()
end
end
function assert_equal(alpha, bravo)
if not is_equal(alpha, bravo) then
error(("Assertion failed: %s == %s"):format(ptostring(alpha), ptostring(bravo)), 2)
end
end
if not DogTag_Test_SecondTime then
local function CreateFontString(parent, name, layer)
local fs = {
[0] = newproxy(), -- fake userdata
}
function fs:GetObjectType()
return "FontString"
end
local text
function fs:SetText(x)
text = x
end
function fs:GetText()
return text
end
local alpha = 1
function fs:SetAlpha(a)
alpha = a
end
function fs:GetAlpha()
return alpha
end
local fontObject
function fs:SetFontObject(object)
fontObject = object
end
function fs:GetFontObject()
return fontObject
end
local fontName, fontSize, fontOutline = "Fritz", 14, ""
function fs:GetFont()
return fontName, fontSize, fontOutline
end
function fs:SetFont(a, b, c)
fontName, fontSize, fontOutline = a, b, c or ''
end
return fs
end
local frames = {}
local frameRegisteredEvents = {}
local ALL_EVENTS = newproxy()
function CreateFrame(frameType, ...)
local frame = {
[0] = newproxy(), -- fake userdata
}
frames[frame] = true
function frame:GetObjectType()
return frameType
end
function frame:GetFrameType()
return frameType
end
local scripts = {}
function frame:SetScript(script, func)
scripts[script] = func
end
function frame:GetScript(script)
return scripts[script]
end
local events = {}
frameRegisteredEvents[frame] = events
function frame:RegisterEvent(event)
events[event] = true
end
function frame:UnregisterEvent(event)
events[event] = nil
end
function frame:UnregisterAllEvents()
for event in pairs(events) do
events[event] = nil
end
end
function frame:RegisterAllEvents()
events[ALL_EVENTS] = true
end
function frame:CreateFontString(...)
return CreateFontString(frame, ...)
end
local isShown = 1
function frame:Show()
isShown = 1
end
function frame:Hide()
isShown = nil
end
function frame:IsShown()
return isShown
end
if frameType == "GameTooltip" then
local owner
function frame:SetOwner(f)
owner = f
end
function frame:IsOwned(f)
return owner == f
end
local fsLeft, fsRight = {}, {}
function frame:AddFontStrings(f1, f2)
fsLeft[#fsLeft+1] = f1
fsRight[#fsRight+1] = f2
end
end
return frame
end
local currentTime = 1e5 -- initial time
function GetTime()
return math.floor(currentTime*1000 + 0.5) / 1000
end
function FireOnUpdate(elapsed)
if not elapsed then
elapsed = 1
end
currentTime = currentTime + elapsed
for frame in pairs(frames) do
local OnUpdate = frame:GetScript("OnUpdate")
if OnUpdate and frame:IsShown() then
OnUpdate(frame, elapsed)
end
end
end
function FireEvent(event, ...)
for frame in pairs(frames) do
if frameRegisteredEvents[frame][event] or frameRegisteredEvents[frame][ALL_EVENTS] then
local OnEvent = frame:GetScript("OnEvent")
if OnEvent then
OnEvent(frame, event, ...)
end
end
end
end
end
RAID_CLASS_COLORS = {
DRUID = { r = 1, g = 0.49, b = 0.04, },
HUNTER = { r = 0.67, g = 0.83, b = 0.45 },
MAGE = { r = 0.41, g = 0.8, b = 0.41 },
PALADIN = { r = 0.96, g = 0.55, b = 0.73 },
PRIEST = { r = 1, g = 1, b = 1 },
ROGUE = { r = 1, g = 0.96, b = 0.41 },
SHAMAN = { r = 0.14, g = 0.35, b = 1 },
WARLOCK = { r = 0.58, g = 0.51, b = 0.79 },
WARRIOR = { r = 0.78, g = 0.61, b = 0.43 },
MONK = { r = 0.0, g = 1.00 , b = 0.59 },
}
local GetMouseFocus_data = nil
function GetMouseFocus()
return GetMouseFocus_data
end
local IsAltKeyDown_data = nil
function IsAltKeyDown()
return IsAltKeyDown_data
end
local IsShiftKeyDown_data = nil
function IsShiftKeyDown()
return IsShiftKeyDown_data
end
local IsControlKeyDown_data = nil
function IsControlKeyDown()
return IsControlKeyDown_data
end
function InCombatLockdown()
return false
end
function LoadAddOn()
end
DogTag_DEBUG = true
DAYS = "Days";
--DAYS_P1 = "Days";
DAYS_ABBR = "%d Days";
--DAYS_ABBR_P1 = "Days";
DAY_ONELETTER_ABBR = "%d d";
HOURS = "Hours";
--HOURS_P1 = "Hours";
HOURS_ABBR = "%d Hr";
--HOURS_ABBR_P1 = "Hrs";
HOUR_ONELETTER_ABBR = "%d h";
MINUTES = "Minutes"; -- Minutes of time
--MINUTES_P1 = "Minutes";
MINUTES_ABBR = "%d Min";
--MINUTES_ABBR_P1 = "Mins";
MINUTE_ONELETTER_ABBR = "%d m";
SECONDS = "Seconds"; -- Seconds of time
--SECONDS_P1 = "Seconds";
SECONDS_ABBR = "%d Sec";
--SECONDS_ABBR_P1 = "Secs";
SECOND_ONELETTER_ABBR = "%d s";
dofile(path .. "LibStub/LibStub.lua")
dofile(path .. "Localization/enUS.lua")
dofile(path .. "Helpers.lua")
dofile(path .. "LibDogTag-3.0.lua")
dofile(path .. "Parser.lua")
dofile(path .. "Compiler.lua")
dofile(path .. "Events.lua")
dofile(path .. "Categories/Math.lua")
dofile(path .. "Categories/Misc.lua")
dofile(path .. "Categories/Operators.lua")
dofile(path .. "Categories/TextManip.lua")
dofile(path .. "Cleanup.lua")
local DogTag = LibStub("LibDogTag-3.0")
local getPoolNum, setPoolNum = DogTag.getPoolNum, DogTag.setPoolNum
local parse = DogTag.parse
local standardize = DogTag.standardize
local function assert_table_usage(func, tableChange)
local previousPoolNum = getPoolNum()
func()
local afterPoolNum = getPoolNum()
local actualChange = afterPoolNum-previousPoolNum
if tableChange ~= actualChange then
-- error(("Unexpected table usage: %d instead of expected %d"):format(actualChange, tableChange), 2)
end
end
local function countTables(t)
if type(t) ~= "table" then
return 0
end
local n = 1
for k, v in pairs(t) do
n = n + countTables(k) + countTables(v)
end
return n
end
local function deepCopy(t)
if type(t) ~= "table" then
return t
end
local x = {}
for k,v in pairs(t) do
x[k] = deepCopy(v)
end
return x
end
local old_parse = parse
function parse(arg)
local start = DogTag.getPoolNum()
local ret = old_parse(arg)
local finish = DogTag.getPoolNum()
local change = finish - start
local num_tables = countTables(ret)
if change ~= num_tables then
error(("Unknown table usage: %d instead of %d"):format(change, num_tables), 2)
end
local r = deepCopy(ret)
DogTag.deepDel(ret)
return r
end
local old_standardize = standardize
function standardize(arg)
local realStart = DogTag.getPoolNum()
local start = realStart - countTables(arg)
local ret = old_standardize(arg)
local finish = DogTag.getPoolNum()
local change = finish - start
local num_tables = countTables(ret)
if change ~= num_tables then
error(("Unknown table usage: %d instead of %d"):format(change, num_tables), 2)
end
DogTag.setPoolNum(realStart)
return ret
end
DogTag:Evaluate("")
local function tuple(...)
local x = { ... }
local n = select('#', ...)
return function()
return unpack(x, 1, n)
end
end
local old_DogTag_Evaluate = DogTag.Evaluate
function DogTag:Evaluate(...)
local start = DogTag.getPoolNum()
local rets = tuple(old_DogTag_Evaluate(self, ...))
local finish = DogTag.getPoolNum()
local change = finish - start
if change ~= 0 then
-- error(("Unknown table usage: %d instead of %d"):format(change, 0), 2)
end
return rets()
end
local old_DogTag_CleanCode = DogTag.CleanCode
function DogTag:CleanCode(...)
local start = DogTag.getPoolNum()
local ret = old_DogTag_CleanCode(self, ...)
local finish = DogTag.getPoolNum()
local change = finish - start
if change ~= 0 then
error(("Unknown table usage: %d instead of %d"):format(change, 0), 2)
end
return ret
end
DogTag:AddTag("Base", "One", {
code = function() return 1 end,
ret = "number",
doc = "Return the number 1",
example = '[One] => "1"',
category = "Testing"
})
DogTag:AddTag("Base", "StaticOne", {
code = function() return 1 end,
ret = "number",
static = true,
doc = "Return the number 1",
example = '[One] => "1"',
category = "Testing"
})
DogTag:AddTag("Base", "Two", {
code = function() return 2 end,
ret = "number",
doc = "Return the number 2",
example = '[Two] => "2"',
category = "Testing"
})
DogTag:AddTag("Base", "FakeOne", {
code = function() return 100 end,
ret = "number",
doc = "Return the number 100",
example = '[FakeOne] => "100"',
category = "Testing"
})
DogTag:AddTag("Base", "PlusOne", {
code = function(number)
return number + 1
end,
arg = {
'number', 'number', "@req"
},
ret = "number",
static = true,
doc = "Return the number 1",
example = '[One] => "1"',
category = "Testing"
})
DogTag:AddTag("Base", "Subtract", {
code = function(left, right)
return left - right
end,
arg = {
'left', 'number', "@req",
'right', 'number', "@req"
},
ret = "number",
doc = "Subtract right from left",
example = '[AddNumbers(1, 2)] => "-1"',
category = "Testing"
})
DogTag:AddTag("Base", "SubtractFive", {
alias = [=[Subtract(number, 5)]=],
arg = {
'number', 'number', '@req',
},
doc = "Subtract 5 from number",
example = '[SubtractFive(10)] => "5"',
category = "Testing",
})
DogTag:AddTag("Base", "SubtractFromFive", {
alias = [=[Subtract(right=number, left=5)]=],
arg = {
'number', 'number', '@req',
},
doc = "Subtract number from 5",
example = '[SubtractFromFive(10)] => "-5"; [SubtractFromFive] => "5"',
category = "Testing",
})
DogTag:AddTag("Base", "ReverseSubtract", {
alias = [=[Subtract(right, left)]=],
arg = {
'left', 'number', "@req",
'right', 'number', "@req"
},
ret = "number",
doc = "Subtract left from right",
example = '[ReverseSubtract(1, 2)] => "1"',
category = "Testing"
})
DogTag:AddTag("Base", "AbsAlias", {
alias = [=[number < 0 ? -number ! number]=],
arg = {
'number', 'number', "@req",
},
ret = "number",
doc = "Get the absolute value of number",
example = '[AbsAlias(5)] => "5"; [AbsAlias(-5)] => "5"',
category = "Testing"
})
local GlobalCheck_data = "Hello World"
DogTag:AddTag("Base", "GlobalCheck", {
code = function()
return GlobalCheck_data
end,
ret = "string;number;nil",
doc = "Return the results of testfunc",
example = '[GlobalCheck] => "Hello World"',
category = "Testing"
})
local myfunc_num = 0
function _G.myfunc()
myfunc_num = myfunc_num + 1
return myfunc_num
end
DogTag:AddTag("Base", "FunctionNumberCheck", {
code = function()
myfunc_num = myfunc_num + 1
return myfunc_num
end,
ret = "number;nil",
doc = "Return the results of myfunc",
example = '[FunctionNumberCheck] => "1"',
category = "Testing"
})
DogTag:AddTag("Base", "AbsoluteValue", {
code = function(number)
return math.abs(number)
end,
arg = {
'number', 'number', "@req",
},
ret = "number",
doc = "Get the absolute value of number",
example = '[AbsoluteValue(5)] => "5"; [AbsoluteValue(-5)] => "5"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckNumDefault", {
code = function(value)
return value
end,
arg = {
'value', 'number', 50
},
ret = "number",
doc = "Return the given argument or 50",
example = '[CheckStrDefault(1)] => "1"; [CheckStrDefault] => "50"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckStrDefault", {
code = function(value)
return value
end,
arg = {
'value', 'string', 'Value'
},
ret = "string",
doc = "Return the given argument or value",
example = '[CheckStrDefault(1)] => "1"; [CheckStrDefault] => "Value"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckNilDefault", {
code = function(value)
return value
end,
arg = {
'value', 'nil;number', false
},
ret = "nil;number",
doc = "Return the given argument or nil",
example = '[CheckNilDefault(1)] => "1"; [CheckNilDefault] => ""',
category = "Testing"
})
DogTag:AddTag("Base", "CheckNumTuple", {
code = function(...)
return ("-"):join(...)
end,
arg = {
'...', 'tuple-number', false
},
ret = "string",
doc = "Join ... separated by dashes",
example = '[CheckNumTuple(1)] => "1"; [CheckNumTuple] => ""',
category = "Testing"
})
DogTag:AddTag("Base", "CheckBooleanTuple", {
code = function(...)
local num = 0
for i = 1, select('#', ...) do
assert(type(select(i, ...)) == "boolean")
if select(i, ...) then
num = num + 2^(i - 1)
end
end
return num
end,
arg = {
'...', 'tuple-boolean', false
},
ret = "number",
doc = "Return the integer formed by the bits of ...",
example = '[CheckBooleanTuple(true, false, true)] => "5"; [CheckBooleanTuple] => "0"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckNilTuple", {
code = function(...)
for i = 1, select('#', ...) do
assert(not select(i, ...))
end
return select('#', ...)
end,
arg = {
'...', 'tuple-nil', false
},
ret = "number",
doc = "Return the number of nils provided",
example = '[CheckNilTuple(nil, nil, nil)] => "3"; [CheckNilTuple] => "0"',
category = "Testing"
})
DogTag:AddTag("Base", "TupleAlias", {
alias = [=[CheckNumTuple(5, ...)]=],
arg = {
'...', 'tuple-number', false
},
doc = "Join ... separated by dashes",
example = '[TupleAlias(1)] => "1"; [TupleAlias] => ""',
category = "Testing"
})
DogTag:AddTag("Base", "OtherTupleAlias", {
alias = [=[Subtract(...)]=],
arg = {
'...', 'tuple-number', false
},
doc = "Subtract the values of ...",
example = '[OtherTupleAlias(5, 2)] => "3"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckAnotherNumTuple", {
code = function(...)
return math.max(0, ...)
end,
arg = {
'...', 'tuple-number', false
},
ret = "string",
doc = "Return the largest number of ...",
globals = 'math.max',
example = '[CheckAnotherNumTuple(1)] => "1"; [CheckAnotherNumTuple] => "0"',
category = "Testing"
})
DogTag:AddTag("Base", "CheckStrTuple", {
code = function(...)
local x = ''
for i = 1, select('#', ...) do
x = x .. select(i, ...):gsub('[aeiou]', 'y')
end
return x
end,
arg = {
'...', 'tuple-string', false
},
ret = "string",
doc = "Join ..., replacing vowels with 'y'",
example = '[CheckStrTuple("Hello")] => "Hylly"; [CheckStrTuple] => ""',
category = "Testing"
})
DogTag:AddTag("Base", "CheckAnyTuple", {
code = function(...)
local x = ''
for i = 1, select('#', ...) do
if i > 1 then
x = x .. ";"
end
x = x .. type(select(i, ...)) .. ":" .. tostring(select(i, ...))
end
return x
end,
arg = {
'...', 'tuple-string;number;nil', false
},
ret = "string",
})
DogTag:AddTag("Base", "Reverse", {
code = function(value)
return value:reverse()
end,
arg = {
'value', 'string', '@req'
},
ret = "string",
doc = "Reverse the characters in value",
example = '[Reverse(Hello)] => "olleH"',
category = "Testing",
})
DogTag:AddTag("Base", "OtherReverse", {
code = function(value)
if value ~= "Stuff" then
return value:reverse()
else
return "ffutS"
end
end,
arg = {
'value', 'string', '@req'
},
ret = "string",
doc = "Reverse the characters in value",
example = '[OtherReverse(Hello)] => "olleH"',
category = "Testing",
})
DogTag:AddTag("Base", "KwargAndTuple", {
code = function(value, ...)
local num = 0
for i = 1, select('#', ...) do
num = num + select(i, ...)
end
return value * num
end,
arg = {
'value', 'number', '@req',
'...', 'tuple-number', false
},
ret = 'number',
globals = 'math.max';
doc = "Return the maximum of ... multiplied by value",
example = '[KwargAndTuple(5, 1, 2, 3)] => "15"',
category = "Testing",
})
DogTag:AddTag("Base", "TupleAndKwarg", {
code = function(value, ...)
local num = 0
for i = 1, select('#', ...) do
num = num + select(i, ...)
end
return value * num
end,
arg = {
'...', 'tuple-number', false,
'value', 'number', '@req'
},
ret = 'number',
globals = 'math.max';
doc = "Return the maximum of ... multiplied by value",
example = '[KwargAndTuple(5, 1, 2, 3)] => "15"',
category = "Testing",
})
DogTag:AddTag("Base", "Type", {
code = function(value)
return type(value)
end,
arg = {
'value', 'number;nil;string', '@req'
},
ret = 'string',
doc = "Return the type of value",
example = '[Type(nil)] => "nil"; [Type("Hello")] => "string"; [Type(5)] => "number"',
category = "Testing",
})
DogTag:AddTag("Base", "BooleanToString", {
code = function(value)
return tostring(value)
end,
arg = {
'value', 'boolean', false
},
ret = 'string',
doc = "Return true or false",
example = '[BooleanToString(nil)] => "false"; [BooleanToString("Hello")] => "true"; [BooleanToString(5)] => "true"',
category = "Testing",
})
DogTag:AddTag("Base", "RetNil", {
code = function()
return nil
end,
arg = {
'value', 'nil;number;string', false
},
ret = 'nil',
doc = "Return nil",
example = '[RetNil] => ""; [RetNil(Anything)] => ""',
category = "Testing",
})
local GlobalCheckBoolean_data = true
DogTag:AddTag("Base", "GlobalCheckBoolean", {
code = function()
return GlobalCheckBoolean_data
end,
ret = 'boolean',
doc = "Return True or blank",
example = '[GlobalCheckBoolean] => ""; [GlobalCheckBoolean] => "True"',
category = "Testing",
})
DogTag:AddTag("Base", "ToString", {
code = function(value)
return '`' .. tostring(value or ''):reverse():reverse() .. '`'
end,
arg = {
'value', 'number;nil;string', '@req'
},
ret = 'string',
doc = "Return value surrounded by tickmarks",
example = '[ToString(nil)] => "``"; [ToString("Hello")] => "`Hello`"; [ToString(5)] => "`5`"',
category = "Testing",
})
local RetSame_types
DogTag:AddTag("Base", "RetSame", {
code = function(value)
return value
end,
arg = {
'value', 'number;nil;string', '@req'
},
ret = function(args)
RetSame_types = args.value.types
return args.value.types
end
})
DogTag:AddTag("Base", "OtherRetSame", {
code = function(value)
return value
end,
arg = {
'value', 'number;nil;string', '@req'
},
ret = 'number;nil;string'
})
DogTag:AddTag("Base", "DynamicCodeTest", {
code = function(args)
if args.value.isLiteral then
local value = args.value.value
return function()
return "literal, " .. tostring(value)
end
else
local value = args.value.value
local tag = value[1] == "tag" and value[2] or value[1]
return function()
return "dynamic, " .. tag
end
end
end,
dynamicCode = true,
arg = {
'value', 'number;nil;string', '@req'
},
ret = "string",
})
local BlizzEventTest_num = 0
DogTag:AddTag("Base", "BlizzEventTest", {
code = function(value)
BlizzEventTest_num = BlizzEventTest_num + 1
return BlizzEventTest_num
end,
arg = {
'value', 'string', "@req"
},
ret = "number",
events = "FAKE_BLIZZARD_EVENT#$value",
doc = "Return the results of BlizzEventTest_num after incrementing",
example = '[BlizzEventTest] => "1"',
category = "Testing"
})
local OtherBlizzEventTest_num = 0
DogTag:AddTag("Base", "OtherBlizzEventTest", {
code = function()
OtherBlizzEventTest_num = OtherBlizzEventTest_num + 1
return OtherBlizzEventTest_num
end,
ret = "number",
events = "OTHER_FAKE_BLIZZARD_EVENT",
doc = "Return the results of OtherBlizzEventTest_num after incrementing",
example = '[OtherBlizzEventTest] => "1"',
category = "Testing"
})
DoubleBlizzEventTest_num = 0
DogTag:AddTag("Base", "DoubleBlizzEventTest", {
code = function(alpha, bravo)
DoubleBlizzEventTest_num = DoubleBlizzEventTest_num + 1
return DoubleBlizzEventTest_num
end,
arg = {
'alpha', 'string', "@req",
'bravo', 'string', "@req",
},
ret = "number",
events = "DOUBLE_BLIZZARD_EVENT#$alpha;DOUBLE_BLIZZARD_EVENT#$bravo",
doc = "Return the results of BlizzEventTest_num after incrementing",
example = '[BlizzEventTest] => "1"',
category = "Testing"
})
local OtherDoubleBlizzEventTest = 0
DogTag:AddTag("Base", "OtherDoubleBlizzEventTest", {
code = function(value)
OtherDoubleBlizzEventTest_num = OtherDoubleBlizzEventTest_num + 1
return OtherDoubleBlizzEventTest_num
end,
arg = {
'alpha', 'string', "@req",
'bravo', 'string', "@req",
},
ret = "number",
events = "OTHER_DOUBLE_BLIZZARD_EVENT#$alpha#$bravo",
doc = "Return the results of OtherDoubleBlizzEventTest_num after incrementing",
example = '[OtherDoubleBlizzEventTest("alpha", "bravo")] => "1"',
category = "Testing"
})
local LibToProvideExtraFunctionality
DogTag:AddAddonFinder("Base", "LibStub", "LibToProvideExtraFunctionality", function(lib)