<commit_before>module T = Test_utils

let (>::) = T.(>::)
let (>:::) = T.(>:::)

let with_context f =
  let context = jsnew WebAudio.audioContext () in
  T.finally (fun () -> f context) (fun () -> context##close ())

let test_make_context () =
  with_context (fun _ -> ())

let test_make_oscillator () =
  with_context
    (fun context ->
      let oscillator = context##createOscillator () in
      oscillator##frequency##value <- 200.0;
      T.assert_equal (oscillator##frequency##value) 200.0;
      oscillator##_type <- (Js.string "sine");
      T.assert_equal (oscillator##_type) (Js.string "sine");
      oscillator##connect_AudioNode (context##destination);
      oscillator##start ();
      oscillator##stop ()
    )

let suite =
  "base_suite" >::: [
    "test_make_context" >:: test_make_context;
    "test_make_oscillator" >:: test_make_oscillator;
  ]

let run_suite log =
  let open T in
  let (_ : result list) = run log suite in
  Js._false
<commit_msg>test: add test_destination<commit_after>module T = Test_utils

let (>::) = T.(>::)
let (>:::) = T.(>:::)

let with_context f =
  let context = jsnew WebAudio.audioContext () in
  T.finally (fun () -> f context) (fun () -> context##close ())

let test_make_context () =
  with_context (fun _ -> ())

let test_destination () =
  with_context
    (fun context ->
      let destination = context##destination in
      T.assert_equal (destination##numberOfInputs) 1;
      T.assert_equal (destination##numberOfOutputs) 0;

      T.assert_equal (destination##channelCountMode) (Js.string "explicit");
      T.assert_equal (destination##channelCount) 2;
      T.assert_equal
        (destination##channelInterpretation) (Js.string "speakers"))

let test_make_oscillator () =
  with_context
    (fun context ->
      let oscillator = context##createOscillator () in
      oscillator##frequency##value <- 200.0;
      T.assert_equal (oscillator##frequency##value) 200.0;
      oscillator##_type <- (Js.string "sine");
      T.assert_equal (oscillator##_type) (Js.string "sine");
      oscillator##connect_AudioNode (context##destination);
      oscillator##start ();
      oscillator##stop ()
    )

let suite =
  "base_suite" >::: [
    "test_make_context" >:: test_make_context;
    "test_destination" >:: test_destination;
    "test_make_oscillator" >:: test_make_oscillator;
  ]

let run_suite log =
  let open T in
  let (_ : result list) = run log suite in
  Js._false

{'fraction_non_alphanumeric': 0.14948665297741273, 'fraction_numerical': 0.0078028747433264885, 'mean_word_length': 3.5962264150943395, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1311958', 'n_tokens_mistral': 830, 'n_tokens_neox': 803, 'n_words': 174}