blob: 0cd547e875e77b0a183bde1db1f31d154705fdb8 [file] [log] [blame]
// 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 'dart:collection';
import 'package:analyzer_experimental/src/generated/java_core.dart';
import 'package:analyzer_experimental/src/generated/java_engine.dart';
import 'package:analyzer_experimental/src/generated/java_junit.dart';
import 'package:analyzer_experimental/src/generated/source.dart';
import 'package:analyzer_experimental/src/generated/error.dart';
import 'package:analyzer_experimental/src/generated/scanner.dart';
import 'package:analyzer_experimental/src/generated/ast.dart';
import 'package:analyzer_experimental/src/generated/parser.dart';
import 'package:analyzer_experimental/src/generated/utilities_dart.dart';
import 'package:unittest/unittest.dart' as _ut;
import 'test_support.dart';
import 'scanner_test.dart' show TokenFactory;
/**
* The class {@code 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
* the interactions between the method under test and other methods.
* <p>
* More complex tests should be defined in the class {@link ComplexParserTest}.
*/
class SimpleParserTest extends ParserTestCase {
void fail_parseCommentReference_this() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["this", 5], "");
SimpleIdentifier identifier2 = EngineTestCase.assertInstanceOf(SimpleIdentifier, reference.identifier);
JUnitTestCase.assertNotNull(identifier2.token);
JUnitTestCase.assertEquals("a", identifier2.name);
JUnitTestCase.assertEquals(5, identifier2.offset);
}
void test_computeStringValue_emptyInterpolationPrefix() {
JUnitTestCase.assertEquals("", computeStringValue("'''"));
}
void test_computeStringValue_escape_b() {
JUnitTestCase.assertEquals("\b", computeStringValue("'\\b'"));
}
void test_computeStringValue_escape_f() {
JUnitTestCase.assertEquals("\f", computeStringValue("'\\f'"));
}
void test_computeStringValue_escape_n() {
JUnitTestCase.assertEquals("\n", computeStringValue("'\\n'"));
}
void test_computeStringValue_escape_notSpecial() {
JUnitTestCase.assertEquals(":", computeStringValue("'\\:'"));
}
void test_computeStringValue_escape_r() {
JUnitTestCase.assertEquals("\r", computeStringValue("'\\r'"));
}
void test_computeStringValue_escape_t() {
JUnitTestCase.assertEquals("\t", computeStringValue("'\\t'"));
}
void test_computeStringValue_escape_u_fixed() {
JUnitTestCase.assertEquals("\u4321", computeStringValue("'\\u4321'"));
}
void test_computeStringValue_escape_u_variable() {
JUnitTestCase.assertEquals("\u0123", computeStringValue("'\\u{123}'"));
}
void test_computeStringValue_escape_v() {
JUnitTestCase.assertEquals("\u000B", computeStringValue("'\\v'"));
}
void test_computeStringValue_escape_x() {
JUnitTestCase.assertEquals("\u00FF", computeStringValue("'\\xFF'"));
}
void test_computeStringValue_noEscape_single() {
JUnitTestCase.assertEquals("text", computeStringValue("'text'"));
}
void test_computeStringValue_noEscape_triple() {
JUnitTestCase.assertEquals("text", computeStringValue("'''text'''"));
}
void test_computeStringValue_raw_single() {
JUnitTestCase.assertEquals("text", computeStringValue("r'text'"));
}
void test_computeStringValue_raw_triple() {
JUnitTestCase.assertEquals("text", computeStringValue("r'''text'''"));
}
void test_computeStringValue_raw_withEscape() {
JUnitTestCase.assertEquals("two\\nlines", computeStringValue("r'two\\nlines'"));
}
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_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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNull(annotation.period);
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);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNull(annotation.period);
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
void test_parseAnnotation_n2() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B", []);
JUnitTestCase.assertNotNull(annotation.atSign);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNull(annotation.period);
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);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNull(annotation.period);
JUnitTestCase.assertNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
void test_parseAnnotation_n3() {
Annotation annotation = ParserTestCase.parse5("parseAnnotation", "@A.B.C", []);
JUnitTestCase.assertNotNull(annotation.atSign);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNotNull(annotation.period);
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);
JUnitTestCase.assertNotNull(annotation.name);
JUnitTestCase.assertNotNull(annotation.period);
JUnitTestCase.assertNotNull(annotation.constructorName);
JUnitTestCase.assertNotNull(annotation.arguments);
}
void test_parseArgument_named() {
NamedExpression expression = ParserTestCase.parse5("parseArgument", "n: x", []);
Label name2 = expression.name;
JUnitTestCase.assertNotNull(name2);
JUnitTestCase.assertNotNull(name2.label);
JUnitTestCase.assertNotNull(name2.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", []);
JUnitTestCase.assertNotNull(test.question);
JUnitTestCase.assertNotNull(test.identifier);
}
void test_parseArgumentList_empty() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "()", []);
NodeList<Expression> arguments2 = argumentList.arguments;
EngineTestCase.assertSize(0, arguments2);
}
void test_parseArgumentList_mixed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(w, x, y: y, z: z)", []);
NodeList<Expression> arguments2 = argumentList.arguments;
EngineTestCase.assertSize(4, arguments2);
}
void test_parseArgumentList_noNamed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(x, y, z)", []);
NodeList<Expression> arguments2 = argumentList.arguments;
EngineTestCase.assertSize(3, arguments2);
}
void test_parseArgumentList_onlyNamed() {
ArgumentList argumentList = ParserTestCase.parse5("parseArgumentList", "(x: x, y: y)", []);
NodeList<Expression> arguments2 = argumentList.arguments;
EngineTestCase.assertSize(2, arguments2);
}
void test_parseAssertStatement() {
AssertStatement statement = ParserTestCase.parse5("parseAssertStatement", "assert (x);", []);
JUnitTestCase.assertNotNull(statement.keyword);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
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;
JUnitTestCase.assertNotNull(invocation.function);
ArgumentList argumentList2 = invocation.argumentList;
JUnitTestCase.assertNotNull(argumentList2);
EngineTestCase.assertSize(1, argumentList2.arguments);
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.array);
JUnitTestCase.assertNotNull(expression.leftBracket);
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;
JUnitTestCase.assertEquals("x", invocation.methodName.name);
ArgumentList argumentList2 = invocation.argumentList;
JUnitTestCase.assertNotNull(argumentList2);
EngineTestCase.assertSize(1, argumentList2.arguments);
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.array);
JUnitTestCase.assertNotNull(expression.leftBracket);
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.array);
JUnitTestCase.assertNotNull(expression.leftBracket);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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.array);
JUnitTestCase.assertNotNull(section.leftBracket);
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_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);
JUnitTestCase.assertNotNull(section.operator);
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);
JUnitTestCase.assertNotNull(section.operator);
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);
JUnitTestCase.assertNotNull(section.period);
JUnitTestCase.assertNotNull(section.methodName);
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(FunctionExpressionInvocation, 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(), TokenFactory.token(Keyword.ABSTRACT)], "class A {}");
JUnitTestCase.assertNull(declaration.documentationComment);
JUnitTestCase.assertNotNull(declaration.abstractKeyword);
JUnitTestCase.assertNull(declaration.extendsClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNull(declaration.extendsClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNotNull(declaration.extendsClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNotNull(declaration.extendsClause);
JUnitTestCase.assertNotNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.name);
JUnitTestCase.assertNull(declaration.typeParameters);
JUnitTestCase.assertNotNull(declaration.extendsClause);
JUnitTestCase.assertNotNull(declaration.withClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.leftBracket);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.name);
JUnitTestCase.assertNull(declaration.typeParameters);
JUnitTestCase.assertNotNull(declaration.extendsClause);
JUnitTestCase.assertNotNull(declaration.withClause);
JUnitTestCase.assertNotNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.leftBracket);
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);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNull(declaration.extendsClause);
JUnitTestCase.assertNotNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
void test_parseClassDeclaration_nonEmpty() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A {var f;}");
JUnitTestCase.assertNull(declaration.documentationComment);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNull(declaration.extendsClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(1, declaration.members);
JUnitTestCase.assertNotNull(declaration.rightBracket);
JUnitTestCase.assertNull(declaration.typeParameters);
}
void test_parseClassDeclaration_typeParameters() {
ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", <Object> [emptyCommentAndMetadata(), null], "class A<B> {}");
JUnitTestCase.assertNull(declaration.documentationComment);
JUnitTestCase.assertNull(declaration.abstractKeyword);
JUnitTestCase.assertNull(declaration.extendsClause);
JUnitTestCase.assertNull(declaration.implementsClause);
JUnitTestCase.assertNotNull(declaration.classKeyword);
JUnitTestCase.assertNotNull(declaration.leftBracket);
JUnitTestCase.assertNotNull(declaration.name);
EngineTestCase.assertSize(0, declaration.members);
JUnitTestCase.assertNotNull(declaration.rightBracket);
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);
JUnitTestCase.assertNotNull(constructor.separator);
JUnitTestCase.assertNull(constructor.externalKeyword);
JUnitTestCase.assertNull(constructor.constKeyword);
JUnitTestCase.assertNull(constructor.factoryKeyword);
JUnitTestCase.assertNull(constructor.name);
JUnitTestCase.assertNotNull(constructor.parameters);
JUnitTestCase.assertNull(constructor.period);
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);
EngineTestCase.assertSize(0, field.metadata);
JUnitTestCase.assertNull(field.keyword);
VariableDeclarationList list = field.fields;
JUnitTestCase.assertNotNull(list);
NodeList<VariableDeclaration> variables2 = list.variables;
EngineTestCase.assertSize(1, variables2);
VariableDeclaration variable = variables2[0];
JUnitTestCase.assertNotNull(variable.name);
}
void test_parseClassMember_field_namedGet() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var get;");
JUnitTestCase.assertNull(field.documentationComment);
EngineTestCase.assertSize(0, field.metadata);
JUnitTestCase.assertNull(field.keyword);
VariableDeclarationList list = field.fields;
JUnitTestCase.assertNotNull(list);
NodeList<VariableDeclaration> variables2 = list.variables;
EngineTestCase.assertSize(1, variables2);
VariableDeclaration variable = variables2[0];
JUnitTestCase.assertNotNull(variable.name);
}
void test_parseClassMember_field_namedOperator() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var operator;");
JUnitTestCase.assertNull(field.documentationComment);
EngineTestCase.assertSize(0, field.metadata);
JUnitTestCase.assertNull(field.keyword);
VariableDeclarationList list = field.fields;
JUnitTestCase.assertNotNull(list);
NodeList<VariableDeclaration> variables2 = list.variables;
EngineTestCase.assertSize(1, variables2);
VariableDeclaration variable = variables2[0];
JUnitTestCase.assertNotNull(variable.name);
}
void test_parseClassMember_field_namedSet() {
FieldDeclaration field = ParserTestCase.parse("parseClassMember", <Object> ["C"], "var set;");
JUnitTestCase.assertNull(field.documentationComment);
EngineTestCase.assertSize(0, field.metadata);
JUnitTestCase.assertNull(field.keyword);
VariableDeclarationList list = field.fields;
JUnitTestCase.assertNotNull(list);
NodeList<VariableDeclaration> variables2 = list.variables;
EngineTestCase.assertSize(1, variables2);
VariableDeclaration variable = variables2[0];
JUnitTestCase.assertNotNull(variable.name);
}
void test_parseClassMember_getter_void() {
MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object> ["C"], "void get g {}");
JUnitTestCase.assertNull(method.documentationComment);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNotNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
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);
JUnitTestCase.assertNull(method.documentationComment);
JUnitTestCase.assertNotNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
JUnitTestCase.assertNotNull(method.parameters);
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);
JUnitTestCase.assertNull(method.documentationComment);
JUnitTestCase.assertNotNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
JUnitTestCase.assertNotNull(method.parameters);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNotNull(method.operatorKeyword);
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);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNull(method.propertyKeyword);
JUnitTestCase.assertNotNull(method.returnType);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNotNull(method.operatorKeyword);
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);
JUnitTestCase.assertNotNull(constructor.constKeyword);
JUnitTestCase.assertNotNull(constructor.factoryKeyword);
JUnitTestCase.assertNotNull(constructor.returnType);
JUnitTestCase.assertNull(constructor.period);
JUnitTestCase.assertNull(constructor.name);
JUnitTestCase.assertNotNull(constructor.parameters);
JUnitTestCase.assertNotNull(constructor.separator);
EngineTestCase.assertSize(0, constructor.initializers);
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);
JUnitTestCase.assertNull(constructor.constKeyword);
JUnitTestCase.assertNotNull(constructor.factoryKeyword);
JUnitTestCase.assertNotNull(constructor.returnType);
JUnitTestCase.assertNull(constructor.period);
JUnitTestCase.assertNull(constructor.name);
JUnitTestCase.assertNotNull(constructor.parameters);
JUnitTestCase.assertNotNull(constructor.separator);
EngineTestCase.assertSize(0, constructor.initializers);
JUnitTestCase.assertNotNull(constructor.redirectedConstructor);
JUnitTestCase.assertNotNull(constructor.body);
}
void test_parseClassTypeAlias() {
Token token2 = TokenFactory.token(Keyword.TYPEDEF);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token2], "A = B;");
JUnitTestCase.assertNotNull(classTypeAlias.keyword);
JUnitTestCase.assertEquals("A", classTypeAlias.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.equals);
JUnitTestCase.assertNull(classTypeAlias.abstractKeyword);
JUnitTestCase.assertNotNullMsg("B", classTypeAlias.superclass.name.name);
JUnitTestCase.assertNull(classTypeAlias.withClause);
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
void test_parseClassTypeAlias_abstract() {
Token token2 = TokenFactory.token(Keyword.TYPEDEF);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token2], "A = abstract B;");
JUnitTestCase.assertNotNull(classTypeAlias.keyword);
JUnitTestCase.assertEquals("A", classTypeAlias.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.equals);
JUnitTestCase.assertNotNull(classTypeAlias.abstractKeyword);
JUnitTestCase.assertNotNullMsg("B", classTypeAlias.superclass.name.name);
JUnitTestCase.assertNull(classTypeAlias.withClause);
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
void test_parseClassTypeAlias_implements() {
Token token2 = TokenFactory.token(Keyword.TYPEDEF);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token2], "A = B implements C;");
JUnitTestCase.assertNotNull(classTypeAlias.keyword);
JUnitTestCase.assertEquals("A", classTypeAlias.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.equals);
JUnitTestCase.assertNull(classTypeAlias.abstractKeyword);
JUnitTestCase.assertNotNullMsg("B", classTypeAlias.superclass.name.name);
JUnitTestCase.assertNull(classTypeAlias.withClause);
JUnitTestCase.assertNotNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
void test_parseClassTypeAlias_with() {
Token token2 = TokenFactory.token(Keyword.TYPEDEF);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token2], "A = B with C;");
JUnitTestCase.assertNotNull(classTypeAlias.keyword);
JUnitTestCase.assertEquals("A", classTypeAlias.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.equals);
JUnitTestCase.assertNull(classTypeAlias.abstractKeyword);
JUnitTestCase.assertNotNullMsg("B", classTypeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.withClause);
JUnitTestCase.assertNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
void test_parseClassTypeAlias_with_implements() {
Token token2 = TokenFactory.token(Keyword.TYPEDEF);
ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", <Object> [emptyCommentAndMetadata(), token2], "A = B with C implements D;");
JUnitTestCase.assertNotNull(classTypeAlias.keyword);
JUnitTestCase.assertEquals("A", classTypeAlias.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.equals);
JUnitTestCase.assertNull(classTypeAlias.abstractKeyword);
JUnitTestCase.assertNotNullMsg("B", classTypeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(classTypeAlias.withClause);
JUnitTestCase.assertNotNull(classTypeAlias.implementsClause);
JUnitTestCase.assertNotNull(classTypeAlias.semicolon);
}
void test_parseCombinators_h() {
List<Combinator> combinators = ParserTestCase.parse5("parseCombinators", "hide a;", []);
EngineTestCase.assertSize(1, combinators);
HideCombinator combinator = combinators[0] as HideCombinator;
JUnitTestCase.assertNotNull(combinator);
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);
HideCombinator hideCombinator = combinators[0] as HideCombinator;
JUnitTestCase.assertNotNull(hideCombinator);
JUnitTestCase.assertNotNull(hideCombinator.keyword);
EngineTestCase.assertSize(1, hideCombinator.hiddenNames);
ShowCombinator showCombinator = combinators[1] as ShowCombinator;
JUnitTestCase.assertNotNull(showCombinator);
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);
ShowCombinator combinator = combinators[0] as ShowCombinator;
JUnitTestCase.assertNotNull(combinator);
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_parseCommentReference_new_prefixed() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["new a.b", 7], "");
PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(PrefixedIdentifier, reference.identifier);
SimpleIdentifier prefix2 = prefixedIdentifier.prefix;
JUnitTestCase.assertNotNull(prefix2.token);
JUnitTestCase.assertEquals("a", prefix2.name);
JUnitTestCase.assertEquals(11, prefix2.offset);
JUnitTestCase.assertNotNull(prefixedIdentifier.period);
SimpleIdentifier identifier2 = prefixedIdentifier.identifier;
JUnitTestCase.assertNotNull(identifier2.token);
JUnitTestCase.assertEquals("b", identifier2.name);
JUnitTestCase.assertEquals(13, identifier2.offset);
}
void test_parseCommentReference_new_simple() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["new a", 5], "");
SimpleIdentifier identifier2 = EngineTestCase.assertInstanceOf(SimpleIdentifier, reference.identifier);
JUnitTestCase.assertNotNull(identifier2.token);
JUnitTestCase.assertEquals("a", identifier2.name);
JUnitTestCase.assertEquals(9, identifier2.offset);
}
void test_parseCommentReference_prefixed() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["a.b", 7], "");
PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(PrefixedIdentifier, reference.identifier);
SimpleIdentifier prefix2 = prefixedIdentifier.prefix;
JUnitTestCase.assertNotNull(prefix2.token);
JUnitTestCase.assertEquals("a", prefix2.name);
JUnitTestCase.assertEquals(7, prefix2.offset);
JUnitTestCase.assertNotNull(prefixedIdentifier.period);
SimpleIdentifier identifier2 = prefixedIdentifier.identifier;
JUnitTestCase.assertNotNull(identifier2.token);
JUnitTestCase.assertEquals("b", identifier2.name);
JUnitTestCase.assertEquals(9, identifier2.offset);
}
void test_parseCommentReference_simple() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["a", 5], "");
SimpleIdentifier identifier2 = EngineTestCase.assertInstanceOf(SimpleIdentifier, reference.identifier);
JUnitTestCase.assertNotNull(identifier2.token);
JUnitTestCase.assertEquals("a", identifier2.name);
JUnitTestCase.assertEquals(5, identifier2.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], "");
EngineTestCase.assertSize(2, references);
CommentReference reference = references[0];
JUnitTestCase.assertNotNull(reference);
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(12, reference.offset);
reference = references[1];
JUnitTestCase.assertNotNull(reference);
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), new StringToken(TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)];
List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
EngineTestCase.assertSize(3, references);
CommentReference reference = references[0];
JUnitTestCase.assertNotNull(reference);
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(12, reference.offset);
reference = references[1];
JUnitTestCase.assertNotNull(reference);
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(20, reference.offset);
reference = references[2];
JUnitTestCase.assertNotNull(reference);
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(35, 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_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_typedef_class_abstract() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "typedef C = abstract S with M;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
JUnitTestCase.assertEquals("C", typeAlias.name.name);
JUnitTestCase.assertNull(typeAlias.typeParameters);
JUnitTestCase.assertNotNull(typeAlias.equals);
JUnitTestCase.assertNotNull(typeAlias.abstractKeyword);
JUnitTestCase.assertEquals("S", typeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(typeAlias.withClause);
JUnitTestCase.assertNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
void test_parseCompilationUnitMember_typedef_class_generic() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "typedef C<E> = S<E> with M<E> implements I<E>;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
JUnitTestCase.assertEquals("C", typeAlias.name.name);
EngineTestCase.assertSize(1, typeAlias.typeParameters.typeParameters);
JUnitTestCase.assertNotNull(typeAlias.equals);
JUnitTestCase.assertNull(typeAlias.abstractKeyword);
JUnitTestCase.assertEquals("S", typeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(typeAlias.withClause);
JUnitTestCase.assertNotNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
void test_parseCompilationUnitMember_typedef_class_implements() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "typedef C = S with M implements I;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
JUnitTestCase.assertEquals("C", typeAlias.name.name);
JUnitTestCase.assertNull(typeAlias.typeParameters);
JUnitTestCase.assertNotNull(typeAlias.equals);
JUnitTestCase.assertNull(typeAlias.abstractKeyword);
JUnitTestCase.assertEquals("S", typeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(typeAlias.withClause);
JUnitTestCase.assertNotNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
void test_parseCompilationUnitMember_typedef_class_noImplements() {
ClassTypeAlias typeAlias = ParserTestCase.parse("parseCompilationUnitMember", <Object> [emptyCommentAndMetadata()], "typedef C = S with M;");
JUnitTestCase.assertNotNull(typeAlias.keyword);
JUnitTestCase.assertEquals("C", typeAlias.name.name);
JUnitTestCase.assertNull(typeAlias.typeParameters);
JUnitTestCase.assertNotNull(typeAlias.equals);
JUnitTestCase.assertNull(typeAlias.abstractKeyword);
JUnitTestCase.assertEquals("S", typeAlias.superclass.name.name);
JUnitTestCase.assertNotNull(typeAlias.withClause);
JUnitTestCase.assertNull(typeAlias.implementsClause);
JUnitTestCase.assertNotNull(typeAlias.semicolon);
}
void test_parseCompilationUnitMember_typedef_function() {
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_parseConditionalExpression() {
ConditionalExpression expression = ParserTestCase.parse5("parseConditionalExpression", "x ? y : z", []);
JUnitTestCase.assertNotNull(expression.condition);
JUnitTestCase.assertNotNull(expression.question);
JUnitTestCase.assertNotNull(expression.thenExpression);
JUnitTestCase.assertNotNull(expression.colon);
JUnitTestCase.assertNotNull(expression.elseExpression);
}
void test_parseConstExpression_instanceCreation() {
InstanceCreationExpression expression = ParserTestCase.parse5("parseConstExpression", "const A()", []);
JUnitTestCase.assertNotNull(expression.keyword);
ConstructorName name = expression.constructorName;
JUnitTestCase.assertNotNull(name);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
void test_parseConstExpression_listLiteral_typed() {
ListLiteral literal = ParserTestCase.parse5("parseConstExpression", "const <A> []", []);
JUnitTestCase.assertNotNull(literal.modifier);
JUnitTestCase.assertNotNull(literal.typeArguments);
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
void test_parseConstExpression_listLiteral_untyped() {
ListLiteral literal = ParserTestCase.parse5("parseConstExpression", "const []", []);
JUnitTestCase.assertNotNull(literal.modifier);
JUnitTestCase.assertNull(literal.typeArguments);
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(0, literal.elements);
JUnitTestCase.assertNotNull(literal.rightBracket);
}
void test_parseConstExpression_mapLiteral_typed() {
MapLiteral literal = ParserTestCase.parse5("parseConstExpression", "const <A> {}", []);
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(0, literal.entries);
JUnitTestCase.assertNotNull(literal.rightBracket);
JUnitTestCase.assertNotNull(literal.typeArguments);
}
void test_parseConstExpression_mapLiteral_untyped() {
MapLiteral literal = ParserTestCase.parse5("parseConstExpression", "const {}", []);
JUnitTestCase.assertNotNull(literal.leftBracket);
EngineTestCase.assertSize(0, literal.entries);
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);
JUnitTestCase.assertNotNull(invocation.expression);
JUnitTestCase.assertNotNull(invocation.fieldName);
JUnitTestCase.assertNotNull(invocation.keyword);
JUnitTestCase.assertNotNull(invocation.period);
}
void test_parseConstructorFieldInitializer_unqualified() {
ConstructorFieldInitializer invocation = ParserTestCase.parse5("parseConstructorFieldInitializer", "a = b", []);
JUnitTestCase.assertNotNull(invocation.equals);
JUnitTestCase.assertNotNull(invocation.expression);
JUnitTestCase.assertNotNull(invocation.fieldName);
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);
JUnitTestCase.assertNotNull(directive.uri);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNull(directive.asToken);
JUnitTestCase.assertNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.ofToken);
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());
JUnitTestCase.assertTrue(comment.isDocumentation());
JUnitTestCase.assertFalse(comment.isEndOfLine());
NodeList<CommentReference> references2 = comment.references;
EngineTestCase.assertSize(1, references2);
CommentReference reference = references2[0];
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);
JUnitTestCase.assertNotNull(statement.body);
JUnitTestCase.assertNotNull(statement.whileKeyword);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(directive.uri);
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);
JUnitTestCase.assertNotNull(directive.uri);
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);
JUnitTestCase.assertNotNull(directive.uri);
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);
JUnitTestCase.assertNotNull(directive.uri);
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);
JUnitTestCase.assertNotNull(directive.uri);
EngineTestCase.assertSize(2, directive.combinators);
JUnitTestCase.assertNotNull(directive.semicolon);
}
void test_parseExpression_assign() {
AssignmentExpression expression = ParserTestCase.parse5("parseExpression", "x = y", []);
JUnitTestCase.assertNotNull(expression.leftHandSide);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
FunctionExpression expression = invocation.function as FunctionExpression;
JUnitTestCase.assertNotNull(expression.parameters);
JUnitTestCase.assertNotNull(expression.body);
ArgumentList list = invocation.argumentList;
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);
JUnitTestCase.assertNotNull(expression.operator);
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);
JUnitTestCase.assertNotNull(expression.operator);
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 keyword2 = result.keyword;
JUnitTestCase.assertNotNull(keyword2);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword2.type);
JUnitTestCase.assertEquals(Keyword.CONST, ((keyword2 as KeywordToken)).keyword);
JUnitTestCase.assertNull(result.type);
}
void test_parseFinalConstVarOrType_const_type() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "const A a");
Token keyword2 = result.keyword;
JUnitTestCase.assertNotNull(keyword2);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword2.type);
JUnitTestCase.assertEquals(Keyword.CONST, ((keyword2 as KeywordToken)).keyword);
JUnitTestCase.assertNotNull(result.type);
}
void test_parseFinalConstVarOrType_final_noType() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "final");
Token keyword2 = result.keyword;
JUnitTestCase.assertNotNull(keyword2);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword2.type);
JUnitTestCase.assertEquals(Keyword.FINAL, ((keyword2 as KeywordToken)).keyword);
JUnitTestCase.assertNull(result.type);
}
void test_parseFinalConstVarOrType_final_type() {
FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType", <Object> [false], "final A a");
Token keyword2 = result.keyword;
JUnitTestCase.assertNotNull(keyword2);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword2.type);
JUnitTestCase.assertEquals(Keyword.FINAL, ((keyword2 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 keyword2 = result.keyword;
JUnitTestCase.assertNotNull(keyword2);
JUnitTestCase.assertEquals(TokenType.KEYWORD, keyword2.type);
JUnitTestCase.assertEquals(Keyword.VAR, ((keyword2 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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNotNull(simpleParameter.keyword);
JUnitTestCase.assertNotNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
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");
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNotNull(parameter.keyword);
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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNotNull(simpleParameter.keyword);
JUnitTestCase.assertNotNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNull(simpleParameter.keyword);
JUnitTestCase.assertNotNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
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");
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNull(parameter.keyword);
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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNull(simpleParameter.keyword);
JUnitTestCase.assertNotNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
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");
JUnitTestCase.assertNotNull(parameter.identifier);
JUnitTestCase.assertNotNull(parameter.keyword);
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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNotNull(simpleParameter.keyword);
JUnitTestCase.assertNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
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");
SimpleFormalParameter simpleParameter = parameter.parameter as SimpleFormalParameter;
JUnitTestCase.assertNotNull(simpleParameter.identifier);
JUnitTestCase.assertNotNull(simpleParameter.keyword);
JUnitTestCase.assertNull(simpleParameter.type);
JUnitTestCase.assertEquals(kind, simpleParameter.kind);
JUnitTestCase.assertNotNull(parameter.separator);
JUnitTestCase.assertNotNull(parameter.defaultValue);
JUnitTestCase.assertEquals(kind, parameter.kind);
}
void test_parseFormalParameterList_empty() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "()", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
JUnitTestCase.assertNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(0, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(3, parameterList.parameters);
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
void test_parseFormalParameterList_named_single() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "({A a})", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(1, parameterList.parameters);
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);
JUnitTestCase.assertNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(3, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(2, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(2, parameterList.parameters);
JUnitTestCase.assertNotNull(parameterList.rightDelimiter);
JUnitTestCase.assertNotNull(parameterList.rightParenthesis);
}
void test_parseFormalParameterList_normal_single() {
FormalParameterList parameterList = ParserTestCase.parse5("parseFormalParameterList", "(A a)", []);
JUnitTestCase.assertNotNull(parameterList.leftParenthesis);
JUnitTestCase.assertNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(1, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(3, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(parameterList.leftDelimiter);
EngineTestCase.assertSize(1, parameterList.parameters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.loopVariable);
JUnitTestCase.assertNotNull(statement.inKeyword);
JUnitTestCase.assertNotNull(statement.iterator);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.loopVariable);
EngineTestCase.assertSize(1, statement.loopVariable.metadata);
JUnitTestCase.assertNotNull(statement.inKeyword);
JUnitTestCase.assertNotNull(statement.iterator);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.loopVariable);
JUnitTestCase.assertNotNull(statement.inKeyword);
JUnitTestCase.assertNotNull(statement.iterator);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.loopVariable);
JUnitTestCase.assertNotNull(statement.inKeyword);
JUnitTestCase.assertNotNull(statement.iterator);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNull(statement.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(0, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNull(statement.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(1, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNull(statement.variables);
JUnitTestCase.assertNotNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(1, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(0, variables2.metadata);
EngineTestCase.assertSize(1, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(0, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(1, variables2.metadata);
EngineTestCase.assertSize(1, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(0, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(1, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(0, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(1, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(1, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(2, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(2, statement.updaters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
VariableDeclarationList variables2 = statement.variables;
JUnitTestCase.assertNotNull(variables2);
EngineTestCase.assertSize(1, variables2.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(1, statement.updaters);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
void test_parseForStatement_loop_u() {
ForStatement statement = ParserTestCase.parse5("parseForStatement", "for (;; i++) {}", []);
JUnitTestCase.assertNotNull(statement.forKeyword);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNull(statement.variables);
JUnitTestCase.assertNull(statement.initialization);
JUnitTestCase.assertNotNull(statement.leftSeparator);
JUnitTestCase.assertNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightSeparator);
EngineTestCase.assertSize(1, statement.updaters);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.body);
}
void test_parseFunctionBody_block() {
BlockFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [false, false], "{}");
JUnitTestCase.assertNotNull(functionBody.block);
}
void test_parseFunctionBody_empty() {
EmptyFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [true, false], ";");
JUnitTestCase.assertNotNull(functionBody.semicolon);
}
void test_parseFunctionBody_expression() {
ExpressionFunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Object> [false, 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, 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);
FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclaration", <Object> [commentAndMetadata(comment, []), null, returnType], "f() {}");
JUnitTestCase.assertEquals(comment, declaration.documentationComment);
JUnitTestCase.assertEquals(returnType, declaration.returnType);
JUnitTestCase.assertNotNull(declaration.name);
FunctionExpression expression = declaration.functionExpression;
JUnitTestCase.assertNotNull(expression);
JUnitTestCase.assertNotNull(expression.body);
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);
FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclaration", <Object> [commentAndMetadata(comment, []), null, returnType], "get p => 0;");
JUnitTestCase.assertEquals(comment, declaration.documentationComment);
JUnitTestCase.assertEquals(returnType, declaration.returnType);
JUnitTestCase.assertNotNull(declaration.name);
FunctionExpression expression = declaration.functionExpression;
JUnitTestCase.assertNotNull(expression);
JUnitTestCase.assertNotNull(expression.body);
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);
FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclaration", <Object> [commentAndMetadata(comment, []), null, returnType], "set p(v) {}");
JUnitTestCase.assertEquals(comment, declaration.documentationComment);
JUnitTestCase.assertEquals(returnType, declaration.returnType);
JUnitTestCase.assertNotNull(declaration.name);
FunctionExpression expression = declaration.functionExpression;
JUnitTestCase.assertNotNull(expression);
JUnitTestCase.assertNotNull(expression.body);
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);
}
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);
MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [commentAndMetadata(comment, []), null, null, returnType], "get a;");
JUnitTestCase.assertNotNull(method.body);
JUnitTestCase.assertEquals(comment, method.documentationComment);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertNull(method.modifierKeyword);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
JUnitTestCase.assertNull(method.parameters);
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);
TypeName returnType = new TypeName.full(new SimpleIdentifier.full(null), null);
MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [commentAndMetadata(comment, []), null, staticKeyword, returnType], "get a;");
JUnitTestCase.assertNotNull(method.body);
JUnitTestCase.assertEquals(comment, method.documentationComment);
JUnitTestCase.assertNull(method.externalKeyword);
JUnitTestCase.assertEquals(staticKeyword, method.modifierKeyword);
JUnitTestCase.assertNotNull(method.name);
JUnitTestCase.assertNull(method.operatorKeyword);
JUnitTestCase.assertNull(method.parameters);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.thenStatement);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.thenStatement);
JUnitTestCase.assertNotNull(statement.elseKeyword);
JUnitTestCase.assertNotNull(statement.elseStatement);
}
void test_parseIfStatement_noElse_block() {
IfStatement statement = ParserTestCase.parse5("parseIfStatement", "if (x) {}", []);
JUnitTestCase.assertNotNull(statement.ifKeyword);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.thenStatement);
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);
JUnitTestCase.assertNotNull(statement.leftParenthesis);
JUnitTestCase.assertNotNull(statement.condition);
JUnitTestCase.assertNotNull(statement.rightParenthesis);
JUnitTestCase.assertNotNull(statement.thenStatement);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNull(directive.asToken);
JUnitTestCase.assertNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNull(directive.asToken);
JUnitTestCase.assertNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNotNull(directive.asToken);
JUnitTestCase.assertNotNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNotNull(directive.asToken);
JUnitTestCase.assertNotNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNotNull(directive.asToken);
JUnitTestCase.assertNotNull(directive.prefix);
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);
JUnitTestCase.assertNotNull(directive.uri);
JUnitTestCase.assertNull(directive.asToken);
JUnitTestCase.assertNull(directive.prefix);
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);
TypeName type = new TypeName.full(new SimpleIdentifier.full(null), null);
FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentifierList", <Object> [commentAndMetadata(comment, []), staticKeyword, null, type], "a = 1, b, c = 3;");
JUnitTestCase.assertEquals(comment, declaration.documentationComment);
VariableDeclarationList fields2 = declaration.fields;
JUnitTestCase.assertNotNull(fields2);
JUnitTestCase.assertNull(fields2.keyword);
JUnitTestCase.assertEquals(type, fields2.type);
EngineTestCase.assertSize(3, fields2.variables);
JUnitTestCase.assertEquals(staticKeyword, declaration.keyword);
JUnitTestCase.assertNotNull(declaration.semicolon);
}
void test_parseInitializedIdentifierList_var() {
Comment comment = Comment.createDocumentationComment(new List<Token>(0));
Token staticKeyword = TokenFactory.token(Keyword.STATIC);
Token varKeyword = TokenFactory.token(Keyword.VAR);
FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentifierList", <Object> [commentAndMetadata(comment, []), staticKeyword, varKeyword, null], "a = 1, b, c = 3;");
JUnitTestCase.assertEquals(comment, declaration.documentationComment);
VariableDeclarationList fields2 = declaration.fields;
JUnitTestCase.assertNotNull(fields2);
JUnitTestCase.assertEquals(varKeyword, fields2.keyword);
JUnitTestCase.assertNull(fields2.type);
EngineTestCase.assertSize(3, fields2.variables);
JUnitTestCase.assertEquals(staticKeyword, declaration.keyword);
JUnitTestCase.assertNotNull(declaration.semicolon);
}
void test_parseInstanceCreationExpression_qualifiedType() {
Token token2 = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token2], "A.B()");
JUnitTestCase.assertEquals(token2, expression.keyword);
ConstructorName name = expression.constructorName;
JUnitTestCase.assertNotNull(name);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
void test_parseInstanceCreationExpression_qualifiedType_named() {
Token token2 = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token2], "A.B.c()");
JUnitTestCase.assertEquals(token2, expression.keyword);
ConstructorName name = expression.constructorName;
JUnitTestCase.assertNotNull(name);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNotNull(name.period);
JUnitTestCase.assertNotNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
void test_parseInstanceCreationExpression_type() {
Token token2 = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token2], "A()");
JUnitTestCase.assertEquals(token2, expression.keyword);
ConstructorName name = expression.constructorName;
JUnitTestCase.assertNotNull(name);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNull(name.period);
JUnitTestCase.assertNull(name.name);
JUnitTestCase.assertNotNull(expression.argumentList);
}
void test_parseInstanceCreationExpression_type_named() {
Token token2 = TokenFactory.token(Keyword.NEW);
InstanceCreationExpression expression = ParserTestCase.parse("parseInstanceCreationExpression", <Object> [token2], "A<B>.c()");
JUnitTestCase.assertEquals(token2, expression.keyword);
ConstructorName name = expression.constructorName;
JUnitTestCase.assertNotNull(name);
JUnitTestCase.assertNotNull(name.type);
JUnitTestCase.assertNotNull(name.period);
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 token2 = TokenFactory.token(Keyword.CONST);
TypeArgumentList typeArguments = new TypeArgumentList.full(null, null, null);
ListLiteral literal = ParserTestCase.parse("parseListLiteral", <Object> [token2, typeArguments], "[]");
JUnitTestCase.assertEquals(token2, literal.modifier);
JUnitTestCase.assertEquals(