public void TestSymbolHashCode() { string s = "foo"; ISymbol sym1 = TransitFactory.Symbol("foo"); ISymbol sym2 = TransitFactory.Symbol("!foo".Substring(1)); ISymbol sym3 = TransitFactory.Symbol("bar"); IKeyword keyword = TransitFactory.Keyword("bar"); Assert.AreEqual(sym1.GetHashCode(), sym2.GetHashCode()); Assert.IsFalse(sym3.GetHashCode() == sym1.GetHashCode()); Assert.IsFalse(keyword.GetHashCode() == sym1.GetHashCode()); Assert.IsFalse(s.GetHashCode() == sym1.GetHashCode()); }
public void TestKeywordHashCode() { string s = "foo"; IKeyword k1 = TransitFactory.Keyword("foo"); IKeyword k2 = TransitFactory.Keyword("!foo".Substring(1)); IKeyword k3 = TransitFactory.Keyword("bar"); ISymbol symbol = TransitFactory.Symbol("bar"); Assert.AreEqual(k1.GetHashCode(), k2.GetHashCode()); Assert.IsFalse(k3.GetHashCode() == k1.GetHashCode()); Assert.IsFalse(symbol.GetHashCode() == k1.GetHashCode()); Assert.IsFalse(s.GetHashCode() == k1.GetHashCode()); }
public void TestUseISymbolAsDictionaryKey() { IDictionary <object, object> d = new Dictionary <object, object>(); d.Add(TransitFactory.Symbol("foo"), 1); d.Add("foo", 2); d.Add(TransitFactory.Symbol("bar"), 3); d.Add("bar", 4); Assert.AreEqual(1, d[TransitFactory.Symbol("foo")]); Assert.AreEqual(2, d["foo"]); Assert.AreEqual(3, d[TransitFactory.Symbol("bar")]); Assert.AreEqual(4, d["bar"]); }
public void TestSymbolEquality() { string s = "foo"; ISymbol sym1 = TransitFactory.Symbol("foo"); ISymbol sym2 = TransitFactory.Symbol("!foo".Substring(1)); ISymbol sym3 = TransitFactory.Symbol("bar"); Assert.AreEqual(sym1, sym2); Assert.AreEqual(sym2, sym1); Assert.IsFalse(sym1.Equals(sym3)); Assert.IsFalse(sym3.Equals(sym1)); Assert.IsFalse(s.Equals(sym1)); Assert.IsFalse(sym1.Equals(s)); }
public void TestSymbolComparator() { List <ISymbol> l = new List <ISymbol> { { TransitFactory.Symbol("bbb") }, { TransitFactory.Symbol("ccc") }, { TransitFactory.Symbol("abc") }, { TransitFactory.Symbol("dab") } }; l.Sort(); Assert.AreEqual("abc", l[0].ToString()); Assert.AreEqual("bbb", l[1].ToString()); Assert.AreEqual("ccc", l[2].ToString()); Assert.AreEqual("dab", l[3].ToString()); }
public void TestWriteSymbol() { Assert.AreEqual(ScalarVerbose("\"~$foo\""), WriteJsonVerbose(TransitFactory.Symbol("foo"))); }
public object FromRepresentation(object representation) { return(TransitFactory.Symbol((string)representation)); }