-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
202 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "BoolTest.h" | ||
|
||
interface BoolDone { | ||
event void unaryDone(bool result, bool arg); | ||
event void binaryDone(bool result, bool_test_args args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
#include "BoolTest.h" | ||
|
||
generic module BoolDoneM(const char testName[]) { | ||
uses interface BoolDone; | ||
} | ||
implementation { | ||
event void BoolDone.unaryDone(bool result, bool arg) { | ||
printf("%10s: %d -> %d\n", testName, arg, result); | ||
} | ||
|
||
event void BoolDone.binaryDone(bool result, bool_test_args args) { | ||
printf("%10s: %d, %d -> %d\n", testName, args.a, args.b, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __BOOL_TEST_H__ | ||
#define __BOOL_TEST_H__ | ||
|
||
#include <stdbool.h> | ||
|
||
typedef struct { | ||
bool a:1; | ||
bool b; | ||
} bool_test_args; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "BoolTest.h" | ||
|
||
interface BoolTest { | ||
command void unary(const bool a); | ||
command void binary(const bool_test_args args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "BoolTest.h" | ||
|
||
generic module BoolTestM(bool val) { | ||
provides interface BoolTest; | ||
provides interface BoolDone; | ||
} | ||
implementation { | ||
command void BoolTest.unary(const bool a) { | ||
const bool result = val ? a : !a; | ||
signal BoolDone.unaryDone(result, a); | ||
} | ||
|
||
command void BoolTest.binary(const bool_test_args args) { | ||
const bool result = val ? args.a ^ args.b | ||
: !(args.a ^ args.b); | ||
signal BoolDone.binaryDone(result, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
#include "BoolTest.h" | ||
|
||
module TestP { | ||
uses interface BoolTest; | ||
} | ||
implementation { | ||
int main() @C() @spontaneous() { | ||
bool_test_args args; | ||
|
||
call BoolTest.unary(false); | ||
call BoolTest.unary(true); | ||
args.a = args.b = false; | ||
call BoolTest.binary(args); | ||
args.b = true; | ||
call BoolTest.binary(args); | ||
args.a = true; args.b = false; | ||
call BoolTest.binary(args); | ||
args.a = args.b = true; | ||
call BoolTest.binary(args); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "BoolTest.h" | ||
|
||
#include <stddef.h> | ||
|
||
configuration test { | ||
} | ||
implementation { | ||
components TestP; | ||
#define define_test(test_name, bool_expr) \ | ||
components new BoolTestM(bool_expr) as Test##test_name; \ | ||
components new BoolDoneM(#test_name) as Done##test_name; \ | ||
Test##test_name <- TestP.BoolTest; \ | ||
Test##test_name <- Done##test_name.BoolDone | ||
|
||
define_test(True, 1 == 1 && 0 < 1); | ||
define_test(False, 0 == 1 || 0 > 1); | ||
define_test(Null, NULL); | ||
define_test(IntTrue, 1234); | ||
define_test(IntZero, 0); | ||
define_test(FloatTrue, 1.23); | ||
define_test(FloatZero, 0.0); | ||
|
||
#undef define_test | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
True: 0 -> 0 | ||
False: 0 -> 1 | ||
Null: 0 -> 1 | ||
IntTrue: 0 -> 0 | ||
IntZero: 0 -> 1 | ||
FloatTrue: 0 -> 0 | ||
FloatZero: 0 -> 1 | ||
True: 1 -> 1 | ||
False: 1 -> 0 | ||
Null: 1 -> 0 | ||
IntTrue: 1 -> 1 | ||
IntZero: 1 -> 0 | ||
FloatTrue: 1 -> 1 | ||
FloatZero: 1 -> 0 | ||
True: 0, 0 -> 0 | ||
False: 0, 0 -> 1 | ||
Null: 0, 0 -> 1 | ||
IntTrue: 0, 0 -> 0 | ||
IntZero: 0, 0 -> 1 | ||
FloatTrue: 0, 0 -> 0 | ||
FloatZero: 0, 0 -> 1 | ||
True: 0, 1 -> 1 | ||
False: 0, 1 -> 0 | ||
Null: 0, 1 -> 0 | ||
IntTrue: 0, 1 -> 1 | ||
IntZero: 0, 1 -> 0 | ||
FloatTrue: 0, 1 -> 1 | ||
FloatZero: 0, 1 -> 0 | ||
True: 1, 0 -> 1 | ||
False: 1, 0 -> 0 | ||
Null: 1, 0 -> 0 | ||
IntTrue: 1, 0 -> 1 | ||
IntZero: 1, 0 -> 0 | ||
FloatTrue: 1, 0 -> 1 | ||
FloatZero: 1, 0 -> 0 | ||
True: 1, 1 -> 0 | ||
False: 1, 1 -> 1 | ||
Null: 1, 1 -> 1 | ||
IntTrue: 1, 1 -> 0 | ||
IntZero: 1, 1 -> 1 | ||
FloatTrue: 1, 1 -> 0 | ||
FloatZero: 1, 1 -> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
In component `test': | ||
test.nc:17: warning: passing argument 1 of `TestNull' makes integer from pointer without a cast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ enum rid | |
RID_LONG, | ||
RID_SIGNED, | ||
RID_COMPLEX, | ||
RID_BOOL, | ||
RID_LASTTYPE, | ||
|
||
RID_INLINE = RID_LASTTYPE, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.