from fpy.data.maybe import Just, Nothing

from fpy.experimental.case import case

import unittest

class TestCase(unittest.TestCase):
    def testConstPat(self):
        @case
        def test(x):
            a = case(x)(
            { 1: 1,
              2: 2 })
            return a

        self.assertEqual(1, test(1))
        self.assertEqual(2, test(2))

    def testTypedPat(self):
        @case
        def test(x, d):
            a = case(x, d)({
                (Just(_x),) : _x,
                (Nothing(),): d
            })
            return a
        self.assertEqual(1, test(Just(1), 0))
        self.assertEqual(0, test(Nothing(), 0))
