Skip to content

Commit ef19073

Browse files
billffacebook-github-bot
authored andcommitted
add code coverage for dt_{with_{persistence,rc},modulo_persistence}
Summary: trivially covered via `static_assert`, so i added all the arraylike cases. added `noexcept` to `folly::FormatValue` for `DataType{,Category}` as i was in the neighborhood. Reviewed By: ricklavoie Differential Revision: D20088132 fbshipit-source-id: 82cd8a003a3b701b35b0636680dc3c96754ccc32
1 parent 49f2e98 commit ef19073

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

hphp/runtime/base/datatype.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace HPHP {
2222

23+
namespace {
24+
2325
///////////////////////////////////////////////////////////////////////////////
2426
// Static asserts.
2527

@@ -191,6 +193,79 @@ static_assert(!isNullType(KindOfString), "");
191193
static_assert(!isNullType(KindOfObject), "");
192194
static_assert(!isNullType(KindOfResource), "");
193195

196+
static_assert(isRealType(KindOfUninit), "");
197+
static_assert(isRealType(KindOfNull), "");
198+
static_assert(isRealType(KindOfArray), "");
199+
static_assert(isRealType(KindOfPersistentArray), "");
200+
static_assert(isRealType(KindOfVArray), "");
201+
static_assert(isRealType(KindOfPersistentVArray), "");
202+
static_assert(isRealType(KindOfDArray), "");
203+
static_assert(isRealType(KindOfPersistentDArray), "");
204+
static_assert(isRealType(KindOfVec), "");
205+
static_assert(isRealType(KindOfPersistentVec), "");
206+
static_assert(isRealType(KindOfDict), "");
207+
static_assert(isRealType(KindOfPersistentDict), "");
208+
static_assert(isRealType(KindOfKeyset), "");
209+
static_assert(isRealType(KindOfPersistentKeyset), "");
210+
static_assert(isRealType(KindOfBoolean), "");
211+
static_assert(isRealType(KindOfInt64), "");
212+
static_assert(isRealType(KindOfDouble), "");
213+
static_assert(isRealType(KindOfPersistentString), "");
214+
static_assert(isRealType(KindOfString), "");
215+
static_assert(isRealType(KindOfObject), "");
216+
static_assert(isRealType(KindOfResource), "");
217+
218+
static_assert(dt_with_rc(KindOfArray) == KindOfArray, "");
219+
static_assert(dt_with_rc(KindOfPersistentArray) == KindOfArray, "");
220+
static_assert(dt_with_rc(KindOfVArray) == KindOfVArray, "");
221+
static_assert(dt_with_rc(KindOfPersistentVArray) == KindOfVArray, "");
222+
static_assert(dt_with_rc(KindOfDArray) == KindOfDArray, "");
223+
static_assert(dt_with_rc(KindOfPersistentDArray) == KindOfDArray, "");
224+
static_assert(dt_with_rc(KindOfString) == KindOfString, "");
225+
static_assert(dt_with_rc(KindOfPersistentString) == KindOfString, "");
226+
static_assert(dt_with_rc(KindOfVec) == KindOfVec, "");
227+
static_assert(dt_with_rc(KindOfPersistentVec) == KindOfVec, "");
228+
static_assert(dt_with_rc(KindOfDict) == KindOfDict, "");
229+
static_assert(dt_with_rc(KindOfPersistentDict) == KindOfDict, "");
230+
static_assert(dt_with_rc(KindOfKeyset) == KindOfKeyset, "");
231+
static_assert(dt_with_rc(KindOfPersistentKeyset) == KindOfKeyset, "");
232+
233+
static_assert(dt_modulo_persistence(KindOfPersistentArray) == KindOfArray, "");
234+
static_assert(dt_modulo_persistence(KindOfArray) == KindOfArray, "");
235+
static_assert(dt_modulo_persistence(KindOfPersistentVArray) == KindOfVArray, "");
236+
static_assert(dt_modulo_persistence(KindOfVArray) == KindOfVArray, "");
237+
static_assert(dt_modulo_persistence(KindOfPersistentDArray) == KindOfDArray, "");
238+
static_assert(dt_modulo_persistence(KindOfDArray) == KindOfDArray, "");
239+
static_assert(dt_modulo_persistence(KindOfPersistentString) == KindOfString, "");
240+
static_assert(dt_modulo_persistence(KindOfString) == KindOfString, "");
241+
static_assert(dt_modulo_persistence(KindOfPersistentVec) == KindOfVec, "");
242+
static_assert(dt_modulo_persistence(KindOfVec) == KindOfVec, "");
243+
static_assert(dt_modulo_persistence(KindOfPersistentDict) == KindOfDict, "");
244+
static_assert(dt_modulo_persistence(KindOfDict) == KindOfDict, "");
245+
static_assert(dt_modulo_persistence(KindOfPersistentKeyset) == KindOfKeyset, "");
246+
static_assert(dt_modulo_persistence(KindOfKeyset) == KindOfKeyset, "");
247+
248+
static_assert(dt_with_persistence(KindOfArray) == KindOfPersistentArray, "");
249+
static_assert(dt_with_persistence(KindOfPersistentArray) ==
250+
KindOfPersistentArray, "");
251+
static_assert(dt_with_persistence(KindOfVArray) == KindOfPersistentVArray, "");
252+
static_assert(dt_with_persistence(KindOfPersistentVArray) ==
253+
KindOfPersistentVArray, "");
254+
static_assert(dt_with_persistence(KindOfDArray) == KindOfPersistentDArray, "");
255+
static_assert(dt_with_persistence(KindOfPersistentDArray) ==
256+
KindOfPersistentDArray, "");
257+
static_assert(dt_with_persistence(KindOfString) == KindOfPersistentString, "");
258+
static_assert(dt_with_persistence(KindOfPersistentString) ==
259+
KindOfPersistentString, "");
260+
static_assert(dt_with_persistence(KindOfVec) == KindOfPersistentVec, "");
261+
static_assert(dt_with_persistence(KindOfPersistentVec) == KindOfPersistentVec, "");
262+
static_assert(dt_with_persistence(KindOfDict) == KindOfPersistentDict, "");
263+
static_assert(dt_with_persistence(KindOfPersistentDict) ==
264+
KindOfPersistentDict, "");
265+
static_assert(dt_with_persistence(KindOfKeyset) == KindOfPersistentKeyset, "");
266+
static_assert(dt_with_persistence(KindOfPersistentKeyset) ==
267+
KindOfPersistentKeyset, "");
268+
194269
static_assert(isRefcountedType(KindOfString), "");
195270
static_assert(isRefcountedType(KindOfObject), "");
196271
static_assert(isRefcountedType(KindOfResource), "");
@@ -264,6 +339,9 @@ static_assert(equivDataTypes(KindOfPersistentDArray, KindOfArray), "");
264339
static_assert(KindOfUninit == static_cast<DataType>(0),
265340
"Several things assume this tag is 0, especially RDS");
266341

342+
343+
} // namespace
344+
267345
///////////////////////////////////////////////////////////////////////////////
268346

269347
MaybeDataType get_datatype(

hphp/runtime/base/datatype.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ bool operator>=(DataType, DataType) = delete;
428428
namespace folly {
429429
template<> class FormatValue<HPHP::DataTypeCategory> {
430430
public:
431-
explicit FormatValue(HPHP::DataTypeCategory val) : m_val(val) {}
431+
explicit FormatValue(HPHP::DataTypeCategory val) noexcept : m_val(val) {}
432432

433433
template<typename Callback>
434434
void format(FormatArg& arg, Callback& cb) const {
@@ -441,7 +441,7 @@ template<> class FormatValue<HPHP::DataTypeCategory> {
441441

442442
template<> class FormatValue<HPHP::DataType> {
443443
public:
444-
explicit FormatValue(HPHP::DataType dt) : m_dt(dt) {}
444+
explicit FormatValue(HPHP::DataType dt) noexcept : m_dt(dt) {}
445445

446446
template<typename C>
447447
void format(FormatArg& arg, C& cb) const {

0 commit comments

Comments
 (0)