Files
palemoon27/mfbt/tests/TestScopeExit.cpp
roytam1 06f122f425 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1176004 - Make jstest's unix task runner a generator; r=sfink (03def3308)
- Bug 1175708 - Followup to fix windows jstests.py bustage on a CLOSED TREE; r=meow (b291f8cd0)
- Bug 1175636 - Do not spawn a watchdog for each test on Windows; r=sfink (c87370ba8)
- Bug 1141283 - Compensate for stackwalk duration and sleep overhead when determining sampler sleep time. r=BenWa (cf155667f)
- Bug 1172186 - Make the profiler build standalone. r=mstange (324ec7283)
- Bug 1176028 - Use the jstest's task generator directly; r=sfink (6dac9eb7a)
- Bug 1176064 - Do processing of the jstest's skiplist inline; r=sfink (af6dd9d06)
- Bug 1165054 - Fix inbound bustage due to missing explicit on single arg constructor r=me (b29da4afe)
- Bug 1182092 - Try harder to filter out template shapes with indexed properties when making unboxed objects, r=jandem. (2540ff768)
- Bug 1180299 - Implement ScopeExit for running actions at the end of a scope, r=Waldo (dd40bb356)
- Bug 1180536 - Use mozilla::ScopeExit to clean up Debugger::addDebugge#eGlobal's consistency on failure; r=sfink (3bec89179)
- Bug 1170216 - When using the slow-and-standard path in js::SetIntegrityLevel, don't manually call setNonwritableArrayLength afterwards. r=Waldo. (563a26f28)
- Bug 1171036 - Change GetLengthProperty slow path to use ToLengthClamped instead of ToUint32. r=Waldo. (c0431c393)
- Bug 1170307 - Inline the common path of NonNullObject; use it instead of ReportObjectRequired in the Debugger. r=shu. (ff70c4e1c)
- Bug 1167883 - Avoid huge stack frames and stack overflow issues with MSVC PGO builds. r=nbp (a02cdc599)
- Bug 1181063 - Use mozilla::IsNaN and mozilla::IsInfinite in Simulator-vixl.cpp. r=Waldo, r=sstangl (552a22923)
- Bug 1181152 - Make Trampoline-mips.cpp compile with clang. r=rankov (d3308f445)
- Bug 1181581 - Fix some typos in comments. r=jandem (79c5de477)
- Bug 1175714 - Watch for baseline frame values with nursery types during OSR, r=jandem. (765346890)
2021-10-22 09:18:33 +08:00

55 lines
928 B
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Assertions.h"
#include "mozilla/ScopeExit.h"
using mozilla::MakeScopeExit;
#define CHECK(c) \
do { \
bool cond = !!(c); \
MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
if (!cond) { \
return false; \
} \
} while (false)
static bool
Test()
{
int a = 1;
int b = 1;
{
a++;
auto guardA = MakeScopeExit([&] {
a--;
});
b++;
auto guardB = MakeScopeExit([&] {
b--;
});
guardB.release();
}
CHECK(a == 1);
CHECK(b == 2);
return true;
}
int
main()
{
if (!Test()) {
return 1;
}
return 0;
}