コード例 #1
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
    def testSplit(self):
        """
        Strings can be split.
        """

        s = StrObject(u"first second")
        result = s.call(u"split", [StrObject(u" ")])
        pieces = [obj._s for obj in unwrapList(result)]
        self.assertEqual(pieces, [u"first", u"second"])
コード例 #2
0
ファイル: test_data.py プロジェクト: washort/typhon
    def testContainsTrue(self):
        """
        String containment tests have true positives.
        """

        haystack = StrObject(u"needle in a haystack")
        needle = StrObject(u"needle")
        result = haystack.call(u"contains", [needle])
        self.assertTrue(result.isTrue())
コード例 #3
0
ファイル: test_data.py プロジェクト: washort/typhon
    def testSplit(self):
        """
        Strings can be split.
        """

        s = StrObject(u"first second")
        result = s.call(u"split", [StrObject(u" ")])
        pieces = [obj._s for obj in unwrapList(result)]
        self.assertEqual(pieces, [u"first", u"second"])
コード例 #4
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
    def testContainsTrue(self):
        """
        String containment tests have true positives.
        """

        haystack = StrObject(u"needle in a haystack")
        needle = StrObject(u"needle")
        result = haystack.call(u"contains", [needle])
        self.assertTrue(result.isTrue())
コード例 #5
0
ファイル: test_data.py プロジェクト: washort/typhon
    def testMakeIterator(self):
        """
        Strings are iterable.
        """

        s = StrObject(u"cs")
        iterator = s.call(u"_makeIterator", [])
        with Ejector() as ej:
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 0)
            self.assertEqual(objs[1]._c, u'c')
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 1)
            self.assertEqual(objs[1]._c, u's')
            self.assertRaises(Ejecting, iterator.call, u"next", [ej])
コード例 #6
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
    def testMakeIterator(self):
        """
        Strings are iterable.
        """

        s = StrObject(u"cs")
        iterator = s.call(u"_makeIterator", [])
        with Ejector() as ej:
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 0)
            self.assertEqual(objs[1]._c, u'c')
            result = iterator.call(u"next", [ej])
            objs = unwrapList(result)
            self.assertEqual(objs[0].getInt(), 1)
            self.assertEqual(objs[1]._c, u's')
            self.assertRaises(Ejecting, iterator.call, u"next", [ej])
コード例 #7
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testToUpperCase(self):
     s = StrObject(u"lower")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"LOWER")
コード例 #8
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testToLowerCaseUnicode(self):
     s = StrObject(u"Α And Ω")
     result = s.call(u"toLowerCase", [])
     self.assertEqual(result._s, u"α and ω")
コード例 #9
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testSliceStartStop(self):
     s = StrObject(u"the lime in the coconut")
     result = s.call(u"slice", [IntObject(4), IntObject(8)])
     self.assertEqual(result._s, u"lime")
コード例 #10
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testSliceStartStop(self):
     s = StrObject(u"the lime in the coconut")
     result = s.call(u"slice", [IntObject(4), IntObject(8)])
     self.assertEqual(result._s, u"lime")
コード例 #11
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testSliceStart(self):
     s = StrObject(u"slice of lemon")
     result = s.call(u"slice", [IntObject(9)])
     self.assertEqual(result._s, u"lemon")
コード例 #12
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testSliceStart(self):
     s = StrObject(u"slice of lemon")
     result = s.call(u"slice", [IntObject(9)])
     self.assertEqual(result._s, u"lemon")
コード例 #13
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testToUpperCaseUnicode(self):
     s = StrObject(u"¡Holá!")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"¡HOLÁ!")
コード例 #14
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testTrimSpaces(self):
     s = StrObject(u"    ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"")
コード例 #15
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testIndexOf(self):
     s = StrObject(u"needle")
     result = s.call(u"indexOf", [StrObject(u"e")])
     self.assertEqual(result.getInt(), 1)
コード例 #16
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testTrimSpaces(self):
     s = StrObject(u"    ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"")
コード例 #17
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testLastIndexOfFail(self):
     s = StrObject(u"needle")
     result = s.call(u"lastIndexOf", [StrObject(u"x")])
     self.assertEqual(result.getInt(), -1)
コード例 #18
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testIndexOf(self):
     s = StrObject(u"needle")
     result = s.call(u"indexOf", [StrObject(u"e")])
     self.assertEqual(result.getInt(), 1)
コード例 #19
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testToUpperCaseUnicode(self):
     s = StrObject(u"¡Holá!")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"¡HOLÁ!")
コード例 #20
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testToLowerCaseUnicode(self):
     s = StrObject(u"Α And Ω")
     result = s.call(u"toLowerCase", [])
     self.assertEqual(result._s, u"α and ω")
コード例 #21
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testTrimWord(self):
     s = StrObject(u"  testing  ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"testing")
コード例 #22
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testToUpperCase(self):
     s = StrObject(u"lower")
     result = s.call(u"toUpperCase", [])
     self.assertEqual(result._s, u"LOWER")
コード例 #23
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testLastIndexOfFail(self):
     s = StrObject(u"needle")
     result = s.call(u"lastIndexOf", [StrObject(u"x")])
     self.assertEqual(result.getInt(), -1)
コード例 #24
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testGet(self):
     s = StrObject(u"index")
     result = s.call(u"get", [IntObject(2)])
     self.assertEqual(result._c, u'd')
コード例 #25
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testTrimWord(self):
     s = StrObject(u"  testing  ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"testing")
コード例 #26
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testJoin(self):
     s = StrObject(u"|")
     result = s.call(
         u"join",
         [ConstList([StrObject(u"5"), StrObject(u"42")])])
     self.assertEqual(result._s, u"5|42")
コード例 #27
0
ファイル: test_data.py プロジェクト: washort/typhon
 def testGet(self):
     s = StrObject(u"index")
     result = s.call(u"get", [IntObject(2)])
     self.assertEqual(result._c, u'd')
コード例 #28
0
ファイル: test_data.py プロジェクト: markrwilliams/typhon
 def testJoin(self):
     s = StrObject(u"|")
     result = s.call(u"join",
             [ConstList([StrObject(u"5"), StrObject(u"42")])])
     self.assertEqual(result._s, u"5|42")