public void singleton_set_contains_only_its_value(int value)
        {
            var target = IntSet.Of(value);

            Assert.IsTrue(target.Contains(value));
            foreach (int sample in AnyBut(value))
            {
                Assert.IsFalse(target.Contains(sample));
            }
        }
Exemple #2
0
        public void RegisterAction(Matcher matcher)
        {
            SymbolBase      outcome = matcher.Outcome;
            AmbiguousSymbol ambiguous;
            Symbol          deterministic;

            if (outcome == null)
            {
                actionToTokenProducer[matcher.Index] =
                    new TokenProducerInfo
                {
                    MainTokenId    = -1,
                    Disambiguation = matcher.Disambiguation,
                    RealActions    = SparseIntSetType.Instance.Of(matcher.Index),
                    PossibleTokens = tokenSetType.Empty
                };
            }
            else if ((ambiguous = outcome as AmbiguousSymbol) != null)
            {
                actionToTokenProducer[matcher.Index] =
                    new TokenProducerInfo
                {
                    MainTokenId    = ambiguous.MainToken,
                    Disambiguation = matcher.Disambiguation,
                    RealActions    = SparseIntSetType.Instance.Of(matcher.Index),
                    PossibleTokens = tokenSetType.Of(ambiguous.Tokens)
                };
            }
            else if ((deterministic = outcome as Symbol) != null)
            {
                actionToTokenProducer[matcher.Index] =
                    new TokenProducerInfo
                {
                    MainTokenId    = deterministic.Index,
                    Disambiguation = matcher.Disambiguation,
                    RealActions    = SparseIntSetType.Instance.Of(matcher.Index),
                    PossibleTokens = tokenSetType.Of(deterministic.Index)
                };
            }
        }
        public void TestOrthohonate()
        {
            GivenInputSets(
                IntSet.Of(A, B, C),
                IntSet.Of(B, C, D),
                IntSet.Of(E),           // unary set should remain unchaged
                IntSet.Of(A),           // unary set will not repeat more than once
                IntSet.Of(C, B),        // duplicate set which will be in output
                IntSet.Of(  )           // empty set will be ignored
                );

            SetOrthohonator.Orthohonate(outputSets);

            Console.WriteLine("Alphabet:" + inputSets.Aggregate((x, y) => IntSet.Of(x.Union(y))));
            Console.WriteLine(string.Join(", ", outputSets));
            Assert.AreEqual(4, outputSets.Count);
            SetsShouldNotHaveCommonItems(outputSets);
            EachResultSetIsSubsetOfSomeInputSet(outputSets);
        }