public void Union_Empty() { var element = ReFactory.NewUnion(Array.Empty <ReElement>()); Assert.That(element, Is.Not.Null); Assert.That(element, Is.TypeOf(typeof(ReEmptyLanguage))); }
public void Union_Single() { var child = ReUtils.NewDummy('1'); var element = ReFactory.NewUnion(ImmutableArray.Create(child)); Assert.That(element, Is.SameAs(child)); }
public void Union_Collapse() { var child1 = ReUtils.NewDummy('1'); var child2 = ReUtils.NewDummy('2'); var child3 = ReUtils.NewDummy('3'); var child4 = ReUtils.NewDummy('4'); var subUnion = new ReUnion(ImmutableArray.Create(child2, child3)); var element = ReFactory.NewUnion(new ReElement[] { child1, subUnion, ReEmptyLanguage.Instance, child4 }); Assert.That(element, Is.Not.Null); Assert.That(element, Is.TypeOf(typeof(ReUnion))); var union = (ReUnion)element; Assert.That(union.Elements, Is.EquivalentTo(new ReElement[] { child1, child2, child3, child4 })); }