org.antlr.test
Class TestAttributes

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.antlr.test.BaseTest
              extended by org.antlr.test.TestAttributes
All Implemented Interfaces:
junit.framework.Test

public class TestAttributes
extends BaseTest

Check the $x, $x.y attributes. For checking the actual translation, assume the Java target. This is still a great test for the semantics of the $x.y stuff regardless of the target.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.antlr.test.BaseTest
BaseTest.StreamVacuum
 
Field Summary
 
Fields inherited from class org.antlr.test.BaseTest
CLASSPATH, jikes, pathSep, stderr, tmpdir
 
Constructor Summary
TestAttributes()
          Public default constructor used by TestRig
 
Method Summary
protected  void checkError(ErrorQueue equeue, GrammarSemanticsMessage expectedMessage)
           
protected  void checkErrors(ErrorQueue equeue, java.util.ArrayList expectedMessages)
          Allow checking for multiple errors in one test
 void test0IndexedGlobalScope()
           
 void testAbsoluteIndexedGlobalScope()
           
 void testAmbiguousTokenRef()
           
 void testAmbiguousTokenRefWithProp()
           
 void testArgReturnValueMismatch()
           
 void testArgsOnToken()
           
 void testArgsOnTokenInLexer()
           
 void testArgsOnTokenInLexerRuleOfCombined()
           
 void testArgsWhenNoneDefined()
           
 void testArgsWithInitValues()
           
 void testArguments()
           
 void testAssignToOwnParamAttr()
           
 void testAssignToOwnRulenameAttr()
           
 void testAssignToTreeNodeAttribute()
           
 void testBasicGlobalScope()
           
 void testBasicRuleScope()
           
 void testCharLabelInLexer()
           
 void testCharListLabelInLexer()
           
 void testCStyleReturnInitValue()
           
 void testDoNotTranslateAttributeCompare()
           
 void testDoNotTranslateScopeAttributeCompare()
           
 void testDynamicRuleScopeRefInSubrule()
           
 void testDynamicScopeRefOkEvenThoughRuleRefExists()
           
 void testEscaped$InAction()
           
 void testEscapedLessThanInAction()
           
 void testForwardRefRuleLabels()
           
 void testFullyQualifiedRefToCurrentRuleParameter()
           
 void testFullyQualifiedRefToCurrentRuleRetVal()
           
 void testFullyQualifiedRefToTemplateAttributeInCurrentRule()
           
 void testGlobalScopeOutsideRule()
           
 void testIllegalAssignRuleRefAttr()
           
 void testIllegalAssignTokenRefAttr()
           
 void testIllegalAssignToLocalAttr()
           
 void testIllegalAssignToOwnRulenameAttr()
           
 void testImplicitRuleLabel()
           
 void testImplicitTokenLabel()
           
 void testIndexedGlobalScope()
           
 void testInvalidArguments()
           
 void testInvalidReturnValues()
           
 void testInvalidRuleAttribute()
           
 void testInvalidRuleLabelAccessesParameter()
           
 void testInvalidRuleLabelAccessesScopeAttribute()
           
 void testIsolatedDynamicRuleScopeRef()
           
 void testIsolatedGlobalScopeRef()
           
 void testIsolatedRefToCurrentRule()
           
 void testIsolatedRefToRule()
           
 void testLabelOnRuleRefInLexer()
           
 void testLexerLabelRefs()
           
 void testLexerRulePropertyRefs()
           
 void testListAndRuleLabelTypeMismatch()
           
 void testListAndTokenLabelTypeMismatch()
           
 void testMissingArgs()
           
 void testMissingArgsInLexer()
           
 void testMissingArgsOnTokenInLexerRuleOfCombined()
           
 void testMissingRuleAttribute()
           
 void testMissingUnlabeledRuleAttribute()
           
 void testMultipleReturnInitValue()
           
 void testNonDynamicAttributeOutsideRule()
           
 void testNonDynamicAttributeOutsideRule2()
           
 void testPlusEqualSetLabel()
           
 void testPlusEqualStringLabel()
           
 void testPlusEqualWildcardLabel()
           
 void testRefToReturnValueBeforeRefToPredefinedAttr()
          $x.start refs are checked during translation not before so ANTLR misses the fact that rule r has refs to predefined attributes if the ref is after the def of the method or self-referential.
 void testRefToRuleRefInLexer()
           
 void testRefToRuleRefInLexerNoAttribute()
           
 void testRefToStartAttributeForCurrentRule()
           
 void testRefToTemplateAttributeForCurrentRule()
           
 void testRefToTextAttributeForCurrentRule()
           
 void testRefToTextAttributeForCurrentTreeRule()
           
 void testReturnInitValue()
           
 void testReturnValue()
           
 void testReturnValues()
           
 void testReturnValueWithNumber()
           
 void testReturnWithMultipleRuleRefs()
           
 void testReuseExistingLabelWithImplicitRuleLabel()
           
 void testReuseExistingLabelWithImplicitTokenLabel()
           
 void testReuseExistingListLabelWithImplicitRuleLabel()
           
 void testReuseExistingListLabelWithImplicitTokenLabel()
           
 void testRuleAndTokenLabelTypeMismatch()
           
 void testRuleLabelBeforeRefToPredefinedAttr()
           
 void testRuleLabelFromMultipleAlts()
           
 void testRuleLabelOnTwoDifferentRulesAST()
           
 void testRuleLabelOnTwoDifferentRulesTemplate()
           
 void testRuleLabels()
           
 void testRuleLabelsWithSpecialToken()
           
 void testRuleLabelWithoutOutputOption()
           
 void testRuleRefWhenRuleHasScope()
           
 void testRuleRefWithDynamicScope()
           
 void testRuleScopeFromAnotherRule()
           
 void testRuleScopeOutsideRule()
           
 void testScopeAndAttributeWithUnderscore()
           
 void testSetFullyQualifiedRefToCurrentRuleRetVal()
           
 void testSettingLexerRulePropertyRefs()
           
 void testSharedGlobalScope()
           
 void testSimplePlusEqualLabel()
           
 void testTokenLabelFromMultipleAlts()
           
 void testTokenLabels()
           
 void testTokenLabelTreeProperty()
           
 void testTokenRefTreeProperty()
           
 void testTreeRuleStopAttributeIsInvalid()
           
 void testUnknownDynamicAttribute()
           
 void testUnknownGlobalDynamicAttribute()
           
 void testUnknownGlobalScope()
           
 void testUnqualifiedRuleScopeAccessInsideRule()
           
 void testUnqualifiedRuleScopeAttribute()
           
 void testWildcardCharLabelInLexer()
           
 void testWildcardCharListLabelInLexer()
           
 
Methods inherited from class org.antlr.test.BaseTest
antlr, compile, eraseFiles, execParser, execTreeParser, execTreeParser, getFirstLineOfException, mkdir, newTool, rawExecRecognizer, rawGenerateAndBuildRecognizer, writeFile, writeTemplateTestFile, writeTestFile, writeTreeTestFile
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestAttributes

public TestAttributes()
Public default constructor used by TestRig

Method Detail

testEscapedLessThanInAction

public void testEscapedLessThanInAction()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testEscaped$InAction

public void testEscaped$InAction()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testArguments

public void testArguments()
                   throws java.lang.Exception
Throws:
java.lang.Exception

testRefToReturnValueBeforeRefToPredefinedAttr

public void testRefToReturnValueBeforeRefToPredefinedAttr()
                                                   throws java.lang.Exception
$x.start refs are checked during translation not before so ANTLR misses the fact that rule r has refs to predefined attributes if the ref is after the def of the method or self-referential. Actually would be ok if I didn't convert actions to strings; keep as templates. June 9, 2006: made action translation leave templates not strings

Throws:
java.lang.Exception

testRuleLabelBeforeRefToPredefinedAttr

public void testRuleLabelBeforeRefToPredefinedAttr()
                                            throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidArguments

public void testInvalidArguments()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testReturnValue

public void testReturnValue()
                     throws java.lang.Exception
Throws:
java.lang.Exception

testReturnValueWithNumber

public void testReturnValueWithNumber()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testReturnValues

public void testReturnValues()
                      throws java.lang.Exception
Throws:
java.lang.Exception

testReturnWithMultipleRuleRefs

public void testReturnWithMultipleRuleRefs()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidReturnValues

public void testInvalidReturnValues()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testTokenLabels

public void testTokenLabels()
                     throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabels

public void testRuleLabels()
                    throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabelsWithSpecialToken

public void testRuleLabelsWithSpecialToken()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testForwardRefRuleLabels

public void testForwardRefRuleLabels()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidRuleLabelAccessesParameter

public void testInvalidRuleLabelAccessesParameter()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidRuleLabelAccessesScopeAttribute

public void testInvalidRuleLabelAccessesScopeAttribute()
                                                throws java.lang.Exception
Throws:
java.lang.Exception

testInvalidRuleAttribute

public void testInvalidRuleAttribute()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testMissingRuleAttribute

public void testMissingRuleAttribute()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testMissingUnlabeledRuleAttribute

public void testMissingUnlabeledRuleAttribute()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testNonDynamicAttributeOutsideRule

public void testNonDynamicAttributeOutsideRule()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testNonDynamicAttributeOutsideRule2

public void testNonDynamicAttributeOutsideRule2()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

testBasicGlobalScope

public void testBasicGlobalScope()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testUnknownGlobalScope

public void testUnknownGlobalScope()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testIndexedGlobalScope

public void testIndexedGlobalScope()
                            throws java.lang.Exception
Throws:
java.lang.Exception

test0IndexedGlobalScope

public void test0IndexedGlobalScope()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testAbsoluteIndexedGlobalScope

public void testAbsoluteIndexedGlobalScope()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testScopeAndAttributeWithUnderscore

public void testScopeAndAttributeWithUnderscore()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

testSharedGlobalScope

public void testSharedGlobalScope()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testGlobalScopeOutsideRule

public void testGlobalScopeOutsideRule()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testRuleScopeOutsideRule

public void testRuleScopeOutsideRule()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testBasicRuleScope

public void testBasicRuleScope()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testUnqualifiedRuleScopeAccessInsideRule

public void testUnqualifiedRuleScopeAccessInsideRule()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testIsolatedDynamicRuleScopeRef

public void testIsolatedDynamicRuleScopeRef()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

testDynamicRuleScopeRefInSubrule

public void testDynamicRuleScopeRefInSubrule()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testIsolatedGlobalScopeRef

public void testIsolatedGlobalScopeRef()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testRuleScopeFromAnotherRule

public void testRuleScopeFromAnotherRule()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testFullyQualifiedRefToCurrentRuleParameter

public void testFullyQualifiedRefToCurrentRuleParameter()
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

testFullyQualifiedRefToCurrentRuleRetVal

public void testFullyQualifiedRefToCurrentRuleRetVal()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testSetFullyQualifiedRefToCurrentRuleRetVal

public void testSetFullyQualifiedRefToCurrentRuleRetVal()
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

testIsolatedRefToCurrentRule

public void testIsolatedRefToCurrentRule()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testIsolatedRefToRule

public void testIsolatedRefToRule()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testFullyQualifiedRefToTemplateAttributeInCurrentRule

public void testFullyQualifiedRefToTemplateAttributeInCurrentRule()
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

testRuleRefWhenRuleHasScope

public void testRuleRefWhenRuleHasScope()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testDynamicScopeRefOkEvenThoughRuleRefExists

public void testDynamicScopeRefOkEvenThoughRuleRefExists()
                                                  throws java.lang.Exception
Throws:
java.lang.Exception

testRefToTemplateAttributeForCurrentRule

public void testRefToTemplateAttributeForCurrentRule()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testRefToTextAttributeForCurrentRule

public void testRefToTextAttributeForCurrentRule()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testRefToStartAttributeForCurrentRule

public void testRefToStartAttributeForCurrentRule()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

testTokenLabelFromMultipleAlts

public void testTokenLabelFromMultipleAlts()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabelFromMultipleAlts

public void testRuleLabelFromMultipleAlts()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testUnknownDynamicAttribute

public void testUnknownDynamicAttribute()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testUnknownGlobalDynamicAttribute

public void testUnknownGlobalDynamicAttribute()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testUnqualifiedRuleScopeAttribute

public void testUnqualifiedRuleScopeAttribute()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testRuleAndTokenLabelTypeMismatch

public void testRuleAndTokenLabelTypeMismatch()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testListAndTokenLabelTypeMismatch

public void testListAndTokenLabelTypeMismatch()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testListAndRuleLabelTypeMismatch

public void testListAndRuleLabelTypeMismatch()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testArgReturnValueMismatch

public void testArgReturnValueMismatch()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testSimplePlusEqualLabel

public void testSimplePlusEqualLabel()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testPlusEqualStringLabel

public void testPlusEqualStringLabel()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testPlusEqualSetLabel

public void testPlusEqualSetLabel()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testPlusEqualWildcardLabel

public void testPlusEqualWildcardLabel()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testImplicitTokenLabel

public void testImplicitTokenLabel()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testImplicitRuleLabel

public void testImplicitRuleLabel()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testReuseExistingLabelWithImplicitRuleLabel

public void testReuseExistingLabelWithImplicitRuleLabel()
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

testReuseExistingListLabelWithImplicitRuleLabel

public void testReuseExistingListLabelWithImplicitRuleLabel()
                                                     throws java.lang.Exception
Throws:
java.lang.Exception

testReuseExistingLabelWithImplicitTokenLabel

public void testReuseExistingLabelWithImplicitTokenLabel()
                                                  throws java.lang.Exception
Throws:
java.lang.Exception

testReuseExistingListLabelWithImplicitTokenLabel

public void testReuseExistingListLabelWithImplicitTokenLabel()
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabelWithoutOutputOption

public void testRuleLabelWithoutOutputOption()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabelOnTwoDifferentRulesAST

public void testRuleLabelOnTwoDifferentRulesAST()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

testRuleLabelOnTwoDifferentRulesTemplate

public void testRuleLabelOnTwoDifferentRulesTemplate()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

testMissingArgs

public void testMissingArgs()
                     throws java.lang.Exception
Throws:
java.lang.Exception

testArgsWhenNoneDefined

public void testArgsWhenNoneDefined()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testReturnInitValue

public void testReturnInitValue()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testMultipleReturnInitValue

public void testMultipleReturnInitValue()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testCStyleReturnInitValue

public void testCStyleReturnInitValue()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testArgsWithInitValues

public void testArgsWithInitValues()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testArgsOnToken

public void testArgsOnToken()
                     throws java.lang.Exception
Throws:
java.lang.Exception

testArgsOnTokenInLexer

public void testArgsOnTokenInLexer()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testLabelOnRuleRefInLexer

public void testLabelOnRuleRefInLexer()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testRefToRuleRefInLexer

public void testRefToRuleRefInLexer()
                             throws java.lang.Exception
Throws:
java.lang.Exception

testRefToRuleRefInLexerNoAttribute

public void testRefToRuleRefInLexerNoAttribute()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testCharLabelInLexer

public void testCharLabelInLexer()
                          throws java.lang.Exception
Throws:
java.lang.Exception

testCharListLabelInLexer

public void testCharListLabelInLexer()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testWildcardCharLabelInLexer

public void testWildcardCharLabelInLexer()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testWildcardCharListLabelInLexer

public void testWildcardCharListLabelInLexer()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testMissingArgsInLexer

public void testMissingArgsInLexer()
                            throws java.lang.Exception
Throws:
java.lang.Exception

testLexerRulePropertyRefs

public void testLexerRulePropertyRefs()
                               throws java.lang.Exception
Throws:
java.lang.Exception

testLexerLabelRefs

public void testLexerLabelRefs()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testSettingLexerRulePropertyRefs

public void testSettingLexerRulePropertyRefs()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testArgsOnTokenInLexerRuleOfCombined

public void testArgsOnTokenInLexerRuleOfCombined()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

testMissingArgsOnTokenInLexerRuleOfCombined

public void testMissingArgsOnTokenInLexerRuleOfCombined()
                                                 throws java.lang.Exception
Throws:
java.lang.Exception

testTokenLabelTreeProperty

public void testTokenLabelTreeProperty()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testTokenRefTreeProperty

public void testTokenRefTreeProperty()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testAmbiguousTokenRef

public void testAmbiguousTokenRef()
                           throws java.lang.Exception
Throws:
java.lang.Exception

testAmbiguousTokenRefWithProp

public void testAmbiguousTokenRefWithProp()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testRuleRefWithDynamicScope

public void testRuleRefWithDynamicScope()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testAssignToOwnRulenameAttr

public void testAssignToOwnRulenameAttr()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testAssignToOwnParamAttr

public void testAssignToOwnParamAttr()
                              throws java.lang.Exception
Throws:
java.lang.Exception

testIllegalAssignToOwnRulenameAttr

public void testIllegalAssignToOwnRulenameAttr()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testIllegalAssignToLocalAttr

public void testIllegalAssignToLocalAttr()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testIllegalAssignRuleRefAttr

public void testIllegalAssignRuleRefAttr()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

testIllegalAssignTokenRefAttr

public void testIllegalAssignTokenRefAttr()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testAssignToTreeNodeAttribute

public void testAssignToTreeNodeAttribute()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testDoNotTranslateAttributeCompare

public void testDoNotTranslateAttributeCompare()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testDoNotTranslateScopeAttributeCompare

public void testDoNotTranslateScopeAttributeCompare()
                                             throws java.lang.Exception
Throws:
java.lang.Exception

testTreeRuleStopAttributeIsInvalid

public void testTreeRuleStopAttributeIsInvalid()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

testRefToTextAttributeForCurrentTreeRule

public void testRefToTextAttributeForCurrentTreeRule()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

checkError

protected void checkError(ErrorQueue equeue,
                          GrammarSemanticsMessage expectedMessage)
                   throws java.lang.Exception
Throws:
java.lang.Exception

checkErrors

protected void checkErrors(ErrorQueue equeue,
                           java.util.ArrayList expectedMessages)
                    throws java.lang.Exception
Allow checking for multiple errors in one test

Throws:
java.lang.Exception