js/src/jsapi-tests/testIntTypesABI.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jsapi-tests/testIntTypesABI.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * This test exercises the full, deliberately-exposed JSAPI interface to ensure
    1.10 + * that no internal integer typedefs leak out.  Include every intentionally
    1.11 + * public header file (and those headers included by them, for completeness),
    1.12 + * even the ones tests.h itself included, to verify this.
    1.13 + */
    1.14 +
    1.15 +#include "jscpucfg.h"
    1.16 +#include "jspubtd.h"
    1.17 +#include "jstypes.h"
    1.18 +
    1.19 +#include "js/Anchor.h"
    1.20 +#include "js/CallArgs.h"
    1.21 +#include "js/CallNonGenericMethod.h"
    1.22 +#include "js/CharacterEncoding.h"
    1.23 +#include "js/Class.h"
    1.24 +#include "js/Date.h"
    1.25 +#include "js/GCAPI.h"
    1.26 +#include "js/HashTable.h"
    1.27 +#include "js/HeapAPI.h"
    1.28 +#include "js/Id.h"
    1.29 +/* LegacyIntTypes.h is deliberately exempted from this requirement */
    1.30 +#include "js/MemoryMetrics.h"
    1.31 +#include "js/OldDebugAPI.h"
    1.32 +#include "js/ProfilingStack.h"
    1.33 +#include "js/PropertyKey.h"
    1.34 +#include "js/RequiredDefines.h"
    1.35 +#include "js/RootingAPI.h"
    1.36 +#include "js/SliceBudget.h"
    1.37 +#include "js/StructuredClone.h"
    1.38 +#include "js/TracingAPI.h"
    1.39 +#include "js/TypeDecls.h"
    1.40 +#include "js/Utility.h"
    1.41 +#include "js/Value.h"
    1.42 +#include "js/Vector.h"
    1.43 +#include "js/WeakMapPtr.h"
    1.44 +#include "jsapi-tests/tests.h"
    1.45 +
    1.46 +/*
    1.47 + * Verify that our public (and intended to be public, versus being that way
    1.48 + * because we haven't made them private yet) headers don't define
    1.49 + * {u,}int{8,16,32,64} or JS{Ui,I}nt{8,16,32,64} types.  If any do, they will
    1.50 + * assuredly conflict with a corresponding typedef below mapping to a *struct*.
    1.51 + *
    1.52 + * Note that tests.h includes a few internal headers; in order that this
    1.53 + * jsapi-test be writable, those internal headers must not import the legacy
    1.54 + * typedefs.
    1.55 + */
    1.56 +
    1.57 +struct ConflictingType {
    1.58 +    uint64_t u64;
    1.59 +};
    1.60 +
    1.61 +typedef ConflictingType uint8;
    1.62 +typedef ConflictingType uint16;
    1.63 +typedef ConflictingType uint32;
    1.64 +typedef ConflictingType uint64;
    1.65 +
    1.66 +typedef ConflictingType int8;
    1.67 +typedef ConflictingType int16;
    1.68 +typedef ConflictingType int32;
    1.69 +typedef ConflictingType int64;
    1.70 +
    1.71 +typedef ConflictingType JSUint8;
    1.72 +typedef ConflictingType JSUint16;
    1.73 +typedef ConflictingType JSUint32;
    1.74 +typedef ConflictingType JSUint64;
    1.75 +
    1.76 +typedef ConflictingType JSInt8;
    1.77 +typedef ConflictingType JSInt16;
    1.78 +typedef ConflictingType JSInt32;
    1.79 +typedef ConflictingType JSInt64;
    1.80 +
    1.81 +typedef ConflictingType jsword;
    1.82 +typedef ConflictingType jsuword;
    1.83 +typedef ConflictingType JSWord;
    1.84 +typedef ConflictingType JSUword;
    1.85 +
    1.86 +BEGIN_TEST(testIntTypesABI)
    1.87 +{
    1.88 +    /* This passes if the typedefs didn't conflict at compile time. */
    1.89 +    return true;
    1.90 +}
    1.91 +END_TEST(testIntTypesABI)

mercurial