示例#1
0
    def testShouldReturnArgumentWhenNothingToCompose(self):
        expected = 1

        composed = compose()
        actual = composed(expected)

        self.assertEqual(actual, expected)
示例#2
0
        def wrap(reducer, initial_state):
            store = other(reducer, initial_state)
            dispatch = store.dispatch
            api = {"dispatch": lambda action: dispatch(action),
                   "get_state": store.get_state}

            chain = map(lambda middleware: middleware(api), middlewares)
            dispatch = compose(*chain)(store.dispatch)

            store.dispatch = dispatch

            return store
示例#3
0
    def testShouldComposeFunctions(self):
        value = 1

        def func1(param):
            self.assertEqual(param, value)
            return param

        def func2(param):
            self.assertEqual(param, value)
            return param

        composed = compose(func1, func2)
        self.assertTrue(callable(composed))

        composed(value)