Beispiel #1
0
        public void ReturnsTheVariableNameSuffixedWithAnIncrementingDigitWhenTheNameIsAlreadyUsed()
        {
            var n = new DefaultNamer();

            Assert.That(n.GetVariableName("variable", new HashSet <string> {
                "variable"
            }), Is.EqualTo("variable1"));
            Assert.That(n.GetVariableName("variable", new HashSet <string> {
                "variable", "variable1"
            }), Is.EqualTo("variable2"));
            Assert.That(n.GetVariableName("variable", new HashSet <string> {
                "variable", "variable1", "variable2"
            }), Is.EqualTo("variable3"));
        }
Beispiel #2
0
        public void ReturnsDollarTPlusAnIncrementingDigitWhenNoDesiredNameWasSpecified()
        {
            var n = new DefaultNamer();

            Assert.That(n.GetVariableName(null, new HashSet <string> {
            }), Is.EqualTo("$t1"));
            Assert.That(n.GetVariableName(null, new HashSet <string> {
                "$t1"
            }), Is.EqualTo("$t2"));
            Assert.That(n.GetVariableName(null, new HashSet <string> {
                "$t1", "$t2"
            }), Is.EqualTo("$t3"));
            Assert.That(n.GetVariableName(null, new HashSet <string> {
                "$t1", "$t2", "$t3"
            }), Is.EqualTo("$t4"));
        }
Beispiel #3
0
        public void ReturnsAValidJavaScriptIdentifierWithNameStartingWithDollarForTransparentIdentifers()
        {
            var n = new DefaultNamer();

            Assert.That(n.GetVariableName("<>identifier", new HashSet <string>()), Is.EqualTo("$identifier"));
        }
Beispiel #4
0
        public void DoesNotReturnKeywords()
        {
            var n = new DefaultNamer();

            Assert.That(n.GetVariableName("finally", new HashSet <string>()), Is.EqualTo("finally1"));
        }
Beispiel #5
0
        public void ReturnsTheVariableNameWhenPossible()
        {
            var n = new DefaultNamer();

            Assert.That(n.GetVariableName("variable", new HashSet <string>()), Is.EqualTo("variable"));
        }