public void SingleGenericTypeParameterWithBaseTypeThenOneWithout()
        {
            var content  = "<TKey extends Something, TValue>";
            var expected = MatchResult.New(
                value: ImmutableList <GenericTypeParameterDetails> .Empty
                .Add(new GenericTypeParameterDetails(
                         name: new NamedTypeDetails(
                             name: new IdentifierDetails("TKey", new SourceRangeDetails(1, 4)),
                             genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                             ),
                         typeConstraint: new NamedTypeDetails(
                             name: new IdentifierDetails("Something", new SourceRangeDetails(14, 9)),
                             genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                             )
                         ))
                .Add(new GenericTypeParameterDetails(
                         new NamedTypeDetails(
                             name: new IdentifierDetails("TValue", new SourceRangeDetails(25, 6)),
                             genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                             ),
                         typeConstraint: Optional <NamedTypeDetails> .Missing
                         )),
                reader: new StringNavigator("")
                );

            AssertResultsMatch(expected, TypeDefinitionParsers.GenericTypeParameters(new StringNavigator(content)));
        }
 public void BlankContent()
 {
     Assert.IsTrue(
         DoOptionalMatchResultsMatch(
             Optional <MatchResult <ImmutableList <GenericTypeParameterDetails> > > .Missing,
             TypeDefinitionParsers.GenericTypeParameters(new StringNavigator(""))
             )
         );
 }
        public void NoLeadingBracket()
        {
            var content = "T";

            Assert.AreEqual(
                Optional <MatchResult <ImmutableList <GenericTypeParameterDetails> > > .Missing,
                TypeDefinitionParsers.GenericTypeParameters(new StringNavigator(content))
                );
        }
 public void BlankContent()
 {
     Assert.IsTrue(
         DoOptionalMatchResultsMatch(
             Optional <MatchResult <InterfaceDetails> > .Missing,
             TypeDefinitionParsers.Interface(new StringNavigator(""))
             )
         );
 }
        public void SingleGenericTypeParameter()
        {
            var content  = "<T>";
            var expected = MatchResult.New(
                value: ImmutableList <GenericTypeParameterDetails> .Empty
                .Add(new GenericTypeParameterDetails(
                         new NamedTypeDetails(
                             name: new IdentifierDetails("T", new SourceRangeDetails(1, 1)),
                             genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                             ),
                         typeConstraint: Optional <NamedTypeDetails> .Missing
                         )),
                reader: new StringNavigator("")
                );

            AssertResultsMatch(expected, TypeDefinitionParsers.GenericTypeParameters(new StringNavigator(content)));
        }
        public void InterfaceWithGenericTypeParameterThatExtendsAnotherGenericInterfaceButThatHasNoProperties()
        {
            var content  = "interface ClassicElement<P> extends ReactElement<P> { }";
            var expected = MatchResult.New(
                value: new InterfaceDetails(
                    name: new IdentifierDetails("ClassicElement", new SourceRangeDetails(10, 14)),
                    genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty.Add(new GenericTypeParameterDetails(
                                                                                                  name: new NamedTypeDetails(
                                                                                                      name: new IdentifierDetails("P", new SourceRangeDetails(25, 1)),
                                                                                                      genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                                                                                                      ),
                                                                                                  typeConstraint: Optional <NamedTypeDetails> .Missing
                                                                                                  )),
                    baseTypes: ImmutableList <NamedTypeDetails> .Empty.Add(new NamedTypeDetails(
                                                                               name: new IdentifierDetails("ReactElement", new SourceRangeDetails(36, 12)),
                                                                               genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty.Add(new GenericTypeParameterDetails(
                                                                                                                                                             name: new NamedTypeDetails(
                                                                                                                                                                 name: new IdentifierDetails("P", new SourceRangeDetails(49, 1)),
                                                                                                                                                                 genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                                                                                                                                                                 ),
                                                                                                                                                             typeConstraint: Optional <NamedTypeDetails> .Missing
                                                                                                                                                             ))
                                                                               )),
                    contents: ImmutableList <PropertyDetails> .Empty,
                    source: new SourceRangeDetails(0, 55)
                    ),
                reader: new StringNavigator("")
                );

            Assert.IsTrue(
                DoOptionalMatchResultsMatch(
                    Optional.For(expected),
                    TypeDefinitionParsers.Interface(new StringNavigator(content)),
                    DoInterfaceDetailsMatch
                    )
                );
        }
        public void InterfaceThatExtendsNestedGenericBaseTypeButHasNoProperties()
        {
            var content  = "interface DOMAttributes extends Props<DOMComponent<any>> { }";
            var expected = MatchResult.New(
                value: new InterfaceDetails(
                    name: new IdentifierDetails("DOMAttributes", new SourceRangeDetails(10, 13)),
                    genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty,
                    baseTypes: ImmutableList <NamedTypeDetails> .Empty.Add(new NamedTypeDetails(
                                                                               name: new IdentifierDetails("Props", new SourceRangeDetails(32, 5)),
                                                                               genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty.Add(new GenericTypeParameterDetails(
                                                                                                                                                             name: new NamedTypeDetails(
                                                                                                                                                                 name: new IdentifierDetails("DOMComponent", new SourceRangeDetails(38, 12)),
                                                                                                                                                                 genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty.Add(new GenericTypeParameterDetails(
                                                                                                                                                                                                                                               name: new NamedTypeDetails(
                                                                                                                                                                                                                                                   name: new IdentifierDetails("any", new SourceRangeDetails(51, 3)),
                                                                                                                                                                                                                                                   genericTypeParams: ImmutableList <GenericTypeParameterDetails> .Empty
                                                                                                                                                                                                                                                   ),
                                                                                                                                                                                                                                               typeConstraint: Optional <NamedTypeDetails> .Missing
                                                                                                                                                                                                                                               ))
                                                                                                                                                                 ),
                                                                                                                                                             typeConstraint: Optional <NamedTypeDetails> .Missing
                                                                                                                                                             ))
                                                                               )),
                    contents: ImmutableList <PropertyDetails> .Empty,
                    source: new SourceRangeDetails(0, 60)
                    ),
                reader: new StringNavigator("")
                );

            Assert.IsTrue(
                DoOptionalMatchResultsMatch(
                    Optional.For(expected),
                    TypeDefinitionParsers.Interface(new StringNavigator(content)),
                    DoInterfaceDetailsMatch
                    )
                );
        }
 public void Null()
 {
     TypeDefinitionParsers.GenericTypeParameters(new StringNavigator(null));
 }
 public void Null()
 {
     TypeDefinitionParsers.Interface(new StringNavigator(null));
 }