Пример #1
0
    def test_19explicit(self):
        # null
        xval = value.null()
        self.assertTrue(xval.is_null())
        self.assertFalse(xval)

        # #symbol
        xval = value.symbol('hello')
        self.assertTrue(xval.is_symbol())
        self.assertTrue(xval.is_string(
        ))  # string is a generic type for error, symbol and string itself
        self.assertEqual(xval.get_value(), 'hello')

        # secure string
        xval = value.secure_string('secure')
        self.assertTrue(xval.is_string())
        self.assertEqual(xval.get_type(with_unit=True),
                         (VALUE_TYPE.T_STRING,
                          2))  # VALUE_UNIT_TYPE_STRING.UT_STRING_SECURE
        self.assertEqual(xval.get_value(), 'secure')

        # error
        xval = value(TypeError('error'))
        self.assertTrue(xval.is_error_string())
        self.assertEqual(xval.get_value(), 'error')  # doesn't raise exception.

        pass
Пример #2
0
    def test_19explicit(self):
        # null
        xval = value.null()
        self.assertTrue(xval.is_null())
        self.assertFalse(xval)

        # #symbol
        xval = value.symbol('hello')
        self.assertTrue(xval.is_symbol())
        self.assertTrue(xval.is_string())   # string is a generic type for error, symbol and string itself
        self.assertEqual(xval.get_value(), 'hello')

        # secure string
        xval = value.secure_string('secure')
        self.assertTrue(xval.is_string())
        self.assertEqual(xval.get_type(with_unit=True), (VALUE_TYPE.T_STRING, 2))  # VALUE_UNIT_TYPE_STRING.UT_STRING_SECURE
        self.assertEqual(xval.get_value(), 'secure')

        # error
        xval = value(TypeError('error'))
        self.assertTrue(xval.is_error_string())
        self.assertEqual(xval.get_value(), 'error')  # doesn't raise exception.

        if sciter.version_num() > 0x04000100:
            # color
            xval = value.color(0x0000FFFF)      # yellow R255, G255, B000 in 0xAABBGGRR form
            self.assertTrue(xval.is_color())
            self.assertEqual(xval.get_value(), 0x0000FFFF)

            # duration
            xval = value.duration(12.5)
            self.assertTrue(xval.is_duration())
            self.assertEqual(xval.get_value(), 12.5)

            # angle
            xval = value.angle(1.0)
            self.assertTrue(xval.is_angle())
            self.assertEqual(xval.get_value(), 1.0)
            pass
        pass
Пример #3
0
    def test_20clear(self):
        xval = value()
        self.assertTrue(xval.is_undefined())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value.null()
        self.assertTrue(xval.is_null())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value.symbol('hello')
        self.assertTrue(xval.is_symbol())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value(17)
        self.assertTrue(xval.is_int())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        pass
Пример #4
0
    def test_20clear(self):
        xval = value()
        self.assertTrue(xval.is_undefined())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value.null()
        self.assertTrue(xval.is_null())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value.symbol('hello')
        self.assertTrue(xval.is_symbol())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        xval = value(17)
        self.assertTrue(xval.is_int())
        xval.clear()
        self.assertTrue(xval.is_undefined())

        pass
Пример #5
0
    def test_19explicit(self):
        # null
        xval = value.null()
        self.assertTrue(xval.is_null())
        self.assertFalse(xval)

        # #symbol
        xval = value.symbol('hello')
        self.assertTrue(xval.is_symbol())
        self.assertTrue(xval.is_string())   # string is a generic type for error, symbol and string itself
        self.assertEqual(xval.get_value(), 'hello')

        # secure string
        xval = value.secure_string('secure')
        self.assertTrue(xval.is_string())
        self.assertEqual(xval.get_type(with_unit=True), (VALUE_TYPE.T_STRING, 2))  # VALUE_UNIT_TYPE_STRING.UT_STRING_SECURE
        self.assertEqual(xval.get_value(), 'secure')

        # error
        xval = value(TypeError('error'))
        self.assertTrue(xval.is_error_string())
        self.assertEqual(xval.get_value(), 'error')  # doesn't raise exception.

        pass