diff --git a/src/libs/replaygain.liq b/src/libs/replaygain.liq index dc3acd35b3..14d28a9f89 100644 --- a/src/libs/replaygain.liq +++ b/src/libs/replaygain.liq @@ -19,7 +19,9 @@ let file.replaygain = () # @flag hidden def file.replaygain.compute(~ratio=50., file_name) = _request = request.create(resolve_metadata=false, file_name) - if request.resolve(_request) then + if + request.resolve(_request) + then _source = source.replaygain.compute(request.once(_request)) source.drop(ratio=ratio, _source) _source.gain() @@ -32,13 +34,17 @@ end # @category Metadata # @param _metadata Metadata from which the ReplayGain should be extracted. def metadata.replaygain(_metadata) = - if list.assoc.mem("r128_track_gain", _metadata) then + if + list.assoc.mem("r128_track_gain", _metadata) + then try float_of_string(_metadata["r128_track_gain"]) / 256. catch _ do null() end - elsif list.assoc.mem("replaygain_track_gain", _metadata) then + elsif + list.assoc.mem("replaygain_track_gain", _metadata) + then replaygain_metadata = _metadata["replaygain_track_gain"] match = r/([+-]?\d*\.?\d*)/.exec(replaygain_metadata) try @@ -65,16 +71,33 @@ def replaces file.replaygain(~id=null(), ~compute=true, ~ratio=50., file_name) = _metadata = file.metadata(exclude=["replaygain_track_gain"], file_name) gain = metadata.replaygain(_metadata) - if gain != null() then - log.info(label=id, "Detected track replaygain #{gain} dB for #{file_name_quoted}.") + if + gain != null() + then + log.info( + label=id, + "Detected track replaygain #{gain} dB for #{file_name_quoted}." + ) gain - elsif compute then - log.info(label=id, "Computing replay gain for #{file_name_quoted}.") + elsif + compute + then + log.info( + label=id, + "Computing replay gain for #{file_name_quoted}." + ) start_time = time() gain = file.replaygain.compute(ratio=ratio, file_name) elapsed_time = time() - start_time - if gain != null() then - log.info(label=id, "Computed replay gain #{gain} dB for #{file_name_quoted} (time: #{elapsed_time} s).") + if + gain != null() + then + log.info( + label=id, + "Computed replay gain #{gain} dB for #{file_name_quoted} (time: #{ + elapsed_time + } s)." + ) end gain else @@ -93,8 +116,15 @@ end def enable_replaygain_metadata(~compute=true, ~ratio=50.) = def replaygain_metadata(~metadata=_, file_name) = gain = file.replaygain(compute=compute, ratio=ratio, file_name) - if gain != null() then - [("replaygain_track_gain", "#{null.get(gain)} dB")] + if + gain != null() + then + [ + ( + "replaygain_track_gain", + "#{null.get(gain)} dB" + ) + ] else [] end diff --git a/tests/failures/ctype.liq b/tests/failures/ctype.liq index 04c934a143..29d12ddb98 100755 --- a/tests/failures/ctype.liq +++ b/tests/failures/ctype.liq @@ -1,7 +1,7 @@ # Testing dynamic kind unification errors. s = mean(sine()) -def mkfilter(graph) +def mkfilter(graph) = x = ffmpeg.filter.audio.input(channels=2, graph, s) ffmpeg.filter.audio.output(graph, x) end diff --git a/tests/failures/error.liq b/tests/failures/error.liq index 7d8477fa15..f4992e8bf3 100755 --- a/tests/failures/error.liq +++ b/tests/failures/error.liq @@ -1,7 +1,9 @@ # Test uncaught errors. def f() = - error.raise("testing exceptions") + error.raise( + "testing exceptions" + ) end f() diff --git a/tests/failures/ref.liq b/tests/failures/ref.liq index 812fab9c8b..71a18dd52c 100755 --- a/tests/failures/ref.liq +++ b/tests/failures/ref.liq @@ -2,9 +2,13 @@ # Ensure that value restriction prevents the usual problems. -def id(x) = x end +def id(x) = + x +end -def incr(n) = n+1 end +def incr(n) = + n + 1 +end r = ref(id) r := incr diff --git a/tests/fixme/GH1170.liq b/tests/fixme/GH1170.liq index beda1f5e32..065c54e8c6 100755 --- a/tests/fixme/GH1170.liq +++ b/tests/fixme/GH1170.liq @@ -12,26 +12,24 @@ s = noise() s = chop(duration=20., s) -track_count = ref 0 +track_count = ref +0 def f(_) = track_count := !track_count + 1 + # Let's do 3 tracks here for security. - if !track_count > 2 then - test.pass() - end + if !track_count > 2 then test.pass() end end -s = on_track(f,s) +s = on_track(f, s) s = crossfade(s) -clock.assign_new(sync="none",[s]) +clock.assign_new(sync="none", [s]) def on_stop() = - if !track_count < 3 then - test.fail() - end + if !track_count < 3 then test.fail() end end output.dummy(on_stop=on_stop, fallible=true, s) diff --git a/tests/fixme/cross2.liq b/tests/fixme/cross2.liq index 519b0c137d..699bdc4c06 100755 --- a/tests/fixme/cross2.liq +++ b/tests/fixme/cross2.liq @@ -9,7 +9,7 @@ jingle = playlist("files/jingles") # id). The inference thus thinks that a.source has methods. And the function f # thus cannot be passed to cross because it is not general enough. -def f(a, b) +def f(a, b) = sequence([a.source, once(jingle), b.source]) end diff --git a/tests/fixme/cross3.liq b/tests/fixme/cross3.liq index f890bc3bd5..c7e38e519f 100755 --- a/tests/fixme/cross3.liq +++ b/tests/fixme/cross3.liq @@ -5,18 +5,18 @@ # Our main source. s = 3. -def once((s:float)) - s.{id = "bla"} +def once((s:float)) = + s.{id="bla"} end # Here, because of once, we infer that f should take as argument a source with # many methods (id, etc.). However, we use it with cross below, which takes a # function operating on undecorated sources. -def f(a) +def f(a) = ignore([once(2.), a]) end -def cross((f : (float) -> unit), s) +def cross((f:(float)->unit), s) = ignore(f) s end diff --git a/tests/fixme/sequence-1.liq b/tests/fixme/sequence-1.liq index 4e286d5cb1..6fc43836f3 100755 --- a/tests/fixme/sequence-1.liq +++ b/tests/fixme/sequence-1.liq @@ -25,17 +25,17 @@ s = once(sine(duration=1.)) # behavior at this point is to go back to seq2, which will notice that s has # become unavailable and end its track and cleanup s. (By then s will be free, # because seq1 will have also move away from it.) -test = fallback(track_sensitive=false, - [ delay(initial=true,0.5, - sequence(id="seq1",[s,fail()])), - sequence(id="seq2",[s,fail()]) ]) +test = + fallback( + track_sensitive=false, + [ + delay(initial=true, 0.5, sequence(id="seq1", [s, fail()])), + sequence(id="seq2", [s, fail()]) + ] + ) -def check() - if source.is_up(s) then - test.fail() - else - test.pass() - end +def check() = + if source.is_up(s) then test.fail() else test.pass() end end -output.dummy(fallback([test,on_track(fun(_)->check(),sine())])) +output.dummy(fallback([test, on_track(fun (_) -> check(), sine())])) diff --git a/tests/fixme/sequence-2.liq b/tests/fixme/sequence-2.liq index 1d0fb60274..cd31a976a7 100644 --- a/tests/fixme/sequence-2.liq +++ b/tests/fixme/sequence-2.liq @@ -17,20 +17,16 @@ # Create a fallible source. We use the experimental operator source.dynamic() # which is bit fragile for a test. -flag = ref true -thread.run(delay=1., { flag:=false }) +flag = ref(true) +thread.run(delay=1., {flag := false}) on = sine() off = fail() -s = source.dynamic({ if !flag then [on] else [off] end }) +s = source.dynamic({if !flag then [on] else [off] end}) -test = sequence([ s, fail() ]) +test = sequence([s, fail()]) -def check() - if source.is_up(s) then - test.fail() - else - test.pass() - end +def check() = + if source.is_up(s) then test.fail() else test.pass() end end -output.dummy(fallback([test,on_track(fun(_)->check(),sine())])) +output.dummy(fallback([test, on_track(fun (_) -> check(), sine())])) diff --git a/tests/language/encoders.liq b/tests/language/encoders.liq index 250040e3ef..057bde8410 100644 --- a/tests/language/encoders.liq +++ b/tests/language/encoders.liq @@ -1,10 +1,8 @@ def f() = def five_point_one(s) = - if false then - output.file(%ffmpeg(%audio(channel_layout=5.1)), "", s) - end + if false then output.file(%ffmpeg(%audio(channel_layout = 5.1)), "", s) end end - five_point_one((sine():source(audio=pcm(5.1)))) + five_point_one((sine() : source(audio=pcm(5.1)))) try enc = %wav(samplesize = 123456) @@ -12,36 +10,44 @@ def f() = if err.kind != "encoder" or - err.message != + + err.message != "invalid sample size" + then test.fail() end end try - let eval _ = "l = [%wav(channels=1), %wav(channels=2)]" + let eval _ = + "l = [%wav(channels=1), %wav(channels=2)]" test.fail() catch _ do () end try - let eval _ = "l = [%mp3(stereo), %wav(channels=1)]" + let eval _ = + "l = [%mp3(stereo), %wav(channels=1)]" test.fail() catch _ do () end try - let eval _ = "l = [(blank():source(audio=pcm(stereo))), (blank():source(audio=pcm(mono)))]" + let eval _ = + "l = [(blank():source(audio=pcm(stereo))), \ + (blank():source(audio=pcm(mono)))]" test.fail() catch _ do () end try - let eval _ = "l = [(blank():source(audio=pcm(mono))), (blank():source(audio=pcm(stereo)))]" + let eval _ = + "l = [(blank():source(audio=pcm(mono))), \ + (blank():source(audio=pcm(stereo)))]" test.fail() catch _ do () diff --git a/tests/language/replaygain.liq b/tests/language/replaygain.liq index 3ebb6b7263..901a7c9e96 100644 --- a/tests/language/replaygain.liq +++ b/tests/language/replaygain.liq @@ -3,34 +3,152 @@ def test_metadata_replaygain() = test.equals(metadata.replaygain([("r128_track_gain", "0")]), 0.) test.equals(metadata.replaygain([("r128_track_gain", "256")]), 1.) - test.equals(metadata.replaygain([("r128_track_gain", "32767")]), 32767./256.) - test.equals(metadata.replaygain([("r128_track_gain", "-32768")]), -32768./256.) + test.equals( + metadata.replaygain([("r128_track_gain", "32767")]), 32767. / 256. + ) + test.equals( + metadata.replaygain([("r128_track_gain", "-32768")]), -32768. / 256. + ) test.equals(metadata.replaygain([("r128_track_gain", "foo")]), null()) - test.equals(metadata.replaygain([("r128_track_gain", "0 foo")]), null()) + test.equals( + metadata.replaygain( + [ + ( + "r128_track_gain", + "0 foo" + ) + ] + ), + null() + ) test.equals(metadata.replaygain([("r128_track_gain", "")]), null()) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 dB")]), 1.) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 dB" + ) + ] + ), + 1. + ) test.equals(metadata.replaygain([("replaygain_track_gain", "1")]), 1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "-1 dB")]), -1.) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "-1 dB" + ) + ] + ), + -1. + ) test.equals(metadata.replaygain([("replaygain_track_gain", "-1")]), -1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "+0.424046 dB")]), 0.424046) - test.equals(metadata.replaygain([("replaygain_track_gain", "+0.424046")]), 0.424046) - test.equals(metadata.replaygain([("replaygain_track_gain", "-10.38500 dB")]), -10.38500) - test.equals(metadata.replaygain([("replaygain_track_gain", "-10.38500")]), -10.38500) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "+0.424046 dB" + ) + ] + ), + 0.424046 + ) + test.equals( + metadata.replaygain([("replaygain_track_gain", "+0.424046")]), 0.424046 + ) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "-10.38500 dB" + ) + ] + ), + -10.38500 + ) + test.equals( + metadata.replaygain([("replaygain_track_gain", "-10.38500")]), -10.38500 + ) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 dB")]), 1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 2 dB")]), 1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 db")]), 1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 DB")]), 1.) - test.equals(metadata.replaygain([("replaygain_track_gain", "1 foo")]), 1.) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 dB" + ) + ] + ), + 1. + ) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 2 dB" + ) + ] + ), + 1. + ) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 db" + ) + ] + ), + 1. + ) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 DB" + ) + ] + ), + 1. + ) + test.equals( + metadata.replaygain( + [ + ( + "replaygain_track_gain", + "1 foo" + ) + ] + ), + 1. + ) test.equals(metadata.replaygain([("replaygain_track_gain", "")]), null()) test.equals(metadata.replaygain([("replaygain_track_gain", "foo")]), null()) test.equals(metadata.replaygain([]), null()) - test.equals(metadata.replaygain([("r128_track_gain", "foo"), ("replaygain_track_gain", "1")]), null()) - test.equals(metadata.replaygain([("replaygain_track_gain", "1"), ("r128_track_gain", "foo")]), null()) + test.equals( + metadata.replaygain( + [("r128_track_gain", "foo"), ("replaygain_track_gain", "1")] + ), + null() + ) + test.equals( + metadata.replaygain( + [("replaygain_track_gain", "1"), ("r128_track_gain", "foo")] + ), + null() + ) test.pass() end diff --git a/tests/language/write_cover.liq b/tests/language/write_cover.liq index 9753418d25..12a696b456 100644 --- a/tests/language/write_cover.liq +++ b/tests/language/write_cover.liq @@ -2,7 +2,10 @@ settings.init.force_start := true target = argv(1) -png = string.base64.decode("iVBORw0KGgoAAAANSUhEUgAAAIAAAACAEAIAAAAczCrfAAAACXBIWXMAAAAAAAAAAQCEeRdzAAACoklEQVR4nO3E4UYYAACF0StJkiRJkiRJkiRJkiRJkiTJli1btmzZsmXLli3atGnTpk2bNm3atEmSJEmSJEmSJEmSJEmSJEnS9h73Oz+O9N/VFbPvurxg9l0XZ8y+6/yE2XedHTH7rtMDZt91ssfsu453mH3X0Raz7zrcYPZdB2vMvmt/hdl37S0x+67dBWbftTPH7Lu2Z5h919YUs+/anGD2XRtjzL5rfYTZd60NMfuu1QFm37Xyh9l3Lf9i9l1LP5h91+I3Zt+18IXZd81/YvZdcx+YfdfsO2bfNfOG2XdNv2L2XVMtzL5rspnZd000Mfuu8UZm3zXWwOy7RuuZfddIHbPvGq5l9l1DNcy+a7Ca2XcNVDH7rv4KZt/1t4zZd/WVMPuu30XMvqu3gNl3/cxj9l09Ocy+63sWs+/qzmD2XV/TmH1XVwqz7/qcxOy7OhOYfdfHOGbf1RHD7LveRzH7rvYIZt/1NozZd7WFMPuu10HMvqs1gNl3tVwy+64X58y+q/mU2Xc9O2b2XU2HzL7ryT6z72rcZfZdj7aZfVfDJrPverDO7LvqV5l9171lZt9Vt8jsu+7MM/uu2llm33Vrmtl31Uwy+64b48y+q3qU2XddG2b2XVWDzL6rsp/Zd1X0Mfuu8l5m31XWw+y7SruZfVdJF7PvKu5k9l1FHcy+q7Cd2XcVtDH7rvxWZt+V95LZd+U+Z/ZdOU+ZfVf2Y2bflfWQ2Xdl3mf2XRl3mX1X+m1m35V2k9l3pV5n9l0plcy+K7mc2XcllTL7rsRiZt+VUMjsu+LzmX1XXC6z74rNZvZdMZnMvis6ndl3RaUy+67IZGbfFZHI7LvC45l9V1gss+8KjWb2XSGRzL4rOJzZdwWFMvuuwGBm3xUQyOw7YOsfJwPDsnrI0ewAAAAASUVORK5CYII=") +png = + string.base64.decode( + "iVBORw0KGgoAAAANSUhEUgAAAIAAAACAEAIAAAAczCrfAAAACXBIWXMAAAAAAAAAAQCEeRdzAAACoklEQVR4nO3E4UYYAACF0StJkiRJkiRJkiRJkiRJkiTJli1btmzZsmXLli3atGnTpk2bNm3atEmSJEmSJEmSJEmSJEmSJEnS9h73Oz+O9N/VFbPvurxg9l0XZ8y+6/yE2XedHTH7rtMDZt91ssfsu453mH3X0Raz7zrcYPZdB2vMvmt/hdl37S0x+67dBWbftTPH7Lu2Z5h919YUs+/anGD2XRtjzL5rfYTZd60NMfuu1QFm37Xyh9l3Lf9i9l1LP5h91+I3Zt+18IXZd81/YvZdcx+YfdfsO2bfNfOG2XdNv2L2XVMtzL5rspnZd000Mfuu8UZm3zXWwOy7RuuZfddIHbPvGq5l9l1DNcy+a7Ca2XcNVDH7rv4KZt/1t4zZd/WVMPuu30XMvqu3gNl3/cxj9l09Ocy+63sWs+/qzmD2XV/TmH1XVwqz7/qcxOy7OhOYfdfHOGbf1RHD7LveRzH7rvYIZt/1NozZd7WFMPuu10HMvqs1gNl3tVwy+64X58y+q/mU2Xc9O2b2XU2HzL7ryT6z72rcZfZdj7aZfVfDJrPverDO7LvqV5l9171lZt9Vt8jsu+7MM/uu2llm33Vrmtl31Uwy+64b48y+q3qU2XddG2b2XVWDzL6rsp/Zd1X0Mfuu8l5m31XWw+y7SruZfVdJF7PvKu5k9l1FHcy+q7Cd2XcVtDH7rvxWZt+V95LZd+U+Z/ZdOU+ZfVf2Y2bflfWQ2Xdl3mf2XRl3mX1X+m1m35V2k9l3pV5n9l0plcy+K7mc2XcllTL7rsRiZt+VUMjsu+LzmX1XXC6z74rNZvZdMZnMvis6ndl3RaUy+67IZGbfFZHI7LvC45l9V1gss+8KjWb2XSGRzL4rOJzZdwWFMvuuwGBm3xUQyOw7YOsfJwPDsnrI0ewAAAAASUVORK5CYII=" + ) file.write(data=png, target) diff --git a/tests/media/multitrack.liq b/tests/media/multitrack.liq index 1357b0be08..86d8ca497c 100644 --- a/tests/media/multitrack.liq +++ b/tests/media/multitrack.liq @@ -61,7 +61,9 @@ def on_close(filename) = ojson = process.read( - "ffprobe -v quiet -print_format json -show_streams #{process.quote(filename)}" + "ffprobe -v quiet -print_format json -show_streams #{ + process.quote(filename) + }" ) let json.parse (parsed : diff --git a/tests/performance/erathostenes.liq b/tests/performance/erathostenes.liq index 405ae05a6d..fc9e60cb20 100755 --- a/tests/performance/erathostenes.liq +++ b/tests/performance/erathostenes.liq @@ -1,27 +1,39 @@ #!../../liquidsoap ../test.liq performance.liq -def erathostenes(n) - l = list.init(n-2, fun (i) -> i+2) +def erathostenes(n) = + l = list.init(n - 2, fun (i) -> i + 2) l = ref(l) p = ref([]) - while not list.is_empty(l()) do - i = list.hd(default=0, l()) - p := list.add(i, p()) - l := list.filter(fun (j) -> j mod i != 0, l()) + while + not list.is_empty(l()) + do + i = list.hd(default=0, l()) + p := list.add(i, p()) + l := list.filter(fun (j) -> j mod i != 0, l()) end list.rev(p()) end -time("Erathostenes (imperative)", {erathostenes(10000)}) +time( + "Erathostenes (imperative)", + {erathostenes(10000)} +) -def erathostenes(n) - def rec aux(p, l) - list.case(l, p, fun (i, l) -> aux(list.add(i, p), list.filter(fun (j) -> j mod i != 0, l))) +def erathostenes(n) = + def rec aux(p, l) = + list.case( + l, + p, + fun (i, l) -> aux(list.add(i, p), list.filter(fun (j) -> j mod i != 0, l)) + ) end - l = list.init(n-2, fun (i) -> i+2) + l = list.init(n - 2, fun (i) -> i + 2) list.rev(aux([], l)) end -time("Erathostenes (recursive)", {erathostenes(10000)}) +time( + "Erathostenes (recursive)", + {erathostenes(10000)} +) exit(0) diff --git a/tests/performance/memory.liq b/tests/performance/memory.liq index 70aa87c0b0..bc59fb37dc 100755 --- a/tests/performance/memory.liq +++ b/tests/performance/memory.liq @@ -1,6 +1,15 @@ #!/usr/bin/env -S ../../liquidsoap ../test.liq performance.liq m = runtime.memory().process_managed_memory -print("Managed memory: #{m} octets") -test.metric(category="memory", name="Process managed memory", value=float(m) / (1024. * 1024.), unit="Mio", min=0.) +print( + "Managed memory: #{m} octets" +) +test.metric( + category="memory", + name= + "Process managed memory", + value=float(m) / (1024. * 1024.), + unit="Mio", + min=0. +) test.pass() diff --git a/tests/performance/performance.liq b/tests/performance/performance.liq index 092b079ac8..e42ff5af1c 100644 --- a/tests/performance/performance.liq +++ b/tests/performance/performance.liq @@ -1,12 +1,16 @@ profile = (environment.get("LIQ_PROFILE") != "") -def time(name, f) +def time(name, f) = if profile then profiler.enable() end - print("Computing #{name}...") + print( + "Computing #{name}..." + ) t = time() f() t = time() - t - print("Computing #{name} took #{string.float(decimal_places=2,t)} seconds.") + print( + "Computing #{name} took #{string.float(decimal_places=2, t)} seconds." + ) test.metric(category="performance", name=name, value=t, unit="s", min=0.) if profile then print(profiler.stats.string()) end end diff --git a/tests/performance/small-record.liq b/tests/performance/small-record.liq index f2f002cbf7..ad672eb61d 100755 --- a/tests/performance/small-record.liq +++ b/tests/performance/small-record.liq @@ -1,43 +1,88 @@ #!/usr/bin/env -S ../../liquidsoap ../test.liq performance.liq -def r2() - r = {a0 = 0, a1 = 1} +def r2() = + r = {a0=0, a1=1} x = ref(0) - for _ = 1 to 200000 do - x := x() + r.a0 + r.a1 - end + for _ = 1 to 200000 do x := x() + r.a0 + r.a1 end end -def r5() - r = {a0 = 0, a1 = 1, a2 = 2, a3 = 3, a4 = 4} +def r5() = + r = {a0=0, a1=1, a2=2, a3=3, a4=4} x = ref(0) - for _ = 1 to 200000 do - x := x() + r.a0 + r.a1 + r.a2 + r.a3 + r.a4 - end + for _ = 1 to 200000 do x := x() + r.a0 + r.a1 + r.a2 + r.a3 + r.a4 end end -def r10() - r = {a0 = 0, a1 = 1, a2 = 2, a3 = 3, a4 = 4, a5 = 5, a6 = 6, a7 = 7, a8 = 8, a9 = 9} +def r10() = + r = {a0=0, a1=1, a2=2, a3=3, a4=4, a5=5, a6=6, a7=7, a8=8, a9=9} x = ref(0) - for _ = 1 to 200000 do - x := x() + r.a0 + r.a1 + r.a2 + r.a3 + r.a4 + r.a5 + r.a6 + r.a7 + r.a8 + r.a9 + for _ = 1 to + 200000 + do + x := + x() + r.a0 + r.a1 + r.a2 + r.a3 + r.a4 + r.a5 + r.a6 + r.a7 + r.a8 + r.a9 end end -def r20() - r = {a00 = 0, a01 = 1, a02 = 2, a03 = 3, a04 = 4, a05 = 5, a06 = 6, a07 = 7, a08 = 8, a09 = 9, - a10 = 0, a11 = 1, a12 = 2, a13 = 3, a14 = 4, a15 = 5, a16 = 6, a17 = 7, a18 = 8, a19 = 9} +def r20() = + r = + { + a00=0, + a01=1, + a02=2, + a03=3, + a04=4, + a05=5, + a06=6, + a07=7, + a08=8, + a09=9, + a10=0, + a11=1, + a12=2, + a13=3, + a14=4, + a15=5, + a16=6, + a17=7, + a18=8, + a19=9 + } x = ref(0) - for _ = 1 to 200000 do - x := x() - + r.a00 + r.a01 + r.a02 + r.a03 + r.a04 + r.a05 + r.a06 + r.a07 + r.a08 + r.a09 - + r.a10 + r.a11 + r.a12 + r.a13 + r.a14 + r.a15 + r.a16 + r.a17 + r.a18 + r.a19 + for _ = 1 to + 200000 + do + x := + x() + r.a00 + r.a01 + r.a02 + r.a03 + r.a04 + r.a05 + r.a06 + r.a07 + + r.a08 + + r.a09 + + r.a10 + + r.a11 + + r.a12 + + r.a13 + + r.a14 + + r.a15 + + r.a16 + + r.a17 + + r.a18 + + r.a19 end end -time("record with 2 fields", r2) -time("record with 5 fields", r5) -time("record with 10 fields", r10) -time("record with 20 fields", r20) +time( + "record with 2 fields", + r2 +) +time( + "record with 5 fields", + r5 +) +time( + "record with 10 fields", + r10 +) +time( + "record with 20 fields", + r20 +) exit(0) diff --git a/tests/regression/GH2585.liq b/tests/regression/GH2585.liq index 2267aedba0..b52dcb21bc 100644 --- a/tests/regression/GH2585.liq +++ b/tests/regression/GH2585.liq @@ -2,7 +2,7 @@ settings.log.level.set(4) test.skip() -output.dummy(fallible = true, sine()) +output.dummy(fallible=true, sine()) count = ref(0) thread.run.recurrent( diff --git a/tests/streams/hls_main_playlist.liq b/tests/streams/hls_main_playlist.liq index b1ea941987..9584b9205c 100644 --- a/tests/streams/hls_main_playlist.liq +++ b/tests/streams/hls_main_playlist.liq @@ -9,7 +9,9 @@ def f() = "steam_b".{bandwidth=456, codecs="codecs_b", video_size=(12, 34)} ] ) - test.equals(playlist, '#EXTM3U\r + test.equals( + playlist, + '#EXTM3U\r #EXT-X-VERSION:54\r foo\r bar\r @@ -17,7 +19,8 @@ bar\r prefix/stream_a.m3u8\r #EXT-X-STREAM-INF:BANDWIDTH=456,CODECS="codecs_b",RESOLUTION=12x34\r prefix/steam_b.m3u8\r -') +' + ) playlist = hls.playlist.main( @@ -29,7 +32,9 @@ prefix/steam_b.m3u8\r "steam_b".{bandwidth=456, codecs="codecs_b", video_size=(12, 34)} ] ) - test.equals(playlist, '#EXTM3U\r + test.equals( + playlist, + '#EXTM3U\r #EXT-X-VERSION:54\r foo\r bar\r @@ -37,16 +42,27 @@ bar\r prefix/stream_a.m3u8\r #EXT-X-STREAM-INF:BANDWIDTH=456,CODECS="codecs_b",RESOLUTION=12x34\r prefix/steam_b.m3u8\r -') +' + ) - playlist = hls.playlist.main(version=54, ["stream_a".{bandwidth=123,codecs="codecs_a"}, "steam_b".{bandwidth=456, codecs="codecs_b", video_size = (12,34)}]) - test.equals(playlist, '#EXTM3U\r + playlist = + hls.playlist.main( + version=54, + [ + "stream_a".{bandwidth=123, codecs="codecs_a"}, + "steam_b".{bandwidth=456, codecs="codecs_b", video_size=(12, 34)} + ] + ) + test.equals( + playlist, + '#EXTM3U\r #EXT-X-VERSION:54\r #EXT-X-STREAM-INF:BANDWIDTH=123,CODECS="codecs_a"\r stream_a.m3u8\r #EXT-X-STREAM-INF:BANDWIDTH=456,CODECS="codecs_b",RESOLUTION=12x34\r steam_b.m3u8\r -') +' + ) test.pass() end diff --git a/tests/streams/icecast_ssl.liq b/tests/streams/icecast_ssl.liq index 244c9b2f07..19e53cb29a 100644 --- a/tests/streams/icecast_ssl.liq +++ b/tests/streams/icecast_ssl.liq @@ -1,24 +1,12 @@ -transport = http.transport.ssl( - certificate="./ssl.cert", - key="./ssl.key" -) +transport = http.transport.ssl(certificate="./ssl.cert", key="./ssl.key") port = random.int(min=8000, max=10000) s = sine() -output.icecast( - port=port, - mount="ssl_test", - transport=transport, - %vorbis, - s) +output.icecast(port=port, mount="ssl_test", transport=transport, %vorbis, s) -i = input.harbor( - buffer=2., - port=port, - transport=transport, - "ssl_test") +i = input.harbor(buffer=2., port=port, transport=transport, "ssl_test") i = source.on_track(i, fun (_) -> test.pass()) diff --git a/tests/streams/icecast_ssl_tls.liq b/tests/streams/icecast_ssl_tls.liq index d9907a356c..28f65a6f0b 100644 --- a/tests/streams/icecast_ssl_tls.liq +++ b/tests/streams/icecast_ssl_tls.liq @@ -1,31 +1,16 @@ log.level := 4 -tls = http.transport.tls( - certificate="./ssl.cert", - key="./ssl.key" -) +tls = http.transport.tls(certificate="./ssl.cert", key="./ssl.key") -ssl = http.transport.ssl( - certificate="./ssl.cert", - key="./ssl.key" -) +ssl = http.transport.ssl(certificate="./ssl.cert", key="./ssl.key") port = random.int(min=8000, max=10000) s = sine() -output.icecast( - port=port, - mount="tls_test", - transport=ssl, - %vorbis, - s) - -i = input.harbor( - buffer=2., - port=port, - transport=tls, - "tls_test") +output.icecast(port=port, mount="tls_test", transport=ssl, %vorbis, s) + +i = input.harbor(buffer=2., port=port, transport=tls, "tls_test") i = source.on_track(i, fun (_) -> test.pass()) diff --git a/tests/streams/icecast_tls.liq b/tests/streams/icecast_tls.liq index 2177bf1916..38a5fccb70 100644 --- a/tests/streams/icecast_tls.liq +++ b/tests/streams/icecast_tls.liq @@ -1,29 +1,22 @@ log.level := 4 -transport = http.transport.tls( - certificate="./ssl.cert", - key="./ssl.key" -) +transport = http.transport.tls(certificate="./ssl.cert", key="./ssl.key") port = random.int(min=8000, max=10000) -thread.run(delay=1., fun () -> begin - s = sine() +thread.run( + delay=1., + fun () -> + begin + s = sine() - output.icecast( - port=port, - mount="tls_test", - transport=transport, - %vorbis, - s - ) -end) + output.icecast( + port=port, mount="tls_test", transport=transport, %vorbis, s + ) + end +) -i = input.harbor( - buffer=2., - port=port, - transport=transport, - "tls_test") +i = input.harbor(buffer=2., port=port, transport=transport, "tls_test") i = source.on_track(i, fun (_) -> test.pass()) diff --git a/tests/streams/icecast_tls_ssl.liq b/tests/streams/icecast_tls_ssl.liq index 15c820f2cd..e36562e3b4 100644 --- a/tests/streams/icecast_tls_ssl.liq +++ b/tests/streams/icecast_tls_ssl.liq @@ -1,31 +1,16 @@ log.level := 4 -tls = http.transport.tls( - certificate="./ssl.cert", - key="./ssl.key" -) +tls = http.transport.tls(certificate="./ssl.cert", key="./ssl.key") -ssl = http.transport.ssl( - certificate="./ssl.cert", - key="./ssl.key" -) +ssl = http.transport.ssl(certificate="./ssl.cert", key="./ssl.key") port = random.int(min=8000, max=10000) s = sine() -output.icecast( - port=port, - mount="tls_test", - transport=tls, - %vorbis, - s) - -i = input.harbor( - buffer=2., - port=port, - transport=ssl, - "tls_test") +output.icecast(port=port, mount="tls_test", transport=tls, %vorbis, s) + +i = input.harbor(buffer=2., port=port, transport=ssl, "tls_test") i = source.on_track(i, fun (_) -> test.pass()) diff --git a/tests/test.liq b/tests/test.liq index 3588ef8660..40190f4814 100644 --- a/tests/test.liq +++ b/tests/test.liq @@ -118,7 +118,9 @@ def test.not_equals(first, second) = error.raise( error.failure, "expected\r\n - #{string.quote(string(first))} == #{string.quote(string(second))}\r\n + #{string.quote(string(first))} == #{ + string.quote(string(second)) + }\r\n to be false.\r\n" ) @@ -148,10 +150,14 @@ end # @param ~digits The number of decimal digits to compare. Default is 7. def test.almost_equals(~digits=7, first, second) = is_almost_equals = test._almost_equals(digits=digits, first, second) - if not is_almost_equals then + if + not is_almost_equals + then error.raise( error.failure, - "#{string.quote(string(first))} != #{string.quote(string(second))} + "#{string.quote(string(first))} != #{ + string.quote(string(second)) + } up to #{digits} digits, diff = #{is_almost_equals.diff}." ) @@ -165,10 +171,14 @@ end # @param ~digits The number of decimal digits to compare. Default is 7. def test.not_almost_equals(~digits=7, first, second) = is_almost_equals = test._almost_equals(digits=digits, first, second) - if is_almost_equals then + if + is_almost_equals + then error.raise( error.failure, - "#{string.quote(string(first))} == #{string.quote(string(second))} + "#{string.quote(string(first))} == #{ + string.quote(string(second)) + } up to #{digits} digits, diff = #{is_almost_equals.diff}." )