-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Dart to executors * Remove web folder from dart_native * Add debug mode for dart_web_client * fix typo * Changes as per review * Switch to node * Remove temp output files * Add output to gitignore * Remove pubspec.lock * Bugfix * Fix dart web invocations * Works now * rename script * Update Dart version + add to GH CI * Use new API * Switch to published package from git * Rev intl4x version
- Loading branch information
Showing
15 changed files
with
499 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -24,3 +24,8 @@ testgen/icu*/*.json | |
|
||
# C / CPP compiled | ||
*.o | ||
|
||
testdriver/.local-chrome/ | ||
testgen/*.json | ||
|
||
TEMP_DATA/* |
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,5 @@ | ||
bin/executor.exe | ||
|
||
.dart_tool | ||
build/ | ||
pubspec.lock |
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,18 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-raw-types: true | ||
errors: | ||
deprecated_member_use_from_same_package: ignore | ||
|
||
linter: | ||
rules: | ||
- always_declare_return_types | ||
- directives_ordering | ||
- prefer_single_quotes | ||
- sort_pub_dependencies | ||
- unnecessary_parenthesis | ||
- avoid_dynamic_calls | ||
- type_annotate_public_apis | ||
- non_constant_identifier_names |
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,91 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'package:intl4x/collation.dart'; | ||
import 'package:intl4x/intl4x.dart'; | ||
|
||
Map<String, List<String>> supportedTests = { | ||
'supported_tests': [ | ||
'coll_shift_short', | ||
'decimal_fmt', | ||
'number_fmt', | ||
'display_names', | ||
'language_display_name', | ||
], | ||
}; | ||
|
||
enum TestTypes { | ||
coll_shift_short, | ||
decimal_fmt, | ||
datetime_fmt, | ||
display_names, | ||
lang_names, | ||
number_fmt; | ||
} | ||
|
||
void main() { | ||
stdin.listen((event) { | ||
var lines = utf8.decode(event); | ||
for (var line in lines.split('\n')) { | ||
if (line == '#EXIT') { | ||
exit(0); | ||
} else if (line == '#VERSION') { | ||
printVersion(); | ||
} else if (line == '#TESTS') { | ||
print(json.encode(supportedTests)); | ||
} else { | ||
Map<String, dynamic> decoded; | ||
try { | ||
decoded = json.decode(line); | ||
} catch (e) { | ||
print('ERROR $line'); | ||
rethrow; | ||
} | ||
|
||
var testType = TestTypes.values | ||
.firstWhere((element) => element.name == decoded['test_type']); | ||
Object result; | ||
switch (testType) { | ||
case TestTypes.coll_shift_short: | ||
result = testCollator(decoded); | ||
break; | ||
case TestTypes.decimal_fmt: | ||
// TODO: Handle this case. | ||
case TestTypes.datetime_fmt: | ||
// TODO: Handle this case. | ||
case TestTypes.display_names: | ||
// TODO: Handle this case. | ||
case TestTypes.lang_names: | ||
// TODO: Handle this case. | ||
case TestTypes.number_fmt: | ||
// TODO: Handle this case. | ||
default: | ||
throw UnsupportedError(''); | ||
} | ||
|
||
var outputLine = {'label': decoded['label'], 'result': result}; | ||
print(json.encode(outputLine)); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
bool testCollator(Map<String, dynamic> decoded) { | ||
var compared = | ||
Intl().collation(CollationOptions(ignorePunctuation: true)).compare( | ||
decoded['string1'], | ||
decoded['string2'], | ||
); | ||
var result = compared <= 0 ? true : false; | ||
return result; | ||
} | ||
|
||
void printVersion() { | ||
var version = Platform.version; | ||
var parsedVersion = version.substring(0, version.indexOf(' ')); | ||
var versionInfo = { | ||
'icuVersion': '71.1', | ||
'platform': 'Dart', | ||
'platformVersion': parsedVersion, | ||
}; | ||
print(json.encode(versionInfo)); | ||
} |
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,17 @@ | ||
name: dart | ||
description: A sample command-line application. | ||
version: 1.0.0 | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ^3.0.0 | ||
|
||
# Add regular dependencies here. | ||
dependencies: | ||
intl4x: ^0.4.0 | ||
|
||
dev_dependencies: | ||
build_runner: ^2.4.4 | ||
build_web_compilers: ^4.0.3 | ||
lints: ^2.0.0 | ||
test: ^1.21.0 |
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,7 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
out/collatorDart.js | ||
out/collatorDart.js.deps | ||
out/collatorDart.js.map | ||
pubspec.lock |
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,5 @@ | ||
import 'collator.dart'; | ||
|
||
void main(List<String> args) { | ||
testCollationShort(args.first); //just some call to not treeshake the function | ||
} |
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,45 @@ | ||
// The Collator used for the actual testing. | ||
|
||
// !!! TODO: Collation: determine the sensitivity that corresponds | ||
// to the strength. | ||
import 'dart:convert'; | ||
|
||
import 'package:intl4x/collation.dart'; | ||
import 'package:intl4x/intl4x.dart'; | ||
|
||
String testCollationShort(String jsonEncoded) { | ||
var json = | ||
jsonDecode(jsonEncoded); // For the moment, use strings for easier interop | ||
// Global default locale | ||
var testLocale = ''; | ||
Map<String, dynamic> outputLine; | ||
|
||
// Set up collator object with optional locale and testOptions. | ||
try { | ||
Intl coll; | ||
if (testLocale.isNotEmpty) { | ||
coll = Intl(locale: Locale.parse(testLocale)); | ||
} else { | ||
coll = Intl(); | ||
} | ||
var d1 = json['string1']; | ||
var d2 = json['string2']; | ||
|
||
var collationOptions = CollationOptions(ignorePunctuation: true); | ||
var compared = coll.collation(collationOptions).compare(d1, d2); | ||
var result = compared <= 0 ? true : false; | ||
outputLine = {'label': json['label'], "result": result}; | ||
|
||
if (result != true) { | ||
// Additional info for the comparison | ||
outputLine['compare'] = compared; | ||
} | ||
} catch (error) { | ||
outputLine = { | ||
'label': json['label'], | ||
'error_message': error.toString(), | ||
'error': 'Collator compare failed' | ||
}; | ||
} | ||
return jsonEncode(outputLine); | ||
} |
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,47 @@ | ||
import 'dart:io'; | ||
|
||
Future<void> main(List<String> args) async { | ||
var name = 'collatorDart'; | ||
var compile = await Process.run('dart', [ | ||
'compile', | ||
'js', | ||
'bin/all_executors.dart', | ||
'-o', | ||
'out/$name.js', | ||
]); | ||
print(compile.stderr); | ||
|
||
prepareOutFile(name, ['testCollationShort']); | ||
} | ||
|
||
/// Prepare the file to export `testCollationShort` | ||
void prepareOutFile(String name, List<String> functions) { | ||
var outFile = File('out/$name.js'); | ||
var s = outFile.readAsStringSync(); | ||
s = s.replaceAll('self.', ''); | ||
s = s.replaceFirst('(function dartProgram() {', | ||
'module.exports = (function dartProgram() {'); | ||
|
||
s = s.replaceFirst('(function dartProgram() {', | ||
'module.exports = (function dartProgram() {'); | ||
|
||
var exportFunctions = functions | ||
.map( | ||
(e) => '''$e: function(arg) { | ||
return A.$e(arg); | ||
}''', | ||
) | ||
.join(',\n'); | ||
s = s.replaceFirst( | ||
'})();\n\n//# sourceMappingURL=$name.js.map', | ||
''' | ||
return { | ||
$exportFunctions | ||
}; | ||
})(); | ||
//# sourceMappingURL=$name.js.map | ||
''', | ||
); | ||
s = 'function dartMainRunner(main, args){}' + s; | ||
outFile.writeAsStringSync(s); | ||
} |
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,10 @@ | ||
var tools = require('./collatorDart'); | ||
// The Collator used for the actual testing. | ||
|
||
// !!! TODO: Collation: determine the sensitivity that corresponds | ||
// to the strength. | ||
module.exports = { | ||
testCollationShort: function (json) { | ||
return JSON.parse(tools.testCollationShort(JSON.stringify(json))); | ||
} | ||
}; |
Oops, something went wrong.