Files
mercury/tests/hard_coded/foreign_enum_mod2.m
Julien Fischer da10e4fb95 Don't run foreign_enum tests in the Java grade.
tests/hard_coded/Mmakefile:
     Foreign enums are only currently supported by the C and C# grades.
     Don't run tests for them in the Java grade.

tests/hard_coded/foreign_enum_mod2.m:
     Comment out a foreign_enum pragma for Java.
2016-02-09 10:47:09 +11:00

75 lines
1.5 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module foreign_enum_mod2.
:- interface.
:- type instrument.
:- type ingredient
---> eggs
; sugar
; flour
; milk.
:- func my_instrument = instrument.
:- implementation.
:- type instrument
---> violin
; piano
; xylophone.
:- type foo
---> foo
; bar
; baz.
my_instrument = piano.
% This should end up in the .int file.
%
:- pragma foreign_enum("C", ingredient/0, [
foreign_enum_mod2.eggs - "EGGS",
foreign_enum_mod2.sugar - "SUGAR",
foreign_enum_mod2.flour - "FLOUR",
foreign_enum_mod2.milk - "MILK"
]).
% As should this.
% XXX not currently supported in Java grade.
%:- pragma foreign_enum("Java", ingredient/0, [
% eggs - "Ingredient.EGGS",
% sugar - "Ingredient.SUGAR",
% flour - "Ingredient.FLOUR",
% milk - "Ingredient.MILK"
%]).
% This shouldn't since the type is not exported.
%
:- pragma foreign_enum("C", foo/0, [
foo - "3",
bar - "4",
baz - "5"
]).
% This shouldn't since the type is abstract.
%
:- pragma foreign_enum("C", instrument/0, [
violin - "100",
piano - "200",
xylophone - "300"
]).
:- pragma foreign_decl("C", "
#define EGGS 10
#define SUGAR 20
#define FLOUR 30
#define MILK 40
").