File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < cassert>
2+
3+ int main () {
4+ int x = 1 ;
5+ int y = (x = 2 , x + 1 );
6+ assert (x == 2 );
7+ assert (y == 3 );
8+
9+ int z = (1 , 2 , 3 );
10+ assert (z == 3 );
11+
12+ int counter = 0 ;
13+ int w = (counter++, counter++, counter);
14+ assert (counter == 2 );
15+ assert (w == 2 );
16+
17+ int a = 0 , b = 0 ;
18+ if ((a = 1 , b = 2 , a + b > 0 )) {
19+ assert (a == 1 );
20+ assert (b == 2 );
21+ }
22+
23+ return 0 ;
24+ }
Original file line number Diff line number Diff line change 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 main ( ) {
10+ std:: process:: exit ( main_0 ( ) ) ;
11+ }
12+ fn main_0 ( ) -> i32 {
13+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( 1 ) ) ;
14+ let y: Value < i32 > = Rc :: new ( RefCell :: new ( {
15+ ( * x. borrow_mut ( ) ) = 2 ;
16+ ( ( * x. borrow ( ) ) + 1 )
17+ } ) ) ;
18+ assert ! ( ( ( * x. borrow( ) ) == 2 ) ) ;
19+ assert ! ( ( ( * y. borrow( ) ) == 3 ) ) ;
20+ let z: Value < i32 > = Rc :: new ( RefCell :: new ( {
21+ 1 ;
22+ 2 ;
23+ 3
24+ } ) ) ;
25+ assert ! ( ( ( * z. borrow( ) ) == 3 ) ) ;
26+ let counter: Value < i32 > = Rc :: new ( RefCell :: new ( 0 ) ) ;
27+ let w: Value < i32 > = Rc :: new ( RefCell :: new ( {
28+ ( * counter. borrow_mut ( ) ) . postfix_inc ( ) ;
29+ ( * counter. borrow_mut ( ) ) . postfix_inc ( ) ;
30+ ( * counter. borrow ( ) )
31+ } ) ) ;
32+ assert ! ( ( ( * counter. borrow( ) ) == 2 ) ) ;
33+ assert ! ( ( ( * w. borrow( ) ) == 2 ) ) ;
34+ let a: Value < i32 > = Rc :: new ( RefCell :: new ( 0 ) ) ;
35+ let b: Value < i32 > = Rc :: new ( RefCell :: new ( 0 ) ) ;
36+ if {
37+ ( * a. borrow_mut ( ) ) = 1 ;
38+ ( * b. borrow_mut ( ) ) = 2 ;
39+ ( ( ( * a. borrow ( ) ) + ( * b. borrow ( ) ) ) > 0 )
40+ } {
41+ assert ! ( ( ( * a. borrow( ) ) == 1 ) ) ;
42+ assert ! ( ( ( * b. borrow( ) ) == 2 ) ) ;
43+ }
44+ return 0 ;
45+ }
Original file line number Diff line number Diff line change 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 fn main ( ) {
10+ unsafe {
11+ std:: process:: exit ( main_0 ( ) as i32 ) ;
12+ }
13+ }
14+ unsafe fn main_0 ( ) -> i32 {
15+ let mut x: i32 = 1 ;
16+ let mut y: i32 = {
17+ x = 2 ;
18+ ( ( x) + ( 1 ) )
19+ } ;
20+ assert ! ( ( ( x) == ( 2 ) ) ) ;
21+ assert ! ( ( ( y) == ( 3 ) ) ) ;
22+ let mut z: i32 = {
23+ 1 ;
24+ 2 ;
25+ 3
26+ } ;
27+ assert ! ( ( ( z) == ( 3 ) ) ) ;
28+ let mut counter: i32 = 0 ;
29+ let mut w: i32 = {
30+ counter. postfix_inc ( ) ;
31+ counter. postfix_inc ( ) ;
32+ counter
33+ } ;
34+ assert ! ( ( ( counter) == ( 2 ) ) ) ;
35+ assert ! ( ( ( w) == ( 2 ) ) ) ;
36+ let mut a: i32 = 0 ;
37+ let mut b: i32 = 0 ;
38+ if {
39+ a = 1 ;
40+ b = 2 ;
41+ ( ( ( a) + ( b) ) > ( 0 ) )
42+ } {
43+ assert ! ( ( ( a) == ( 1 ) ) ) ;
44+ assert ! ( ( ( b) == ( 2 ) ) ) ;
45+ }
46+ return 0 ;
47+ }
You can’t perform that action at this time.
0 commit comments