Skip to content

Commit d8ded4f

Browse files
committed
Update tests
1 parent 24e8901 commit d8ded4f

4 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
extern crate libcc2rs;
2+
use libcc2rs::*;
3+
use std::cell::RefCell;
4+
use std::collections::BTreeMap;
5+
use std::io::prelude::*;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::AsFd;
8+
use std::rc::{Rc, Weak};
9+
pub fn pick_0() -> i32 {
10+
return if false { 1 } else { 2 };
11+
}
12+
pub fn test_1() {
13+
let mut compile_time: bool = true;
14+
assert!(compile_time);
15+
let mut run_time: bool = false;
16+
assert!(!(run_time));
17+
assert!((({ pick_0() }) == 2));
18+
}
19+
pub fn main() {
20+
__cpp2rust_init_globals();
21+
std::process::exit(main_0());
22+
}
23+
fn main_0() -> i32 {
24+
({ test_1() });
25+
return 0;
26+
}
27+
pub fn __cpp2rust_init_globals() {}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extern crate libc;
2+
use libc::*;
3+
extern crate libcc2rs;
4+
use libcc2rs::*;
5+
use std::collections::BTreeMap;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
8+
use std::rc::Rc;
9+
pub unsafe fn pick_0() -> i32 {
10+
return if false { 1 } else { 2 };
11+
}
12+
pub unsafe fn test_1() {
13+
let compile_time: bool = true;
14+
assert!(compile_time);
15+
let mut run_time: bool = false;
16+
assert!(!(run_time));
17+
assert!(((unsafe { pick_0() }) == (2)));
18+
}
19+
pub fn main() {
20+
unsafe {
21+
__cpp2rust_init_globals();
22+
std::process::exit(main_0() as i32);
23+
}
24+
}
25+
unsafe fn main_0() -> i32 {
26+
(unsafe { test_1() });
27+
return 0;
28+
}
29+
pub unsafe fn __cpp2rust_init_globals() {}

‎tests/unit/out/refcount/constexpr_function.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ pub fn in_constant_context_6() -> bool {
4141
return (({ runtime_only_0(1) }) == 0);
4242
}
4343
const _: () = assert!(true, "in_constant_context()");
44+
pub fn imm_7(mut b: bool) -> bool {
45+
return b;
46+
}
4447
#[derive(Copy, Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)]
4548
#[byte_size(4)]
4649
pub struct P {
@@ -72,8 +75,20 @@ fn main_0() -> i32 {
7275
assert!((({ PImpl::get(&p.as_pointer(),) }) == 9));
7376
let mut k: i32 = ({ scaled_2(4) });
7477
assert!((k == 4));
78+
let mut ce: bool = true;
79+
assert!(ce);
80+
let mut n: i32 = if true { 13 } else { 17 };
81+
assert!((n == 13));
82+
assert!(s_8.with(|rc| *rc.borrow()));
83+
let mut rt: bool = false;
84+
assert!(!(rt));
85+
let mut b: bool = ({ imm_7(true) });
86+
assert!(b);
7587
return 0;
7688
}
89+
thread_local!(
90+
static s_8: Value<bool> = Rc::new(RefCell::new(true));
91+
);
7792
pub trait FlagImpl {
7893
fn to_bool(&self) -> bool;
7994
}

‎tests/unit/out/unsafe/constexpr_function.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ pub unsafe fn in_constant_context_6() -> bool {
4444
return ((unsafe { runtime_only_0(1) }) == (0));
4545
}
4646
const _: () = assert!(true, "in_constant_context()");
47+
pub unsafe fn imm_7(mut b: bool) -> bool {
48+
return b;
49+
}
4750
#[repr(C)]
4851
#[derive(Copy, Clone, VaArg, FnPtrArg, Default)]
4952
pub struct P {
@@ -81,6 +84,16 @@ unsafe fn main_0() -> i32 {
8184
assert!(((unsafe { P::get(&p,) }) == (9)));
8285
let k: i32 = (unsafe { scaled_2(4) });
8386
assert!(((k) == (4)));
87+
let ce: bool = true;
88+
assert!(ce);
89+
let n: i32 = if true { 13 } else { 17 };
90+
assert!(((n) == (13)));
91+
assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut s_8)));
92+
let mut rt: bool = false;
93+
assert!(!(rt));
94+
let mut b: bool = (unsafe { imm_7(true) });
95+
assert!(b);
8496
return 0;
8597
}
98+
static mut s_8: std::cell::LazyCell<bool> = std::cell::LazyCell::new(|| unsafe { true });
8699
pub unsafe fn __cpp2rust_init_globals() {}

0 commit comments

Comments
 (0)