Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 68233003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/element_test.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/parser_test.dart
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index e8f3dad20df26c6b4183afb9afe611f3a689f5b7..5332a38f55caebfd69a931274281f0d72c95859f 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -1,6 +1,8 @@
// This code was auto-generated, is not intended to be edited, and is subject to
// significant change. Please see the README file for more information.
+
library engine.parser_test;
+
import 'package:analyzer/src/generated/java_core.dart';
import 'package:analyzer/src/generated/java_junit.dart';
import 'package:analyzer/src/generated/error.dart';
@@ -15,6 +17,7 @@ import 'test_support.dart';
import 'scanner_test.dart' show TokenFactory;
import 'ast_test.dart' show ASTFactory;
import 'element_test.dart' show ElementFactory;
+
/**
* The class `SimpleParserTest` defines parser tests that test individual parsing method. The
* code fragments should be as minimal as possible in order to test the method, but should not test
@@ -30,188 +33,262 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("a", identifier.name);
JUnitTestCase.assertEquals(5, identifier.offset);
}
+
void test_computeStringValue_emptyInterpolationPrefix() {
JUnitTestCase.assertEquals("", computeStringValue("'''", true, false));
}
+
void test_computeStringValue_escape_b() {
JUnitTestCase.assertEquals("\b", computeStringValue("'\\b'", true, true));
}
+
void test_computeStringValue_escape_f() {
JUnitTestCase.assertEquals("\f", computeStringValue("'\\f'", true, true));
}
+
void test_computeStringValue_escape_n() {
JUnitTestCase.assertEquals("\n", computeStringValue("'\\n'", true, true));
}
+
void test_computeStringValue_escape_notSpecial() {
JUnitTestCase.assertEquals(":", computeStringValue("'\\:'", true, true));
}
+
void test_computeStringValue_escape_r() {
JUnitTestCase.assertEquals("\r", computeStringValue("'\\r'", true, true));
}
+
void test_computeStringValue_escape_t() {
JUnitTestCase.assertEquals("\t", computeStringValue("'\\t'", true, true));
}
+
void test_computeStringValue_escape_u_fixed() {
JUnitTestCase.assertEquals("\u4321", computeStringValue("'\\u4321'", true, true));
}
+
void test_computeStringValue_escape_u_variable() {
JUnitTestCase.assertEquals("\u0123", computeStringValue("'\\u{123}'", true, true));
}
+
void test_computeStringValue_escape_v() {
JUnitTestCase.assertEquals("\u000B", computeStringValue("'\\v'", true, true));
}
+
void test_computeStringValue_escape_x() {
JUnitTestCase.assertEquals("\u00FF", computeStringValue("'\\xFF'", true, true));
}
+
void test_computeStringValue_noEscape_single() {
JUnitTestCase.assertEquals("text", computeStringValue("'text'", true, true));
}
+
void test_computeStringValue_noEscape_triple() {
JUnitTestCase.assertEquals("text", computeStringValue("'''text'''", true, true));
}
+
void test_computeStringValue_raw_single() {
JUnitTestCase.assertEquals("text", computeStringValue("r'text'", true, true));
}
+
void test_computeStringValue_raw_triple() {
JUnitTestCase.assertEquals("text", computeStringValue("r'''text'''", true, true));
}
+
void test_computeStringValue_raw_withEscape() {
JUnitTestCase.assertEquals("two\\nlines", computeStringValue("r'two\\nlines'", true, true));
}
+
void test_computeStringValue_triple_internalQuote_first_empty() {
JUnitTestCase.assertEquals("'", computeStringValue("''''", true, false));
}
+
void test_computeStringValue_triple_internalQuote_first_nonEmpty() {
JUnitTestCase.assertEquals("'text", computeStringValue("''''text", true, false));
}
+
void test_computeStringValue_triple_internalQuote_last_empty() {
JUnitTestCase.assertEquals("", computeStringValue("'''", false, true));
}
+
void test_computeStringValue_triple_internalQuote_last_nonEmpty() {
JUnitTestCase.assertEquals("text", computeStringValue("text'''", false, true));
}
+
void test_constFactory() {
ParserTestCase.parse("parseClassMember", <Object> ["C"], "const factory C() = A;");
}
+
void test_createSyntheticIdentifier() {
SimpleIdentifier identifier = createSyntheticIdentifier();
JUnitTestCase.assertTrue(identifier.isSynthetic);
}
+
void test_createSyntheticStringLiteral() {
SimpleStringLiteral literal = createSyntheticStringLiteral();
JUnitTestCase.assertTrue(literal.isSynthetic);
}
+
void test_isFunctionDeclaration_nameButNoReturn_block() {
JUnitTestCase.assertTrue(isFunctionDeclaration("f() {}"));
}
+
void test_isFunctionDeclaration_nameButNoReturn_expression() {
JUnitTestCase.assertTrue(isFunctionDeclaration("f() => e"));
}
+
void test_isFunctionDeclaration_normalReturn_block() {
JUnitTestCase.assertTrue(isFunctionDeclaration("C f() {}"));
}
+
void test_isFunctionDeclaration_normalReturn_expression() {
JUnitTestCase.assertTrue(isFunctionDeclaration("C f() => e"));
}
+
void test_isFunctionDeclaration_voidReturn_block() {
JUnitTestCase.assertTrue(isFunctionDeclaration("void f() {}"));
}
+
void test_isFunctionDeclaration_voidReturn_expression() {
JUnitTestCase.assertTrue(isFunctionDeclaration("void f() => e"));
}
+
void test_isFunctionExpression_false_noBody() {
JUnitTestCase.assertFalse(isFunctionExpression("f();"));
}
+
void test_isFunctionExpression_false_notParameters() {
JUnitTestCase.assertFalse(isFunctionExpression("(a + b) {"));
}
+
void test_isFunctionExpression_noName_block() {
JUnitTestCase.assertTrue(isFunctionExpression("() {}"));
}
+
void test_isFunctionExpression_noName_expression() {
JUnitTestCase.assertTrue(isFunctionExpression("() => e"));
}
+
+ void test_isFunctionExpression_parameter_final() {
+ JUnitTestCase.assertTrue(isFunctionExpression("(final a) {}"));
+ JUnitTestCase.assertTrue(isFunctionExpression("(final a, b) {}"));
+ JUnitTestCase.assertTrue(isFunctionExpression("(final a, final b) {}"));
+ }
+
+ void test_isFunctionExpression_parameter_final_typed() {
+ JUnitTestCase.assertTrue(isFunctionExpression("(final int a) {}"));
+ JUnitTestCase.assertTrue(isFunctionExpression("(final prefix.List a) {}"));
+ JUnitTestCase.assertTrue(isFunctionExpression("(final List<int> a) {}"));
+ JUnitTestCase.assertTrue(isFunctionExpression("(final prefix.List<int> a) {}"));
+ }
+
void test_isFunctionExpression_parameter_multiple() {
JUnitTestCase.assertTrue(isFunctionExpression("(a, b) {}"));
}
+
void test_isFunctionExpression_parameter_named() {
JUnitTestCase.assertTrue(isFunctionExpression("({a}) {}"));
}
+
void test_isFunctionExpression_parameter_optional() {
JUnitTestCase.assertTrue(isFunctionExpression("([a]) {}"));
}
+
void test_isFunctionExpression_parameter_single() {
JUnitTestCase.assertTrue(isFunctionExpression("(a) {}"));
}
+
void test_isFunctionExpression_parameter_typed() {
JUnitTestCase.assertTrue(isFunctionExpression("(int a, int b) {}"));
}
+
void test_isInitializedVariableDeclaration_assignment() {
JUnitTestCase.assertFalse(isInitializedVariableDeclaration("a = null;"));
}
+
void test_isInitializedVariableDeclaration_comparison() {
JUnitTestCase.assertFalse(isInitializedVariableDeclaration("a < 0;"));
}
+
void test_isInitializedVariableDeclaration_conditional() {
JUnitTestCase.assertFalse(isInitializedVariableDeclaration("a == null ? init() : update();"));
}
+
void test_isInitializedVariableDeclaration_const_noType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("const a = 0;"));
}
+
void test_isInitializedVariableDeclaration_const_noType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("const a;"));
}
+
void test_isInitializedVariableDeclaration_const_simpleType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("const A a;"));
}
+
void test_isInitializedVariableDeclaration_final_noType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("final a = 0;"));
}
+
void test_isInitializedVariableDeclaration_final_noType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("final a;"));
}
+
void test_isInitializedVariableDeclaration_final_simpleType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("final A a = 0;"));
}
+
void test_isInitializedVariableDeclaration_functionDeclaration_typed() {
JUnitTestCase.assertFalse(isInitializedVariableDeclaration("A f() {};"));
}
+
void test_isInitializedVariableDeclaration_functionDeclaration_untyped() {
JUnitTestCase.assertFalse(isInitializedVariableDeclaration("f() {};"));
}
+
void test_isInitializedVariableDeclaration_noType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("var a = 0;"));
}
+
void test_isInitializedVariableDeclaration_noType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("var a;"));
}
+
void test_isInitializedVariableDeclaration_parameterizedType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("List<int> a = null;"));
}
+
void test_isInitializedVariableDeclaration_parameterizedType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("List<int> a;"));
}
+
void test_isInitializedVariableDeclaration_simpleType_initialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("A a = 0;"));
}
+
void test_isInitializedVariableDeclaration_simpleType_uninitialized() {
JUnitTestCase.assertTrue(isInitializedVariableDeclaration("A a;"));
}
+
void test_isSwitchMember_case_labeled() {
JUnitTestCase.assertTrue(isSwitchMember("l1: l2: case"));
}
+
void test_isSwitchMember_case_unlabeled() {
JUnitTestCase.assertTrue(isSwitchMember("case"));
}
+
void test_isSwitchMember_default_labeled() {
JUnitTestCase.assertTrue(isSwitchMember("l1: l2: default"));
}
+
void test_isSwitchMember_default_unlabeled() {
JUnitTestCase.assertTrue(isSwitchMember("default"));
}
+
void test_isSwitchMember_false() {
JUnitTestCase.assertFalse(isSwitchMember("break;"));
}
+
void test_parseAdditiveExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseAdditiveExpression", "x + y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -219,6 +296,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.PLUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseAdditiveExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseAdditiveExpression", "super + y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -226,6 +304,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.PLUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseAnnotation_n1() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -234,6 +313,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNull(annotation.arguments);
}
+
void test_parseAnnotation_n1_a() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A(x,y)", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -242,6 +322,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
+
void test_parseAnnotation_n2() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -250,6 +331,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNull(annotation.arguments);
}
+
void test_parseAnnotation_n2_a() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B(x,y)", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -258,6 +340,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
+
void test_parseAnnotation_n3() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B.C", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -266,6 +349,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(annotation.constructorName);
JUnitTestCase.assertNull(annotation.arguments);
}
+
void test_parseAnnotation_n3_a() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B.C(x,y)", []);
JUnitTestCase.assertNotNull(annotation.atSign);
@@ -274,6 +358,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
+
void test_parseArgument_named() {
NamedExpression expression = ParserTestCase.parse5("parseArgument", "n: x", []);
Label name = expression.name;
@@ -282,36 +367,43 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(name.colon);
JUnitTestCase.assertNotNull(expression.expression);
}
+
void test_parseArgument_unnamed() {
String lexeme = "x";
SimpleIdentifier identifier = ParserTestCase.parse5("parseArgument", lexeme, []);
JUnitTestCase.assertEquals(lexeme, identifier.name);
}
+
void test_parseArgumentDefinitionTest() {
ArgumentDefinitionTest test = ParserTestCase.parse5("parseArgumentDefinitionTest", "?x", [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]);
JUnitTestCase.assertNotNull(test.question);
JUnitTestCase.assertNotNull(test.identifier);
}
+
void test_parseArgumentList_empty() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "()", []);
NodeList<Expression> arguments = argumentList.arguments;
EngineTestCase.assertSize(0, arguments);
}
+
void test_parseArgumentList_mixed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(w, x, y: y, z: z)", []);
NodeList<Expression> arguments = argumentList.arguments;
EngineTestCase.assertSize(4, arguments);
}
+
void test_parseArgumentList_noNamed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(x, y, z)", []);
NodeList<Expression> arguments = argumentList.arguments;
EngineTestCase.assertSize(3, arguments);
}
+
void test_parseArgumentList_onlyNamed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(x: x, y: y)", []);
NodeList<Expression> arguments = argumentList.arguments;
EngineTestCase.assertSize(2, arguments);
}
+
void test_parseAssertStatement() {
AssertStatement statement = ParserTestCase.parse5("parseAssertStatement", "assert (x);", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -320,6 +412,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseAssignableExpression_expression_args_dot() {
PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "(x)(y).z");
FunctionExpressionInvocation invocation = propertyAccess.target as FunctionExpressionInvocation;
@@ -330,12 +423,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(propertyAccess.operator);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parseAssignableExpression_expression_dot() {
PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "(x).y");
JUnitTestCase.assertNotNull(propertyAccess.target);
JUnitTestCase.assertNotNull(propertyAccess.operator);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parseAssignableExpression_expression_index() {
IndexExpression expression = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "(x)[y]");
JUnitTestCase.assertNotNull(expression.target);
@@ -343,10 +438,12 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.index);
JUnitTestCase.assertNotNull(expression.rightBracket);
}
+
void test_parseAssignableExpression_identifier() {
SimpleIdentifier identifier = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "x");
JUnitTestCase.assertNotNull(identifier);
}
+
void test_parseAssignableExpression_identifier_args_dot() {
PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "x(y).z");
MethodInvocation invocation = propertyAccess.target as MethodInvocation;
@@ -357,12 +454,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(propertyAccess.operator);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parseAssignableExpression_identifier_dot() {
PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "x.y");
JUnitTestCase.assertNotNull(propertyAccess.target);
JUnitTestCase.assertNotNull(propertyAccess.operator);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parseAssignableExpression_identifier_index() {
IndexExpression expression = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "x[y]");
JUnitTestCase.assertNotNull(expression.target);
@@ -370,12 +469,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.index);
JUnitTestCase.assertNotNull(expression.rightBracket);
}
+
void test_parseAssignableExpression_super_dot() {
PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "super.y");
EngineTestCase.assertInstanceOf(SuperExpression, propertyAccess.target);
JUnitTestCase.assertNotNull(propertyAccess.operator);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parseAssignableExpression_super_index() {
IndexExpression expression = ParserTestCase.parse("parseAssignableExpression", <Object> [false], "super[y]");
EngineTestCase.assertInstanceOf(SuperExpression, expression.target);
@@ -383,21 +484,25 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.index);
JUnitTestCase.assertNotNull(expression.rightBracket);
}
+
void test_parseAssignableSelector_dot() {
PropertyAccess selector = ParserTestCase.parse("parseAssignableSelector", <Object> [null, true], ".x");
JUnitTestCase.assertNotNull(selector.operator);
JUnitTestCase.assertNotNull(selector.propertyName);
}
+
void test_parseAssignableSelector_index() {
IndexExpression selector = ParserTestCase.parse("parseAssignableSelector", <Object> [null, true], "[x]");
JUnitTestCase.assertNotNull(selector.leftBracket);
JUnitTestCase.assertNotNull(selector.index);
JUnitTestCase.assertNotNull(selector.rightBracket);
}
+
void test_parseAssignableSelector_none() {
SimpleIdentifier selector = ParserTestCase.parse("parseAssignableSelector", <Object> [new SimpleIdentifier.full(null), true], ";");
JUnitTestCase.assertNotNull(selector);
}
+
void test_parseBitwiseAndExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseAndExpression", "x & y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -405,6 +510,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.AMPERSAND, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBitwiseAndExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseAndExpression", "super & y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -412,6 +518,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.AMPERSAND, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBitwiseOrExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseOrExpression", "x | y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -419,6 +526,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.BAR, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBitwiseOrExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseOrExpression", "super | y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -426,6 +534,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.BAR, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBitwiseXorExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseXorExpression", "x ^ y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -433,6 +542,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.CARET, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBitwiseXorExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseBitwiseXorExpression", "super ^ y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -440,30 +550,35 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.CARET, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseBlock_empty() {
Block block = ParserTestCase.parse5("parseBlock", "{}", []);
JUnitTestCase.assertNotNull(block.leftBracket);
EngineTestCase.assertSize(0, block.statements);
JUnitTestCase.assertNotNull(block.rightBracket);
}
+
void test_parseBlock_nonEmpty() {
Block block = ParserTestCase.parse5("parseBlock", "{;}", []);
JUnitTestCase.assertNotNull(block.leftBracket);
EngineTestCase.assertSize(1, block.statements);
JUnitTestCase.assertNotNull(block.rightBracket);
}
+
void test_parseBreakStatement_label() {
BreakStatement statement = ParserTestCase.parse5("parseBreakStatement", "break foo;", []);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNotNull(statement.label);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseBreakStatement_noLabel() {
BreakStatement statement = ParserTestCase.parse5("parseBreakStatement", "break;", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNull(statement.label);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseCascadeSection_i() {
IndexExpression section = ParserTestCase.parse5("parseCascadeSection", "..[i]", []);
JUnitTestCase.assertNull(section.target);
@@ -471,11 +586,13 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(section.index);
JUnitTestCase.assertNotNull(section.rightBracket);
}
+
void test_parseCascadeSection_ia() {
FunctionExpressionInvocation section = ParserTestCase.parse5("parseCascadeSection", "..[i](b)", []);
EngineTestCase.assertInstanceOf(IndexExpression, section.function);
JUnitTestCase.assertNotNull(section.argumentList);
}
+
void test_parseCascadeSection_ii() {
MethodInvocation section = ParserTestCase.parse5("parseCascadeSection", "..a(b).c(d)", []);
EngineTestCase.assertInstanceOf(MethodInvocation, section.target);
@@ -484,12 +601,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(section.argumentList);
EngineTestCase.assertSize(1, section.argumentList.arguments);
}
+
void test_parseCascadeSection_p() {
PropertyAccess section = ParserTestCase.parse5("parseCascadeSection", "..a", []);
JUnitTestCase.assertNull(section.target);
JUnitTestCase.assertNotNull(section.operator);
JUnitTestCase.assertNotNull(section.propertyName);
}
+
void test_parseCascadeSection_p_assign() {
AssignmentExpression section = ParserTestCase.parse5("parseCascadeSection", "..a = 3", []);
JUnitTestCase.assertNotNull(section.leftHandSide);
@@ -497,6 +616,7 @@ class SimpleParserTest extends ParserTestCase {
Expression rhs = section.rightHandSide;
JUnitTestCase.assertNotNull(rhs);
}
+
void test_parseCascadeSection_p_assign_withCascade() {
AssignmentExpression section = ParserTestCase.parse5("parseCascadeSection", "..a = 3..m()", []);
JUnitTestCase.assertNotNull(section.leftHandSide);
@@ -504,12 +624,14 @@ class SimpleParserTest extends ParserTestCase {
Expression rhs = section.rightHandSide;
EngineTestCase.assertInstanceOf(IntegerLiteral, rhs);
}
+
void test_parseCascadeSection_p_builtIn() {
PropertyAccess section = ParserTestCase.parse5("parseCascadeSection", "..as", []);
JUnitTestCase.assertNull(section.target);
JUnitTestCase.assertNotNull(section.operator);
JUnitTestCase.assertNotNull(section.propertyName);
}
+
void test_parseCascadeSection_pa() {
MethodInvocation section = ParserTestCase.parse5("parseCascadeSection", "..a(b)", []);
JUnitTestCase.assertNull(section.target);
@@ -518,24 +640,28 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(section.argumentList);
EngineTestCase.assertSize(1, section.argumentList.arguments);
}
+
void test_parseCascadeSection_paa() {
FunctionExpressionInvocation section = ParserTestCase.parse5("parseCascadeSection", "..a(b)(c)", []);
EngineTestCase.assertInstanceOf(MethodInvocation, section.function);
JUnitTestCase.assertNotNull(section.argumentList);
EngineTestCase.assertSize(1, section.argumentList.arguments);
}
+
void test_parseCascadeSection_paapaa() {
FunctionExpressionInvocation section = ParserTestCase.parse5("parseCascadeSection", "..a(b)(c).d(e)(f)", []);
EngineTestCase.assertInstanceOf(MethodInvocation, section.function);
JUnitTestCase.assertNotNull(section.argumentList);
EngineTestCase.assertSize(1, section.argumentList.arguments);
}
+
void test_parseCascadeSection_pap() {
PropertyAccess section = ParserTestCase.parse5("parseCascadeSection", "..a(b).c", []);
JUnitTestCase.assertNotNull(section.target);
JUnitTestCase.assertNotNull(section.operator);
JUnitTestCase.assertNotNull(section.propertyName);
}
+
void test_parseClassDeclaration_abstract() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [
emptyCommentAndMetadata(),
@@ -551,6 +677,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_empty() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -564,6 +691,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_extends() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A extends B {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -577,6 +705,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_extendsAndImplements() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A extends B implements C {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -590,6 +719,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_extendsAndWith() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A extends B with C {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -604,6 +734,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, declaration.members);
JUnitTestCase.assertNotNull(declaration.rightBracket);
}
+
void test_parseClassDeclaration_extendsAndWithAndImplements() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A extends B with C implements D {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -618,6 +749,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, declaration.members);
JUnitTestCase.assertNotNull(declaration.rightBracket);
}
+
void test_parseClassDeclaration_implements() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A implements C {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -631,6 +763,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_native() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A native 'nativeValue' {}");
NativeClause nativeClause = declaration.nativeClause;
@@ -640,6 +773,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertSame(nativeClause.keyword, nativeClause.beginToken);
JUnitTestCase.assertSame(nativeClause.name.endToken, nativeClause.endToken);
}
+
void test_parseClassDeclaration_nonEmpty() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A {var f;}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -653,6 +787,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
+
void test_parseClassDeclaration_typeAlias_implementsC() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A = Object with B implements C;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -664,6 +799,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(1, typeAlias.implementsClause.interfaces.length);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseClassDeclaration_typeAlias_withB() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A = Object with B;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -675,6 +811,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseClassDeclaration_typeParameters() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A<B> {}");
JUnitTestCase.assertNull(declaration.documentationComment);
@@ -689,6 +826,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(declaration.typeParameters);
EngineTestCase.assertSize(1, declaration.typeParameters.typeParameters);
}
+
void test_parseClassMember_constructor_withInitializers() {
ConstructorDeclaration constructor = ParserTestCase.parse("parseClassMember", <Object> ["C"], "C(_, _\$, this.__) : _a = _ + _\$ {}");
JUnitTestCase.assertNotNull(constructor.body);
@@ -702,6 +840,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(constructor.returnType);
EngineTestCase.assertSize(1, constructor.initializers);
}
+
void test_parseClassMember_field_instance_prefixedType() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "p.A f;");
JUnitTestCase.assertNull(field.documentationComment);
@@ -714,6 +853,7 @@ class SimpleParserTest extends ParserTestCase {
VariableDeclaration variable = variables[0];
JUnitTestCase.assertNotNull(variable.name);
}
+
void test_parseClassMember_field_namedGet() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var get;");
JUnitTestCase.assertNull(field.documentationComment);
@@ -726,6 +866,7 @@ class SimpleParserTest extends ParserTestCase {
VariableDeclaration variable = variables[0];
JUnitTestCase.assertNotNull(variable.name);
}
+
void test_parseClassMember_field_namedOperator() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var operator;");
JUnitTestCase.assertNull(field.documentationComment);
@@ -738,6 +879,21 @@ class SimpleParserTest extends ParserTestCase {
VariableDeclaration variable = variables[0];
JUnitTestCase.assertNotNull(variable.name);
}
+
+ void test_parseClassMember_field_namedOperator_withAssignment() {
+ FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var operator = (5);");
+ JUnitTestCase.assertNull(field.documentationComment);
+ EngineTestCase.assertSize(0, field.metadata);
+ JUnitTestCase.assertNull(field.staticKeyword);
+ VariableDeclarationList list = field.fields;
+ JUnitTestCase.assertNotNull(list);
+ NodeList<VariableDeclaration> variables = list.variables;
+ EngineTestCase.assertSize(1, variables);
+ VariableDeclaration variable = variables[0];
+ JUnitTestCase.assertNotNull(variable.name);
+ JUnitTestCase.assertNotNull(variable.initializer);
+ }
+
void test_parseClassMember_field_namedSet() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var set;");
JUnitTestCase.assertNull(field.documentationComment);
@@ -750,6 +906,7 @@ class SimpleParserTest extends ParserTestCase {
VariableDeclaration variable = variables[0];
JUnitTestCase.assertNotNull(variable.name);
}
+
void test_parseClassMember_getter_void() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "void get g {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -761,6 +918,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(method.operatorKeyword);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_external() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "external m();");
JUnitTestCase.assertNotNull(method.body);
@@ -773,6 +931,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNull(method.returnType);
}
+
void test_parseClassMember_method_external_withTypeAndArgs() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "external int m(int a);");
JUnitTestCase.assertNotNull(method.body);
@@ -785,6 +944,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
}
+
void test_parseClassMember_method_get_noType() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "get() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -797,6 +957,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_get_type() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "int get() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -809,6 +970,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_get_void() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "void get() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -821,6 +983,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_operator_noType() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "operator() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -833,6 +996,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_operator_type() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "int operator() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -845,6 +1009,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_operator_void() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "void operator() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -857,6 +1022,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_returnType_parameterized() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "p.A m() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -869,6 +1035,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_set_noType() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "set() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -881,6 +1048,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_set_type() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "int set() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -893,6 +1061,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_method_set_void() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "void set() {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -905,6 +1074,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_operator_index() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "int operator [](int i) {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -917,6 +1087,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_operator_indexAssign() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "int operator []=(int i) {}");
JUnitTestCase.assertNull(method.documentationComment);
@@ -929,6 +1100,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.parameters);
JUnitTestCase.assertNotNull(method.body);
}
+
void test_parseClassMember_redirectingFactory_const() {
ConstructorDeclaration constructor = ParserTestCase.parse("parseClassMember", <Object> ["C"], "const factory C() = B;");
JUnitTestCase.assertNull(constructor.externalKeyword);
@@ -943,6 +1115,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(constructor.redirectedConstructor);
JUnitTestCase.assertNotNull(constructor.body);
}
+
void test_parseClassMember_redirectingFactory_nonConst() {
ConstructorDeclaration constructor = ParserTestCase.parse("parseClassMember", <Object> ["C"], "factory C() = B;");
JUnitTestCase.assertNull(constructor.externalKeyword);
@@ -957,6 +1130,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(constructor.redirectedConstructor);
JUnitTestCase.assertNotNull(constructor.body);
}
+
void test_parseClassTypeAlias() {
Token token = TokenFactory.token(Keyword.CLASS);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = B;");
@@ -969,6 +1143,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
+
void test_parseClassTypeAlias_abstract() {
Token token = TokenFactory.token(Keyword.CLASS);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = abstract B;");
@@ -981,6 +1156,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
+
void test_parseClassTypeAlias_implements() {
Token token = TokenFactory.token(Keyword.CLASS);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = B implements C;");
@@ -993,6 +1169,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
+
void test_parseClassTypeAlias_with() {
Token token = TokenFactory.token(Keyword.CLASS);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = B with C;");
@@ -1005,6 +1182,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
+
void test_parseClassTypeAlias_with_implements() {
Token token = TokenFactory.token(Keyword.CLASS);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = B with C implements D;");
@@ -1017,6 +1195,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
+
void test_parseCombinators_h() {
List<Combinator> combinators = ParserTestCase.parse5("parseCombinators", "hide a;", []);
EngineTestCase.assertSize(1, combinators);
@@ -1025,6 +1204,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(combinator.keyword);
EngineTestCase.assertSize(1, combinator.hiddenNames);
}
+
void test_parseCombinators_hs() {
List<Combinator> combinators = ParserTestCase.parse5("parseCombinators", "hide a show b;", []);
EngineTestCase.assertSize(2, combinators);
@@ -1037,10 +1217,12 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(showCombinator.keyword);
EngineTestCase.assertSize(1, showCombinator.shownNames);
}
+
void test_parseCombinators_hshs() {
List<Combinator> combinators = ParserTestCase.parse5("parseCombinators", "hide a show b hide c show d;", []);
EngineTestCase.assertSize(4, combinators);
}
+
void test_parseCombinators_s() {
List<Combinator> combinators = ParserTestCase.parse5("parseCombinators", "show a;", []);
EngineTestCase.assertSize(1, combinators);
@@ -1049,56 +1231,67 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(combinator.keyword);
EngineTestCase.assertSize(1, combinator.shownNames);
}
+
void test_parseCommentAndMetadata_c() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "/** 1 */ void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(0, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_cmc() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(1, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_cmcm() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ @B void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(2, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_cmm() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "/** 1 */ @A @B void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(2, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_m() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "@A void", []);
JUnitTestCase.assertNull(commentAndMetadata.comment);
EngineTestCase.assertSize(1, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_mcm() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "@A /** 1 */ @B void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(2, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_mcmc() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "@A /** 1 */ @B /** 2 */ void", []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(2, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_mm() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "@A @B(x) void", []);
JUnitTestCase.assertNull(commentAndMetadata.comment);
EngineTestCase.assertSize(2, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_none() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", "void", []);
JUnitTestCase.assertNull(commentAndMetadata.comment);
EngineTestCase.assertSize(0, commentAndMetadata.metadata);
}
+
void test_parseCommentAndMetadata_singleLine() {
CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", EngineTestCase.createSource(["/// 1", "/// 2", "void"]), []);
JUnitTestCase.assertNotNull(commentAndMetadata.comment);
EngineTestCase.assertSize(0, commentAndMetadata.metadata);
}
+
void test_parseCommentReference_new_prefixed() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["new a.b", 7], "");
PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(PrefixedIdentifier, reference.identifier);
@@ -1112,6 +1305,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("b", identifier.name);
JUnitTestCase.assertEquals(13, identifier.offset);
}
+
void test_parseCommentReference_new_simple() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["new a", 5], "");
SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(SimpleIdentifier, reference.identifier);
@@ -1119,6 +1313,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("a", identifier.name);
JUnitTestCase.assertEquals(9, identifier.offset);
}
+
void test_parseCommentReference_prefixed() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["a.b", 7], "");
PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(PrefixedIdentifier, reference.identifier);
@@ -1132,6 +1327,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("b", identifier.name);
JUnitTestCase.assertEquals(9, identifier.offset);
}
+
void test_parseCommentReference_simple() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["a", 5], "");
SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(SimpleIdentifier, reference.identifier);
@@ -1139,6 +1335,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("a", identifier.name);
JUnitTestCase.assertEquals(5, identifier.offset);
}
+
void test_parseCommentReferences_multiLine() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [b] zzz */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1152,6 +1349,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(20, reference.offset);
}
+
void test_parseCommentReferences_singleLine() {
List<Token> tokens = <Token> [
new StringToken(TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3),
@@ -1171,6 +1369,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(35, reference.offset);
}
+
void test_parseCommentReferences_skipCodeBlock_bracketed() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1180,6 +1379,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(24, reference.offset);
}
+
void test_parseCommentReferences_skipCodeBlock_spaces() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/**\n * a[i]\n * xxx [i] zzz\n */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1189,6 +1389,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(27, reference.offset);
}
+
void test_parseCommentReferences_skipLinkDefinition() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a]: http://www.google.com (Google) [b] zzz */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1198,6 +1399,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(44, reference.offset);
}
+
void test_parseCommentReferences_skipLinked() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a](http://www.google.com) [b] zzz */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1207,6 +1409,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(35, reference.offset);
}
+
void test_parseCommentReferences_skipReferenceLink() {
List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
@@ -1216,156 +1419,202 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(15, reference.offset);
}
+
void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "abstract<dynamic> _abstract = new abstract.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
+ void test_parseCompilationUnit_builtIn_asFunctionName() {
+ ParserTestCase.parse5("parseCompilationUnit", "abstract(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "as(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "dynamic(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "export(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "external(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "factory(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "get(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "implements(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "import(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "library(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "operator(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "part(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "set(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "static(x) => 0;", []);
+ ParserTestCase.parse5("parseCompilationUnit", "typedef(x) => 0;", []);
+ }
+
void test_parseCompilationUnit_directives_multiple() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "library l;\npart 'a.dart';", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(2, unit.directives);
EngineTestCase.assertSize(0, unit.declarations);
}
+
void test_parseCompilationUnit_directives_single() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "library l;", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(1, unit.directives);
EngineTestCase.assertSize(0, unit.declarations);
}
+
void test_parseCompilationUnit_empty() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(0, unit.declarations);
}
+
void test_parseCompilationUnit_exportAsPrefix() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "export.A _export = new export.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
void test_parseCompilationUnit_exportAsPrefix_parameterized() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "export<dynamic> _export = new export.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
void test_parseCompilationUnit_operatorAsPrefix_parameterized() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "operator<dynamic> _operator = new operator.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
void test_parseCompilationUnit_script() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "#! /bin/dart", []);
JUnitTestCase.assertNotNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(0, unit.declarations);
}
+
void test_parseCompilationUnit_topLevelDeclaration() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "class A {}", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
void test_parseCompilationUnit_typedefAsPrefix() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "typedef.A _typedef = new typedef.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
EngineTestCase.assertSize(0, unit.directives);
EngineTestCase.assertSize(1, unit.declarations);
}
+
void test_parseCompilationUnitMember_abstractAsPrefix() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "abstract.A _abstract = new abstract.A();");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseCompilationUnitMember_class() {
ClassDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "class A {}");
JUnitTestCase.assertEquals("A", declaration.name.name);
EngineTestCase.assertSize(0, declaration.members);
}
+
void test_parseCompilationUnitMember_constVariable() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "const int x = 0;");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseCompilationUnitMember_finalVariable() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "final x = 0;");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseCompilationUnitMember_function_external_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external f();");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_function_external_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external int f();");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_function_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "f() {}");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_function_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "int f() {}");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_function_void() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void f() {}");
JUnitTestCase.assertNotNull(declaration.returnType);
}
+
void test_parseCompilationUnitMember_getter_external_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external get p;");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_getter_external_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external int get p;");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_getter_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "get p => 0;");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_getter_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "int get p => 0;");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_setter_external_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external set p(v);");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_setter_external_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "external void set p(int v);");
JUnitTestCase.assertNotNull(declaration.externalKeyword);
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_setter_noType() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "set p(v) {}");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_setter_type() {
FunctionDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void set p(int v) {}");
JUnitTestCase.assertNotNull(declaration.functionExpression);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseCompilationUnitMember_typeAlias_abstract() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "class C = abstract S with M;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -1378,6 +1627,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseCompilationUnitMember_typeAlias_generic() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "class C<E> = S<E> with M<E> implements I<E>;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -1390,6 +1640,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseCompilationUnitMember_typeAlias_implements() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "class C = S with M implements I;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -1402,6 +1653,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseCompilationUnitMember_typeAlias_noImplements() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "class C = S with M;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -1414,26 +1666,31 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
+
void test_parseCompilationUnitMember_typedef() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "typedef F();");
JUnitTestCase.assertEquals("F", typeAlias.name.name);
EngineTestCase.assertSize(0, typeAlias.parameters.parameters);
}
+
void test_parseCompilationUnitMember_variable() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "var x = 0;");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseCompilationUnitMember_variableGet() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "String get = null;");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseCompilationUnitMember_variableSet() {
TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "String set = null;");
JUnitTestCase.assertNotNull(declaration.semicolon);
JUnitTestCase.assertNotNull(declaration.variables);
}
+
void test_parseConditionalExpression() {
ConditionalExpression expression = ParserTestCase.parse5("parseConditionalExpression", "x ? y : z", []);
JUnitTestCase.assertNotNull(expression.condition);
@@ -1442,6 +1699,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.colon);
JUnitTestCase.assertNotNull(expression.elseExpression);
}
+
void test_parseConstExpression_instanceCreation() {
InstanceCreationExpression expression = ParserTestCase.parse5("parseConstExpression", "const A()", []);
JUnitTestCase.assertNotNull(expression.keyword);
@@ -1452,6 +1710,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseConstExpression_listLiteral_typed() {
ListLiteral literal = ParserTestCase.parse5("parseConstExpression", "const <A> []", []);
JUnitTestCase.assertNotNull(literal.constKeyword);
@@ -1460,6 +1719,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseConstExpression_listLiteral_untyped() {
ListLiteral literal = ParserTestCase.parse5("parseConstExpression", "const []", []);
JUnitTestCase.assertNotNull(literal.constKeyword);
@@ -1468,6 +1728,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseConstExpression_mapLiteral_typed() {
MapLiteral literal = ParserTestCase.parse5("parseConstExpression", "const <A, B> {}", []);
JUnitTestCase.assertNotNull(literal.leftBracket);
@@ -1475,6 +1736,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(literal.rightBracket);
JUnitTestCase.assertNotNull(literal.typeArguments);
}
+
void test_parseConstExpression_mapLiteral_untyped() {
MapLiteral literal = ParserTestCase.parse5("parseConstExpression", "const {}", []);
JUnitTestCase.assertNotNull(literal.leftBracket);
@@ -1482,8 +1744,10 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(literal.rightBracket);
JUnitTestCase.assertNull(literal.typeArguments);
}
+
void test_parseConstructor() {
}
+
void test_parseConstructorFieldInitializer_qualified() {
ConstructorFieldInitializer invocation = ParserTestCase.parse5("parseConstructorFieldInitializer", "this.a = b", []);
JUnitTestCase.assertNotNull(invocation.equals);
@@ -1492,6 +1756,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNotNull(invocation.period);
}
+
void test_parseConstructorFieldInitializer_unqualified() {
ConstructorFieldInitializer invocation = ParserTestCase.parse5("parseConstructorFieldInitializer", "a = b", []);
JUnitTestCase.assertNotNull(invocation.equals);
@@ -1500,42 +1765,49 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(invocation.keyword);
JUnitTestCase.assertNull(invocation.period);
}
+
void test_parseConstructorName_named_noPrefix() {
ConstructorName name = ParserTestCase.parse5("parseConstructorName", "A.n;", []);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
}
+
void test_parseConstructorName_named_prefixed() {
ConstructorName name = ParserTestCase.parse5("parseConstructorName", "p.A.n;", []);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNotNull(name.period);
JUnitTestCase.assertNotNull(name.name);
}
+
void test_parseConstructorName_unnamed_noPrefix() {
ConstructorName name = ParserTestCase.parse5("parseConstructorName", "A;", []);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
}
+
void test_parseConstructorName_unnamed_prefixed() {
ConstructorName name = ParserTestCase.parse5("parseConstructorName", "p.A;", []);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
}
+
void test_parseContinueStatement_label() {
ContinueStatement statement = ParserTestCase.parse5("parseContinueStatement", "continue foo;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNotNull(statement.label);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseContinueStatement_noLabel() {
ContinueStatement statement = ParserTestCase.parse5("parseContinueStatement", "continue;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNull(statement.label);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseDirective_export() {
ExportDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1543,6 +1815,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseDirective_import() {
ImportDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1552,18 +1825,21 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseDirective_library() {
LibraryDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "library l;");
JUnitTestCase.assertNotNull(directive.libraryToken);
JUnitTestCase.assertNotNull(directive.name);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseDirective_part() {
PartDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "part 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.partToken);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseDirective_partOf() {
PartOfDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "part of l;");
JUnitTestCase.assertNotNull(directive.partToken);
@@ -1571,12 +1847,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(directive.libraryName);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseDocumentationComment_block() {
Comment comment = ParserTestCase.parse5("parseDocumentationComment", "/** */ class", []);
JUnitTestCase.assertFalse(comment.isBlock);
JUnitTestCase.assertTrue(comment.isDocumentation);
JUnitTestCase.assertFalse(comment.isEndOfLine);
}
+
void test_parseDocumentationComment_block_withReference() {
Comment comment = ParserTestCase.parse5("parseDocumentationComment", "/** [a] */ class", []);
JUnitTestCase.assertFalse(comment.isBlock);
@@ -1588,12 +1866,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(reference);
JUnitTestCase.assertEquals(5, reference.offset);
}
+
void test_parseDocumentationComment_endOfLine() {
Comment comment = ParserTestCase.parse5("parseDocumentationComment", "/// \n/// \n class", []);
JUnitTestCase.assertFalse(comment.isBlock);
JUnitTestCase.assertTrue(comment.isDocumentation);
JUnitTestCase.assertFalse(comment.isEndOfLine);
}
+
void test_parseDoStatement() {
DoStatement statement = ParserTestCase.parse5("parseDoStatement", "do {} while (x);", []);
JUnitTestCase.assertNotNull(statement.doKeyword);
@@ -1604,10 +1884,12 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseEmptyStatement() {
EmptyStatement statement = ParserTestCase.parse5("parseEmptyStatement", ";", []);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseEqualityExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseEqualityExpression", "x == y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -1615,6 +1897,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ_EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseEqualityExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseEqualityExpression", "super == y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -1622,6 +1905,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ_EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseExportDirective_hide() {
ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart' hide A, B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1629,6 +1913,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseExportDirective_hide_show() {
ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart' hide A show B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1636,6 +1921,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(2, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseExportDirective_noCombinator() {
ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1643,6 +1929,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseExportDirective_show() {
ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart' show A, B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1650,6 +1937,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseExportDirective_show_hide() {
ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Object> [emptyCommentAndMetadata()], "export 'lib/lib.dart' show B hide A;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -1657,6 +1945,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(2, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseExpression_assign() {
AssignmentExpression expression = ParserTestCase.parse5("parseExpression", "x = y", []);
JUnitTestCase.assertNotNull(expression.leftHandSide);
@@ -1664,6 +1953,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightHandSide);
}
+
void test_parseExpression_comparison() {
BinaryExpression expression = ParserTestCase.parse5("parseExpression", "--a.b == c", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -1671,6 +1961,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ_EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseExpression_invokeFunctionExpression() {
FunctionExpressionInvocation invocation = ParserTestCase.parse5("parseExpression", "(a) {return a + a;} (3)", []);
EngineTestCase.assertInstanceOf(FunctionExpression, invocation.function);
@@ -1681,20 +1972,24 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(list);
EngineTestCase.assertSize(1, list.arguments);
}
+
void test_parseExpression_superMethodInvocation() {
MethodInvocation invocation = ParserTestCase.parse5("parseExpression", "super.m()", []);
JUnitTestCase.assertNotNull(invocation.target);
JUnitTestCase.assertNotNull(invocation.methodName);
JUnitTestCase.assertNotNull(invocation.argumentList);
}
+
void test_parseExpressionList_multiple() {
List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1, 2, 3", []);
EngineTestCase.assertSize(3, result);
}
+
void test_parseExpressionList_single() {
List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1", []);
EngineTestCase.assertSize(1, result);
}
+
void test_parseExpressionWithoutCascade_assign() {
AssignmentExpression expression = ParserTestCase.parse5("parseExpressionWithoutCascade", "x = y", []);
JUnitTestCase.assertNotNull(expression.leftHandSide);
@@ -1702,6 +1997,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightHandSide);
}
+
void test_parseExpressionWithoutCascade_comparison() {
BinaryExpression expression = ParserTestCase.parse5("parseExpressionWithoutCascade", "--a.b == c", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -1709,86 +2005,99 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.EQ_EQ, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseExpressionWithoutCascade_superMethodInvocation() {
MethodInvocation invocation = ParserTestCase.parse5("parseExpressionWithoutCascade", "super.m()", []);
JUnitTestCase.assertNotNull(invocation.target);
JUnitTestCase.assertNotNull(invocation.methodName);
JUnitTestCase.assertNotNull(invocation.argumentList);
}
+
void test_parseExtendsClause() {
ExtendsClause clause = ParserTestCase.parse5("parseExtendsClause", "extends B", []);
JUnitTestCase.assertNotNull(clause.keyword);
JUnitTestCase.assertNotNull(clause.superclass);
EngineTestCase.assertInstanceOf(TypeName, clause.superclass);
}
+
void test_parseFinalConstVarOrType_const_noType() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "const");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.CONST, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.CONST, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNull(result.type);
}
+
void test_parseFinalConstVarOrType_const_type() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "const A a");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.CONST, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.CONST, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_final_noType() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "final");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.FINAL, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.FINAL, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNull(result.type);
}
+
void test_parseFinalConstVarOrType_final_prefixedType() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "final p.A a");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.FINAL, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.FINAL, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_final_type() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "final A a");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.FINAL, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.FINAL, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_type_parameterized() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "A<B> a");
JUnitTestCase.assertNull(result.keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_type_prefixed() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "p.A a");
JUnitTestCase.assertNull(result.keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_type_prefixedAndParameterized() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "p.A<B> a");
JUnitTestCase.assertNull(result.keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_type_simple() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "A a");
JUnitTestCase.assertNull(result.keyword);
JUnitTestCase.assertNotNull(result.type);
}
+
void test_parseFinalConstVarOrType_var() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "var");
Token keyword = result.keyword;
JUnitTestCase.assertNotNull(keyword);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword.type);
- JUnitTestCase.assertEquals(Keyword.VAR, ((keyword as KeywordToken)).keyword);
+ JUnitTestCase.assertEquals(Keyword.VAR, (keyword as KeywordToken).keyword);
JUnitTestCase.assertNull(result.type);
}
+
void test_parseFormalParameter_final_withType_named() {
ParameterKind kind = ParameterKind.NAMED;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "final A a : null");
@@ -1801,6 +2110,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_final_withType_normal() {
ParameterKind kind = ParameterKind.REQUIRED;
SimpleFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "final A a");
@@ -1809,6 +2119,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.type);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_final_withType_positional() {
ParameterKind kind = ParameterKind.POSITIONAL;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "final A a = null");
@@ -1821,6 +2132,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_nonFinal_withType_named() {
ParameterKind kind = ParameterKind.NAMED;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "A a : null");
@@ -1833,6 +2145,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_nonFinal_withType_normal() {
ParameterKind kind = ParameterKind.REQUIRED;
SimpleFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "A a");
@@ -1841,6 +2154,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.type);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_nonFinal_withType_positional() {
ParameterKind kind = ParameterKind.POSITIONAL;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "A a = null");
@@ -1853,6 +2167,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_var() {
ParameterKind kind = ParameterKind.REQUIRED;
SimpleFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "var a");
@@ -1861,6 +2176,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(parameter.type);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_var_named() {
ParameterKind kind = ParameterKind.NAMED;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "var a : null");
@@ -1873,6 +2189,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameter_var_positional() {
ParameterKind kind = ParameterKind.POSITIONAL;
DefaultFormalParameter parameter = ParserTestCase.parse("parseFormalParameter", <Object> [kind], "var a = null");
@@ -1885,6 +2202,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
+
void test_parseFormalParameterList_empty() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "()", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1893,6 +2211,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_named_multiple() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "({A a : 1, B b, C c : 3})", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1901,6 +2220,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_named_single() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "({A a})", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1909,6 +2229,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_normal_multiple() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "(A a, B b, C c)", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1917,6 +2238,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_normal_named() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "(A a, {B b})", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1925,6 +2247,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_normal_positional() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "(A a, [B b])", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1933,6 +2256,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_normal_single() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "(A a)", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1941,6 +2265,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_positional_multiple() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "([A a = null, B b, C c = null])", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1949,6 +2274,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseFormalParameterList_positional_single() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "([A a = null])", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
@@ -1957,6 +2283,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
+
void test_parseForStatement_each_identifier() {
ForEachStatement statement = ParserTestCase.parse5("parseForStatement", "for (element in list) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -1968,6 +2295,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_each_noType_metadata() {
ForEachStatement statement = ParserTestCase.parse5("parseForStatement", "for (@A var element in list) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -1980,6 +2308,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_each_type() {
ForEachStatement statement = ParserTestCase.parse5("parseForStatement", "for (A element in list) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -1991,6 +2320,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_each_var() {
ForEachStatement statement = ParserTestCase.parse5("parseForStatement", "for (var element in list) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2002,6 +2332,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_c() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (; i < count;) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2015,6 +2346,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_cu() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (; i < count; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2028,6 +2360,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_ecu() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (i--; i < count; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2041,6 +2374,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_i() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (var i = 0;;) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2057,6 +2391,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_i_withMetadata() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (@A var i = 0;;) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2073,6 +2408,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_ic() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (var i = 0; i < count;) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2088,6 +2424,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_icu() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (var i = 0; i < count; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2103,6 +2440,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_iicuu() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (int i = 0, j = count; i < j; i++, j--) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2118,6 +2456,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_iu() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (var i = 0;; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2133,6 +2472,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseForStatement_loop_u() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (;; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
@@ -2146,26 +2486,31 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseFunctionBody_block() {
BlockFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [false, null, false], "{}");
JUnitTestCase.assertNotNull(functionBody.block);
}
+
void test_parseFunctionBody_empty() {
EmptyFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [true, null, false], ";");
JUnitTestCase.assertNotNull(functionBody.semicolon);
}
+
void test_parseFunctionBody_expression() {
ExpressionFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [false, null, false], "=> y;");
JUnitTestCase.assertNotNull(functionBody.functionDefinition);
JUnitTestCase.assertNotNull(functionBody.expression);
JUnitTestCase.assertNotNull(functionBody.semicolon);
}
+
void test_parseFunctionBody_nativeFunctionBody() {
NativeFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [false, null, false], "native 'str';");
JUnitTestCase.assertNotNull(functionBody.nativeToken);
JUnitTestCase.assertNotNull(functionBody.stringLiteral);
JUnitTestCase.assertNotNull(functionBody.semicolon);
}
+
void test_parseFunctionDeclaration_function() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -2179,6 +2524,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.parameters);
JUnitTestCase.assertNull(declaration.propertyKeyword);
}
+
void test_parseFunctionDeclaration_getter() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -2192,6 +2538,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(expression.parameters);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseFunctionDeclaration_setter() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -2205,21 +2552,25 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.parameters);
JUnitTestCase.assertNotNull(declaration.propertyKeyword);
}
+
void test_parseFunctionDeclarationStatement() {
FunctionDeclarationStatement statement = ParserTestCase.parse5("parseFunctionDeclarationStatement", "void f(int p) => p * 2;", []);
JUnitTestCase.assertNotNull(statement.functionDeclaration);
}
+
void test_parseFunctionExpression_body_inExpression() {
FunctionExpression expression = ParserTestCase.parse5("parseFunctionExpression", "(int i) => i++", []);
JUnitTestCase.assertNotNull(expression.body);
JUnitTestCase.assertNotNull(expression.parameters);
- JUnitTestCase.assertNull(((expression.body as ExpressionFunctionBody)).semicolon);
+ JUnitTestCase.assertNull((expression.body as ExpressionFunctionBody).semicolon);
}
+
void test_parseFunctionExpression_minimal() {
FunctionExpression expression = ParserTestCase.parse5("parseFunctionExpression", "() {}", []);
JUnitTestCase.assertNotNull(expression.body);
JUnitTestCase.assertNotNull(expression.parameters);
}
+
void test_parseGetter_nonStatic() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -2234,6 +2585,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.propertyKeyword);
JUnitTestCase.assertEquals(returnType, method.returnType);
}
+
void test_parseGetter_static() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.token(Keyword.STATIC);
@@ -2253,14 +2605,17 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.propertyKeyword);
JUnitTestCase.assertEquals(returnType, method.returnType);
}
+
void test_parseIdentifierList_multiple() {
List<SimpleIdentifier> list = ParserTestCase.parse5("parseIdentifierList", "a, b, c", []);
EngineTestCase.assertSize(3, list);
}
+
void test_parseIdentifierList_single() {
List<SimpleIdentifier> list = ParserTestCase.parse5("parseIdentifierList", "a", []);
EngineTestCase.assertSize(1, list);
}
+
void test_parseIfStatement_else_block() {
IfStatement statement = ParserTestCase.parse5("parseIfStatement", "if (x) {} else {}", []);
JUnitTestCase.assertNotNull(statement.ifKeyword);
@@ -2271,6 +2626,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.elseKeyword);
JUnitTestCase.assertNotNull(statement.elseStatement);
}
+
void test_parseIfStatement_else_statement() {
IfStatement statement = ParserTestCase.parse5("parseIfStatement", "if (x) f(x); else f(y);", []);
JUnitTestCase.assertNotNull(statement.ifKeyword);
@@ -2281,6 +2637,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.elseKeyword);
JUnitTestCase.assertNotNull(statement.elseStatement);
}
+
void test_parseIfStatement_noElse_block() {
IfStatement statement = ParserTestCase.parse5("parseIfStatement", "if (x) {}", []);
JUnitTestCase.assertNotNull(statement.ifKeyword);
@@ -2291,6 +2648,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.elseKeyword);
JUnitTestCase.assertNull(statement.elseStatement);
}
+
void test_parseIfStatement_noElse_statement() {
IfStatement statement = ParserTestCase.parse5("parseIfStatement", "if (x) f(x);", []);
JUnitTestCase.assertNotNull(statement.ifKeyword);
@@ -2301,16 +2659,19 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.elseKeyword);
JUnitTestCase.assertNull(statement.elseStatement);
}
+
void test_parseImplementsClause_multiple() {
ImplementsClause clause = ParserTestCase.parse5("parseImplementsClause", "implements A, B, C", []);
EngineTestCase.assertSize(3, clause.interfaces);
JUnitTestCase.assertNotNull(clause.keyword);
}
+
void test_parseImplementsClause_single() {
ImplementsClause clause = ParserTestCase.parse5("parseImplementsClause", "implements A", []);
EngineTestCase.assertSize(1, clause.interfaces);
JUnitTestCase.assertNotNull(clause.keyword);
}
+
void test_parseImportDirective_hide() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart' hide A, B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2320,6 +2681,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseImportDirective_noCombinator() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2329,6 +2691,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseImportDirective_prefix() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart' as a;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2338,6 +2701,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseImportDirective_prefix_hide_show() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart' as a hide A show B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2347,6 +2711,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(2, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseImportDirective_prefix_show_hide() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart' as a show B hide A;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2356,6 +2721,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(2, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseImportDirective_show() {
ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Object> [emptyCommentAndMetadata()], "import 'lib/lib.dart' show A, B;");
JUnitTestCase.assertNotNull(directive.keyword);
@@ -2365,6 +2731,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseInitializedIdentifierList_type() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.token(Keyword.STATIC);
@@ -2383,6 +2750,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(staticKeyword, declaration.staticKeyword);
JUnitTestCase.assertNotNull(declaration.semicolon);
}
+
void test_parseInitializedIdentifierList_var() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.token(Keyword.STATIC);
@@ -2401,6 +2769,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(staticKeyword, declaration.staticKeyword);
JUnitTestCase.assertNotNull(declaration.semicolon);
}
+
void test_parseInstanceCreationExpression_qualifiedType() {
Token token = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token], "A.B()");
@@ -2412,6 +2781,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseInstanceCreationExpression_qualifiedType_named() {
Token token = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token], "A.B.c()");
@@ -2423,6 +2793,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseInstanceCreationExpression_type() {
Token token = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token], "A()");
@@ -2434,6 +2805,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseInstanceCreationExpression_type_named() {
Token token = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token], "A<B>.c()");
@@ -2445,22 +2817,26 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseLibraryDirective() {
LibraryDirective directive = ParserTestCase.parse("parseLibraryDirective", <Object> [emptyCommentAndMetadata()], "library l;");
JUnitTestCase.assertNotNull(directive.libraryToken);
JUnitTestCase.assertNotNull(directive.name);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parseLibraryIdentifier_multiple() {
String name = "a.b.c";
LibraryIdentifier identifier = ParserTestCase.parse5("parseLibraryIdentifier", name, []);
JUnitTestCase.assertEquals(name, identifier.name);
}
+
void test_parseLibraryIdentifier_single() {
String name = "a";
LibraryIdentifier identifier = ParserTestCase.parse5("parseLibraryIdentifier", name, []);
JUnitTestCase.assertEquals(name, identifier.name);
}
+
void test_parseListLiteral_empty_oneToken() {
Token token = TokenFactory.token(Keyword.CONST);
TypeArgumentList typeArguments = null;
@@ -2471,6 +2847,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListLiteral_empty_twoTokens() {
Token token = TokenFactory.token(Keyword.CONST);
TypeArgumentList typeArguments = null;
@@ -2481,6 +2858,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListLiteral_multiple() {
ListLiteral literal = ParserTestCase.parse("parseListLiteral", <Object> [null, null], "[1, 2, 3]");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2489,6 +2867,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(3, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListLiteral_single() {
ListLiteral literal = ParserTestCase.parse("parseListLiteral", <Object> [null, null], "[1]");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2497,6 +2876,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListOrMapLiteral_list_noType() {
ListLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object> [null], "[1]");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2505,6 +2885,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListOrMapLiteral_list_type() {
ListLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object> [null], "<int> [1]");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2513,6 +2894,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListOrMapLiteral_map_noType() {
MapLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object> [null], "{'1' : 1}");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2521,6 +2903,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseListOrMapLiteral_map_type() {
MapLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object> [null], "<String, int> {'1' : 1}");
JUnitTestCase.assertNull(literal.constKeyword);
@@ -2529,6 +2912,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseLogicalAndExpression() {
BinaryExpression expression = ParserTestCase.parse5("parseLogicalAndExpression", "x && y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -2536,6 +2920,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.AMPERSAND_AMPERSAND, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseLogicalOrExpression() {
BinaryExpression expression = ParserTestCase.parse5("parseLogicalOrExpression", "x || y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -2543,6 +2928,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.BAR_BAR, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseMapLiteral_empty() {
Token token = TokenFactory.token(Keyword.CONST);
TypeArgumentList typeArguments = ASTFactory.typeArgumentList([
@@ -2555,64 +2941,77 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseMapLiteral_multiple() {
MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null, null], "{'a' : b, 'x' : y}");
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(2, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseMapLiteral_single() {
MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null, null], "{'x' : y}");
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(1, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
+
void test_parseMapLiteralEntry_complex() {
MapLiteralEntry entry = ParserTestCase.parse5("parseMapLiteralEntry", "2 + 2 : y", []);
JUnitTestCase.assertNotNull(entry.key);
JUnitTestCase.assertNotNull(entry.separator);
JUnitTestCase.assertNotNull(entry.value);
}
+
void test_parseMapLiteralEntry_int() {
MapLiteralEntry entry = ParserTestCase.parse5("parseMapLiteralEntry", "0 : y", []);
JUnitTestCase.assertNotNull(entry.key);
JUnitTestCase.assertNotNull(entry.separator);
JUnitTestCase.assertNotNull(entry.value);
}
+
void test_parseMapLiteralEntry_string() {
MapLiteralEntry entry = ParserTestCase.parse5("parseMapLiteralEntry", "'x' : y", []);
JUnitTestCase.assertNotNull(entry.key);
JUnitTestCase.assertNotNull(entry.separator);
JUnitTestCase.assertNotNull(entry.value);
}
+
void test_parseModifiers_abstract() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "abstract A", []);
JUnitTestCase.assertNotNull(modifiers.abstractKeyword);
}
+
void test_parseModifiers_const() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "const A", []);
JUnitTestCase.assertNotNull(modifiers.constKeyword);
}
+
void test_parseModifiers_external() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "external A", []);
JUnitTestCase.assertNotNull(modifiers.externalKeyword);
}
+
void test_parseModifiers_factory() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "factory A", []);
JUnitTestCase.assertNotNull(modifiers.factoryKeyword);
}
+
void test_parseModifiers_final() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "final A", []);
JUnitTestCase.assertNotNull(modifiers.finalKeyword);
}
+
void test_parseModifiers_static() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "static A", []);
JUnitTestCase.assertNotNull(modifiers.staticKeyword);
}
+
void test_parseModifiers_var() {
Modifiers modifiers = ParserTestCase.parse5("parseModifiers", "var A", []);
JUnitTestCase.assertNotNull(modifiers.varKeyword);
}
+
void test_parseMultiplicativeExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseMultiplicativeExpression", "x * y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -2620,6 +3019,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.STAR, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseMultiplicativeExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseMultiplicativeExpression", "super * y", []);
EngineTestCase.assertInstanceOf(SuperExpression, expression.leftOperand);
@@ -2627,6 +3027,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.STAR, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseNewExpression() {
InstanceCreationExpression expression = ParserTestCase.parse5("parseNewExpression", "new A()", []);
JUnitTestCase.assertNotNull(expression.keyword);
@@ -2637,51 +3038,64 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parseNonLabeledStatement_const_list_empty() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const [];", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_const_list_nonEmpty() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const [1, 2];", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_const_map_empty() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const {};", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_const_map_nonEmpty() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const {'a' : 1};", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_const_object() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const A();", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_const_object_named_typeParameters() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "const A<B>.c();", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_constructorInvocation() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "new C().m();", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_false() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "false;", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_functionDeclaration() {
ParserTestCase.parse5("parseNonLabeledStatement", "f() {};", []);
}
+
void test_parseNonLabeledStatement_functionDeclaration_arguments() {
ParserTestCase.parse5("parseNonLabeledStatement", "f(void g()) {};", []);
}
+
void test_parseNonLabeledStatement_functionExpressionIndex() {
ParserTestCase.parse5("parseNonLabeledStatement", "() {}[0] = null;", []);
}
+
void test_parseNonLabeledStatement_functionInvocation() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "f();", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_invokeFunctionExpression() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "(a) {return a + a;} (3);", []);
EngineTestCase.assertInstanceOf(FunctionExpressionInvocation, statement.expression);
@@ -2694,22 +3108,27 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(list);
EngineTestCase.assertSize(1, list.arguments);
}
+
void test_parseNonLabeledStatement_null() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "null;", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_startingWithBuiltInIdentifier() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "library.getName();", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_true() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "true;", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNonLabeledStatement_typeCast() {
ExpressionStatement statement = ParserTestCase.parse5("parseNonLabeledStatement", "double.NAN as num;", []);
JUnitTestCase.assertNotNull(statement.expression);
}
+
void test_parseNormalFormalParameter_field_const_noType() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "const this.a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
@@ -2717,6 +3136,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_const_type() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "const A this.a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
@@ -2724,6 +3144,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_final_noType() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "final this.a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
@@ -2731,6 +3152,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_final_type() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "final A this.a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
@@ -2738,6 +3160,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_function_nested() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "this.a(B b))", []);
JUnitTestCase.assertNull(parameter.keyword);
@@ -2747,6 +3170,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList);
EngineTestCase.assertSize(1, parameterList.parameters);
}
+
void test_parseNormalFormalParameter_field_function_noNested() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "this.a())", []);
JUnitTestCase.assertNull(parameter.keyword);
@@ -2756,6 +3180,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameterList);
EngineTestCase.assertSize(0, parameterList.parameters);
}
+
void test_parseNormalFormalParameter_field_noType() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "this.a)", []);
JUnitTestCase.assertNull(parameter.keyword);
@@ -2763,6 +3188,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_type() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "A this.a)", []);
JUnitTestCase.assertNull(parameter.keyword);
@@ -2770,6 +3196,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_field_var() {
FieldFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "var this.a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
@@ -2777,60 +3204,70 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_function_noType() {
FunctionTypedFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "a())", []);
JUnitTestCase.assertNull(parameter.returnType);
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNotNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_function_type() {
FunctionTypedFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "A a())", []);
JUnitTestCase.assertNotNull(parameter.returnType);
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNotNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_function_void() {
FunctionTypedFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "void a())", []);
JUnitTestCase.assertNotNull(parameter.returnType);
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNotNull(parameter.parameters);
}
+
void test_parseNormalFormalParameter_simple_const_noType() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "const a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
JUnitTestCase.assertNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseNormalFormalParameter_simple_const_type() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "const A a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
JUnitTestCase.assertNotNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseNormalFormalParameter_simple_final_noType() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "final a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
JUnitTestCase.assertNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseNormalFormalParameter_simple_final_type() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "final A a)", []);
JUnitTestCase.assertNotNull(parameter.keyword);
JUnitTestCase.assertNotNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseNormalFormalParameter_simple_noType() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "a)", []);
JUnitTestCase.assertNull(parameter.keyword);
JUnitTestCase.assertNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseNormalFormalParameter_simple_type() {
SimpleFormalParameter parameter = ParserTestCase.parse5("parseNormalFormalParameter", "A a)", []);
JUnitTestCase.assertNull(parameter.keyword);
JUnitTestCase.assertNotNull(parameter.type);
JUnitTestCase.assertNotNull(parameter.identifier);
}
+
void test_parseOperator() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -2845,14 +3282,17 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertEquals(returnType, method.returnType);
}
+
void test_parseOptionalReturnType() {
}
+
void test_parsePartDirective_part() {
PartDirective directive = ParserTestCase.parse("parsePartDirective", <Object> [emptyCommentAndMetadata()], "part 'lib/lib.dart';");
JUnitTestCase.assertNotNull(directive.partToken);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parsePartDirective_partOf() {
PartOfDirective directive = ParserTestCase.parse("parsePartDirective", <Object> [emptyCommentAndMetadata()], "part of l;");
JUnitTestCase.assertNotNull(directive.partToken);
@@ -2860,40 +3300,47 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(directive.libraryName);
JUnitTestCase.assertNotNull(directive.semicolon);
}
+
void test_parsePostfixExpression_decrement() {
PostfixExpression expression = ParserTestCase.parse5("parsePostfixExpression", "i--", []);
JUnitTestCase.assertNotNull(expression.operand);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.MINUS_MINUS, expression.operator.type);
}
+
void test_parsePostfixExpression_increment() {
PostfixExpression expression = ParserTestCase.parse5("parsePostfixExpression", "i++", []);
JUnitTestCase.assertNotNull(expression.operand);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.PLUS_PLUS, expression.operator.type);
}
+
void test_parsePostfixExpression_none_indexExpression() {
IndexExpression expression = ParserTestCase.parse5("parsePostfixExpression", "a[0]", []);
JUnitTestCase.assertNotNull(expression.target);
JUnitTestCase.assertNotNull(expression.index);
}
+
void test_parsePostfixExpression_none_methodInvocation() {
MethodInvocation expression = ParserTestCase.parse5("parsePostfixExpression", "a.m()", []);
JUnitTestCase.assertNotNull(expression.target);
JUnitTestCase.assertNotNull(expression.methodName);
JUnitTestCase.assertNotNull(expression.argumentList);
}
+
void test_parsePostfixExpression_none_propertyAccess() {
PrefixedIdentifier expression = ParserTestCase.parse5("parsePostfixExpression", "a.b", []);
JUnitTestCase.assertNotNull(expression.prefix);
JUnitTestCase.assertNotNull(expression.identifier);
}
+
void test_parsePrefixedIdentifier_noPrefix() {
String lexeme = "bar";
SimpleIdentifier identifier = ParserTestCase.parse5("parsePrefixedIdentifier", lexeme, []);
JUnitTestCase.assertNotNull(identifier.token);
JUnitTestCase.assertEquals(lexeme, identifier.name);
}
+
void test_parsePrefixedIdentifier_prefix() {
String lexeme = "foo.bar";
PrefixedIdentifier identifier = ParserTestCase.parse5("parsePrefixedIdentifier", lexeme, []);
@@ -2901,86 +3348,104 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(identifier.period);
JUnitTestCase.assertEquals("bar", identifier.identifier.name);
}
+
void test_parsePrimaryExpression_const() {
InstanceCreationExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "const A()", []);
JUnitTestCase.assertNotNull(expression);
}
+
void test_parsePrimaryExpression_double() {
String doubleLiteral = "3.2e4";
DoubleLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", doubleLiteral, []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertEquals(double.parse(doubleLiteral), literal.value);
}
+
void test_parsePrimaryExpression_false() {
BooleanLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "false", []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertFalse(literal.value);
}
+
void test_parsePrimaryExpression_function_arguments() {
FunctionExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "(int i) => i + 1", []);
JUnitTestCase.assertNotNull(expression.parameters);
JUnitTestCase.assertNotNull(expression.body);
}
+
void test_parsePrimaryExpression_function_noArguments() {
FunctionExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "() => 42", []);
JUnitTestCase.assertNotNull(expression.parameters);
JUnitTestCase.assertNotNull(expression.body);
}
+
void test_parsePrimaryExpression_hex() {
String hexLiteral = "3F";
IntegerLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "0x${hexLiteral}", []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertEquals(int.parse(hexLiteral, radix: 16), literal.value);
}
+
void test_parsePrimaryExpression_identifier() {
SimpleIdentifier identifier = ParserTestCase.parse5("parsePrimaryExpression", "a", []);
JUnitTestCase.assertNotNull(identifier);
}
+
void test_parsePrimaryExpression_int() {
String intLiteral = "472";
IntegerLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", intLiteral, []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertEquals(int.parse(intLiteral), literal.value);
}
+
void test_parsePrimaryExpression_listLiteral() {
ListLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "[ ]", []);
JUnitTestCase.assertNotNull(literal);
}
+
void test_parsePrimaryExpression_listLiteral_index() {
ListLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "[]", []);
JUnitTestCase.assertNotNull(literal);
}
+
void test_parsePrimaryExpression_listLiteral_typed() {
ListLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "<A>[ ]", []);
JUnitTestCase.assertNotNull(literal.typeArguments);
EngineTestCase.assertSize(1, literal.typeArguments.arguments);
}
+
void test_parsePrimaryExpression_mapLiteral() {
MapLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "{}", []);
JUnitTestCase.assertNotNull(literal);
}
+
void test_parsePrimaryExpression_mapLiteral_typed() {
MapLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "<A, B>{}", []);
JUnitTestCase.assertNotNull(literal.typeArguments);
EngineTestCase.assertSize(2, literal.typeArguments.arguments);
}
+
void test_parsePrimaryExpression_new() {
InstanceCreationExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "new A()", []);
JUnitTestCase.assertNotNull(expression);
}
+
void test_parsePrimaryExpression_null() {
NullLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "null", []);
JUnitTestCase.assertNotNull(literal.literal);
}
+
void test_parsePrimaryExpression_parenthesized() {
ParenthesizedExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "(x)", []);
JUnitTestCase.assertNotNull(expression);
}
+
void test_parsePrimaryExpression_string() {
SimpleStringLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "\"string\"", []);
JUnitTestCase.assertFalse(literal.isMultiline);
JUnitTestCase.assertEquals("string", literal.value);
}
+
void test_parsePrimaryExpression_super() {
PropertyAccess propertyAccess = ParserTestCase.parse5("parsePrimaryExpression", "super.x", []);
JUnitTestCase.assertTrue(propertyAccess.target is SuperExpression);
@@ -2988,18 +3453,22 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.PERIOD, propertyAccess.operator.type);
JUnitTestCase.assertNotNull(propertyAccess.propertyName);
}
+
void test_parsePrimaryExpression_this() {
ThisExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "this", []);
JUnitTestCase.assertNotNull(expression.keyword);
}
+
void test_parsePrimaryExpression_true() {
BooleanLiteral literal = ParserTestCase.parse5("parsePrimaryExpression", "true", []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertTrue(literal.value);
}
+
void test_Parser() {
JUnitTestCase.assertNotNull(new Parser(null, null));
}
+
void test_parseRedirectingConstructorInvocation_named() {
RedirectingConstructorInvocation invocation = ParserTestCase.parse5("parseRedirectingConstructorInvocation", "this.a()", []);
JUnitTestCase.assertNotNull(invocation.argumentList);
@@ -3007,6 +3476,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNotNull(invocation.period);
}
+
void test_parseRedirectingConstructorInvocation_unnamed() {
RedirectingConstructorInvocation invocation = ParserTestCase.parse5("parseRedirectingConstructorInvocation", "this()", []);
JUnitTestCase.assertNotNull(invocation.argumentList);
@@ -3014,12 +3484,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNull(invocation.period);
}
+
void test_parseRelationalExpression_as() {
AsExpression expression = ParserTestCase.parse5("parseRelationalExpression", "x as Y", []);
JUnitTestCase.assertNotNull(expression.expression);
JUnitTestCase.assertNotNull(expression.asOperator);
JUnitTestCase.assertNotNull(expression.type);
}
+
void test_parseRelationalExpression_is() {
IsExpression expression = ParserTestCase.parse5("parseRelationalExpression", "x is y", []);
JUnitTestCase.assertNotNull(expression.expression);
@@ -3027,6 +3499,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(expression.notOperator);
JUnitTestCase.assertNotNull(expression.type);
}
+
void test_parseRelationalExpression_isNot() {
IsExpression expression = ParserTestCase.parse5("parseRelationalExpression", "x is! y", []);
JUnitTestCase.assertNotNull(expression.expression);
@@ -3034,6 +3507,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(expression.notOperator);
JUnitTestCase.assertNotNull(expression.type);
}
+
void test_parseRelationalExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseRelationalExpression", "x < y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -3041,6 +3515,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.LT, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseRelationalExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseRelationalExpression", "super < y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -3048,32 +3523,38 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.LT, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseRethrowExpression() {
RethrowExpression expression = ParserTestCase.parse5("parseRethrowExpression", "rethrow;", []);
JUnitTestCase.assertNotNull(expression.keyword);
}
+
void test_parseReturnStatement_noValue() {
ReturnStatement statement = ParserTestCase.parse5("parseReturnStatement", "return;", []);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNull(statement.expression);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseReturnStatement_value() {
ReturnStatement statement = ParserTestCase.parse5("parseReturnStatement", "return x;", []);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNotNull(statement.expression);
JUnitTestCase.assertNotNull(statement.semicolon);
}
+
void test_parseReturnType_nonVoid() {
TypeName typeName = ParserTestCase.parse5("parseReturnType", "A<B>", []);
JUnitTestCase.assertNotNull(typeName.name);
JUnitTestCase.assertNotNull(typeName.typeArguments);
}
+
void test_parseReturnType_void() {
TypeName typeName = ParserTestCase.parse5("parseReturnType", "void", []);
JUnitTestCase.assertNotNull(typeName.name);
JUnitTestCase.assertNull(typeName.typeArguments);
}
+
void test_parseSetter_nonStatic() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
@@ -3088,6 +3569,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.propertyKeyword);
JUnitTestCase.assertEquals(returnType, method.returnType);
}
+
void test_parseSetter_static() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.token(Keyword.STATIC);
@@ -3107,6 +3589,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(method.propertyKeyword);
JUnitTestCase.assertEquals(returnType, method.returnType);
}
+
void test_parseShiftExpression_normal() {
BinaryExpression expression = ParserTestCase.parse5("parseShiftExpression", "x << y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -3114,6 +3597,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.LT_LT, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseShiftExpression_super() {
BinaryExpression expression = ParserTestCase.parse5("parseShiftExpression", "super << y", []);
JUnitTestCase.assertNotNull(expression.leftOperand);
@@ -3121,54 +3605,65 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.LT_LT, expression.operator.type);
JUnitTestCase.assertNotNull(expression.rightOperand);
}
+
void test_parseSimpleIdentifier_builtInIdentifier() {
String lexeme = "as";
SimpleIdentifier identifier = ParserTestCase.parse5("parseSimpleIdentifier", lexeme, []);
JUnitTestCase.assertNotNull(identifier.token);
JUnitTestCase.assertEquals(lexeme, identifier.name);
}
+
void test_parseSimpleIdentifier_normalIdentifier() {
String lexeme = "foo";
SimpleIdentifier identifier = ParserTestCase.parse5("parseSimpleIdentifier", lexeme, []);
JUnitTestCase.assertNotNull(identifier.token);
JUnitTestCase.assertEquals(lexeme, identifier.name);
}
+
void test_parseSimpleIdentifier1_normalIdentifier() {
}
+
void test_parseStatement_functionDeclaration() {
FunctionDeclarationStatement statement = ParserTestCase.parse5("parseStatement", "int f(a, b) {};", []);
JUnitTestCase.assertNotNull(statement.functionDeclaration);
}
+
void test_parseStatement_mulipleLabels() {
LabeledStatement statement = ParserTestCase.parse5("parseStatement", "l: m: return x;", []);
EngineTestCase.assertSize(2, statement.labels);
JUnitTestCase.assertNotNull(statement.statement);
}
+
void test_parseStatement_noLabels() {
ParserTestCase.parse5("parseStatement", "return x;", []);
}
+
void test_parseStatement_singleLabel() {
LabeledStatement statement = ParserTestCase.parse5("parseStatement", "l: return x;", []);
EngineTestCase.assertSize(1, statement.labels);
JUnitTestCase.assertNotNull(statement.statement);
}
+
void test_parseStatements_multiple() {
List<Statement> statements = ParserTestCase.parseStatements("return; return;", 2, []);
EngineTestCase.assertSize(2, statements);
}
+
void test_parseStatements_single() {
List<Statement> statements = ParserTestCase.parseStatements("return;", 1, []);
EngineTestCase.assertSize(1, statements);
}
+
void test_parseStringLiteral_adjacent() {
AdjacentStrings literal = ParserTestCase.parse5("parseStringLiteral", "'a' 'b'", []);
NodeList<StringLiteral> strings = literal.strings;
EngineTestCase.assertSize(2, strings);
StringLiteral firstString = strings[0];
StringLiteral secondString = strings[1];
- JUnitTestCase.assertEquals("a", ((firstString as SimpleStringLiteral)).value);
- JUnitTestCase.assertEquals("b", ((secondString as SimpleStringLiteral)).value);
+ JUnitTestCase.assertEquals("a", (firstString as SimpleStringLiteral).value);
+ JUnitTestCase.assertEquals("b", (secondString as SimpleStringLiteral).value);
}
+
void test_parseStringLiteral_interpolated() {
StringInterpolation literal = ParserTestCase.parse5("parseStringLiteral", "'a \${b} c \$this d'", []);
NodeList<InterpolationElement> elements = literal.elements;
@@ -3179,11 +3674,13 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertTrue(elements[3] is InterpolationExpression);
JUnitTestCase.assertTrue(elements[4] is InterpolationString);
}
+
void test_parseStringLiteral_single() {
SimpleStringLiteral literal = ParserTestCase.parse5("parseStringLiteral", "'a'", []);
JUnitTestCase.assertNotNull(literal.literal);
JUnitTestCase.assertEquals("a", literal.value);
}
+
void test_parseSuperConstructorInvocation_named() {
SuperConstructorInvocation invocation = ParserTestCase.parse5("parseSuperConstructorInvocation", "super.a()", []);
JUnitTestCase.assertNotNull(invocation.argumentList);
@@ -3191,6 +3688,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNotNull(invocation.period);
}
+
void test_parseSuperConstructorInvocation_unnamed() {
SuperConstructorInvocation invocation = ParserTestCase.parse5("parseSuperConstructorInvocation", "super()", []);
JUnitTestCase.assertNotNull(invocation.argumentList);
@@ -3198,6 +3696,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNull(invocation.period);
}
+
void test_parseSwitchStatement_case() {
SwitchStatement statement = ParserTestCase.parse5("parseSwitchStatement", "switch (a) {case 1: return 'I';}", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -3208,6 +3707,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, statement.members);
JUnitTestCase.assertNotNull(statement.rightBracket);
}
+
void test_parseSwitchStatement_empty() {
SwitchStatement statement = ParserTestCase.parse5("parseSwitchStatement", "switch (a) {}", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -3218,6 +3718,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(0, statement.members);
JUnitTestCase.assertNotNull(statement.rightBracket);
}
+
void test_parseSwitchStatement_labeledCase() {
SwitchStatement statement = ParserTestCase.parse5("parseSwitchStatement", "switch (a) {l1: l2: l3: case(1):}", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -3229,6 +3730,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(3, statement.members[0].labels);
JUnitTestCase.assertNotNull(statement.rightBracket);
}
+
void test_parseSwitchStatement_labeledStatementInCase() {
SwitchStatement statement = ParserTestCase.parse5("parseSwitchStatement", "switch (a) {case 0: f(); l1: g(); break;}", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -3240,6 +3742,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(3, statement.members[0].statements);
JUnitTestCase.assertNotNull(statement.rightBracket);
}
+
void test_parseSymbolLiteral_builtInIdentifier() {
SymbolLiteral literal = ParserTestCase.parse5("parseSymbolLiteral", "#dynamic.static.abstract", []);
JUnitTestCase.assertNotNull(literal.poundSign);
@@ -3249,6 +3752,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("static", components[1].lexeme);
JUnitTestCase.assertEquals("abstract", components[2].lexeme);
}
+
void test_parseSymbolLiteral_multiple() {
SymbolLiteral literal = ParserTestCase.parse5("parseSymbolLiteral", "#a.b.c", []);
JUnitTestCase.assertNotNull(literal.poundSign);
@@ -3258,6 +3762,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals("b", components[1].lexeme);
JUnitTestCase.assertEquals("c", components[2].lexeme);
}
+
void test_parseSymbolLiteral_operator() {
SymbolLiteral literal = ParserTestCase.parse5("parseSymbolLiteral", "#==", []);
JUnitTestCase.assertNotNull(literal.poundSign);
@@ -3265,6 +3770,7 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertLength(1, components);
JUnitTestCase.assertEquals("==", components[0].lexeme);
}
+
void test_parseSymbolLiteral_single() {
SymbolLiteral literal = ParserTestCase.parse5("parseSymbolLiteral", "#a", []);
JUnitTestCase.assertNotNull(literal.poundSign);
@@ -3272,16 +3778,19 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertLength(1, components);
JUnitTestCase.assertEquals("a", components[0].lexeme);
}
+
void test_parseThrowExpression() {
ThrowExpression expression = ParserTestCase.parse5("parseThrowExpression", "throw x;", []);
JUnitTestCase.assertNotNull(expression.keyword);
JUnitTestCase.assertNotNull(expression.expression);
}
+
void test_parseThrowExpressionWithoutCascade() {
ThrowExpression expression = ParserTestCase.parse5("parseThrowExpressionWithoutCascade", "throw x;", []);
JUnitTestCase.assertNotNull(expression.keyword);
JUnitTestCase.assertNotNull(expression.expression);
}
+
void test_parseTryStatement_catch() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} catch (e) {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3299,6 +3808,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.finallyKeyword);
JUnitTestCase.assertNull(statement.finallyBlock);
}
+
void test_parseTryStatement_catch_finally() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} catch (e, s) {} finally {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3316,6 +3826,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.finallyKeyword);
JUnitTestCase.assertNotNull(statement.finallyBlock);
}
+
void test_parseTryStatement_finally() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} finally {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3324,6 +3835,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.finallyKeyword);
JUnitTestCase.assertNotNull(statement.finallyBlock);
}
+
void test_parseTryStatement_multiple() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} on NPE catch (e) {} on Error {} catch (e) {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3332,6 +3844,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.finallyKeyword);
JUnitTestCase.assertNull(statement.finallyBlock);
}
+
void test_parseTryStatement_on() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} on Error {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3349,6 +3862,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.finallyKeyword);
JUnitTestCase.assertNull(statement.finallyBlock);
}
+
void test_parseTryStatement_on_catch() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} on Error catch (e, s) {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3366,6 +3880,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(statement.finallyKeyword);
JUnitTestCase.assertNull(statement.finallyBlock);
}
+
void test_parseTryStatement_on_catch_finally() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {} on Error catch (e, s) {} finally {}", []);
JUnitTestCase.assertNotNull(statement.tryKeyword);
@@ -3383,6 +3898,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.finallyKeyword);
JUnitTestCase.assertNotNull(statement.finallyBlock);
}
+
void test_parseTypeAlias_function_noParameters() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef bool F();");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3392,6 +3908,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNull(typeAlias.typeParameters);
}
+
void test_parseTypeAlias_function_noReturnType() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef F();");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3401,6 +3918,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNull(typeAlias.typeParameters);
}
+
void test_parseTypeAlias_function_parameterizedReturnType() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef A<B> F();");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3410,6 +3928,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNull(typeAlias.typeParameters);
}
+
void test_parseTypeAlias_function_parameters() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef bool F(Object value);");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3419,6 +3938,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNull(typeAlias.typeParameters);
}
+
void test_parseTypeAlias_function_typeParameters() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef bool F<E>();");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3428,6 +3948,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNotNull(typeAlias.typeParameters);
}
+
void test_parseTypeAlias_function_voidReturnType() {
FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object> [emptyCommentAndMetadata()], "typedef void F();");
JUnitTestCase.assertNotNull(typeAlias.keyword);
@@ -3437,12 +3958,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(typeAlias.semicolon);
JUnitTestCase.assertNull(typeAlias.typeParameters);
}
+
void test_parseTypeArgumentList_multiple() {
TypeArgumentList argumentList = ParserTestCase.parse5("parseTypeArgumentList", "<int, int, int>", []);
JUnitTestCase.assertNotNull(argumentList.leftBracket);
EngineTestCase.assertSize(3, argumentList.arguments);
JUnitTestCase.assertNotNull(argumentList.rightBracket);
}
+
void test_parseTypeArgumentList_nested() {
TypeArgumentList argumentList = ParserTestCase.parse5("parseTypeArgumentList", "<A<B>>", []);
JUnitTestCase.assertNotNull(argumentList.leftBracket);
@@ -3454,64 +3977,75 @@ class SimpleParserTest extends ParserTestCase {
EngineTestCase.assertSize(1, innerList.arguments);
JUnitTestCase.assertNotNull(argumentList.rightBracket);
}
+
void test_parseTypeArgumentList_single() {
TypeArgumentList argumentList = ParserTestCase.parse5("parseTypeArgumentList", "<int>", []);
JUnitTestCase.assertNotNull(argumentList.leftBracket);
EngineTestCase.assertSize(1, argumentList.arguments);
JUnitTestCase.assertNotNull(argumentList.rightBracket);
}
+
void test_parseTypeName_parameterized() {
TypeName typeName = ParserTestCase.parse5("parseTypeName", "List<int>", []);
JUnitTestCase.assertNotNull(typeName.name);
JUnitTestCase.assertNotNull(typeName.typeArguments);
}
+
void test_parseTypeName_simple() {
TypeName typeName = ParserTestCase.parse5("parseTypeName", "int", []);
JUnitTestCase.assertNotNull(typeName.name);
JUnitTestCase.assertNull(typeName.typeArguments);
}
+
void test_parseTypeParameter_bounded() {
TypeParameter parameter = ParserTestCase.parse5("parseTypeParameter", "A extends B", []);
JUnitTestCase.assertNotNull(parameter.bound);
JUnitTestCase.assertNotNull(parameter.keyword);
JUnitTestCase.assertNotNull(parameter.name);
}
+
void test_parseTypeParameter_simple() {
TypeParameter parameter = ParserTestCase.parse5("parseTypeParameter", "A", []);
JUnitTestCase.assertNull(parameter.bound);
JUnitTestCase.assertNull(parameter.keyword);
JUnitTestCase.assertNotNull(parameter.name);
}
+
void test_parseTypeParameterList_multiple() {
TypeParameterList parameterList = ParserTestCase.parse5("parseTypeParameterList", "<A, B extends C, D>", []);
JUnitTestCase.assertNotNull(parameterList.leftBracket);
JUnitTestCase.assertNotNull(parameterList.rightBracket);
EngineTestCase.assertSize(3, parameterList.typeParameters);
}
+
void test_parseTypeParameterList_parameterizedWithTrailingEquals() {
TypeParameterList parameterList = ParserTestCase.parse5("parseTypeParameterList", "<A extends B<E>>=", []);
JUnitTestCase.assertNotNull(parameterList.leftBracket);
JUnitTestCase.assertNotNull(parameterList.rightBracket);
EngineTestCase.assertSize(1, parameterList.typeParameters);
}
+
void test_parseTypeParameterList_single() {
TypeParameterList parameterList = ParserTestCase.parse5("parseTypeParameterList", "<A>", []);
JUnitTestCase.assertNotNull(parameterList.leftBracket);
JUnitTestCase.assertNotNull(parameterList.rightBracket);
EngineTestCase.assertSize(1, parameterList.typeParameters);
}
+
void test_parseTypeParameterList_withTrailingEquals() {
TypeParameterList parameterList = ParserTestCase.parse5("parseTypeParameterList", "<A>=", []);
JUnitTestCase.assertNotNull(parameterList.leftBracket);
JUnitTestCase.assertNotNull(parameterList.rightBracket);
EngineTestCase.assertSize(1, parameterList.typeParameters);
}
+
void test_parseUnaryExpression_decrement_normal() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "--x", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.MINUS_MINUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_decrement_super() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "--super", []);
JUnitTestCase.assertNotNull(expression.operator);
@@ -3524,6 +4058,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(TokenType.MINUS, operand.operator.type);
JUnitTestCase.assertNotNull(operand.operand);
}
+
void test_parseUnaryExpression_decrement_super_propertyAccess() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "--super.x", []);
JUnitTestCase.assertNotNull(expression.operator);
@@ -3533,12 +4068,14 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertTrue(operand.target is SuperExpression);
JUnitTestCase.assertEquals("x", operand.propertyName.name);
}
+
void test_parseUnaryExpression_increment_normal() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "++x", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.PLUS_PLUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_increment_super_index() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "++super[0]", []);
JUnitTestCase.assertNotNull(expression.operator);
@@ -3548,6 +4085,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertTrue(operand.realTarget is SuperExpression);
JUnitTestCase.assertTrue(operand.index is IntegerLiteral);
}
+
void test_parseUnaryExpression_increment_super_propertyAccess() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "++super.x", []);
JUnitTestCase.assertNotNull(expression.operator);
@@ -3557,102 +4095,119 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertTrue(operand.target is SuperExpression);
JUnitTestCase.assertEquals("x", operand.propertyName.name);
}
+
void test_parseUnaryExpression_minus_normal() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "-x", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.MINUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_minus_super() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "-super", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.MINUS, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_not_normal() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "!x", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.BANG, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_not_super() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "!super", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.BANG, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_tilda_normal() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "~x", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.TILDE, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseUnaryExpression_tilda_super() {
PrefixExpression expression = ParserTestCase.parse5("parseUnaryExpression", "~super", []);
JUnitTestCase.assertNotNull(expression.operator);
JUnitTestCase.assertEquals(TokenType.TILDE, expression.operator.type);
JUnitTestCase.assertNotNull(expression.operand);
}
+
void test_parseVariableDeclaration_equals() {
VariableDeclaration declaration = ParserTestCase.parse5("parseVariableDeclaration", "a = b", []);
JUnitTestCase.assertNotNull(declaration.name);
JUnitTestCase.assertNotNull(declaration.equals);
JUnitTestCase.assertNotNull(declaration.initializer);
}
+
void test_parseVariableDeclaration_noEquals() {
VariableDeclaration declaration = ParserTestCase.parse5("parseVariableDeclaration", "a", []);
JUnitTestCase.assertNotNull(declaration.name);
JUnitTestCase.assertNull(declaration.equals);
JUnitTestCase.assertNull(declaration.initializer);
}
+
void test_parseVariableDeclarationList_const_noType() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "const a");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList_const_type() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "const A a");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNotNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList_final_noType() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "final a");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList_final_type() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "final A a");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNotNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList_type_multiple() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "A a, b, c");
JUnitTestCase.assertNull(declarationList.keyword);
JUnitTestCase.assertNotNull(declarationList.type);
EngineTestCase.assertSize(3, declarationList.variables);
}
+
void test_parseVariableDeclarationList_type_single() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "A a");
JUnitTestCase.assertNull(declarationList.keyword);
JUnitTestCase.assertNotNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList_var_multiple() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "var a, b, c");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNull(declarationList.type);
EngineTestCase.assertSize(3, declarationList.variables);
}
+
void test_parseVariableDeclarationList_var_single() {
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata()], "var a");
JUnitTestCase.assertNotNull(declarationList.keyword);
JUnitTestCase.assertNull(declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList2_type() {
TypeName type = new TypeName.full(new SimpleIdentifier.full(null), null);
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata(), null, type], "a");
@@ -3660,6 +4215,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertEquals(type, declarationList.type);
EngineTestCase.assertSize(1, declarationList.variables);
}
+
void test_parseVariableDeclarationList2_var() {
Token keyword = TokenFactory.token(Keyword.VAR);
VariableDeclarationList declarationList = ParserTestCase.parse("parseVariableDeclarationList", <Object> [emptyCommentAndMetadata(), keyword, null], "a, b, c");
@@ -3667,6 +4223,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNull(declarationList.type);
EngineTestCase.assertSize(3, declarationList.variables);
}
+
void test_parseVariableDeclarationStatement_multiple() {
VariableDeclarationStatement statement = ParserTestCase.parse("parseVariableDeclarationStatement", <Object> [emptyCommentAndMetadata()], "var x, y, z;");
JUnitTestCase.assertNotNull(statement.semicolon);
@@ -3674,6 +4231,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(variableList);
EngineTestCase.assertSize(3, variableList.variables);
}
+
void test_parseVariableDeclarationStatement_single() {
VariableDeclarationStatement statement = ParserTestCase.parse("parseVariableDeclarationStatement", <Object> [emptyCommentAndMetadata()], "var x;");
JUnitTestCase.assertNotNull(statement.semicolon);
@@ -3681,6 +4239,7 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(variableList);
EngineTestCase.assertSize(1, variableList.variables);
}
+
void test_parseWhileStatement() {
WhileStatement statement = ParserTestCase.parse5("parseWhileStatement", "while (x) {}", []);
JUnitTestCase.assertNotNull(statement.keyword);
@@ -3689,100 +4248,121 @@ class SimpleParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
+
void test_parseWithClause_multiple() {
WithClause clause = ParserTestCase.parse5("parseWithClause", "with A, B, C", []);
JUnitTestCase.assertNotNull(clause.withKeyword);
EngineTestCase.assertSize(3, clause.mixinTypes);
}
+
void test_parseWithClause_single() {
WithClause clause = ParserTestCase.parse5("parseWithClause", "with M", []);
JUnitTestCase.assertNotNull(clause.withKeyword);
EngineTestCase.assertSize(1, clause.mixinTypes);
}
+
void test_skipPrefixedIdentifier_invalid() {
Token following = skip("skipPrefixedIdentifier", "+");
JUnitTestCase.assertNull(following);
}
+
void test_skipPrefixedIdentifier_notPrefixed() {
Token following = skip("skipPrefixedIdentifier", "a +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipPrefixedIdentifier_prefixed() {
Token following = skip("skipPrefixedIdentifier", "a.b +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipReturnType_invalid() {
Token following = skip("skipReturnType", "+");
JUnitTestCase.assertNull(following);
}
+
void test_skipReturnType_type() {
Token following = skip("skipReturnType", "C +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipReturnType_void() {
Token following = skip("skipReturnType", "void +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipSimpleIdentifier_identifier() {
Token following = skip("skipSimpleIdentifier", "i +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipSimpleIdentifier_invalid() {
Token following = skip("skipSimpleIdentifier", "9 +");
JUnitTestCase.assertNull(following);
}
+
void test_skipSimpleIdentifier_pseudoKeyword() {
Token following = skip("skipSimpleIdentifier", "as +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipStringLiteral_adjacent() {
Token following = skip("skipStringLiteral", "'a' 'b' +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipStringLiteral_interpolated() {
Token following = skip("skipStringLiteral", "'a\${b}c' +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipStringLiteral_invalid() {
Token following = skip("skipStringLiteral", "a");
JUnitTestCase.assertNull(following);
}
+
void test_skipStringLiteral_single() {
Token following = skip("skipStringLiteral", "'a' +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipTypeArgumentList_invalid() {
Token following = skip("skipTypeArgumentList", "+");
JUnitTestCase.assertNull(following);
}
+
void test_skipTypeArgumentList_multiple() {
Token following = skip("skipTypeArgumentList", "<E, F, G> +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipTypeArgumentList_single() {
Token following = skip("skipTypeArgumentList", "<E> +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipTypeName_invalid() {
Token following = skip("skipTypeName", "+");
JUnitTestCase.assertNull(following);
}
+
void test_skipTypeName_parameterized() {
Token following = skip("skipTypeName", "C<E<F<G>>> +");
JUnitTestCase.assertNotNull(following);
JUnitTestCase.assertEquals(TokenType.PLUS, following.type);
}
+
void test_skipTypeName_simple() {
Token following = skip("skipTypeName", "C +");
JUnitTestCase.assertNotNull(following);
@@ -3799,7 +4379,7 @@ class SimpleParserTest extends ParserTestCase {
* @throws Exception if the method could not be invoked or throws an exception
*/
String computeStringValue(String lexeme, bool first, bool last) {
- AnalysisErrorListener listener = new AnalysisErrorListener_24();
+ AnalysisErrorListener listener = new AnalysisErrorListener_25();
Parser parser = new Parser(null, listener);
return invokeParserMethodImpl(parser, "computeStringValue", <Object> [lexeme, first, last], null) as String;
}
@@ -3902,6 +4482,7 @@ class SimpleParserTest extends ParserTestCase {
Parser parser = new Parser(null, listener);
return invokeParserMethodImpl(parser, methodName, <Object> [tokenStream], tokenStream) as Token;
}
+
static dartSuite() {
_ut.group('SimpleParserTest', () {
_ut.test('test_Parser', () {
@@ -4040,6 +4621,14 @@ class SimpleParserTest extends ParserTestCase {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_isFunctionExpression_noName_expression);
});
+ _ut.test('test_isFunctionExpression_parameter_final', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_isFunctionExpression_parameter_final);
+ });
+ _ut.test('test_isFunctionExpression_parameter_final_typed', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_isFunctionExpression_parameter_final_typed);
+ });
_ut.test('test_isFunctionExpression_parameter_multiple', () {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_isFunctionExpression_parameter_multiple);
@@ -4408,6 +4997,10 @@ class SimpleParserTest extends ParserTestCase {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseClassMember_field_namedOperator);
});
+ _ut.test('test_parseClassMember_field_namedOperator_withAssignment', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseClassMember_field_namedOperator_withAssignment);
+ });
_ut.test('test_parseClassMember_field_namedSet', () {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseClassMember_field_namedSet);
@@ -4704,6 +5297,10 @@ class SimpleParserTest extends ParserTestCase {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCompilationUnit_abstractAsPrefix_parameterized);
});
+ _ut.test('test_parseCompilationUnit_builtIn_asFunctionName', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCompilationUnit_builtIn_asFunctionName);
+ });
_ut.test('test_parseCompilationUnit_directives_multiple', () {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCompilationUnit_directives_multiple);
@@ -6035,11 +6632,13 @@ class SimpleParserTest extends ParserTestCase {
});
}
}
-class AnalysisErrorListener_24 implements AnalysisErrorListener {
+
+class AnalysisErrorListener_25 implements AnalysisErrorListener {
void onError(AnalysisError event) {
JUnitTestCase.fail("Unexpected compilation error: ${event.message} (${event.offset}, ${event.length})");
}
}
+
/**
* The class `ComplexParserTest` defines parser tests that test the parsing of more complex
* code fragments or the interactions between multiple parsing methods. For example, tests to ensure
@@ -6052,27 +6651,33 @@ class ComplexParserTest extends ParserTestCase {
BinaryExpression expression = ParserTestCase.parseExpression("x + y - z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_additiveExpression_noSpaces() {
BinaryExpression expression = ParserTestCase.parseExpression("i+1", []);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
EngineTestCase.assertInstanceOf(IntegerLiteral, expression.rightOperand);
}
+
void test_additiveExpression_precedence_multiplicative_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x * y + z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_additiveExpression_precedence_multiplicative_left_withSuper() {
BinaryExpression expression = ParserTestCase.parseExpression("super * y - z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_additiveExpression_precedence_multiplicative_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x + y * z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_additiveExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super + y - z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_assignableExpression_arguments_normal_chain() {
PropertyAccess propertyAccess1 = ParserTestCase.parseExpression("a(b)(c).d(e).f", []);
JUnitTestCase.assertEquals("f", propertyAccess1.propertyName.name);
@@ -6091,90 +6696,109 @@ class ComplexParserTest extends ParserTestCase {
JUnitTestCase.assertNotNull(argumentList4);
EngineTestCase.assertSize(1, argumentList4.arguments);
}
+
void test_assignmentExpression_compound() {
AssignmentExpression expression = ParserTestCase.parseExpression("x = y = 0", []);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftHandSide);
EngineTestCase.assertInstanceOf(AssignmentExpression, expression.rightHandSide);
}
+
void test_assignmentExpression_indexExpression() {
AssignmentExpression expression = ParserTestCase.parseExpression("x[1] = 0", []);
EngineTestCase.assertInstanceOf(IndexExpression, expression.leftHandSide);
EngineTestCase.assertInstanceOf(IntegerLiteral, expression.rightHandSide);
}
+
void test_assignmentExpression_prefixedIdentifier() {
AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0", []);
EngineTestCase.assertInstanceOf(PrefixedIdentifier, expression.leftHandSide);
EngineTestCase.assertInstanceOf(IntegerLiteral, expression.rightHandSide);
}
+
void test_assignmentExpression_propertyAccess() {
AssignmentExpression expression = ParserTestCase.parseExpression("super.y = 0", []);
EngineTestCase.assertInstanceOf(PropertyAccess, expression.leftHandSide);
EngineTestCase.assertInstanceOf(IntegerLiteral, expression.rightHandSide);
}
+
void test_bitwiseAndExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x & y & z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseAndExpression_precedence_equality_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x == y && z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseAndExpression_precedence_equality_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x && y == z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseAndExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super & y & z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseOrExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x | y | z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseOrExpression_precedence_xor_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseOrExpression_precedence_xor_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseOrExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super | y | z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseXorExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseXorExpression_precedence_and_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseXorExpression_precedence_and_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseXorExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super ^ y ^ z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_cascade_withAssignment() {
CascadeExpression cascade = ParserTestCase.parseExpression("new Map()..[3] = 4 ..[0] = 11;", []);
Expression target = cascade.target;
for (Expression section in cascade.cascadeSections) {
EngineTestCase.assertInstanceOf(AssignmentExpression, section);
- Expression lhs = ((section as AssignmentExpression)).leftHandSide;
+ Expression lhs = (section as AssignmentExpression).leftHandSide;
EngineTestCase.assertInstanceOf(IndexExpression, lhs);
IndexExpression index = lhs as IndexExpression;
JUnitTestCase.assertTrue(index.isCascaded);
JUnitTestCase.assertSame(target, index.realTarget);
}
}
+
void test_conditionalExpression_precedence_logicalOrExpression() {
ConditionalExpression expression = ParserTestCase.parseExpression("a | b ? y : z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.condition);
}
+
void test_constructor_initializer_withParenthesizedExpression() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.createSource([
"class C {",
@@ -6185,90 +6809,112 @@ class ComplexParserTest extends ParserTestCase {
NodeList<CompilationUnitMember> declarations = unit.declarations;
EngineTestCase.assertSize(1, declarations);
}
+
void test_equalityExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x == y != z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_equalityExpression_precedence_relational_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x is y == z", []);
EngineTestCase.assertInstanceOf(IsExpression, expression.leftOperand);
}
+
void test_equalityExpression_precedence_relational_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x == y is z", []);
EngineTestCase.assertInstanceOf(IsExpression, expression.rightOperand);
}
+
void test_equalityExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super == y != z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalAndExpression() {
BinaryExpression expression = ParserTestCase.parseExpression("x && y && z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalAndExpression_precedence_bitwiseOr_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x | y < z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalAndExpression_precedence_bitwiseOr_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x < y | z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_logicalOrExpression() {
BinaryExpression expression = ParserTestCase.parseExpression("x || y || z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalOrExpression_precedence_logicalAnd_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x && y || z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalOrExpression_precedence_logicalAnd_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x || y && z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_multipleLabels_statement() {
LabeledStatement statement = ParserTestCase.parseStatement("a: b: c: return x;", []);
EngineTestCase.assertSize(3, statement.labels);
EngineTestCase.assertInstanceOf(ReturnStatement, statement.statement);
}
+
void test_multiplicativeExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x * y / z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_multiplicativeExpression_precedence_unary_left() {
BinaryExpression expression = ParserTestCase.parseExpression("-x * y", []);
EngineTestCase.assertInstanceOf(PrefixExpression, expression.leftOperand);
}
+
void test_multiplicativeExpression_precedence_unary_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x * -y", []);
EngineTestCase.assertInstanceOf(PrefixExpression, expression.rightOperand);
}
+
void test_multiplicativeExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super * y / z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_relationalExpression_precedence_shift_right() {
IsExpression expression = ParserTestCase.parseExpression("x << y is z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.expression);
}
+
void test_shiftExpression_normal() {
BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_shiftExpression_precedence_additive_left() {
BinaryExpression expression = ParserTestCase.parseExpression("x + y << z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_shiftExpression_precedence_additive_right() {
BinaryExpression expression = ParserTestCase.parseExpression("x << y + z", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_shiftExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super >> 4 << 3", []);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_topLevelVariable_withMetadata() {
ParserTestCase.parseCompilationUnit("String @A string;", []);
}
+
static dartSuite() {
_ut.group('ComplexParserTest', () {
_ut.test('test_additiveExpression_noSpaces', () {
@@ -6462,12 +7108,12 @@ class ComplexParserTest extends ParserTestCase {
});
}
}
+
/**
* Instances of the class `ASTValidator` are used to validate the correct construction of an
* AST structure.
*/
class ASTValidator extends UnifyingASTVisitor<Object> {
-
/**
* A list containing the errors found while traversing the AST structure.
*/
@@ -6488,6 +7134,7 @@ class ASTValidator extends UnifyingASTVisitor<Object> {
JUnitTestCase.fail(builder.toString());
}
}
+
Object visitNode(ASTNode node) {
validate(node);
return super.visitNode(node);
@@ -6533,8 +7180,8 @@ class ASTValidator extends UnifyingASTVisitor<Object> {
}
}
}
-class ParserTestCase extends EngineTestCase {
+class ParserTestCase extends EngineTestCase {
/**
* An empty array of objects used as arguments to zero-argument methods.
*/
@@ -6769,11 +7416,13 @@ class ParserTestCase extends EngineTestCase {
* @return an empty CommentAndMetadata object that can be used for testing
*/
CommentAndMetadata emptyCommentAndMetadata() => new CommentAndMetadata(null, new List<Annotation>());
+
static dartSuite() {
_ut.group('ParserTestCase', () {
});
}
}
+
class ResolutionCopierTest extends EngineTestCase {
void test_visitAnnotation() {
String annotationName = "proxy";
@@ -6784,6 +7433,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitArgumentDefinitionTest() {
String identifier = "p";
ArgumentDefinitionTest fromNode = ASTFactory.argumentDefinitionTest(identifier);
@@ -6796,6 +7446,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitAsExpression() {
AsExpression fromNode = ASTFactory.asExpression(ASTFactory.identifier3("x"), ASTFactory.typeName4("A", []));
Type2 propagatedType = ElementFactory.classElement2("A", []).type;
@@ -6807,6 +7458,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitAssignmentExpression() {
AssignmentExpression fromNode = ASTFactory.assignmentExpression(ASTFactory.identifier3("a"), TokenType.PLUS_EQ, ASTFactory.identifier3("b"));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6824,6 +7476,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitBinaryExpression() {
BinaryExpression fromNode = ASTFactory.binaryExpression(ASTFactory.identifier3("a"), TokenType.PLUS, ASTFactory.identifier3("b"));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6841,6 +7494,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitBooleanLiteral() {
BooleanLiteral fromNode = ASTFactory.booleanLiteral(true);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6852,6 +7506,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitCascadeExpression() {
CascadeExpression fromNode = ASTFactory.cascadeExpression(ASTFactory.identifier3("a"), [ASTFactory.identifier3("b")]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6863,6 +7518,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitCompilationUnit() {
CompilationUnit fromNode = ASTFactory.compilationUnit();
CompilationUnitElement element = new CompilationUnitElementImpl("test.dart");
@@ -6871,6 +7527,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitConditionalExpression() {
ConditionalExpression fromNode = ASTFactory.conditionalExpression(ASTFactory.identifier3("c"), ASTFactory.identifier3("a"), ASTFactory.identifier3("b"));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6882,24 +7539,27 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitConstructorDeclaration() {
String className = "A";
String constructorName = "c";
ConstructorDeclaration fromNode = ASTFactory.constructorDeclaration(ASTFactory.identifier3(className), constructorName, ASTFactory.formalParameterList([]), null);
- ConstructorElement element = ElementFactory.constructorElement(ElementFactory.classElement2(className, []), constructorName);
+ ConstructorElement element = ElementFactory.constructorElement2(ElementFactory.classElement2(className, []), constructorName, []);
fromNode.element = element;
ConstructorDeclaration toNode = ASTFactory.constructorDeclaration(ASTFactory.identifier3(className), constructorName, ASTFactory.formalParameterList([]), null);
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitConstructorName() {
ConstructorName fromNode = ASTFactory.constructorName(ASTFactory.typeName4("A", []), "c");
- ConstructorElement staticElement = ElementFactory.constructorElement(ElementFactory.classElement2("A", []), "c");
+ ConstructorElement staticElement = ElementFactory.constructorElement2(ElementFactory.classElement2("A", []), "c", []);
fromNode.staticElement = staticElement;
ConstructorName toNode = ASTFactory.constructorName(ASTFactory.typeName4("A", []), "c");
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
}
+
void test_visitDoubleLiteral() {
DoubleLiteral fromNode = ASTFactory.doubleLiteral(1.0);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -6911,6 +7571,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitExportDirective() {
ExportDirective fromNode = ASTFactory.exportDirective2("dart:uri", []);
ExportElement element = new ExportElementImpl();
@@ -6919,6 +7580,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitFunctionExpression() {
FunctionExpression fromNode = ASTFactory.functionExpression2(ASTFactory.formalParameterList([]), ASTFactory.emptyFunctionBody());
MethodElement element = ElementFactory.methodElement("m", ElementFactory.classElement2("C", []).type, []);
@@ -6933,6 +7595,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitFunctionExpressionInvocation() {
FunctionExpressionInvocation fromNode = ASTFactory.functionExpressionInvocation(ASTFactory.identifier3("f"), []);
MethodElement propagatedElement = ElementFactory.methodElement("m", ElementFactory.classElement2("C", []).type, []);
@@ -6950,6 +7613,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitImportDirective() {
ImportDirective fromNode = ASTFactory.importDirective2("dart:uri", null, []);
ImportElement element = new ImportElementImpl();
@@ -6958,6 +7622,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitIndexExpression() {
IndexExpression fromNode = ASTFactory.indexExpression(ASTFactory.identifier3("a"), ASTFactory.integer(0));
MethodElement propagatedElement = ElementFactory.methodElement("m", ElementFactory.classElement2("C", []).type, []);
@@ -6978,11 +7643,12 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitInstanceCreationExpression() {
InstanceCreationExpression fromNode = ASTFactory.instanceCreationExpression2(Keyword.NEW, ASTFactory.typeName4("C", []), []);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
fromNode.propagatedType = propagatedType;
- ConstructorElement staticElement = ElementFactory.constructorElement(ElementFactory.classElement2("C", []), null);
+ ConstructorElement staticElement = ElementFactory.constructorElement2(ElementFactory.classElement2("C", []), null, []);
fromNode.staticElement = staticElement;
Type2 staticType = ElementFactory.classElement2("C", []).type;
fromNode.staticType = staticType;
@@ -6992,6 +7658,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitIntegerLiteral() {
IntegerLiteral fromNode = ASTFactory.integer(2);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7003,6 +7670,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitIsExpression() {
IsExpression fromNode = ASTFactory.isExpression(ASTFactory.identifier3("x"), false, ASTFactory.typeName4("A", []));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7014,6 +7682,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitLibraryIdentifier() {
LibraryIdentifier fromNode = ASTFactory.libraryIdentifier([ASTFactory.identifier3("lib")]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7025,6 +7694,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitListLiteral() {
ListLiteral fromNode = ASTFactory.listLiteral([]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7036,6 +7706,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitMapLiteral() {
MapLiteral fromNode = ASTFactory.mapLiteral2([]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7047,6 +7718,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitMethodInvocation() {
MethodInvocation fromNode = ASTFactory.methodInvocation2("m", []);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7058,6 +7730,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitNamedExpression() {
NamedExpression fromNode = ASTFactory.namedExpression2("n", ASTFactory.integer(0));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7069,6 +7742,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitNullLiteral() {
NullLiteral fromNode = ASTFactory.nullLiteral();
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7080,6 +7754,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitParenthesizedExpression() {
ParenthesizedExpression fromNode = ASTFactory.parenthesizedExpression(ASTFactory.integer(0));
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7091,6 +7766,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitPartDirective() {
PartDirective fromNode = ASTFactory.partDirective2("part.dart");
LibraryElement element = new LibraryElementImpl(null, ASTFactory.libraryIdentifier2(["lib"]));
@@ -7099,6 +7775,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitPartOfDirective() {
PartOfDirective fromNode = ASTFactory.partOfDirective(ASTFactory.libraryIdentifier2(["lib"]));
LibraryElement element = new LibraryElementImpl(null, ASTFactory.libraryIdentifier2(["lib"]));
@@ -7107,6 +7784,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(element, toNode.element);
}
+
void test_visitPostfixExpression() {
String variableName = "x";
PostfixExpression fromNode = ASTFactory.postfixExpression(ASTFactory.identifier3(variableName), TokenType.PLUS_PLUS);
@@ -7125,6 +7803,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitPrefixedIdentifier() {
PrefixedIdentifier fromNode = ASTFactory.identifier5("p", "f");
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7136,6 +7815,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitPrefixExpression() {
PrefixExpression fromNode = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, ASTFactory.identifier3("x"));
MethodElement propagatedElement = ElementFactory.methodElement("+", ElementFactory.classElement2("C", []).type, []);
@@ -7153,6 +7833,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitPropertyAccess() {
PropertyAccess fromNode = ASTFactory.propertyAccess2(ASTFactory.identifier3("x"), "y");
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7164,14 +7845,16 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitRedirectingConstructorInvocation() {
RedirectingConstructorInvocation fromNode = ASTFactory.redirectingConstructorInvocation([]);
- ConstructorElement staticElement = ElementFactory.constructorElement(ElementFactory.classElement2("C", []), null);
+ ConstructorElement staticElement = ElementFactory.constructorElement2(ElementFactory.classElement2("C", []), null, []);
fromNode.staticElement = staticElement;
RedirectingConstructorInvocation toNode = ASTFactory.redirectingConstructorInvocation([]);
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
}
+
void test_visitRethrowExpression() {
RethrowExpression fromNode = ASTFactory.rethrowExpression();
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7183,6 +7866,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitSimpleIdentifier() {
SimpleIdentifier fromNode = ASTFactory.identifier3("x");
MethodElement propagatedElement = ElementFactory.methodElement("m", ElementFactory.classElement2("C", []).type, []);
@@ -7203,6 +7887,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitSimpleStringLiteral() {
SimpleStringLiteral fromNode = ASTFactory.string2("abc");
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7214,6 +7899,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitStringInterpolation() {
StringInterpolation fromNode = ASTFactory.string([ASTFactory.interpolationString("a", "'a'")]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7225,14 +7911,16 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitSuperConstructorInvocation() {
SuperConstructorInvocation fromNode = ASTFactory.superConstructorInvocation([]);
- ConstructorElement staticElement = ElementFactory.constructorElement(ElementFactory.classElement2("C", []), null);
+ ConstructorElement staticElement = ElementFactory.constructorElement2(ElementFactory.classElement2("C", []), null, []);
fromNode.staticElement = staticElement;
SuperConstructorInvocation toNode = ASTFactory.superConstructorInvocation([]);
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(staticElement, toNode.staticElement);
}
+
void test_visitSuperExpression() {
SuperExpression fromNode = ASTFactory.superExpression();
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7244,6 +7932,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitSymbolLiteral() {
SymbolLiteral fromNode = ASTFactory.symbolLiteral(["s"]);
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7255,6 +7944,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitThisExpression() {
ThisExpression fromNode = ASTFactory.thisExpression();
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7266,6 +7956,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitThrowExpression() {
ThrowExpression fromNode = ASTFactory.throwExpression();
Type2 propagatedType = ElementFactory.classElement2("C", []).type;
@@ -7277,6 +7968,7 @@ class ResolutionCopierTest extends EngineTestCase {
JUnitTestCase.assertSame(propagatedType, toNode.propagatedType);
JUnitTestCase.assertSame(staticType, toNode.staticType);
}
+
void test_visitTypeName() {
TypeName fromNode = ASTFactory.typeName4("C", []);
Type2 type = ElementFactory.classElement2("C", []).type;
@@ -7285,6 +7977,7 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
JUnitTestCase.assertSame(type, toNode.type);
}
+
static dartSuite() {
_ut.group('ResolutionCopierTest', () {
_ut.test('test_visitAnnotation', () {
@@ -7466,6 +8159,7 @@ class ResolutionCopierTest extends EngineTestCase {
});
}
}
+
/**
* The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code
* sequences to ensure that the correct recovery steps are taken in the parser.
@@ -7482,11 +8176,13 @@ class RecoveryParserTest extends ParserTestCase {
" return result;",
"}"]), []);
}
+
void test_additiveExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("+ y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_additiveExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("+", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7496,16 +8192,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_additiveExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x +", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_additiveExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super +", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_additiveExpression_precedence_multiplicative_left() {
BinaryExpression expression = ParserTestCase.parseExpression("* +", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7513,6 +8212,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_additiveExpression_precedence_multiplicative_right() {
BinaryExpression expression = ParserTestCase.parseExpression("+ *", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7520,45 +8220,53 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_additiveExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super + +", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_assignmentExpression_missing_compound1() {
AssignmentExpression expression = ParserTestCase.parseExpression("= y = 0", [ParserErrorCode.MISSING_IDENTIFIER]);
Expression syntheticExpression = expression.leftHandSide;
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_assignmentExpression_missing_compound2() {
AssignmentExpression expression = ParserTestCase.parseExpression("x = = 0", [ParserErrorCode.MISSING_IDENTIFIER]);
- Expression syntheticExpression = ((expression.rightHandSide as AssignmentExpression)).leftHandSide;
+ Expression syntheticExpression = (expression.rightHandSide as AssignmentExpression).leftHandSide;
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_assignmentExpression_missing_compound3() {
AssignmentExpression expression = ParserTestCase.parseExpression("x = y =", [ParserErrorCode.MISSING_IDENTIFIER]);
- Expression syntheticExpression = ((expression.rightHandSide as AssignmentExpression)).rightHandSide;
+ Expression syntheticExpression = (expression.rightHandSide as AssignmentExpression).rightHandSide;
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_assignmentExpression_missing_LHS() {
AssignmentExpression expression = ParserTestCase.parseExpression("= 0", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftHandSide);
JUnitTestCase.assertTrue(expression.leftHandSide.isSynthetic);
}
+
void test_assignmentExpression_missing_RHS() {
AssignmentExpression expression = ParserTestCase.parseExpression("x =", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftHandSide);
JUnitTestCase.assertTrue(expression.rightHandSide.isSynthetic);
}
+
void test_bitwiseAndExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("& y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_bitwiseAndExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("&", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7568,16 +8276,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseAndExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x &", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseAndExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super &", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseAndExpression_precedence_equality_left() {
BinaryExpression expression = ParserTestCase.parseExpression("== &&", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7585,6 +8296,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseAndExpression_precedence_equality_right() {
BinaryExpression expression = ParserTestCase.parseExpression("&& ==", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7592,17 +8304,20 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseAndExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super & &", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseOrExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("| y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_bitwiseOrExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("|", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7612,16 +8327,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseOrExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x |", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseOrExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super |", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseOrExpression_precedence_xor_left() {
BinaryExpression expression = ParserTestCase.parseExpression("^ |", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7629,6 +8347,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseOrExpression_precedence_xor_right() {
BinaryExpression expression = ParserTestCase.parseExpression("| ^", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7636,17 +8355,20 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseOrExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super | |", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseXorExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("^ y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_bitwiseXorExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("^", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7656,16 +8378,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseXorExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x ^", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseXorExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super ^", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_bitwiseXorExpression_precedence_and_left() {
BinaryExpression expression = ParserTestCase.parseExpression("& ^", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7673,6 +8398,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_bitwiseXorExpression_precedence_and_right() {
BinaryExpression expression = ParserTestCase.parseExpression("^ &", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7680,30 +8406,36 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_bitwiseXorExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super ^ ^", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_classTypeAlias_withBody() {
ParserTestCase.parseCompilationUnit(EngineTestCase.createSource(["class A {}", "class B = Object with A {}"]), [ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_conditionalExpression_missingElse() {
ConditionalExpression expression = ParserTestCase.parse5("parseConditionalExpression", "x ? y :", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.elseExpression);
JUnitTestCase.assertTrue(expression.elseExpression.isSynthetic);
}
+
void test_conditionalExpression_missingThen() {
ConditionalExpression expression = ParserTestCase.parse5("parseConditionalExpression", "x ? : z", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.thenExpression);
JUnitTestCase.assertTrue(expression.thenExpression.isSynthetic);
}
+
void test_equalityExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("== y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_equalityExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("==", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7713,16 +8445,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_equalityExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x ==", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_equalityExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super ==", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_equalityExpression_precedence_relational_left() {
BinaryExpression expression = ParserTestCase.parseExpression("is ==", [
ParserErrorCode.EXPECTED_TYPE_NAME,
@@ -7730,6 +8465,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(IsExpression, expression.leftOperand);
}
+
void test_equalityExpression_precedence_relational_right() {
BinaryExpression expression = ParserTestCase.parseExpression("== is", [
ParserErrorCode.EXPECTED_TYPE_NAME,
@@ -7737,6 +8473,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(IsExpression, expression.rightOperand);
}
+
void test_equalityExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super == ==", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7744,6 +8481,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_expressionList_multiple_end() {
List<Expression> result = ParserTestCase.parse5("parseExpressionList", ", 2, 3, 4", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertSize(4, result);
@@ -7751,6 +8489,7 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_expressionList_multiple_middle() {
List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1, 2, , 4", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertSize(4, result);
@@ -7758,6 +8497,7 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_expressionList_multiple_start() {
List<Expression> result = ParserTestCase.parse5("parseExpressionList", "1, 2, 3,", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertSize(4, result);
@@ -7765,17 +8505,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, syntheticExpression);
JUnitTestCase.assertTrue(syntheticExpression.isSynthetic);
}
+
void test_incomplete_topLevelVariable() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("String", [ParserErrorCode.EXPECTED_EXECUTABLE]);
NodeList<CompilationUnitMember> declarations = unit.declarations;
EngineTestCase.assertSize(1, declarations);
CompilationUnitMember member = declarations[0];
EngineTestCase.assertInstanceOf(TopLevelVariableDeclaration, member);
- NodeList<VariableDeclaration> variables = ((member as TopLevelVariableDeclaration)).variables.variables;
+ NodeList<VariableDeclaration> variables = (member as TopLevelVariableDeclaration).variables.variables;
EngineTestCase.assertSize(1, variables);
SimpleIdentifier name = variables[0].name;
JUnitTestCase.assertTrue(name.isSynthetic);
}
+
void test_isExpression_noType() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", [
ParserErrorCode.EXPECTED_TYPE_NAME,
@@ -7794,11 +8536,13 @@ class RecoveryParserTest extends ParserTestCase {
JUnitTestCase.assertTrue(type.name.isSynthetic);
EngineTestCase.assertInstanceOf(EmptyStatement, ifStatement.thenStatement);
}
+
void test_logicalAndExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("&& y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_logicalAndExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("&&", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7808,11 +8552,13 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_logicalAndExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x &&", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_logicalAndExpression_precedence_bitwiseOr_left() {
BinaryExpression expression = ParserTestCase.parseExpression("| &&", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7820,6 +8566,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalAndExpression_precedence_bitwiseOr_right() {
BinaryExpression expression = ParserTestCase.parseExpression("&& |", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7827,11 +8574,13 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_logicalOrExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("|| y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_logicalOrExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("||", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7841,11 +8590,13 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_logicalOrExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x ||", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_logicalOrExpression_precedence_logicalAnd_left() {
BinaryExpression expression = ParserTestCase.parseExpression("&& ||", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7853,6 +8604,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_logicalOrExpression_precedence_logicalAnd_right() {
BinaryExpression expression = ParserTestCase.parseExpression("|| &&", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7860,11 +8612,13 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_multiplicativeExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_multiplicativeExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("*", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7874,24 +8628,29 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_multiplicativeExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x *", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_multiplicativeExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super *", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_multiplicativeExpression_precedence_unary_left() {
BinaryExpression expression = ParserTestCase.parseExpression("-x *", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(PrefixExpression, expression.leftOperand);
}
+
void test_multiplicativeExpression_precedence_unary_right() {
BinaryExpression expression = ParserTestCase.parseExpression("* -y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(PrefixExpression, expression.rightOperand);
}
+
void test_multiplicativeExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super == ==", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7899,17 +8658,20 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_prefixExpression_missing_operand_minus() {
PrefixExpression expression = ParserTestCase.parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.operand);
JUnitTestCase.assertTrue(expression.operand.isSynthetic);
JUnitTestCase.assertEquals(TokenType.MINUS, expression.operator.type);
}
+
void test_relationalExpression_missing_LHS() {
IsExpression expression = ParserTestCase.parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.expression);
JUnitTestCase.assertTrue(expression.expression.isSynthetic);
}
+
void test_relationalExpression_missing_LHS_RHS() {
IsExpression expression = ParserTestCase.parseExpression("is", [
ParserErrorCode.EXPECTED_TYPE_NAME,
@@ -7919,11 +8681,13 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(TypeName, expression.type);
JUnitTestCase.assertTrue(expression.type.isSynthetic);
}
+
void test_relationalExpression_missing_RHS() {
IsExpression expression = ParserTestCase.parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]);
EngineTestCase.assertInstanceOf(TypeName, expression.type);
JUnitTestCase.assertTrue(expression.type.isSynthetic);
}
+
void test_relationalExpression_precedence_shift_right() {
IsExpression expression = ParserTestCase.parseExpression("<< is", [
ParserErrorCode.EXPECTED_TYPE_NAME,
@@ -7931,11 +8695,13 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.expression);
}
+
void test_shiftExpression_missing_LHS() {
BinaryExpression expression = ParserTestCase.parseExpression("<< y", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.leftOperand);
JUnitTestCase.assertTrue(expression.leftOperand.isSynthetic);
}
+
void test_shiftExpression_missing_LHS_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("<<", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7945,16 +8711,19 @@ class RecoveryParserTest extends ParserTestCase {
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_shiftExpression_missing_RHS() {
BinaryExpression expression = ParserTestCase.parseExpression("x <<", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_shiftExpression_missing_RHS_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super <<", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression.rightOperand);
JUnitTestCase.assertTrue(expression.rightOperand.isSynthetic);
}
+
void test_shiftExpression_precedence_unary_left() {
BinaryExpression expression = ParserTestCase.parseExpression("+ <<", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7962,6 +8731,7 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_shiftExpression_precedence_unary_right() {
BinaryExpression expression = ParserTestCase.parseExpression("<< +", [
ParserErrorCode.MISSING_IDENTIFIER,
@@ -7969,12 +8739,14 @@ class RecoveryParserTest extends ParserTestCase {
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.rightOperand);
}
+
void test_shiftExpression_super() {
BinaryExpression expression = ParserTestCase.parseExpression("super << <<", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(BinaryExpression, expression.leftOperand);
}
+
void test_typedef_eof() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("typedef n", [
ParserErrorCode.EXPECTED_TOKEN,
@@ -7984,6 +8756,7 @@ class RecoveryParserTest extends ParserTestCase {
CompilationUnitMember member = declarations[0];
EngineTestCase.assertInstanceOf(FunctionTypeAlias, member);
}
+
static dartSuite() {
_ut.group('RecoveryParserTest', () {
_ut.test('test_additiveExpression_missing_LHS', () {
@@ -8301,40 +9074,52 @@ class RecoveryParserTest extends ParserTestCase {
});
}
}
+
class IncrementalParserTest extends EngineTestCase {
void fail_reparse_oneFunctionToTwo() {
assertParse("f() {}", "f() => 0; g() {}");
}
+
void test_reparse_addedAfterIdentifier1() {
assertParse("f() => a + b;", "f() => abs + b;");
}
+
void test_reparse_addedAfterIdentifier2() {
assertParse("f() => a + b;", "f() => a + bar;");
}
+
void test_resparse_addedBeforeIdentifier1() {
assertParse("f() => a + b;", "f() => xa + b;");
}
+
void test_resparse_addedBeforeIdentifier2() {
assertParse("f() => a + b;", "f() => a + xb;");
}
+
void test_resparse_addedNewIdentifier1() {
assertParse("a; c;", "a; b c;");
}
+
void test_resparse_addedNewIdentifier2() {
assertParse("a; c;", "a;b c;");
}
+
void test_resparse_appendWhitespace1() {
assertParse("f() => a + b;", "f() => a + b; ");
}
+
void test_resparse_appendWhitespace2() {
assertParse("f() => a + b;", "f() => a + b; ");
}
+
void test_resparse_insertedPeriod() {
assertParse("f() => a + b;", "f() => a + b.;");
}
+
void test_resparse_insertWhitespace() {
assertParse("f() => a + b;", "f() => a + b;");
}
+
void assertParse(String originalContents, String modifiedContents) {
int originalLength = originalContents.length;
int modifiedLength = modifiedContents.length;
@@ -8373,6 +9158,7 @@ class IncrementalParserTest extends EngineTestCase {
JUnitTestCase.assertNotNull(incrementalUnit);
JUnitTestCase.assertTrue(ASTComparator.equals3(modifiedUnit, incrementalUnit));
}
+
static dartSuite() {
_ut.group('IncrementalParserTest', () {
_ut.test('test_reparse_addedAfterIdentifier1', () {
@@ -8418,6 +9204,7 @@ class IncrementalParserTest extends EngineTestCase {
});
}
}
+
/**
* The class `ErrorParserTest` defines parser tests that test the parsing of code to ensure
* that errors are correctly reported, and in some cases, not reported.
@@ -8427,790 +9214,1041 @@ class ErrorParserTest extends ParserTestCase {
TypedLiteral literal = ParserTestCase.parse4("parseListOrMapLiteral", <Object> [null], "1", [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]);
JUnitTestCase.assertTrue(literal.isSynthetic);
}
+
void fail_illegalAssignmentToNonAssignable_superAssigned() {
ParserTestCase.parseExpression("super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
}
+
void fail_invalidCommentReference__new_nonIdentifier() {
ParserTestCase.parse4("parseCommentReference", <Object> ["new 42", 0], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
}
+
void fail_invalidCommentReference__new_tooMuch() {
ParserTestCase.parse4("parseCommentReference", <Object> ["new a.b.c.d", 0], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
}
+
void fail_invalidCommentReference__nonNew_nonIdentifier() {
ParserTestCase.parse4("parseCommentReference", <Object> ["42", 0], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
}
+
void fail_invalidCommentReference__nonNew_tooMuch() {
ParserTestCase.parse4("parseCommentReference", <Object> ["a.b.c.d", 0], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
}
+
void fail_missingClosingParenthesis() {
ParserTestCase.parse5("parseFormalParameterList", "(int a, int b ;", [ParserErrorCode.MISSING_CLOSING_PARENTHESIS]);
}
+
void fail_missingFunctionParameters_local_nonVoid_block() {
ParserTestCase.parseStatement("int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void fail_missingFunctionParameters_local_nonVoid_expression() {
ParserTestCase.parseStatement("int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void fail_namedFunctionExpression() {
Expression expression = ParserTestCase.parse5("parsePrimaryExpression", "f() {}", [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]);
EngineTestCase.assertInstanceOf(FunctionExpression, expression);
}
+
void fail_unexpectedToken_invalidPostfixExpression() {
ParserTestCase.parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]);
}
+
void fail_varAndType_local() {
ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]);
}
+
void fail_varAndType_parameter() {
ParserTestCase.parse5("parseFormalParameterList", "(var int x)", [ParserErrorCode.VAR_AND_TYPE]);
}
+
void test_abstractClassMember_constructor() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "abstract C.c();", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
}
+
void test_abstractClassMember_field() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "abstract C f;", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
}
+
void test_abstractClassMember_getter() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "abstract get m;", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
}
+
void test_abstractClassMember_method() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "abstract m();", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
}
+
void test_abstractClassMember_setter() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "abstract set m(v);", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
}
+
void test_abstractTopLevelFunction_function() {
ParserTestCase.parseCompilationUnit("abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
}
+
void test_abstractTopLevelFunction_getter() {
ParserTestCase.parseCompilationUnit("abstract get m {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
}
+
void test_abstractTopLevelFunction_setter() {
ParserTestCase.parseCompilationUnit("abstract set m(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
}
+
void test_abstractTopLevelVariable() {
ParserTestCase.parseCompilationUnit("abstract C f;", [ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE]);
}
+
void test_abstractTypeDef() {
ParserTestCase.parseCompilationUnit("abstract typedef F();", [ParserErrorCode.ABSTRACT_TYPEDEF]);
}
+
void test_assertDoesNotTakeAssignment() {
ParserTestCase.parse5("parseAssertStatement", "assert(b = true);", [ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT]);
}
+
void test_assertDoesNotTakeCascades() {
ParserTestCase.parse5("parseAssertStatement", "assert(new A()..m());", [ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE]);
}
+
void test_assertDoesNotTakeRethrow() {
ParserTestCase.parse5("parseAssertStatement", "assert(rethrow);", [ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW]);
}
+
void test_assertDoesNotTakeThrow() {
ParserTestCase.parse5("parseAssertStatement", "assert(throw x);", [ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW]);
}
+
void test_breakOutsideOfLoop_breakInDoStatement() {
ParserTestCase.parse5("parseDoStatement", "do {break;} while (x);", []);
}
+
void test_breakOutsideOfLoop_breakInForStatement() {
ParserTestCase.parse5("parseForStatement", "for (; x;) {break;}", []);
}
+
void test_breakOutsideOfLoop_breakInIfStatement() {
ParserTestCase.parse5("parseIfStatement", "if (x) {break;}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
}
+
void test_breakOutsideOfLoop_breakInSwitchStatement() {
ParserTestCase.parse5("parseSwitchStatement", "switch (x) {case 1: break;}", []);
}
+
void test_breakOutsideOfLoop_breakInWhileStatement() {
ParserTestCase.parse5("parseWhileStatement", "while (x) {break;}", []);
}
+
void test_breakOutsideOfLoop_functionExpression_inALoop() {
ParserTestCase.parseStatement("for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
}
+
void test_breakOutsideOfLoop_functionExpression_withALoop() {
ParserTestCase.parseStatement("() {for (; x;) {break;}};", []);
}
+
void test_constAndFinal() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const final int x;", [ParserErrorCode.CONST_AND_FINAL]);
}
+
void test_constAndVar() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const var x;", [ParserErrorCode.CONST_AND_VAR]);
}
+
void test_constClass() {
ParserTestCase.parseCompilationUnit("const class C {}", [ParserErrorCode.CONST_CLASS]);
}
+
void test_constConstructorWithBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const C() {}", [ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY]);
}
+
void test_constFactory() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const factory C() {}", [ParserErrorCode.CONST_FACTORY]);
}
+
void test_constMethod() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const int m() {}", [ParserErrorCode.CONST_METHOD]);
}
+
void test_constructorWithReturnType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "C C() {}", [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
}
+
void test_constructorWithReturnType_var() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "var C() {}", [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
}
+
void test_constTypedef() {
ParserTestCase.parseCompilationUnit("const typedef F();", [ParserErrorCode.CONST_TYPEDEF]);
}
+
void test_continueOutsideOfLoop_continueInDoStatement() {
ParserTestCase.parse5("parseDoStatement", "do {continue;} while (x);", []);
}
+
void test_continueOutsideOfLoop_continueInForStatement() {
ParserTestCase.parse5("parseForStatement", "for (; x;) {continue;}", []);
}
+
void test_continueOutsideOfLoop_continueInIfStatement() {
ParserTestCase.parse5("parseIfStatement", "if (x) {continue;}", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
}
+
void test_continueOutsideOfLoop_continueInSwitchStatement() {
ParserTestCase.parse5("parseSwitchStatement", "switch (x) {case 1: continue a;}", []);
}
+
void test_continueOutsideOfLoop_continueInWhileStatement() {
ParserTestCase.parse5("parseWhileStatement", "while (x) {continue;}", []);
}
+
void test_continueOutsideOfLoop_functionExpression_inALoop() {
ParserTestCase.parseStatement("for(; x;) {() {continue;};}", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
}
+
void test_continueOutsideOfLoop_functionExpression_withALoop() {
ParserTestCase.parseStatement("() {for (; x;) {continue;}};", []);
}
+
void test_continueWithoutLabelInCase_error() {
ParserTestCase.parse5("parseSwitchStatement", "switch (x) {case 1: continue;}", [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]);
}
+
void test_continueWithoutLabelInCase_noError() {
ParserTestCase.parse5("parseSwitchStatement", "switch (x) {case 1: continue a;}", []);
}
+
void test_continueWithoutLabelInCase_noError_switchInLoop() {
ParserTestCase.parse5("parseWhileStatement", "while (a) { switch (b) {default: continue;}}", []);
}
+
void test_deprecatedClassTypeAlias() {
ParserTestCase.parseCompilationUnit("typedef C = abstract S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]);
}
+
void test_deprecatedClassTypeAlias_withGeneric() {
ParserTestCase.parseCompilationUnit("typedef C<T> = abstract S<T> with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]);
}
+
void test_directiveAfterDeclaration_classBeforeDirective() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("class Foo{} library l;", [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_directiveAfterDeclaration_classBetweenDirectives() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("library l;\nclass Foo{}\npart 'a.dart';", [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_duplicatedModifier_const() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const const m;", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicatedModifier_external() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external external f();", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicatedModifier_factory() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "factory factory C() {}", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicatedModifier_final() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final final m;", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicatedModifier_static() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static static var m;", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicatedModifier_var() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "var var m;", [ParserErrorCode.DUPLICATED_MODIFIER]);
}
+
void test_duplicateLabelInSwitchStatement() {
ParserTestCase.parse5("parseSwitchStatement", "switch (e) {l1: case 0: break; l1: case 1: break;}", [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]);
}
+
void test_equalityCannotBeEqualityOperand_eq_eq() {
ParserTestCase.parseExpression("1 == 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
}
+
void test_equalityCannotBeEqualityOperand_eq_neq() {
ParserTestCase.parseExpression("1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
}
+
void test_equalityCannotBeEqualityOperand_neq_eq() {
ParserTestCase.parseExpression("1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
}
+
void test_expectedCaseOrDefault() {
ParserTestCase.parse5("parseSwitchStatement", "switch (e) {break;}", [ParserErrorCode.EXPECTED_CASE_OR_DEFAULT]);
}
+
void test_expectedClassMember_inClass_afterType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "heart 2 heart", [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
}
+
void test_expectedClassMember_inClass_beforeType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "4 score", [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
}
+
void test_expectedExecutable_inClass_afterVoid() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]);
}
+
void test_expectedExecutable_topLevel_afterType() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "heart 2 heart", [ParserErrorCode.EXPECTED_EXECUTABLE]);
}
+
void test_expectedExecutable_topLevel_afterVoid() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]);
}
+
void test_expectedExecutable_topLevel_beforeType() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]);
}
+
void test_expectedInterpolationIdentifier() {
ParserTestCase.parse5("parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_expectedStringLiteral() {
StringLiteral expression = ParserTestCase.parse5("parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]);
JUnitTestCase.assertTrue(expression.isSynthetic);
}
+
void test_expectedToken_commaMissingInArgumentList() {
ParserTestCase.parse5("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_expectedToken_parseStatement_afterVoid() {
ParserTestCase.parseStatement("void}", [
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_expectedToken_semicolonAfterClass() {
Token token = TokenFactory.token(Keyword.CLASS);
ParserTestCase.parse4("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token], "A = B", [ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_expectedToken_semicolonMissingAfterExpression() {
ParserTestCase.parseStatement("x", [ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_expectedToken_whileMissingInDoStatement() {
ParserTestCase.parseStatement("do {} (x);", [ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_expectedTypeName_is() {
ParserTestCase.parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]);
}
+
void test_exportDirectiveAfterPartDirective() {
ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]);
}
+
void test_externalAfterConst() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const external C();", [ParserErrorCode.EXTERNAL_AFTER_CONST]);
}
+
void test_externalAfterFactory() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "factory external C();", [ParserErrorCode.EXTERNAL_AFTER_FACTORY]);
}
+
void test_externalAfterStatic() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static external int m();", [ParserErrorCode.EXTERNAL_AFTER_STATIC]);
}
+
void test_externalClass() {
ParserTestCase.parseCompilationUnit("external class C {}", [ParserErrorCode.EXTERNAL_CLASS]);
}
+
void test_externalConstructorWithBody_factory() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external factory C() {}", [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
}
+
void test_externalConstructorWithBody_named() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external C.c() {}", [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
}
+
void test_externalField_const() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external const A f;", [ParserErrorCode.EXTERNAL_FIELD]);
}
+
void test_externalField_final() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external final A f;", [ParserErrorCode.EXTERNAL_FIELD]);
}
+
void test_externalField_static() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external static A f;", [ParserErrorCode.EXTERNAL_FIELD]);
}
+
void test_externalField_typed() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external A f;", [ParserErrorCode.EXTERNAL_FIELD]);
}
+
void test_externalField_untyped() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external var f;", [ParserErrorCode.EXTERNAL_FIELD]);
}
+
void test_externalGetterWithBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external int get x {}", [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]);
}
+
void test_externalMethodWithBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external m() {}", [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
}
+
void test_externalOperatorWithBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external operator +(int value) {}", [ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]);
}
+
void test_externalSetterWithBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "external set x(int value) {}", [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]);
}
+
void test_externalTypedef() {
ParserTestCase.parseCompilationUnit("external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]);
}
+
void test_factoryTopLevelDeclaration_class() {
ParserTestCase.parseCompilationUnit("factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
}
+
void test_factoryTopLevelDeclaration_typedef() {
ParserTestCase.parseCompilationUnit("factory typedef F();", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
}
+
void test_factoryWithoutBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "factory C();", [ParserErrorCode.FACTORY_WITHOUT_BODY]);
}
+
void test_fieldInitializerOutsideConstructor() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void m(this.x);", [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
}
+
void test_finalAndVar() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final var x;", [ParserErrorCode.FINAL_AND_VAR]);
}
+
void test_finalClass() {
ParserTestCase.parseCompilationUnit("final class C {}", [ParserErrorCode.FINAL_CLASS]);
}
+
void test_finalConstructor() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final C() {}", [ParserErrorCode.FINAL_CONSTRUCTOR]);
}
+
void test_finalMethod() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final int m() {}", [ParserErrorCode.FINAL_METHOD]);
}
+
void test_finalTypedef() {
ParserTestCase.parseCompilationUnit("final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]);
}
+
void test_functionTypedParameter_const() {
ParserTestCase.parseCompilationUnit("void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
}
+
void test_functionTypedParameter_final() {
ParserTestCase.parseCompilationUnit("void f(final x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
}
+
void test_functionTypedParameter_var() {
ParserTestCase.parseCompilationUnit("void f(var x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
}
+
void test_getterInFunction_block() {
ParserTestCase.parseStatement("get x { return _x; }", [ParserErrorCode.GETTER_IN_FUNCTION]);
}
+
void test_getterInFunction_expression() {
ParserTestCase.parseStatement("get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]);
}
+
void test_getterWithParameters() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "int get x() {}", [ParserErrorCode.GETTER_WITH_PARAMETERS]);
}
+
void test_illegalAssignmentToNonAssignable_superAssigned() {
ParserTestCase.parseExpression("super = x;", [
ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
}
+
void test_implementsBeforeExtends() {
ParserTestCase.parseCompilationUnit("class A implements B extends C {}", [ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS]);
}
+
void test_implementsBeforeWith() {
ParserTestCase.parseCompilationUnit("class A extends B implements C with D {}", [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]);
}
+
void test_importDirectiveAfterPartDirective() {
ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]);
}
+
void test_initializedVariableInForEach() {
ParserTestCase.parse5("parseForStatement", "for (int a = 0 in foo) {}", [ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH]);
}
+
void test_invalidCodePoint() {
ParserTestCase.parse5("parseStringLiteral", "'\\uD900'", [ParserErrorCode.INVALID_CODE_POINT]);
}
+
void test_invalidHexEscape_invalidDigit() {
ParserTestCase.parse5("parseStringLiteral", "'\\x0 a'", [ParserErrorCode.INVALID_HEX_ESCAPE]);
}
+
void test_invalidHexEscape_tooFewDigits() {
ParserTestCase.parse5("parseStringLiteral", "'\\x0'", [ParserErrorCode.INVALID_HEX_ESCAPE]);
}
+
void test_invalidInterpolationIdentifier_startWithDigit() {
ParserTestCase.parse5("parseStringLiteral", "'\$1'", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_invalidOperator() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void operator ===(x) {}", [ParserErrorCode.INVALID_OPERATOR]);
}
+
void test_invalidOperatorForSuper() {
ParserTestCase.parse5("parseUnaryExpression", "++super", [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]);
}
+
void test_invalidUnicodeEscape_incomplete_noDigits() {
ParserTestCase.parse5("parseStringLiteral", "'\\u{'", [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
}
+
void test_invalidUnicodeEscape_incomplete_someDigits() {
ParserTestCase.parse5("parseStringLiteral", "'\\u{0A'", [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
}
+
void test_invalidUnicodeEscape_invalidDigit() {
ParserTestCase.parse5("parseStringLiteral", "'\\u0 a'", [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
}
+
void test_invalidUnicodeEscape_tooFewDigits_fixed() {
ParserTestCase.parse5("parseStringLiteral", "'\\u04'", [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
}
+
void test_invalidUnicodeEscape_tooFewDigits_variable() {
ParserTestCase.parse5("parseStringLiteral", "'\\u{}'", [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
}
+
void test_invalidUnicodeEscape_tooManyDigits_variable() {
ParserTestCase.parse5("parseStringLiteral", "'\\u{12345678}'", [
ParserErrorCode.INVALID_UNICODE_ESCAPE,
ParserErrorCode.INVALID_CODE_POINT]);
}
+
void test_libraryDirectiveNotFirst() {
ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]);
}
+
void test_libraryDirectiveNotFirst_afterPart() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("part 'a.dart';\nlibrary l;", [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_localFunctionDeclarationModifier_abstract() {
ParserTestCase.parseStatement("abstract f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
}
+
void test_localFunctionDeclarationModifier_external() {
ParserTestCase.parseStatement("external f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
}
+
void test_localFunctionDeclarationModifier_factory() {
ParserTestCase.parseStatement("factory f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
}
+
void test_localFunctionDeclarationModifier_static() {
ParserTestCase.parseStatement("static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
}
+
void test_missingAssignableSelector_identifiersAssigned() {
ParserTestCase.parseExpression("x.y = y;", []);
}
+
void test_missingAssignableSelector_postfix_minusMinus_literal() {
ParserTestCase.parseExpression("0--", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
}
+
void test_missingAssignableSelector_postfix_plusPlus_literal() {
ParserTestCase.parseExpression("0++", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
}
+
void test_missingAssignableSelector_prefix_minusMinus_literal() {
ParserTestCase.parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
}
+
void test_missingAssignableSelector_prefix_plusPlus_literal() {
ParserTestCase.parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
}
+
void test_missingAssignableSelector_primarySelectorPostfix() {
ParserTestCase.parseExpression("x(y)(z)++", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
}
+
void test_missingAssignableSelector_selector() {
ParserTestCase.parseExpression("x(y)(z).a++", []);
}
+
void test_missingAssignableSelector_superPrimaryExpression() {
SuperExpression expression = ParserTestCase.parse5("parsePrimaryExpression", "super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
JUnitTestCase.assertNotNull(expression.keyword);
}
+
void test_missingAssignableSelector_superPropertyAccessAssigned() {
ParserTestCase.parseExpression("super.x = x;", []);
}
+
void test_missingCatchOrFinally() {
TryStatement statement = ParserTestCase.parse5("parseTryStatement", "try {}", [ParserErrorCode.MISSING_CATCH_OR_FINALLY]);
JUnitTestCase.assertNotNull(statement);
}
+
void test_missingClassBody() {
ParserTestCase.parseCompilationUnit("class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]);
}
+
void test_missingConstFinalVarOrType_static() {
ParserTestCase.parseCompilationUnit("class A { static f; }", [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
}
+
void test_missingConstFinalVarOrType_topLevel() {
ParserTestCase.parse4("parseFinalConstVarOrType", <Object> [false], "a;", [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
}
+
void test_missingExpressionInThrow_withCascade() {
ParserTestCase.parse5("parseThrowExpression", "throw;", [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]);
}
+
void test_missingExpressionInThrow_withoutCascade() {
ParserTestCase.parse5("parseThrowExpressionWithoutCascade", "throw;", [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]);
}
+
void test_missingFunctionBody_emptyNotAllowed() {
ParserTestCase.parse4("parseFunctionBody", <Object> [false, ParserErrorCode.MISSING_FUNCTION_BODY, false], ";", [ParserErrorCode.MISSING_FUNCTION_BODY]);
}
+
void test_missingFunctionBody_invalid() {
ParserTestCase.parse4("parseFunctionBody", <Object> [false, ParserErrorCode.MISSING_FUNCTION_BODY, false], "return 0;", [ParserErrorCode.MISSING_FUNCTION_BODY]);
}
+
void test_missingFunctionParameters_local_void_block() {
ParserTestCase.parseStatement("void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingFunctionParameters_local_void_expression() {
ParserTestCase.parseStatement("void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingFunctionParameters_topLevel_nonVoid_block() {
ParserTestCase.parseCompilationUnit("int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingFunctionParameters_topLevel_nonVoid_expression() {
ParserTestCase.parseCompilationUnit("int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingFunctionParameters_topLevel_void_block() {
ParserTestCase.parseCompilationUnit("void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingFunctionParameters_topLevel_void_expression() {
ParserTestCase.parseCompilationUnit("void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
}
+
void test_missingIdentifier_afterOperator() {
ParserTestCase.parse5("parseMultiplicativeExpression", "1 *", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_missingIdentifier_beforeClosingCurly() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "int}", [
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN]);
}
+
void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() {
ParserTestCase.parse5("parseFunctionDeclarationStatement", "A<T> () {}", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_missingIdentifier_inSymbol_afterPeriod() {
ParserTestCase.parse5("parseSymbolLiteral", "#a.", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_missingIdentifier_inSymbol_first() {
ParserTestCase.parse5("parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]);
}
+
void test_missingIdentifier_number() {
SimpleIdentifier expression = ParserTestCase.parse5("parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]);
JUnitTestCase.assertTrue(expression.isSynthetic);
}
+
void test_missingKeywordOperator() {
ParserTestCase.parse4("parseOperator", <Object> [emptyCommentAndMetadata(), null, null], "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
}
+
void test_missingKeywordOperator_parseClassMember() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "+() {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
}
+
void test_missingKeywordOperator_parseClassMember_afterTypeName() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "int +() {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
}
+
void test_missingKeywordOperator_parseClassMember_afterVoid() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void +() {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
}
+
void test_missingNameInLibraryDirective() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_missingNameInPartOfDirective() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_missingStatement() {
ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]);
}
+
void test_missingStatement_afterVoid() {
ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]);
}
+
void test_missingTerminatorForParameterGroup_named() {
ParserTestCase.parse5("parseFormalParameterList", "(a, {b: 0)", [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
void test_missingTerminatorForParameterGroup_optional() {
ParserTestCase.parse5("parseFormalParameterList", "(a, [b = 0)", [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
void test_missingTypedefParameters_nonVoid() {
ParserTestCase.parseCompilationUnit("typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
}
+
void test_missingTypedefParameters_typeParameters() {
ParserTestCase.parseCompilationUnit("typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
}
+
void test_missingTypedefParameters_void() {
ParserTestCase.parseCompilationUnit("typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
}
+
void test_missingVariableInForEach() {
ParserTestCase.parse5("parseForStatement", "for (a < b in foo) {}", [ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH]);
}
+
void test_mixedParameterGroups_namedPositional() {
ParserTestCase.parse5("parseFormalParameterList", "(a, {b}, [c])", [ParserErrorCode.MIXED_PARAMETER_GROUPS]);
}
+
void test_mixedParameterGroups_positionalNamed() {
ParserTestCase.parse5("parseFormalParameterList", "(a, [b], {c})", [ParserErrorCode.MIXED_PARAMETER_GROUPS]);
}
+
void test_multipleExtendsClauses() {
ParserTestCase.parseCompilationUnit("class A extends B extends C {}", [ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES]);
}
+
void test_multipleImplementsClauses() {
ParserTestCase.parseCompilationUnit("class A implements B implements C {}", [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]);
}
+
void test_multipleLibraryDirectives() {
ParserTestCase.parseCompilationUnit("library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]);
}
+
void test_multipleNamedParameterGroups() {
ParserTestCase.parse5("parseFormalParameterList", "(a, {b}, {c})", [ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS]);
}
+
void test_multiplePartOfDirectives() {
ParserTestCase.parseCompilationUnit("part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]);
}
+
void test_multiplePositionalParameterGroups() {
ParserTestCase.parse5("parseFormalParameterList", "(a, [b], [c])", [ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS]);
}
+
void test_multipleVariablesInForEach() {
ParserTestCase.parse5("parseForStatement", "for (int a, b in foo) {}", [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]);
}
+
void test_multipleWithClauses() {
ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", [ParserErrorCode.MULTIPLE_WITH_CLAUSES]);
}
+
void test_namedParameterOutsideGroup() {
ParserTestCase.parse5("parseFormalParameterList", "(a, b : 0)", [ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]);
}
+
void test_nonConstructorFactory_field() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "factory int x;", [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]);
}
+
void test_nonConstructorFactory_method() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "factory int m() {}", [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]);
}
+
void test_nonIdentifierLibraryName_library() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_nonIdentifierLibraryName_partOf() {
CompilationUnit unit = ParserTestCase.parseCompilationUnit("part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
JUnitTestCase.assertNotNull(unit);
}
+
void test_nonPartOfDirectiveInPart_after() {
ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]);
}
+
void test_nonPartOfDirectiveInPart_before() {
ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]);
}
+
void test_nonUserDefinableOperator() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "operator +=(int x) => x + 1;", [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]);
}
+
void test_optionalAfterNormalParameters_named() {
ParserTestCase.parseCompilationUnit("f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
}
+
void test_optionalAfterNormalParameters_positional() {
ParserTestCase.parseCompilationUnit("f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
}
+
void test_parseCascadeSection_missingIdentifier() {
MethodInvocation methodInvocation = ParserTestCase.parse5("parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]);
JUnitTestCase.assertNull(methodInvocation.target);
JUnitTestCase.assertEquals("", methodInvocation.methodName.name);
EngineTestCase.assertSize(0, methodInvocation.argumentList.arguments);
}
+
void test_positionalAfterNamedArgument() {
ParserTestCase.parse5("parseArgumentList", "(x: 1, 2)", [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]);
}
+
void test_positionalParameterOutsideGroup() {
ParserTestCase.parse5("parseFormalParameterList", "(a, b = 0)", [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]);
}
+
void test_redirectionInNonFactoryConstructor() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "C() = D;", [ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR]);
}
+
void test_setterInFunction_block() {
ParserTestCase.parseStatement("set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]);
}
+
void test_setterInFunction_expression() {
ParserTestCase.parseStatement("set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]);
}
+
void test_staticAfterConst() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "final static int f;", [ParserErrorCode.STATIC_AFTER_FINAL]);
}
+
void test_staticAfterFinal() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "const static int f;", [ParserErrorCode.STATIC_AFTER_CONST]);
}
+
void test_staticAfterVar() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "var static f;", [ParserErrorCode.STATIC_AFTER_VAR]);
}
+
void test_staticConstructor() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static C.m() {}", [ParserErrorCode.STATIC_CONSTRUCTOR]);
}
+
void test_staticGetterWithoutBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static get m;", [ParserErrorCode.STATIC_GETTER_WITHOUT_BODY]);
}
+
void test_staticOperator_noReturnType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static operator +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]);
}
+
void test_staticOperator_returnType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static int operator +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]);
}
+
void test_staticSetterWithoutBody() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "static set m(x);", [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]);
}
+
void test_staticTopLevelDeclaration_class() {
ParserTestCase.parseCompilationUnit("static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
}
+
void test_staticTopLevelDeclaration_function() {
ParserTestCase.parseCompilationUnit("static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
}
+
void test_staticTopLevelDeclaration_typedef() {
ParserTestCase.parseCompilationUnit("static typedef F();", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
}
+
void test_staticTopLevelDeclaration_variable() {
ParserTestCase.parseCompilationUnit("static var x;", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
}
+
void test_switchHasCaseAfterDefaultCase() {
ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0; case 1: return 1;}", [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]);
}
+
void test_switchHasCaseAfterDefaultCase_repeated() {
ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", [
ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE,
ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]);
}
+
void test_switchHasMultipleDefaultCases() {
ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0; default: return 1;}", [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]);
}
+
void test_switchHasMultipleDefaultCases_repeated() {
ParserTestCase.parse5("parseSwitchStatement", "switch (a) {default: return 0; default: return 1; default: return 2;}", [
ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES,
ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]);
}
+
void test_topLevelOperator_withoutType() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_LEVEL_OPERATOR]);
}
+
void test_topLevelOperator_withType() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "bool operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_LEVEL_OPERATOR]);
}
+
void test_topLevelOperator_withVoid() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void operator +(bool x, bool y) => x | y;", [ParserErrorCode.TOP_LEVEL_OPERATOR]);
}
+
void test_unexpectedTerminatorForParameterGroup_named() {
ParserTestCase.parse5("parseFormalParameterList", "(a, b})", [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
void test_unexpectedTerminatorForParameterGroup_optional() {
ParserTestCase.parse5("parseFormalParameterList", "(a, b])", [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
void test_unexpectedToken_semicolonBetweenClassMembers() {
ParserTestCase.parse4("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]);
}
+
void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() {
ParserTestCase.parseCompilationUnit("int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]);
}
+
void test_useOfUnaryPlusOperator() {
SimpleIdentifier expression = ParserTestCase.parse5("parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]);
EngineTestCase.assertInstanceOf(SimpleIdentifier, expression);
JUnitTestCase.assertTrue(expression.isSynthetic);
}
+
void test_varAndType_field() {
ParserTestCase.parseCompilationUnit("class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]);
}
+
void test_varAndType_topLevelVariable() {
ParserTestCase.parseCompilationUnit("var int x;", [ParserErrorCode.VAR_AND_TYPE]);
}
+
void test_varAsTypeName_as() {
ParserTestCase.parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]);
}
+
void test_varClass() {
ParserTestCase.parseCompilationUnit("var class C {}", [ParserErrorCode.VAR_CLASS]);
}
+
void test_varReturnType() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "var m() {}", [ParserErrorCode.VAR_RETURN_TYPE]);
}
+
void test_varTypedef() {
ParserTestCase.parseCompilationUnit("var typedef F();", [ParserErrorCode.VAR_TYPEDEF]);
}
+
void test_voidParameter() {
ParserTestCase.parse5("parseNormalFormalParameter", "void a)", [ParserErrorCode.VOID_PARAMETER]);
}
+
void test_voidVariable_parseClassMember_initializer() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void x = 0;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_parseClassMember_noInitializer() {
ParserTestCase.parse4("parseClassMember", <Object> ["C"], "void x;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_parseCompilationUnit_initializer() {
ParserTestCase.parseCompilationUnit("void x = 0;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_parseCompilationUnit_noInitializer() {
ParserTestCase.parseCompilationUnit("void x;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_parseCompilationUnitMember_initializer() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void a = 0;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_parseCompilationUnitMember_noInitializer() {
ParserTestCase.parse4("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "void a;", [ParserErrorCode.VOID_VARIABLE]);
}
+
void test_voidVariable_statement_initializer() {
ParserTestCase.parseStatement("void x = 0;", [
ParserErrorCode.VOID_VARIABLE,
ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
}
+
void test_voidVariable_statement_noInitializer() {
ParserTestCase.parseStatement("void x;", [
ParserErrorCode.VOID_VARIABLE,
ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
}
+
void test_withBeforeExtends() {
ParserTestCase.parseCompilationUnit("class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]);
}
+
void test_withWithoutExtends() {
ParserTestCase.parse4("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A with B, C {}", [ParserErrorCode.WITH_WITHOUT_EXTENDS]);
}
+
void test_wrongSeparatorForNamedParameter() {
ParserTestCase.parse5("parseFormalParameterList", "(a, {b = 0})", [ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER]);
}
+
void test_wrongSeparatorForPositionalParameter() {
ParserTestCase.parse5("parseFormalParameterList", "(a, [b : 0])", [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]);
}
+
void test_wrongTerminatorForParameterGroup_named() {
ParserTestCase.parse5("parseFormalParameterList", "(a, {b, c])", [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
void test_wrongTerminatorForParameterGroup_optional() {
ParserTestCase.parse5("parseFormalParameterList", "(a, [b, c})", [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
}
+
static dartSuite() {
_ut.group('ErrorParserTest', () {
_ut.test('test_abstractClassMember_constructor', () {
@@ -10168,6 +11206,7 @@ class ErrorParserTest extends ParserTestCase {
});
}
}
+
main() {
ComplexParserTest.dartSuite();
ErrorParserTest.dartSuite();
@@ -10326,7 +11365,7 @@ Map<String, MethodTrampoline> _methodTable_Parser = <String, MethodTrampoline> {
'peek_0': new MethodTrampoline(0, (Parser target) => target.peek()),
'peek_1': new MethodTrampoline(1, (Parser target, arg0) => target.peek2(arg0)),
'reportError_3': new MethodTrampoline(3, (Parser target, arg0, arg1, arg2) => target.reportError(arg0, arg1, arg2)),
- 'reportError_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target.reportError8(arg0, arg1)),
+ 'reportError_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target.reportError9(arg0, arg1)),
'scrapeTodoComment_1': new MethodTrampoline(1, (Parser target, arg0) => target.scrapeTodoComment(arg0)),
'skipFinalConstVarOrType_1': new MethodTrampoline(1, (Parser target, arg0) => target.skipFinalConstVarOrType(arg0)),
'skipFormalParameterList_1': new MethodTrampoline(1, (Parser target, arg0) => target.skipFormalParameterList(arg0)),
« no previous file with comments | « pkg/analyzer/test/generated/element_test.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698