tests/ops: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:51:09 -05:00
1 parent 9d80ee11b9
commit 75ddfb4068
5 files changed
+7 -58

No files matched your search

+1 -10
View File
@@ -1,6 +1,4 @@
-- ops/AudioOps tests: toAudio from a Decoder, gain / gainDb / normalize, peak / RMS of known signals, remix matrices
-- (5.1 -> stereo -> mono, mono -> stereo / 5.1), resample through codecs/audio/Resample, trim, concat and mix with rate /
-- channel conversion, fades, bad arguments (Err.ARG, never a throw), and the F.ops facade.
-- ops/AudioOps tests on known signals.
local T = require("@tests/T")
local AudioOps = require("@rosetta/ops/AudioOps")
local Types = require("@rosetta/Types")
@@ -31,7 +29,6 @@ local sine = audio(8000, 2, 8000, function(f, c)
return (if c == 0 then 0.5 else 0.25) * math.sin(2 * math.pi * 440 * f / 8000)
end)
-- toAudio
do
local dec = Pcm.audioDecoder(sine)
local a = AudioOps.toAudio(dec) :: Types.Audio
@@ -41,7 +38,6 @@ do
t:check(e2 and e2.code == Err.LIMIT, "maxFrames -> LIMIT")
end
-- levels
do
local p, per = AudioOps.peak(sine)
t:check(near(p :: number, 0.5, 1e-3) and near((per :: any)[2], 0.25, 1e-3), "peak")
@@ -57,7 +53,6 @@ do
t:check(z and z.frames == 10, "normalize silence")
end
-- channels
do
-- 5.1 (WAVE order FL FR C LFE BL BR) with distinct constants
local five = audio(8000, 6, 4, function(_, c)
@@ -81,7 +76,6 @@ do
t:check(e and e.code == Err.ARG, "downmix to more channels: ARG")
end
-- time
do
local r = AudioOps.resample(sine, 16000) :: Types.Audio
t:check(r.sampleRate == 16000 and r.frames == 16000, "resample 8 -> 16 kHz")
@@ -108,7 +102,6 @@ do
t:check(at(fd, 0, 0) == 0 and near(at(fd, 2000, 0), at(sine, 2000, 0) * 0.5, 1e-6) and near(at(fd, 7999, 0), 0), "fades")
end
-- bad arguments: Err.ARG, never a throw
do
local junk: { any } = { nil, 5, "x", {}, { kind = "audio" }, Types.Image.new(2, 2) }
local calls = {
@@ -134,7 +127,6 @@ do
t:check(AudioOps.remix(sine, 0) == nil, "zero channels")
end
-- the F.ops facade
do
t:check(F.ops.audio == AudioOps, "F.ops.audio")
t:check(F.ops.image ~= nil and type(F.ops.image.resize) == "function", "F.ops.image")
@@ -147,5 +139,4 @@ do
t:check(F.ops.nothing == nil, "unknown ops: nil")
end
-- (no decoder here: the no-throw pass is the bad-arguments block above)
t:done()