public void TestSelectStatement() { string text = @" select { case option1:{} case option2:{} case option3:{} }"; var selectStatement = NSScript.ParseStatement(text) as SelectStatement; Assert.NotNull(selectStatement); Assert.Equal(SyntaxNodeKind.SelectStatement, selectStatement.Kind); var body = selectStatement.Body; Assert.Equal(3, body.Statements.Length); var firstSection = body.Statements[0] as SelectSection; Assert.NotNull(firstSection); Assert.Equal(SyntaxNodeKind.SelectSection, firstSection.Kind); Assert.Equal("option1", firstSection.Label.FullName); Assert.NotNull(firstSection.Body); }
public void TestReturnStatement() { string text = "return;"; var statement = NSScript.ParseStatement(text) as ReturnStatement; Assert.NotNull(statement); Assert.Equal(SyntaxNodeKind.ReturnStatement, statement.Kind); }
public void TestCallSceneStatement() { string text = "call_scene @->testscene;"; var statement = NSScript.ParseStatement(text) as CallSceneStatement; Assert.NotNull(statement); Assert.Equal(SyntaxNodeKind.CallSceneStatement, statement.Kind); Assert.Equal("@->testscene", statement.SceneName.FullName); }
public void TestCallChapterStatement() { string text = "call_chapter @->testchapter;"; var statement = NSScript.ParseStatement(text) as CallChapterStatement; Assert.NotNull(statement); Assert.Equal(SyntaxNodeKind.CallChapterStatement, statement.Kind); Assert.Equal("@->testchapter", statement.ChapterName.FullName); }
public void TestWhileStatement() { string text = "while (true){}"; var whileStatement = NSScript.ParseStatement(text) as WhileStatement; Assert.NotNull(whileStatement); Assert.Equal(SyntaxNodeKind.WhileStatement, whileStatement.Kind); Assert.NotNull(whileStatement.Condition); Assert.NotNull(whileStatement.Body); string toStringResult = Helpers.RemoveNewLineCharacters(whileStatement.ToString()); Assert.Equal(text, toStringResult); }
public void TestIfStatementWithElseClause() { string text = "if (#flag == true){}else{}"; var ifStatement = NSScript.ParseStatement(text) as IfStatement; Assert.NotNull(ifStatement); Assert.Equal(SyntaxNodeKind.IfStatement, ifStatement.Kind); Assert.NotNull(ifStatement.Condition); Assert.NotNull(ifStatement.IfTrueStatement); Assert.NotNull(ifStatement.IfFalseStatement); string toStringResult = Helpers.RemoveNewLineCharacters(ifStatement.ToString()); Assert.Equal(text, toStringResult); }