stdafx.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Copyright (c) ChakraCore Project Contributors. All rights reserved.
  4. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  5. //-------------------------------------------------------------------------------------------------------
  6. #pragma once
  7. #pragma warning(disable: 4127) // constant expression for Trace/Assert
  8. #include <map>
  9. #define IfFailedReturn(EXPR) do { hr = (EXPR); if (FAILED(hr)) { return hr; }} while(FALSE)
  10. #define IfFailedGoLabel(expr, label) do { hr = (expr); if (FAILED(hr)) { goto label; } } while (FALSE)
  11. #define IfFailGo(expr) IfFailedGoLabel(hr = (expr), Error)
  12. #define IfFalseGo(expr) do { if(!(expr)) { hr = E_FAIL; goto Error; } } while(0)
  13. #ifdef Assert
  14. #undef Assert
  15. #endif
  16. #ifdef AssertMsg
  17. #undef AssertMsg
  18. #endif
  19. #if defined(DBG)
  20. #define DebugOnly(x) x
  21. #if !defined(CHAKRACORE_STRINGIZE)
  22. #define CHAKRACORE_STRINGIZE_IMPL(x) #x
  23. #define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
  24. #endif
  25. #define AssertMsg(exp, comment) \
  26. do { \
  27. if (!(exp)) \
  28. { \
  29. fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, CHAKRACORE_STRINGIZE(exp), comment); \
  30. fflush(stderr); \
  31. DebugBreak(); \
  32. } \
  33. } while (0)
  34. #else
  35. #define AssertMsg(exp, comment) ((void)0)
  36. #endif //defined(DBG)
  37. #define Assert(exp) AssertMsg(exp, #exp)
  38. #define _JSRT_
  39. #include "ChakraCore.h"
  40. #include "Core/CommonTypedefs.h"
  41. #include <FileLoadHelpers.h>
  42. #include "TestHooks.h"
  43. extern TestHooks g_testHooks;
  44. extern bool g_testHooksLoaded;