source: src/tests/ifcond.c @ 2472a19

new-envwith_gc
Last change on this file since 2472a19 was a01f7c94, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Implement multi-declaration if conditional and update test

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[a01f7c94]1//
[96ff407]2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
[377e33f]3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
[a01f7c94]6//
7// ifcond.c --
8//
[377e33f]9// Author           : Peter A. Buhr
10// Created On       : Sat Aug 26 10:13:11 2017
[a01f7c94]11// Last Modified By : Rob Schluntz
12// Last Modified On : Fri Sep 01 15:22:19 2017
13// Update Count     : 14
14//
[377e33f]15
[a01f7c94]16#include <fstream>
[377e33f]17
18int f( int r ) { return r; }
19
20int main( void ) {
21        int x = 4, y = 3;
22
23        if ( int x = 1 ) {
24                sout | "x != 0 correct" | endl;
25        } else {
26                sout | "x == 0 incorrect" | endl;
27        } // if
28
[a01f7c94]29        if ( int x = 4, y = 0 ) {
30                sout | "x != 0 && y != 0 incorrect" | endl;
31        } else if ( int x = 4, y = 1 ) {
[377e33f]32                sout | "x != 0 && y != 0 correct" | endl;
[a01f7c94]33        } else {
34                sout | "x == 0 || y == 0 incorrect" | endl;
[377e33f]35        } // if
36
37        if ( int x = 5, y = f( x ); x == y ) {
38                sout | "x == y correct" | endl;
39        } else {
40                sout | "x != y incorrect" | endl;
41        } // if
42} // main
43
44// Local Variables: //
45// tab-width: 4 //
46// compile-command: "cfa ifcond.c" //
47// End: //
Note: See TracBrowser for help on using the repository browser.