Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/20/18 13:49:19 (6 years ago)
Author:
lkammere
Message:

#2886: Add constants to grammar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/Test/TreeHashingTest.cs

    r15834 r15849  
    1212    private TerminalSymbol varB;
    1313    private TerminalSymbol varC;
     14    private TerminalSymbol c;
    1415
    1516    [TestInitialize]
     
    2021      varB = grammar.VarTerminals.First(s => s.StringRepresentation == "b");
    2122      varC = grammar.VarTerminals.First(s => s.StringRepresentation == "c");
     23      c = grammar.Const;
    2224    }
    2325
     
    132134    }
    133135
     136    // Constants
     137    [TestMethod]
     138    [TestCategory("TreeHashing")]
     139    public void SimpleConst() {
     140      SymbolString s1 = new SymbolString(new Symbol[] { c, varA, grammar.Multiplication, c, grammar.Addition});
     141      SymbolString s2 = new SymbolString(new Symbol[] { c, varA, grammar.Multiplication, c, varA, grammar.Multiplication, grammar.Addition, c, grammar.Addition });
     142
     143      int hash1 = grammar.Hasher.CalcHashCode(s1);
     144      int hash2 = grammar.Hasher.CalcHashCode(s2);
     145
     146      Assert.AreEqual(hash1, hash2);
     147    }
     148
    134149    /* DEPRECATED; SINCE WE DO NOT ALLOW COMPOUND DIVISIONS
    135150    [TestMethod]
Note: See TracChangeset for help on using the changeset viewer.