Пример #1
0
        private static ITranslationUnit BuildParenthesizedExpressionTranslationUnit(ParenthesizedExpressionSyntax expression, SemanticModel semanticModel)
        {
            ParenthesizedExpression parenthesizedExpressionHelper = new ParenthesizedExpression(expression, semanticModel);

            return(ParenthesizedExpressionTranslationUnit.Create(
                       new ExpressionTranslationUnitBuilder(parenthesizedExpressionHelper.Expression, semanticModel).Build()));
        }
Пример #2
0
        public void Parenthesized()
        {
            ITranslationUnit number = Expressions.RandomIntegerLiteral;

            ITranslationUnit translationUnit = ParenthesizedExpressionTranslationUnit.Create(number);

            string typescript = translationUnit.Translate();

            new Utils.FileWriter(TestSuite.Context).WriteToFile(typescript,
                                                                string.Format("{0}.Code", nameof(this.Parenthesized)),
                                                                Utils.FileType.TypeScript);

            Assert.AreEqual(string.Format("({0})", number.Translate()),
                            typescript, "Expression does not match expected!");
        }
Пример #3
0
        public string MixedExpressionSimpleParentheticArithmetic()
        {
            // Expression: 2 * 3 + 100++ * (200 - 300)
            var translationUnit = BinaryExpressionTranslationUnit.Create(
                BinaryExpressionTranslationUnit.Create(
                    LiteralTranslationUnit <int> .Create(2),
                    LiteralTranslationUnit <int> .Create(3),
                    OperatorToken.Multiplication),
                BinaryExpressionTranslationUnit.Create(
                    UnaryExpressionTranslationUnit.Create(
                        LiteralTranslationUnit <int> .Create(100),
                        OperatorToken.Increment,
                        UnaryExpressionTranslationUnit.UnaryPosition.Postfix),
                    ParenthesizedExpressionTranslationUnit.Create(
                        BinaryExpressionTranslationUnit.Create(
                            LiteralTranslationUnit <int> .Create(200),
                            LiteralTranslationUnit <int> .Create(300),
                            OperatorToken.Subtraction)),
                    OperatorToken.Multiplication),
                OperatorToken.Addition);

            return(translationUnit.Translate());
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="expression"></param>
 /// <returns></returns>
 public static ITranslationUnit BuildExpressionTranslationUnit(ITranslationUnit expression)
 {
     return(ParenthesizedExpressionTranslationUnit.Create(expression));
 }