Skip to content

Commit

Permalink
update enumconst test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j authored and PMunch committed Jan 20, 2023
1 parent 0c909d5 commit ff64a92
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/tenumconst.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ enum {
ANON_B,
ANON_C = -1
};

enum {
ANON_D = 0,

// this is ignored now
ANON_E = 'E'
};

#include <limits.h>

typedef enum {
SHORT = SHRT_MAX
} enum_short;

typedef enum {
WORD = INT_MAX
} enum_word;

// does not not work
// typedef enum {
// LONG = LONG_MAX
// } enum_long;
9 changes: 9 additions & 0 deletions tests/tenumconst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "../src/futhark"

importc:
path "."
compilerArg "-fshort-enums"
"tenumconst.h"


Expand All @@ -18,3 +19,11 @@ doAssert MY_VAR_E == MY_VAR_A
doAssert ANON_A == 0
doAssert ANON_B == 1
doAssert ANON_C == -1

doAssert sizeof(ANON_D) == 1

doAssert sizeof(SHORT) == 2
doAssert SHORT.ord == 0x7fff

doAssert sizeof(WORD) == 4
doAssert WORD.ord == 0x7fffffff

0 comments on commit ff64a92

Please sign in to comment.