enabling <coroutine> from std library for folly when c++ version is 20
[hiphop-php.git] / hphp / runtime / test / type-check-test.cpp
blob1834c48f6515b353180f6735b4e2ce2df3b743c8
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/vm/type-constraint.h"
19 #include <gtest/gtest.h>
21 namespace HPHP {
22 TEST(TypeChecks, TypeVar) {
24 * Test the following types of type constraints
25 * main: TypeConstraint{flags:TypeVar, type:Mixed, clsName:<null>, typeName:T}
27 auto const typeVar = TypeConstraint(
28 AnnotType::Mixed,
29 TypeConstraintFlags::TypeVar,
30 LowStringPtr(StringData::MakeStatic("T"))
32 auto const tic = TypeIntersectionConstraint(std::vector<TypeConstraint>({typeVar}));
33 EXPECT_EQ(KindOfNull, tic.defaultValue()->m_type);
36 TEST(TypeChecks, NullableString) {
37 auto nullableString = TypeConstraint(
38 AnnotType::String,
39 (TypeConstraintFlags::Nullable
40 | TypeConstraintFlags::Resolved
41 | TypeConstraintFlags::DisplayNullable
42 | TypeConstraintFlags::UpperBound),
43 LowStringPtr(StringData::MakeStatic("HH\\string"))
45 auto const tic = TypeIntersectionConstraint(std::vector<TypeConstraint>({nullableString}));
46 EXPECT_EQ(KindOfNull, tic.defaultValue()->m_type);