blob: 37a59f2a1c99244dee311681e47b3bd2fe806a8b [file] [log] [blame]
// Copyright (c) 2020, 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.
// test w/ `dart test -N use_is_even_rather_than_modulo`
// ignore_for_file: unused_local_variable
void f() {
bool isEven = 1 % 2 == 0; //LINT
bool isOdd = 13 % 2 == 1; //LINT
int number = 3;
bool c = number % 2 == 0; //LINT
// Not equality operator is okay
bool a = 1 % 2 >= 0;
bool d = number % 2 != 0;
// Modulo by any other number than 2 is okay
d = number % 3 == 1;
// Not modulo operation is okay.
d = number + 2 == 0;
// Compare to not an IntegerLiteral is okay.
bool b = 1 % 2 == 3 - 3;
a = 1.isEven;
a = 2.isOdd;
}