Files
mercury/tests/valid/switch_detection_bug.m
Zoltan Somogyi c03b11ca48 Update the style of more test cases.
And updated expected outputs for changed line numbers.
2021-07-27 19:29:21 +10:00

63 lines
2.0 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% This is a regression test for a bug in switch detection
% where it was preferring incomplete switches to complete
% one-case switches, and hence inferring the wrong determinism.
%---------------------------------------------------------------------------%
:- module switch_detection_bug.
:- interface.
:- type note
---> note(rank, modifier, octave).
:- type rank
---> c
; d
; e
; f
; g
; a
; b.
:- type modifier
---> natural
; sharp
; flat.
:- type octave == int.
:- type qualifier
---> maj
; min.
:- pred next_topnote(note::in, qualifier::in, note::out) is multi.
%---------------------------------------------------------------------------%
:- implementation.
next_topnote(note(c, _, Oct), _, note(d, natural, Oct)).
next_topnote(note(d, _, Oct), _, note(c, natural, Oct)).
next_topnote(note(d, _, Oct), maj, note(e, natural, Oct)).
next_topnote(note(d, _, Oct), min, note(e, flat, Oct)).
next_topnote(note(e, _, Oct), _, note(d, natural, Oct)).
next_topnote(note(e, _, Oct), _, note(f, natural, Oct)).
next_topnote(note(f, _, Oct), maj, note(e, natural, Oct)).
next_topnote(note(f, _, Oct), min, note(e, flat, Oct)).
next_topnote(note(g, _, Oct), _, note(f, natural, Oct)).
next_topnote(note(g, _, Oct), min, note(a, flat, Oct)).
next_topnote(note(g, _, Oct), maj, note(a, natural, Oct)).
next_topnote(note(a, _, Oct), _, note(g, natural, Oct)).
next_topnote(note(a, _, Oct), min, note(b, flat, Oct)).
next_topnote(note(a, _, Oct), maj, note(b, natural, Oct)).
next_topnote(note(b, _, Oct), maj, note(a, natural, Oct)).
next_topnote(note(b, _, Oct), min, note(a, flat, Oct)).
%---------------------------------------------------------------------------%