blob: 88d5bc0212563b552ef4324b275d0805f1e14847 [file] [log] [blame]
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. 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:analyzer/file_system/file_system.dart';
/// Helper for creating mock packages.
class MockPackages {
/// Create a fake 'js' package that can be used by tests.
static void addJsPackageFiles(Folder rootFolder) {
var libFolder = rootFolder.getChildAssumingFolder('lib');
libFolder.getChildAssumingFile('js.dart').writeAsStringSync(r'''
library js;
class JS {
const JS([String js]);
}
''');
}
/// Create a fake 'meta' package that can be used by tests.
static void addMetaPackageFiles(Folder rootFolder) {
var libFolder = rootFolder.getChildAssumingFolder('lib');
libFolder.getChildAssumingFile('meta.dart').writeAsStringSync(r'''
library meta;
const _AlwaysThrows alwaysThrows = const _AlwaysThrows();
const _DoNotStore doNotStore = _DoNotStore();
const _Factory factory = const _Factory();
const Immutable immutable = const Immutable();
const _Literal literal = const _Literal();
const _MustCallSuper mustCallSuper = const _MustCallSuper();
const _NonVirtual nonVirtual = const _NonVirtual();
const _OptionalTypeArgs optionalTypeArgs = const _OptionalTypeArgs();
const _Protected protected = const _Protected();
const Required required = const Required();
const _Sealed sealed = const _Sealed();
const _VisibleForTesting visibleForTesting = const _VisibleForTesting();
class _AlwaysThrows {
const _AlwaysThrows();
}
class _DoNotStore {
const _DoNotStore();
}
class _Factory {
const _Factory();
}
class Immutable {
final String reason;
const Immutable([this.reason]);
}
class _Literal {
const _Literal();
}
class _MustCallSuper {
const _MustCallSuper();
}
class _NonVirtual {
const _NonVirtual();
}
class _OptionalTypeArgs {
const _OptionalTypeArgs();
}
class _Protected {
const _Protected();
}
class Required {
final String reason;
const Required([this.reason]);
}
class _Sealed {
const _Sealed();
}
class _VisibleForTesting {
const _VisibleForTesting();
}
''');
}
}