예제 #1
0
    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
    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
    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
 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
 def testSliceStart(self):
     s = StrObject(u"slice of lemon")
     result = s.call(u"slice", [IntObject(9)])
     self.assertEqual(result._s, u"lemon")
예제 #13
0
 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
 def testTrimSpaces(self):
     s = StrObject(u"    ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"")
예제 #17
0
 def testLastIndexOfFail(self):
     s = StrObject(u"needle")
     result = s.call(u"lastIndexOf", [StrObject(u"x")])
     self.assertEqual(result.getInt(), -1)
예제 #18
0
 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
 def testToLowerCaseUnicode(self):
     s = StrObject(u"Α And Ω")
     result = s.call(u"toLowerCase", [])
     self.assertEqual(result._s, u"α and ω")
예제 #21
0
 def testTrimWord(self):
     s = StrObject(u"  testing  ")
     result = s.call(u"trim", [])
     self.assertEqual(result._s, u"testing")
예제 #22
0
 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
 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
 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")