@@ -0,0 +1,1060 @@
+import unittest%0A%0Aimport numpy%0A%0Aimport chainer%0Afrom chainer import backend%0Afrom chainer.backends import cuda%0Afrom chainer.backends import intel64%0Afrom chainer import testing%0Afrom chainer.testing import attr%0A%0A%0Aclass MockDistribution(object):%0A%0A    def __init__(self, x):%0A        self.x = x%0A        self.h_call_count = 0%0A        self.y_call_count = 0%0A%0A    @chainer.distribution.cached_property%0A    def h(self):%0A        self.h_call_count += 1%0A        return self.x * 2%0A%0A    @chainer.distribution.cached_property%0A    def y(self):%0A        self.y_call_count += 1%0A        return self.h * 3%0A%0A%0Aclass TestCachedProperty(unittest.TestCase):%0A%0A    def test1(self):%0A        obj = MockDistribution(chainer.Variable(numpy.array(%5B1.%5D)))%0A        obj.h%0A        obj.h%0A        obj.h%0A        assert obj.h_call_count == 1%0A%0A    def test2(self):%0A        obj = MockDistribution(chainer.Variable(numpy.array(%5B1.%5D)))%0A        with chainer.no_backprop_mode():%0A            obj.h%0A            obj.h%0A            obj.h%0A        assert obj.h_call_count == 1%0A%0A%0Atesting.run_module(__name__, __file__)%0A

Add test