コード例 #1
0
ファイル: test_optimizations.py プロジェクト: google/tmppy
      List<tmppy_internal_test_module_x18...>,
      List<tmppy_internal_test_module_x17...>,
      std::is_same<
          BoolList<(tmppy_internal_tmppy_builtins_x310<
                    List<tmppy_internal_test_module_x18...>,
                    tmppy_internal_test_module_x17>::value)...>,
          BoolList<(Select1stBoolType<true, tmppy_internal_test_module_x17>::
                        value)...>>::value>::value;
};
template <typename tmppy_internal_test_module_x5,
          typename tmppy_internal_test_module_x6>
struct eq {
  using error = void;
  static constexpr bool value =
      tmppy_internal_test_module_x23<tmppy_internal_test_module_x5,
                                     tmppy_internal_test_module_x6>::value;
};
''')
def test_optimization_type_set_equals():
    from tmppy import Type
    from typing import Set

    def eq(x: Set[Type], y: Set[Type]):
        return x == y

    assert eq({Type('int')}, {Type('float')}) == False


if __name__ == '__main__':
    main()
コード例 #2
0
@assert_conversion_fails
def test_attribute_access_on_list_error():
    from tmppy import Type
    assert [Type('int')].type == Type(
        'int'
    )  # error: Attribute access is not supported for values of type List\[Type\].


@assert_conversion_fails
def test_attribute_access_on_set_error():
    from tmppy import Type
    assert {Type('int')}.type == Type(
        'int'
    )  # error: Attribute access is not supported for values of type Set\[Type\].


@assert_conversion_fails
def test_attribute_access_on_function_error():
    from tmppy import Type

    def f(x: Type):
        return x

    assert f.type == Type(
        'int'
    )  # error: Attribute access is not supported for values of type \(Type\) -> Type.


if __name__ == '__main__':
    main(__file__)