From 1c991cbf11b22989bde1adde35d690d9bb059a98 Mon Sep 17 00:00:00 2001 From: Samuel Gomes <47574584+a740g@users.noreply.github.com> Date: Sat, 10 Sep 2022 08:54:31 +0530 Subject: [PATCH] Added tests for bad audio handles and backdround `SOUND` --- .../audio_handle_test/handle_test.bas | 23 ++++++++++ .../audio_handle_test/handle_test.output | 4 ++ .../audio_sound_test/sound_test.bas | 46 +++++++++++++++++++ .../audio_sound_test/sound_test.output | 3 ++ 4 files changed, 76 insertions(+) create mode 100644 tests/compile_tests/audio_handle_test/handle_test.bas create mode 100644 tests/compile_tests/audio_handle_test/handle_test.output create mode 100644 tests/compile_tests/audio_sound_test/sound_test.bas create mode 100644 tests/compile_tests/audio_sound_test/sound_test.output diff --git a/tests/compile_tests/audio_handle_test/handle_test.bas b/tests/compile_tests/audio_handle_test/handle_test.bas new file mode 100644 index 000000000..a35ea4b23 --- /dev/null +++ b/tests/compile_tests/audio_handle_test/handle_test.bas @@ -0,0 +1,23 @@ +Option _Explicit +$Console +$ScreenHide +_Dest _Console + +' Try to open a non-existent file +Dim handle As Long + +handle = _SndOpen("dummy.flac") +Print handle +If Not handle Then + Print "This failure was expected!" +End If + + +handle = _SndCopy(handle) +Print handle +If Not handle Then + Print "So was this!" +End If + +System + diff --git a/tests/compile_tests/audio_handle_test/handle_test.output b/tests/compile_tests/audio_handle_test/handle_test.output new file mode 100644 index 000000000..d0bdc79ac --- /dev/null +++ b/tests/compile_tests/audio_handle_test/handle_test.output @@ -0,0 +1,4 @@ + 0 +This failure was expected! + 0 +So was this! diff --git a/tests/compile_tests/audio_sound_test/sound_test.bas b/tests/compile_tests/audio_sound_test/sound_test.bas new file mode 100644 index 000000000..253eb97f3 --- /dev/null +++ b/tests/compile_tests/audio_sound_test/sound_test.bas @@ -0,0 +1,46 @@ +Option _Explicit +$Console +$ScreenHide +_Dest _Console + +Dim As Long i, note, duration +Dim word As String +Dim As Double t, ct, d1, d2 + +Play "mb" + +t = Timer +For i = 1 To 34 + Read note, duration, word + Sound note, duration: Print word$; +Next +Print +ct = Timer +If t > ct Then t = t - 86400 +d1 = ct - t + +Restore +Play "mf" + +t = Timer +For i = 1 To 34 + Read note, duration, word + Sound note, duration: Print word$; +Next +Print +ct = Timer +If t > ct Then t = t - 86400 +d2 = ct - t + +If d2 - d1 > 5 Then + Print "Foreground playback always takes longer to complete than background playback." +End If + +System + +Data 392,8,"My ",659,8,"Bon-",587,8,"nie ",523,8,"lies ",587,8,"O-",523,8,"Ver ",440,8,"the " +Data 392,8,"O-",330,32,"cean ",392,8,"My ",659,8,"Bon-",587,8,"nie ",523,8,"lies " +Data 523,8,"O-",494,8,"ver ",523,8,"the ",587,40,"sea ",392,8,"My ",659,8,"Bon-",587,8,"nie" +Data 523,8," lies ",587,8,"O-",523,8,"ver ",440,8,"the ",392,8,"O-",330,32,"cean ",392,8,"Oh " +Data 440,8,"bring ",587,8,"back ",523,8,"my ",494,8,"Bon-",440,8,"nie ",494,8,"to ",523,32,"me..!" + diff --git a/tests/compile_tests/audio_sound_test/sound_test.output b/tests/compile_tests/audio_sound_test/sound_test.output new file mode 100644 index 000000000..bfdc140e2 --- /dev/null +++ b/tests/compile_tests/audio_sound_test/sound_test.output @@ -0,0 +1,3 @@ +My Bon-nie lies O-Ver the O-cean My Bon-nie lies O-ver the sea My Bon-nie lies O-ver the O-cean Oh bring back my Bon-nie to me..! +My Bon-nie lies O-Ver the O-cean My Bon-nie lies O-ver the sea My Bon-nie lies O-ver the O-cean Oh bring back my Bon-nie to me..! +Foreground playback always takes longer to complete than background playback.