Class TestStringTemplate
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.antlr.stringtemplate.test.TestStringTemplate
- All Implemented Interfaces:
junit.framework.Test
public class TestStringTemplate
extends junit.framework.TestCase
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassclassclassclassclassstatic classstatic classclassstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidFIXME: Dannish does not work if typed directly in with default file encoding on windows.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidThis fails because checkNullAttributeAgainstFormalArguments looks for a formal argument at the current level not of the original embedded template.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidAs of 2.0, you can test a boolean valuevoidvoidvoidvoidvoidvoidvoidvoidvoidFIXME: BUG! Iterator is not reset from first to second $x$ Either reset the iterator or pass an attribute that knows to get the iterator each time.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidAdded feature for ST-21voidvoidvoidtestMap()voidTest that a map can return a string with the word: default.voidTest that a map can have only the default entry.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidIf an iterator is sent into ST, it must be cannot be reset after each use so repeated refs yield empty values.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidCheck what happens when a semicolon is appended to a single line template Should fail with a parse error(?) and not a missing template error.voidvoidvoidvoidvoidvoidvoidvoidvoidCheck syntax and setAttribute-time errorsvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidstatic voidMethods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
-
Constructor Details
-
TestStringTemplate
public TestStringTemplate()
-
-
Method Details
-
testInterfaceFileFormat
-
testNoGroupLoader
-
testCannotFindInterfaceFile
-
testMultiDirGroupLoading
-
testGroupSatisfiesSingleInterface
-
testGroupExtendsSuperGroup
-
testGroupExtendsSuperGroupWithAngleBrackets
-
testMissingInterfaceTemplate
-
testMissingOptionalInterfaceTemplate
-
testMismatchedInterfaceTemplate
-
testGroupFileFormat
-
testEscapedTemplateDelimiters
-
testTemplateParameterDecls
-
testTemplateRedef
-
testMissingInheritedAttribute
-
testFormalArgumentAssignment
-
testUndefinedArgumentAssignment
-
testFormalArgumentAssignmentInApply
-
testUndefinedArgumentAssignmentInApply
-
testUndefinedAttributeReference
-
testUndefinedDefaultAttributeReference
-
testAngleBracketsWithGroupFile
-
testAngleBracketsNoGroup
-
testRegionRef
-
testEmbeddedRegionRef
-
testRegionRefAngleBrackets
-
testEmbeddedRegionRefAngleBrackets
-
testEmbeddedRegionRefWithNewlinesAngleBrackets
-
testRegionRefWithDefAngleBrackets
-
testRegionRefWithDefInConditional
-
testRegionRefWithImplicitDefInConditional
-
testRegionOverride
-
testRegionOverrideRefSuperRegion
-
testRegionOverrideRefSuperRegion3Levels
-
testRegionOverrideRefSuperImplicitRegion
-
testEmbeddedRegionRedefError
-
testImplicitRegionRedefError
-
testImplicitOverriddenRegionRedefError
-
testUnknownRegionDefError
-
testSuperRegionRefError
-
testMissingEndRegionError
-
testMissingEndRegionErrorAngleBrackets
-
testSimpleInheritance
-
testOverrideInheritance
-
testMultiLevelInheritance
-
testComplicatedInheritance
-
test3LevelSuperRef
-
testExprInParens
-
testMultipleAdditions
-
testCollectionAttributes
-
testParenthesizedExpression
-
testApplyTemplateNameExpression
-
testApplyTemplateNameTemplateEval
-
testTemplateNameExpression
-
testMissingEndDelimiter
-
testSetButNotRefd
-
testNullTemplateApplication
-
testNullTemplateToMultiValuedApplication
-
testChangingAttrValueTemplateApplicationToVector
-
testChangingAttrValueRepeatedTemplateApplicationToVector
-
testAlternatingTemplateApplication
-
testExpressionAsRHSOfAssignment
-
testTemplateApplicationAsRHSOfAssignment
-
testParameterAndAttributeScoping
-
testComplicatedSeparatorExpr
-
testAttributeRefButtedUpAgainstEndifAndWhitespace
-
testStringCatenationOnSingleValuedAttributeViaTemplateLiteral
-
testStringCatenationOpOnArg
-
testStringCatenationOpOnArgWithEqualsInString
-
testApplyingTemplateFromDiskWithPrecompiledIF
-
testMultiValuedAttributeWithAnonymousTemplateUsingIndexVariableI
-
testFindTemplateInCLASSPATH
-
testApplyTemplateToSingleValuedAttribute
-
testStringLiteralAsAttribute
-
testApplyTemplateToSingleValuedAttributeWithDefaultAttribute
-
testApplyAnonymousTemplateToSingleValuedAttribute
-
testApplyAnonymousTemplateToMultiValuedAttribute
-
testApplyAnonymousTemplateToAggregateAttribute
-
testRepeatedApplicationOfTemplateToSingleValuedAttribute
-
testRepeatedApplicationOfTemplateToMultiValuedAttributeWithSeparator
-
testMultiValuedAttributeWithSeparator
-
testSingleValuedAttributes
-
testIFTemplate
-
testIFCondWithParensTemplate
-
testIFCondWithParensDollarDelimsTemplate
-
testIFBoolean
-
testNestedIFTemplate
-
testIFConditionWithTemplateApplication
-
testObjectPropertyReference
-
testApplyRepeatedAnonymousTemplateWithForeignTemplateRefToMultiValuedAttribute
-
testRecursion
-
testNestedAnonymousTemplates
-
testAnonymousTemplateAccessToEnclosingAttributes
-
testNestedAnonymousTemplatesAgain
-
testEscapes
-
testEscapesOutsideExpressions
-
testElseClause
-
testElseIfClause
-
testElseIfClauseAngleBrackets
-
testElseIfClause2
-
testElseIfClauseAndElse
-
testNestedIF
-
testEmbeddedMultiLineIF
-
testSimpleIndentOfAttributeList
-
testIndentOfMultilineAttributes
-
testIndentOfMultipleBlankLines
-
testIndentBetweenLeftJustifiedLiterals
-
testNestedIndent
-
testAlternativeWriter
-
testApplyAnonymousTemplateToMapAndSet
-
testDumpMapAndSet
-
testApplyAnonymousTemplateToArrayAndMapProperty
-
testSuperTemplateRef
-
testApplySuperTemplateRef
-
testLazyEvalOfSuperInApplySuperTemplateRef
-
testTemplatePolymorphism
-
testListOfEmbeddedTemplateSeesEnclosingAttributes
-
testInheritArgumentFromRecursiveTemplateApplication
-
testDeliberateRecursiveTemplateApplication
-
testImmediateTemplateAsAttributeLoop
-
testTemplateAlias
-
testTemplateGetPropertyGetsAttribute
-
testComplicatedIndirectTemplateApplication
-
testIndirectTemplateApplication
-
testIndirectTemplateWithArgsApplication
-
testNullIndirectTemplateApplication
-
testNullIndirectTemplate
-
testHashMapPropertyFetch
-
testHashMapPropertyFetchEmbeddedStringTemplate
-
testEmbeddedComments
-
testEmbeddedCommentsAngleBracketed
-
testLineBreak
-
testLineBreak2
-
testLineBreakNoWhiteSpace
-
testLineBreakDollar
-
testLineBreakDollar2
-
testLineBreakNoWhiteSpaceDollar
-
testCharLiterals
-
testNewlineNormalizationInTemplateString
-
testNewlineNormalizationInTemplateStringPC
-
testNewlineNormalizationInAttribute
-
testUnicodeLiterals
-
testEmptyIteratedValueGetsSeparator
-
testMissingIteratedConditionalValueGetsNOSeparator
-
testMissingIteratedConditionalValueGetsNOSeparator2
-
testMissingIteratedDoubleConditionalValueGetsNOSeparator
-
testIteratedConditionalWithEmptyElseValueGetsSeparator
-
testWhiteSpaceAtEndOfTemplate
-
testSizeZeroButNonNullListGetsNoOutput
-
testNullListGetsNoOutput
-
testEmptyListGetsNoOutput
-
testEmptyListNoIteratorGetsNoOutput
-
testEmptyExprAsFirstLineGetsNoOutput
-
testSizeZeroOnLineByItselfGetsNoOutput
-
testSizeZeroOnLineWithIndentGetsNoOutput
-
testSimpleAutoIndent
-
testComputedPropertyName
-
testNonNullButEmptyIteratorTestsFalse
-
testDoNotInheritAttributesThroughFormalArgs
-
testArgEvaluationContext
-
testPassThroughAttributes
-
testPassThroughAttributes2
-
testDefaultArgument
-
testDefaultArgument2
-
testDefaultArgumentManuallySet
-
testDefaultArgumentImplicitlySet
This fails because checkNullAttributeAgainstFormalArguments looks for a formal argument at the current level not of the original embedded template. We have defined it all the way in the embedded, but there is no value so we try to look upwards ala dynamic scoping. When it reaches the top, it doesn't find a value but it will miss the formal argument down in the embedded. By definition, though, the formal parameter exists if we have a default value. look up the value to see if it's null without checking checkNullAttributeAgainstFormalArguments.- Throws:
Exception
-
testDefaultArgumentAsTemplate
-
testDefaultArgumentAsTemplate2
-
testDoNotUseDefaultArgument
-
testDefaultArgumentInParensToEvalEarly
-
testArgumentsAsTemplates
-
testTemplateArgumentEvaluatedInSurroundingContext
-
testArgumentsAsTemplatesDefaultDelimiters
-
testDefaultArgsWhenNotInvoked
-
testRendererForST
-
testRendererWithFormat
-
testRendererWithFormatAndList
-
testRendererWithFormatAndSeparator
-
testRendererWithFormatAndSeparatorAndNull
-
testEmbeddedRendererSeesEnclosing
-
testRendererForGroup
-
testOverriddenRenderer
-
testMap
-
testMapValuesAreTemplates
-
testMapKeyLookupViaTemplate
-
testMapMissingDefaultValueIsEmpty
-
testMapHiddenByFormalArg
-
testMapEmptyValueAndAngleBracketStrings
-
testMapDefaultValue
-
testMapEmptyDefaultValue
-
testMapDefaultValueIsKey
-
testMapDefaultStringAsKey
-
testMapDefaultIsDefaultString
-
testMapViaEnclosingTemplates
-
testMapViaEnclosingTemplates2
-
testEmptyGroupTemplate
-
testEmptyStringAndEmptyAnonTemplateAsParameterUsingAngleBracketLexer
-
testEmptyStringAndEmptyAnonTemplateAsParameterUsingDollarLexer
-
test8BitEuroChars
-
test16BitUnicodeChar
-
testFirstOp
-
testTruncOp
-
testRestOp
-
testRestOpEmptyList
-
testReUseOfRestResult
-
testLastOp
-
testCombinedOp
-
testCatListAndSingleAttribute
-
testReUseOfCat
-
testCatListAndEmptyAttributes
-
testNestedOp
-
testFirstWithOneAttributeOp
-
testLastWithOneAttributeOp
-
testLastWithLengthOneListAttributeOp
-
testRestWithOneAttributeOp
-
testRestWithLengthOneListAttributeOp
-
testRepeatedRestOp
-
testRepeatedIteratedAttrFromArg
-
testIncomingLists
FIXME: BUG! Iterator is not reset from first to second $x$ Either reset the iterator or pass an attribute that knows to get the iterator each time. Seems like first, tail do not have same problem as they yield objects. Maybe make a RestIterator like I have CatIterator.- Throws:
Exception
-
testIncomingListsAreNotModified
-
testIncomingListsAreNotModified2
-
testIncomingArraysAreOk
-
testMultipleRefsToListAttribute
-
testApplyTemplateWithSingleFormalArgs
-
testApplyTemplateWithNoFormalArgs
-
testAnonTemplateArgs
-
testAnonTemplateWithArgHasNoITArg
-
testAnonTemplateArgs2
-
testFirstWithCatAttribute
-
testFirstWithListOfMaps
-
testJustCat
-
testCat2Attributes
-
testCat2AttributesWithApply
-
testCat3Attributes
-
testCatWithTemplateApplicationAsElement
-
testCatWithIFAsElement
-
testCatWithNullTemplateApplicationAsElement
-
testCatWithNestedTemplateApplicationAsElement
-
testListAsTemplateArgument
-
testSingleExprTemplateArgument
-
testSingleExprTemplateArgumentInApply
-
testSoleFormalTemplateArgumentInMultiApply
-
testSingleExprTemplateArgumentError
-
testInvokeIndirectTemplateWithSingleFormalArgs
-
testParallelAttributeIteration
-
testParallelAttributeIterationWithNullValue
-
testParallelAttributeIterationHasI
-
testParallelAttributeIterationWithDifferentSizes
-
testParallelAttributeIterationWithSingletons
-
testParallelAttributeIterationWithMismatchArgListSizes
-
testParallelAttributeIterationWithMissingArgs
-
testParallelAttributeIterationWithDifferentSizesTemplateRefInsideToo
-
testAnonTemplateOnLeftOfApply
-
testOverrideThroughConditional
-
testNonPublicPropertyAccess
-
testIndexVar
-
testIndex0Var
-
testIndexVarWithMultipleExprs
-
testIndex0VarWithMultipleExprs
-
testArgumentContext
-
testNoDotsInAttributeNames
-
testNoDotsInTemplateNames
-
testLineWrap
-
testLineWrapWithNormalizedNewlines
-
testLineWrapAnchored
-
testSubtemplatesAnchorToo
-
testFortranLineWrap
-
testLineWrapWithDiffAnchor
-
testLineWrapEdgeCase
-
testLineWrapLastCharIsNewline
-
testLineWrapCharAfterWrapIsNewline
-
testLineWrapForAnonTemplate
-
testLineWrapForAnonTemplateAnchored
-
testLineWrapForAnonTemplateComplicatedWrap
-
testIndentBeyondLineWidth
-
testIndentedExpr
-
testNestedIndentedExpr
-
testNestedWithIndentAndTrackStartOfExpr
-
testLineDoesNotWrapDueToLiteral
-
testSingleValueWrap
-
testLineWrapInNestedExpr
-
testBackslash
-
testBackslash2
-
testEscapeEscape
-
testEscapeEscapeNestedAngle
-
testListOfIntArrays
-
testNullOptionSingleNullValue
-
testNullOptionHasEmptyNullValue
-
testNullOptionSingleNullValueInList
-
testNullValueInList
-
testNullValueInListNoNullOption
-
testNullValueInListWithTemplateApply
-
testNullValueInListWithTemplateApplyNullFirstValue
-
testNullSingleValueInListWithTemplateApply
-
testNullSingleValueWithTemplateApply
-
testLengthOp
-
testLengthOpWithMap
-
testLengthOpWithSet
-
testLengthOpNull
-
testLengthOpSingleValue
-
testLengthOpPrimitive
-
testLengthOpOfListWithNulls
-
testStripOpOfListWithNulls
-
testStripOpOfListOfListsWithNulls
-
testStripOpOfSingleAlt
-
testStripOpOfNull
-
testReUseOfStripResult
-
testLengthOpOfStrippedListWithNulls
-
testLengthOpOfStrippedListWithNullsFrontAndBack
-
testMapKeys
-
testMapValues
-
testMapKeysWithIntegerType
-
testSuperReferenceInIfClause
Check what happens when a semicolon is appended to a single line template Should fail with a parse error(?) and not a missing template error. FIXME: This should generate a warning or error about that semi colon.Bug ref: JIRA bug ST-2
- Throws:
Exception
-
testListLiteralWithEmptyElements
-
testTemplateApplicationAsOptionValue
-
writeFile
-