<commit_before>package tests.rescala


class EmptySignalTestSuite extends RETests {

  allEngines("basic Empty Signal Test"){ engine => import engine._

    val v = Var.empty[Int]

    intercept[NoSuchElementException](v.now)

    var res = -100

    v.observe(res = _)

    assert(res == -100, "sanity")

    val s = v.map(1.+)

    intercept[NoSuchElementException](s.now)

    v.set(100)

    assert(res == 100, "observed?")
    assert(v.now == 100, "changed from empty to value")
    assert(s.now == 101, "changed from empty to value 2")



  }

  allEngines("unwrap Empty Signal"){ engine => import engine._
    val v = Var.empty[Event[Int]]
    val e = v.flatten

    var res = -100

    e.observe(res = _)

    assert(res === -100, "sanity")

    val evt = Evt[Int]

    v.set(evt)

    evt.fire(20)

    assert(res === 20, "could unwrap after Val was empty")

  }
<commit_msg>test case for flatten of empty signal when mapping event<commit_after>package tests.rescala


class EmptySignalTestSuite extends RETests {

  allEngines("basic Empty Signal Test"){ engine => import engine._

    val v = Var.empty[Int]

    intercept[NoSuchElementException](v.now)

    var res = -100

    v.observe(res = _)

    assert(res == -100, "sanity")

    val s = v.map(1.+)

    intercept[NoSuchElementException](s.now)

    v.set(100)

    assert(res == 100, "observed?")
    assert(v.now == 100, "changed from empty to value")
    assert(s.now == 101, "changed from empty to value 2")



  }

  allEngines("flatten empty signal when mapping event"){ engine => import engine._

    val v = Var.empty[Event[Unit]]

    val e1 = Evt[Unit]

    val e2 = e1 map { _ => v.flatten.count }

    var s: Signal[Int] = null

    e2.observe(s = _)

    e1.fire()

    assert(s != null, "sanity")

    assert(s.now == 0, "mapped event")


    val e3 = Evt[Unit]

    v.set(e3)

    assert(s.now == 0, "mapped event after var set")

    e3.fire()

    assert(s.now == 1, "mapped event after event fire")
  }

  allEngines("unwrap Empty Signal"){ engine => import engine._
    val v = Var.empty[Event[Int]]
    val e = v.flatten

    var res = -100

    e.observe(res = _)

    assert(res === -100, "sanity")

    val evt = Evt[Int]

    v.set(evt)

    evt.fire(20)

    assert(res === 20, "could unwrap after Val was empty")

  }

{'fraction_non_alphanumeric': 0.14007782101167315, 'fraction_numerical': 0.030696065715520967, 'mean_word_length': 2.6788553259141494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6271106', 'n_tokens_mistral': 918, 'n_tokens_neox': 795, 'n_words': 219}