source:
tests/ifwhileCtl.cfa
@
1b64344
Last change on this file since 1b64344 was 200fcb3, checked in by , 6 years ago | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[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 | // |
[dc8511c] | 7 | // ifwhileCtl.cfa -- |
[a01f7c94] | 8 | // |
[377e33f] | 9 | // Author : Peter A. Buhr |
10 | // Created On : Sat Aug 26 10:13:11 2017 | |
[d56cc219] | 11 | // Last Modified By : Peter A. Buhr |
[200fcb3] | 12 | // Last Modified On : Tue Dec 4 21:39:18 2018 |
13 | // Update Count : 23 | |
[a01f7c94] | 14 | // |
[377e33f] | 15 | |
[73abe95] | 16 | #include <fstream.hfa> |
[377e33f] | 17 | |
18 | int f( int r ) { return r; } | |
19 | ||
20 | int main( void ) { | |
21 | int x = 4, y = 3; | |
22 | ||
23 | if ( int x = 1 ) { | |
[200fcb3] | 24 | sout | "x != 0 correct"; |
[377e33f] | 25 | } else { |
[200fcb3] | 26 | sout | "x == 0 incorrect"; |
[377e33f] | 27 | } // if |
28 | ||
[a01f7c94] | 29 | if ( int x = 4, y = 0 ) { |
[200fcb3] | 30 | sout | "x != 0 && y != 0 incorrect"; |
[a01f7c94] | 31 | } else if ( int x = 4, y = 1 ) { |
[200fcb3] | 32 | sout | "x != 0 && y != 0 correct"; |
[a01f7c94] | 33 | } else { |
[200fcb3] | 34 | sout | "x == 0 || y == 0 incorrect"; |
[377e33f] | 35 | } // if |
36 | ||
37 | if ( int x = 5, y = f( x ); x == y ) { | |
[200fcb3] | 38 | sout | "x == y correct"; |
[377e33f] | 39 | } else { |
[200fcb3] | 40 | sout | "x != y incorrect"; |
[377e33f] | 41 | } // if |
[d56cc219] | 42 | |
43 | if ( struct S { int i; } s = { 3 }; s.i < 4 ) { | |
[401e61f] | 44 | S s1; |
[200fcb3] | 45 | sout | "s.i < 4 correct"; |
[d56cc219] | 46 | } else { |
[401e61f] | 47 | S s1; |
[200fcb3] | 48 | sout | "s.i >= 4 incorrect"; |
[d56cc219] | 49 | } // if |
[401e61f] | 50 | |
51 | while ( int x = 1 ) { | |
[200fcb3] | 52 | sout | "x != 0 correct"; |
[401e61f] | 53 | break; |
54 | } // while | |
55 | ||
56 | while ( int x = 4, y = 0 ) { | |
[200fcb3] | 57 | sout | "x != 0 && y != 0 incorrect"; |
[401e61f] | 58 | } // while |
59 | ||
60 | while ( int x = 5, y = f( x ); x == y ) { | |
[200fcb3] | 61 | sout | "x == y correct"; |
[401e61f] | 62 | break; |
63 | } // while | |
64 | ||
65 | while ( struct S { int i; } s = { 3 }; s.i < 4 ) { | |
66 | S s1; | |
[200fcb3] | 67 | sout | "s.i < 4 correct"; |
[401e61f] | 68 | break; |
69 | } // while | |
[377e33f] | 70 | } // main |
71 | ||
72 | // Local Variables: // | |
73 | // tab-width: 4 // | |
[dc8511c] | 74 | // compile-command: "cfa ifwhileCtl.cfa" // |
[377e33f] | 75 | // End: // |
Note: See TracBrowser
for help on using the repository browser.