]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/const-int-overflowing.rs
const-int-overflowing.rs += overflowing_neg
[rust.git] / src / test / run-pass / const-int-overflowing.rs
index 0f8f230f456bd32c824d7a3ed310616447f8a795..e8fd022e6829633ecf1c6a970d282778c89f9a74 100644 (file)
@@ -1,15 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(const_int_overflowing)]
-
 const ADD_A: (u32, bool) = 5u32.overflowing_add(2);
 const ADD_B: (u32, bool) = u32::max_value().overflowing_add(1);
 
@@ -25,6 +13,9 @@
 const SHR_A: (u32, bool) = 0x10u32.overflowing_shr(4);
 const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132);
 
+const NEG_A: (u32, bool) = 0.overflowing_neg();
+const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg();
+
 fn ident<T>(ident: T) -> T {
     ident
 }
@@ -44,4 +35,7 @@ fn main() {
 
     assert_eq!(SHR_A, ident((0x1, false)));
     assert_eq!(SHR_B, ident((0x1, true)));
+
+    assert_eq!(NEG_A, ident((0, false)));
+    assert_eq!(NEG_B, ident((1, true)));
 }