blob: bbc5800a135fc8c9a6e6e2b2116037ca02b34d83 [file] [log] [blame]
// Copyright (c) 2021, 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.
// Checks that _WindowsCodePageEncoder.convert() throws an exception on
// platforms other than Windows.
import "dart:io";
import 'dart:mirrors';
import "package:expect/expect.dart";
ClassMirror findWindowsCodePageEncoder() {
final dartIo =
currentMirrorSystem().libraries[Uri(scheme: "dart", path: "io")];
if (dartIo == null) {
throw StateError("dart:io not present");
final classes = dartIo.declarations.values
.where((d) =>
d is ClassMirror &&
.map((d) => d as ClassMirror)
1, classes.length, "Expected exactly one _WindowsCodePageEncoder");
return classes[0];
test() {
final winCodePageEncoder = findWindowsCodePageEncoder();
final encoder = winCodePageEncoder.newInstance(Symbol(""), List.empty());
try {
encoder.invoke(Symbol("convert"), List.of(["test"]));
"expected UnsupportedError on ${Platform.operatingSystem}");
} on UnsupportedError catch (e) {
Platform.isWindows, "unexpected UnsupportedError on Windows: $e");
void main() {