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

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

Issue 630163004: Add SingleStringLiteral with accessors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add GeneralizingAstVisitor.visitSingleStringLiteral Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/ast_test.dart
diff --git a/pkg/analyzer/test/generated/ast_test.dart b/pkg/analyzer/test/generated/ast_test.dart
index ad8c4b0040bc336f46c8afbf2849599c2d5cacc5..a1f9bec2cfd22ca9e8c312c11308ac4a983456f1 100644
--- a/pkg/analyzer/test/generated/ast_test.dart
+++ b/pkg/analyzer/test/generated/ast_test.dart
@@ -1573,15 +1573,26 @@ class SimpleIdentifierTest extends ParserTestCase {
}
class SimpleStringLiteralTest extends ParserTestCase {
- void test_getValueOffset() {
- JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").valueOffset);
- JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").valueOffset);
- JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").valueOffset);
- JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X").valueOffset);
- JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").valueOffset);
- JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X").valueOffset);
- JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").valueOffset);
- JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X").valueOffset);
+ void test_contentsOffset() {
+ JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").contentsOffset);
+ JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").contentsOffset);
+ JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsOffset);
+ JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X").contentsOffset);
+ JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").contentsOffset);
+ JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X").contentsOffset);
+ JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsOffset);
+ JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X").contentsOffset);
+ }
+
+ void test_contentsEnd() {
+ JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").contentsEnd);
+ JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").contentsEnd);
+ JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsEnd);
+ JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X").contentsEnd);
+ JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").contentsEnd);
+ JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X").contentsEnd);
+ JUnitTestCase.assertEquals(5, new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsEnd);
+ JUnitTestCase.assertEquals(5, new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X").contentsEnd);
}
void test_isMultiline() {
@@ -1617,9 +1628,13 @@ class SimpleStringLiteralTest extends ParserTestCase {
static dartSuite() {
_ut.group('SimpleStringLiteralTest', () {
- _ut.test('test_getValueOffset', () {
+ _ut.test('test_contentsOffset', () {
final __test = new SimpleStringLiteralTest();
- runJUnitTest(__test, __test.test_getValueOffset);
+ runJUnitTest(__test, __test.test_contentsOffset);
+ });
+ _ut.test('test_contentsEnd', () {
+ final __test = new SimpleStringLiteralTest();
+ runJUnitTest(__test, __test.test_contentsEnd);
});
_ut.test('test_isMultiline', () {
final __test = new SimpleStringLiteralTest();
@@ -1637,6 +1652,88 @@ class SimpleStringLiteralTest extends ParserTestCase {
}
}
+class StringInterpolationTest extends ParserTestCase {
+ void test_contentsOffsetEnd() {
+ var be = AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
+ // 'a${bb}ccc'
+ {
+ var ae = AstFactory.interpolationString("'a", "a");
+ var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(1, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ // '''a${bb}ccc'''
+ {
+ var ae = AstFactory.interpolationString("'''a", "a");
+ var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(3, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ // """a${bb}ccc"""
+ {
+ var ae = AstFactory.interpolationString('"""a', "a");
+ var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(3, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ // r'a${bb}ccc'
+ {
+ var ae = AstFactory.interpolationString("r'a", "a");
+ var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(2, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ // r'''a${bb}ccc'''
+ {
+ var ae = AstFactory.interpolationString("r'''a", "a");
+ var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(4, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ // r"""a${bb}ccc"""
+ {
+ var ae = AstFactory.interpolationString('r"""a', "a");
+ var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
+ var cElement = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, cElement]);
+ JUnitTestCase.assertEquals(4, node.contentsOffset);
+ JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd);
+ }
+ }
+
+ void test_isRaw() {
+ var ae = AstFactory.interpolationString("'a", "a");
+ var be = AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
+ var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
+ var ce = new InterpolationString(cToken, 'ccc');
+ StringInterpolation node = AstFactory.string([ae, ae, ce]);
+ JUnitTestCase.assertFalse(node.isRaw);
+ }
+
+ static dartSuite() {
+ _ut.group('StringInterpolationTest', () {
+ _ut.test('test_contentsOffsetEnd', () {
+ final __test = new StringInterpolationTest();
+ runJUnitTest(__test, __test.test_contentsOffsetEnd);
+ });
+ _ut.test('test_isRaw', () {
+ final __test = new StringInterpolationTest();
+ runJUnitTest(__test, __test.test_isRaw);
+ });
+ });
+ }
+}
+
class ToSourceVisitorTest extends EngineTestCase {
void test_visitAdjacentStrings() {
_assertSource("'a' 'b'", AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2("b")]));
@@ -4056,5 +4153,6 @@ main() {
NodeListTest.dartSuite();
SimpleIdentifierTest.dartSuite();
SimpleStringLiteralTest.dartSuite();
+ StringInterpolationTest.dartSuite();
VariableDeclarationTest.dartSuite();
}
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698