Hash :
9740b01b
        
        Author :
  
        
        Date :
2023-09-08T16:30:08
        
      
Enhance UnlockedTailCall run method UnlockedTailCall::CallType is now std::function<void(void *)> This is in preparation for upcoming changes where unlocked tail calls need access to objects outside block and namespace scope. Bug: angleproject:8340 Tests: UnlockedTailCall* Change-Id: Ida6822b701c5c11ce4b8f6e3aae53108755e2cad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4852021 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
//
// Copyright 2023 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UnlockedTailCall_unittest.cpp: Unit tests of the UnlockedTailCall class.
#include <gtest/gtest.h>
#include "libANGLE/angletypes.h"
namespace angle
{
void SetUpTailCall(UnlockedTailCall *unlockedTailCall, int *result)
{
    unlockedTailCall->add([result](void *resultOut) {
        (void)resultOut;
        ++*result;
    });
}
// Test basic functionality
TEST(UnlockedTailCall, Basic)
{
    int a = 10;
    int b = 500;
    UnlockedTailCall unlockedTailCall;
    ASSERT_FALSE(unlockedTailCall.any());
    SetUpTailCall(&unlockedTailCall, &a);
    ASSERT_TRUE(unlockedTailCall.any());
    SetUpTailCall(&unlockedTailCall, &b);
    ASSERT_TRUE(unlockedTailCall.any());
    unlockedTailCall.run(nullptr);
    ASSERT_EQ(a, 11);
    ASSERT_EQ(b, 501);
}
}  // namespace angle