Skip to content

Commit

Permalink
Rename platform: console to standalone. (dart-lang#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored and kevmoo committed Jul 6, 2017
1 parent 460402e commit 6362206
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
15 changes: 8 additions & 7 deletions lib/src/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ part 'platform.g.dart';

abstract class KnownPlatforms {
static const String browser = 'browser';
static const String console = 'console';
static const String standalone = 'standalone';
static const String flutter = 'flutter';
static const String mirrors = 'mirrors';

Expand Down Expand Up @@ -49,19 +49,20 @@ class PlatformInfo extends Object with _$PlatformInfoSerializerMixin {
bool get hasConflict =>
(!worksAnywhere) ||
(uses.contains(KnownPlatforms.flutter) && !worksInFlutter) ||
(uses.contains(KnownPlatforms.native) && !worksInConsole);
(uses.contains(KnownPlatforms.native) && !worksInStandalone);

bool get worksEverywhere =>
worksInBrowser && worksInConsole && worksInFlutter;
worksInBrowser && worksInStandalone && worksInFlutter;

bool get worksAnywhere => worksInBrowser || worksInConsole || worksInFlutter;
bool get worksAnywhere =>
worksInBrowser || worksInStandalone || worksInFlutter;

bool get worksInBrowser =>
_hasNoUseOf([KnownPlatforms.flutter, KnownPlatforms.native]) &&
(uses.contains(KnownPlatforms.browser) ||
_hasNoUseOf([KnownPlatforms.console]));
_hasNoUseOf([KnownPlatforms.standalone]));

bool get worksInConsole =>
bool get worksInStandalone =>
_hasNoUseOf([KnownPlatforms.browser, KnownPlatforms.flutter]);

bool get worksInFlutter => _hasNoUseOf([
Expand Down Expand Up @@ -100,7 +101,7 @@ PlatformInfo classifyPlatform(Iterable<String> dependencies) {
}

if (libs.contains('dart:io')) {
uses.add(KnownPlatforms.console);
uses.add(KnownPlatforms.standalone);
}

if (libs.contains('dart:ui')) {
Expand Down
6 changes: 3 additions & 3 deletions test/end2end/http_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ final data = {
"package:typed_data/typed_data.dart"
],
"platform": {
"uses": ["browser", "console"]
"uses": ["browser", "standalone"]
}
},
"lib/http.dart": {
Expand Down Expand Up @@ -351,7 +351,7 @@ final data = {
"package:typed_data/typed_data.dart"
],
"platform": {
"uses": ["console"]
"uses": ["standalone"]
}
},
"lib/src/base_client.dart": {
Expand Down Expand Up @@ -584,7 +584,7 @@ final data = {
"package:typed_data/typed_data.dart"
],
"platform": {
"uses": ["console"]
"uses": ["standalone"]
}
},
"test/html/client_test.dart": {
Expand Down
36 changes: 18 additions & 18 deletions test/platform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isTrue);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isTrue);
expect(p.worksInStandalone, isTrue);
expect(p.worksInFlutter, isTrue);
});

Expand All @@ -21,7 +21,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isTrue);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isTrue);
expect(p.worksInStandalone, isTrue);
expect(p.worksInFlutter, isTrue);
});

Expand All @@ -31,7 +31,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isTrue);
expect(p.worksInStandalone, isTrue);
expect(p.worksInFlutter, isTrue);
});

Expand All @@ -41,15 +41,15 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);

p = classifyPlatform(['dart:svg']);
expect(p.hasConflict, isFalse);
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
});

Expand All @@ -59,7 +59,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isTrue);
});

Expand All @@ -69,7 +69,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isTrue);
expect(p.worksInStandalone, isTrue);
expect(p.worksInFlutter, isFalse);
});

Expand All @@ -79,7 +79,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
});

Expand All @@ -89,9 +89,9 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isTrue);
expect(p.worksInStandalone, isTrue);
expect(p.worksInFlutter, isFalse);
expect(p.uses, [KnownPlatforms.console, KnownPlatforms.native]);
expect(p.uses, [KnownPlatforms.native, KnownPlatforms.standalone]);
});

test('detect angular', () {
Expand All @@ -101,7 +101,7 @@ void main() {
expect(p.worksAnywhere, isTrue);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isTrue);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
expect(p.uses, [KnownPlatforms.angular, KnownPlatforms.browser]);
});
Expand All @@ -114,7 +114,7 @@ void main() {
expect(p.worksAnywhere, isFalse);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
});

Expand All @@ -124,7 +124,7 @@ void main() {
expect(p.worksAnywhere, isFalse);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
});

Expand All @@ -134,7 +134,7 @@ void main() {
expect(p.worksAnywhere, isFalse);
expect(p.worksEverywhere, isFalse);
expect(p.worksInBrowser, isFalse);
expect(p.worksInConsole, isFalse);
expect(p.worksInStandalone, isFalse);
expect(p.worksInFlutter, isFalse);
expect(p.uses, [KnownPlatforms.flutter, KnownPlatforms.native]);
});
Expand All @@ -152,24 +152,24 @@ void main() {
PlatformInfo pa = sum.libraries['package:_example/a.dart'];
PlatformInfo pb = sum.libraries['package:_example/b.dart'];
expect(pa.worksInBrowser, isTrue);
expect(pa.worksInConsole, isFalse);
expect(pa.worksInStandalone, isFalse);
expect(pb.worksInBrowser, isFalse);
expect(pb.worksInConsole, isTrue);
expect(pb.worksInStandalone, isTrue);
});

test('detects flutter in pubspec', () {
PlatformSummary sum = classifyPlatforms(flutterPluginPubspec, {});
expect(sum.hasConflict, isFalse);
expect(sum.package.worksInFlutter, isTrue);
expect(sum.package.worksInConsole, isFalse);
expect(sum.package.worksInStandalone, isFalse);
expect(sum.package.worksInBrowser, isFalse);
});

test('detects flutter in dependencies', () {
PlatformSummary sum = classifyPlatforms(flutterSdkPubspec, {});
expect(sum.hasConflict, isFalse);
expect(sum.package.worksInFlutter, isTrue);
expect(sum.package.worksInConsole, isFalse);
expect(sum.package.worksInStandalone, isFalse);
expect(sum.package.worksInBrowser, isFalse);
});
});
Expand Down

0 comments on commit 6362206

Please sign in to comment.