Skip to content

Commit

Permalink
Deduplicate and fix a test
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 3, 2018
1 parent 9d613c2 commit eb31ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 48 deletions.
45 changes: 0 additions & 45 deletions src/test/run-pass/ctfe/union-ice.rs

This file was deleted.

14 changes: 11 additions & 3 deletions src/test/run-pass/union/union-const-eval-field.rs
Expand Up @@ -10,7 +10,7 @@

#![feature(const_fn)]

type Field1 = i32;
type Field1 = (i32, u32);
type Field2 = f32;
type Field3 = i64;

Expand All @@ -21,7 +21,7 @@ union DummyUnion {
}

const FLOAT1_AS_I32: i32 = 1065353216;
const UNION: DummyUnion = DummyUnion { field1: FLOAT1_AS_I32 };
const UNION: DummyUnion = DummyUnion { field1: (FLOAT1_AS_I32, 0) };

const fn read_field1() -> Field1 {
const FIELD1: Field1 = unsafe { UNION.field1 };
Expand All @@ -39,7 +39,15 @@ const fn read_field3() -> Field3 {
}

fn main() {
assert_eq!(read_field1(), FLOAT1_AS_I32);
let foo = FLOAT1_AS_I32;
assert_eq!(read_field1().0, foo);
assert_eq!(read_field1().0, FLOAT1_AS_I32);

let foo = 1.0;
assert_eq!(read_field2(), foo);
assert_eq!(read_field2(), 1.0);

assert_eq!(read_field3(), unsafe { UNION.field3 });
let foo = unsafe { UNION.field3 };
assert_eq!(read_field3(), foo);
}

0 comments on commit eb31ae2

Please sign in to comment.