Skip to main content

module lang::flybytes::tests::SwitchTests

rascal-0.40.17
flybytes-0.2.8

Usage

import lang::flybytes::tests::SwitchTests;

Source code

http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/tests/SwitchTests.rsc

Dependencies

import lang::flybytes::Syntax;
import lang::flybytes::Compiler;
import Node;

function switchClass

Class switchClass(SwitchOption option)

function testSwitchClass

bool testSwitchClass(Class c, int input, int result)

function switchDefaultClass

Class switchDefaultClass(SwitchOption option)

function switchCompactClass

Class switchCompactClass(SwitchOption option)

Tests

test simpleSwitch1table

test bool simpleSwitch1table() = testSwitchClass(switchClass(table()), 42, 42);

test simpleSwitch2table

test bool simpleSwitch2table() = testSwitchClass(switchClass(table()), 12, 12);

test simpleSwitch3table

test bool simpleSwitch3table() = testSwitchClass(switchClass(table()), 18, 0);

test simpleSwitch1lookup

test bool simpleSwitch1lookup() = testSwitchClass(switchClass(lookup()), 42, 42);

test simpleSwitch2lookup

test bool simpleSwitch2lookup() = testSwitchClass(switchClass(lookup()), 12, 12);

test simpleSwitch3lookup

test bool simpleSwitch3lookup() = testSwitchClass(switchClass(lookup()), 18, 0);

test simpleSwitch1auto

test bool simpleSwitch1auto() = testSwitchClass(switchClass(auto()), 42, 42);

test simpleSwitch2auto

test bool simpleSwitch2auto() = testSwitchClass(switchClass(auto()), 12, 12);

test simpleSwitch3auto

test bool simpleSwitch3auto() = testSwitchClass(switchClass(auto()), 18, 0);

test simpleDefaultSwitch1Table

test bool simpleDefaultSwitch1Table() = testSwitchClass(switchDefaultClass(table()), 42, 42);

test simpleDefaultSwitch2Table

test bool simpleDefaultSwitch2Table() = testSwitchClass(switchDefaultClass(table()), 12, 12);

test simpleDefaultSwitch3Table

test bool simpleDefaultSwitch3Table() = testSwitchClass(switchDefaultClass(table()), 0, -1);

test simpleDefaultSwitch1Lookup

test bool simpleDefaultSwitch1Lookup() = testSwitchClass(switchDefaultClass(lookup()), 42, 42);

test simpleDefaultSwitch2Lookup

test bool simpleDefaultSwitch2Lookup() = testSwitchClass(switchDefaultClass(lookup()), 12, 12);

test simpleDefaultSwitch3Lookup

test bool simpleDefaultSwitch3Lookup() = testSwitchClass(switchDefaultClass(lookup()), 0, -1);

test simpleDefaultSwitch1Auto

test bool simpleDefaultSwitch1Auto() = testSwitchClass(switchDefaultClass(auto()), 42, 42);

test simpleDefaultSwitch2Auto

test bool simpleDefaultSwitch2Auto() = testSwitchClass(switchDefaultClass(auto()), 12, 12);

test simpleDefaultSwitch3Auto

test bool simpleDefaultSwitch3Auto() = testSwitchClass(switchDefaultClass(auto()), 0, -1);

test compactDefaultSwitch1Table

test bool compactDefaultSwitch1Table() = testSwitchClass(switchCompactClass(table()), 0, 0);

test compactDefaultSwitch2Table

test bool compactDefaultSwitch2Table() = testSwitchClass(switchCompactClass(table()), 1, 1);

test compactDefaultSwitch3Table

test bool compactDefaultSwitch3Table() = testSwitchClass(switchCompactClass(table()), 2, 2);

test compactDefaultSwitch4Table

test bool compactDefaultSwitch4Table() = testSwitchClass(switchCompactClass(table()), 6, 5);

test compactDefaultSwitch1Lookup

test bool compactDefaultSwitch1Lookup() = testSwitchClass(switchCompactClass(lookup()),  0, 0);

test compactDefaultSwitch2Lookup

test bool compactDefaultSwitch2Lookup() = testSwitchClass(switchCompactClass(lookup()),  1, 1);

test compactDefaultSwitch3Lookup

test bool compactDefaultSwitch3Lookup() = testSwitchClass(switchCompactClass(lookup()),  2, 2);

test compactDefaultSwitch4Lookup

test bool compactDefaultSwitch4Lookup() = testSwitchClass(switchCompactClass(lookup()),  6, 5);

test compactDefaultSwitch1Auto

test bool compactDefaultSwitch1Auto() = testSwitchClass(switchCompactClass(auto()), 0, 0);

test compactDefaultSwitch2Auto

test bool compactDefaultSwitch2Auto() = testSwitchClass(switchCompactClass(auto()), 1, 1);

test compactDefaultSwitch3Auto

test bool compactDefaultSwitch3Auto() = testSwitchClass(switchCompactClass(auto()), 2, 2);

test compactDefaultSwitch4Auto

test bool compactDefaultSwitch4Auto() = testSwitchClass(switchCompactClass(auto()), 6, 5);