Files
sdk/tests/language/string/no_operator_test.dart
Johnni Winther b8b072ed3b [cfe] Update message for undefined access
This updates the message text for undefined access. Instead of saying
that the member is not defined on the "class", it now says on the "type".

Closes #60290

Change-Id: I9387f892e99ba109b9b1d99af25714ab83b5350c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433941
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-17 04:03:26 -07:00

75 lines
3.1 KiB
Dart

// Copyright (c) 2015, 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:expect/expect.dart';
main() {
var x = "x";
var y = "y";
Expect.throws(() => x < y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '<' isn't defined for the type 'String'.
Expect.throws(() => x <= y);
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '<=' isn't defined for the type 'String'.
Expect.throws(() => x > y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '>' isn't defined for the type 'String'.
Expect.throws(() => x >= y);
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '>=' isn't defined for the type 'String'.
Expect.throws(() => x - y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '-' isn't defined for the type 'String'.
Expect.throws(() => x * y);
// ^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
Expect.throws(() => x / y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '/' isn't defined for the type 'String'.
Expect.throws(() => x ~/ y);
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '~/' isn't defined for the type 'String'.
Expect.throws(() => x % y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '%' isn't defined for the type 'String'.
Expect.throws(() => x >> y);
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '>>' isn't defined for the type 'String'.
Expect.throws(() => x << y);
// ^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '<<' isn't defined for the type 'String'.
Expect.throws(() => x & y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '&' isn't defined for the type 'String'.
Expect.throws(() => x | y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '|' isn't defined for the type 'String'.
Expect.throws(() => x ^ y);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '^' isn't defined for the type 'String'.
Expect.throws(() => -x);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator 'unary-' isn't defined for the type 'String'.
Expect.throws(() => ~x);
// ^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
// [cfe] The operator '~' isn't defined for the type 'String'.
}