Skip to content

Commit

Permalink
Added unit tests for Expression Language parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Jun 4, 2021
1 parent 2e248f5 commit 3501738
Show file tree
Hide file tree
Showing 99 changed files with 815 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
package fr.adrienbrault.idea.symfony2plugin.tests.expressionLanguage;

import com.intellij.testFramework.ParsingTestCase;
import fr.adrienbrault.idea.symfony2plugin.expressionLanguage.ExpressionLanguageParserDefinition;

public class ExpressionLanguageParsingTest extends ParsingTestCase {

public ExpressionLanguageParsingTest() {
super("", "test", new ExpressionLanguageParserDefinition());
}

public void testNotExpr() {
doTest(true);
}

public void testUnaryMinus() {
doTest(true);
}

public void testUnaryPlus() {
doTest(true);
}

public void testDivExpr() {
doTest(true);
}

public void testMulExpr() {
doTest(true);
}

public void testModExpr() {
doTest(true);
}

public void testPlusExpr() {
doTest(true);
}

public void testMinusExpr() {
doTest(true);
}

public void testRangeExpr() {
doTest(true);
}

public void testIdenticalExpr() {
doTest(true);
}

public void testNotIdenticalExpr() {
doTest(true);
}

public void testEqExpr() {
doTest(true);
}

public void testNotEqExpr() {
doTest(true);
}

public void testGtExpr() {
doTest(true);
}

public void testGteExpr() {
doTest(true);
}

public void testLtExpr() {
doTest(true);
}

public void testLteExpr() {
doTest(true);
}

public void testNotInExpr() {
doTest(true);
}

public void testInExpr() {
doTest(true);
}

public void testMatchesExpr() {
doTest(true);
}

public void testOrExpr() {
doTest(true);
}

public void testAndExpr() {
doTest(true);
}

public void testBitAndExpr() {
doTest(true);
}

public void testBitOrExpr() {
doTest(true);
}

public void testBitXorExpr() {
doTest(true);
}

public void testExpExpr() {
doTest(true);
}

public void testParenExpr() {
doTest(true);
}

public void testNumberLiteral() {
doTest(true);
}

public void testNumberLiteralWithFraction() {
doTest(true);
}

public void testStringDoubleQuoteLiteral() {
doTest(true);
}

public void testEmptyStringDoubleQuoteLiteral() {
doTest(true);
}

public void testStringSingleQuoteLiteral() {
doTest(true);
}

public void testEmptyStringSingleQuoteLiteral() {
doTest(true);
}

public void testTrueLiteral() {
doTest(true);
}

public void testTrueUppercaseLiteral() {
doTest(true);
}

public void testFalseLiteral() {
doTest(true);
}

public void testFalseUppercaseLiteral() {
doTest(true);
}

public void testNullLiteral() {
doTest(true);
}

public void testNullUppercaseLiteral() {
doTest(true);
}

public void testEmptyArrayLiteral() {
doTest(true);
}

public void testArrayLiteral() {
doTest(true);
}

public void testEmptyHashLiteral() {
doTest(true);
}

public void testHashLiteral() {
doTest(true);
}

public void testFunctionCallWithoutArgs() {
doTest(true);
}

public void testFunctionCallWithArgs() {
doTest(true);
}

public void testMethodCallWithoutArgs() {
doTest(true);
}

public void testMethodCallWithArgs() {
doTest(true);
}

public void testTernaryExpr() {
doTest(true);
}

public void testElvisExpr() {
doTest(true);
}

@Override
protected String getTestDataPath() {
return "src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/expressionLanguage/testData";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a && b
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Expression Language File
ExpressionLanguageAndExprImpl(AND_EXPR)
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.OP_AND)('&&')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('b')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[1, a, "string", [], [1, 2, 3], {}, { foo: "Foo", bar: "Bar" }]
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Expression Language File
ExpressionLanguageArrayExprImpl(ARRAY_EXPR)
PsiElement( ExpressionLanguageType.[)('[')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('1')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.string)('"string"')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageArrayExprImpl(ARRAY_EXPR)
PsiElement( ExpressionLanguageType.[)('[')
PsiElement( ExpressionLanguageType.])(']')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageArrayExprImpl(ARRAY_EXPR)
PsiElement( ExpressionLanguageType.[)('[')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('1')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('2')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('3')
PsiElement( ExpressionLanguageType.])(']')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageHashExprImpl(HASH_EXPR)
PsiElement( ExpressionLanguageType.{)('{')
PsiElement( ExpressionLanguageType.})('}')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageHashExprImpl(HASH_EXPR)
PsiElement( ExpressionLanguageType.{)('{')
PsiWhiteSpace(' ')
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('foo')
PsiElement( ExpressionLanguageType.syntax)(':')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.string)('"Foo"')
PsiElement( ExpressionLanguageType.syntax)(',')
PsiWhiteSpace(' ')
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('bar')
PsiElement( ExpressionLanguageType.syntax)(':')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.string)('"Bar"')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.})('}')
PsiElement( ExpressionLanguageType.])(']')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a & b
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Expression Language File
ExpressionLanguageBitAndExprImpl(BIT_AND_EXPR)
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.&)('&')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('b')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a | b
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Expression Language File
ExpressionLanguageBitOrExprImpl(BIT_OR_EXPR)
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.|)('|')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('b')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a ^ b
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Expression Language File
ExpressionLanguageBitXorExprImpl(BIT_XOR_EXPR)
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.^)('^')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('b')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 / 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Expression Language File
ExpressionLanguageDivExprImpl(DIV_EXPR)
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('4')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType./)('/')
PsiWhiteSpace(' ')
ExpressionLanguageLiteralExprImpl(LITERAL_EXPR)
PsiElement( ExpressionLanguageType.number)('2')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a ?: b
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Expression Language File
ExpressionLanguageTernaryExprImpl(TERNARY_EXPR)
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('a')
PsiWhiteSpace(' ')
PsiElement( ExpressionLanguageType.syntax)('?')
PsiErrorElement:<expr> expected, got ':'
<empty list>
PsiElement( ExpressionLanguageType.syntax)(':')
PsiWhiteSpace(' ')
ExpressionLanguageRefExprImpl(REF_EXPR)
ExpressionLanguageIdentifierImpl(IDENTIFIER)
PsiElement( ExpressionLanguageType.id)('b')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Expression Language File
ExpressionLanguageArrayExprImpl(ARRAY_EXPR)
PsiElement( ExpressionLanguageType.[)('[')
PsiElement( ExpressionLanguageType.])(']')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Expression Language File
ExpressionLanguageHashExprImpl(HASH_EXPR)
PsiElement( ExpressionLanguageType.{)('{')
PsiElement( ExpressionLanguageType.})('}')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
""
Loading

0 comments on commit 3501738

Please sign in to comment.