Example #1
0
 public void BacktickTokenWorks()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("backtick check.txt"));
       handle.FastForwardToLine(3);
       var t = handle.ProcessWithToken<BacktickToken>();
       t.BackTickValue.ShouldBeEqualTo("echo y| cacls %(Binaries.Identity) /G everyone:R");
 }
Example #2
0
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     if (!commentMatch.IsMatch(handle.CurrentLine))
     return null;
       handle.CurrentHandled();
       return this;
 }
Example #3
0
 public void ADashCanBeEscaped()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptNeedingDashEscaping.txt"));
       handle.FastForwardToLine(5);
       var t = handle.ProcessWithToken<AnyToken>();
       t["ZipFileName"].ShouldBeEqualTo("ber-$(currentTag).zip");
 }
Example #4
0
 public void NodeWithOptionsHasIndexer()
 {
     var handle = new TokenizerHandle(DataMother.GetEmptyProjectFile());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t["DefaultTargets"].ShouldBeEqualTo("Main");
       t["Bla"].ShouldBeNull();
 }
Example #5
0
 public void PowershellScriptCallToken()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershellExecAsTask.txt"));
       handle.FastForwardToLine(4);
       var t = handle.ProcessWithToken<PSScriptCallToken>();
       t.ShouldNotBeNull();
       t.Word.ShouldBeEqualTo("MakeFile");
 }
Example #6
0
 public void NodeWithOptionsEscapesDefault()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("node with default needs escaping.txt"));
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t["Default"].ShouldBeEqualTo("Default stuff \" Hoho");
       t.Options.Count.ShouldBeEqualTo(4);
 }
Example #7
0
 public void DefaultOptionMapping()
 {
     var handle = new TokenizerHandle(DataMother.NodeWithOptionsVariantB());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t.MapDefaultTo("Option1");
       t["Default"].ShouldBeNull();
       t["Option1"].ShouldNotBeNull();
 }
Example #8
0
 protected override void withinHandle(TokenizerHandle tHandle)
 {
     var typeOfOutput = tHandle.CurrentLine.TrimStart(' ', '\t').Substring(0, 1);
       if (typeOfOutput == "@")
     ValueType = PSScriptReturnValueType.ItemGroup;
       else if (typeOfOutput == "$")
     ValueType = PSScriptReturnValueType.Property;
       else
     throw new InvalidOperationException("Impossible! No way!");
 }
Example #9
0
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     var match = psScriptStart.Match(handle.CurrentLine);
       if (match.Groups.Count != 2)
     return null;
       Terminator = match.Groups[1].Value;
       extractScript(handle);
       handle.CurrentHandled();
       return this;
 }
Example #10
0
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     var match = matchBacktick.Match(handle.CurrentLine);
       if (match.Groups.Count > 1)
       {
     BackTickValue = match.Groups[1].Value;
     handle.CurrentHandled();
     return this;
       }
       return null;
 }
Example #11
0
 public IToken Check(TokenizerHandle handle)
 {
     var t = this.handle(handle);
       if (t!= null)
       {
     var returnToken = t.Clone();
     t.reset();
     return returnToken;
       }
       return null;
 }
Example #12
0
 public void TokenHandleReturnsEmptyStringOnceItIsRunOut()
 {
     var th = new TokenizerHandle("hello" + Environment.NewLine + "world");
       th.Advance();
       th.CurrentLine.ShouldBeEqualTo("hello");
       th.CurrentHandled();
       th.Advance();
       th.CurrentLine.ShouldBeEqualTo("world");
       th.CurrentHandled();
       th.Advance();
       th.CurrentLine.ShouldBeNull();
 }
Example #13
0
        protected override AbstractToken handle(TokenizerHandle tHandle)
        {
            var m = matchRegEx.Match(tHandle.CurrentLine);
              if (m.Groups.Count == 0 || m.Groups.Count != 3)
            return null;

              VariableName = m.Groups[1].Captures[0].Value.Trim(' ');
              Value = m.Groups[2].Captures[0].Value.Trim(' ');
              tHandle.CurrentHandled();
              withinHandle(tHandle);
              return this;
        }
Example #14
0
        public void NodeWithOptionsWorksAsExpected()
        {
            var handle = new TokenizerHandle(DataMother.GetNodeWithOptions());
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.ShouldHaveCount(4);
              t.Options["Default"].StartsWith("Default").ShouldBeTrue();
              t.Options["Option1"].ShouldBeEqualTo("Bla di Bla");
              t.Options["Option3"].ShouldBeEqualTo("Blablub");
        }
Example #15
0
 protected void extractScript(TokenizerHandle h)
 {
     h.CurrentHandled();
       h.Advance();
       var rEnd = new Regex(@"\s*" + Terminator);
       var b = new StringBuilder();
       while (!rEnd.IsMatch(h.CurrentLine))
       {
     b.AppendLine(h.CurrentLine);
     h.CurrentHandled();
     h.Advance();
       }
       Script = b.ToString();
 }
Example #16
0
        public void TargetTokenWorksAsExpected()
        {
            var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
              handle.FastForwardToLine(3);

              var t = handle.ProcessWithToken<TargetToken>();
              t.ShouldNotBeNull();
              t.Options.ShouldHaveCount(2);
              t.Options["Default"].StartsWith("Default").ShouldBeTrue();
              t.Options["Depends"].StartsWith("Deps").ShouldBeTrue();
        }
Example #17
0
        public void ProjectTokenWorksAsExpectedVariantB()
        {
            var handle = new TokenizerHandle(DataMother.NodeWithOptionsVariantB());
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.Count.ShouldBeEqualTo(3);
        }
Example #18
0
 public void VariableTokenWorksAsExpected()
 {
     var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
       handle.FastForwardToLine(2);
       var t = handle.ProcessWithToken<VariableToken>();
       t.ShouldNotBeNull();
       t.VariableName.ShouldBeEqualTo("Foo");
       t.Value.ShouldBeEqualTo("Bar Baz");
 }
Example #19
0
 protected abstract AbstractToken handle(TokenizerHandle handle);
Example #20
0
 public void ProjectTokenDoesNotGobbleOptionsOfTargetToken()
 {
     var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t.Options.ShouldHaveCount(1);
 }
Example #21
0
 public void PowershellScriptToken()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershell.txt"));
       handle.FastForwardToLine(7);
       var t = handle.ProcessWithToken<PSExternalScriptToken>();
       t.ScriptName.ShouldBeEqualTo("smallPNGs");
       t.Script.IndexOf("echo").ShouldBeSmallerThan(5);
       t.Script.Contains("FullName").ShouldBeTrue();
       t.Terminator.ShouldBeEqualTo("END");
 }
Example #22
0
 public void PowershellScriptCallTokenNotMatchingScriptDef()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershell.txt"));
       handle.FastForwardToLine(7);
       var t = handle.ProcessWithToken<PSScriptCallToken>();
       t.ShouldBeNull();
 }
Example #23
0
 private static AnyToken asNodeWithOptions(AbstractDefinedValueToken varToken)
 {
     var h = new TokenizerHandle(varToken.Value);
     h.Advance();
     var anyToken = new AnyToken();
     anyToken = (AnyToken) anyToken.Check(h);
     if (anyToken == null)
       throw new ArgumentException("Value to " + varToken.VariableName + " could not be understood.");
     return anyToken;
 }
Example #24
0
        public void ProjectTokenWorksAsExpected()
        {
            var handle = new TokenizerHandle("Project \"Main\"");
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.Count.ShouldBeEqualTo(1);
              t.Word.ShouldBeEqualTo("Project");
        }
Example #25
0
 protected virtual void withinHandle(TokenizerHandle tHandle)
 {
 }
Example #26
0
File: EndToken.cs Project: flq/rfb
 public IToken Check(TokenizerHandle handle)
 {
     return null;
 }