forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle reserved Kotlin keywords (flutter#86518)
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/flutter_tools/test/general.shard/android/template_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:file/file.dart'; | ||
import 'package:file/memory.dart'; | ||
import 'package:flutter_tools/src/base/logger.dart'; | ||
import 'package:flutter_tools/src/isolated/mustache_template.dart'; | ||
import 'package:flutter_tools/src/template.dart'; | ||
|
||
import '../../src/common.dart'; | ||
|
||
void main() { | ||
|
||
testWithoutContext('kotlin reserved keywords', () { | ||
final FileSystem fileSystem = MemoryFileSystem.test(); | ||
final BufferLogger logger = BufferLogger.test(); | ||
final Directory rootDir = fileSystem.currentDirectory; | ||
final Directory templateSource = rootDir.childDirectory('src'); | ||
final Directory imageSourceDir = templateSource; | ||
final Directory destination = rootDir.childDirectory('dest'); | ||
|
||
const String outputClass = 'SomeClass.kt'; | ||
|
||
final File sourceFile = templateSource.childFile('$outputClass.tmpl'); | ||
|
||
templateSource.createSync(); | ||
sourceFile.writeAsStringSync('package {{androidIdentifier}};'); | ||
|
||
final Template template = Template( | ||
templateSource, | ||
imageSourceDir, | ||
fileSystem: fileSystem, | ||
logger: logger, | ||
templateRenderer: const MustacheTemplateRenderer(), | ||
templateManifest: null | ||
); | ||
|
||
final Map<String, Object> context = <String, Object>{ | ||
'androidIdentifier': 'in.when.there' | ||
}; | ||
template.render(destination, context); | ||
|
||
final File destinationFile = destination.childFile(outputClass); | ||
expect(destinationFile.readAsStringSync(), equals('package `in`.`when`.there;')); | ||
}); | ||
|
||
} |