Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: runtime/vm/atomic_test.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/atomic_simulator.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/atomic.h"
5 #include "platform/assert.h" 6 #include "platform/assert.h"
6 #include "platform/utils.h" 7 #include "platform/utils.h"
7 #include "vm/atomic.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 VM_UNIT_TEST_CASE(FetchAndIncrement) { 13 VM_UNIT_TEST_CASE(FetchAndIncrement) {
14 uintptr_t v = 42; 14 uintptr_t v = 42;
15 EXPECT_EQ(static_cast<uintptr_t>(42), 15 EXPECT_EQ(static_cast<uintptr_t>(42),
16 AtomicOperations::FetchAndIncrement(&v)); 16 AtomicOperations::FetchAndIncrement(&v));
17 EXPECT_EQ(static_cast<uintptr_t>(43), v); 17 EXPECT_EQ(static_cast<uintptr_t>(43), v);
18 } 18 }
19 19
20
21 VM_UNIT_TEST_CASE(FetchAndDecrement) { 20 VM_UNIT_TEST_CASE(FetchAndDecrement) {
22 uintptr_t v = 42; 21 uintptr_t v = 42;
23 EXPECT_EQ(static_cast<uintptr_t>(42), 22 EXPECT_EQ(static_cast<uintptr_t>(42),
24 AtomicOperations::FetchAndDecrement(&v)); 23 AtomicOperations::FetchAndDecrement(&v));
25 EXPECT_EQ(static_cast<uintptr_t>(41), v); 24 EXPECT_EQ(static_cast<uintptr_t>(41), v);
26 } 25 }
27 26
28
29 VM_UNIT_TEST_CASE(FetchAndIncrementSigned) { 27 VM_UNIT_TEST_CASE(FetchAndIncrementSigned) {
30 intptr_t v = -42; 28 intptr_t v = -42;
31 EXPECT_EQ(static_cast<intptr_t>(-42), 29 EXPECT_EQ(static_cast<intptr_t>(-42),
32 AtomicOperations::FetchAndIncrement(&v)); 30 AtomicOperations::FetchAndIncrement(&v));
33 EXPECT_EQ(static_cast<intptr_t>(-41), v); 31 EXPECT_EQ(static_cast<intptr_t>(-41), v);
34 } 32 }
35 33
36
37 VM_UNIT_TEST_CASE(FetchAndDecrementSigned) { 34 VM_UNIT_TEST_CASE(FetchAndDecrementSigned) {
38 intptr_t v = -42; 35 intptr_t v = -42;
39 EXPECT_EQ(static_cast<intptr_t>(-42), 36 EXPECT_EQ(static_cast<intptr_t>(-42),
40 AtomicOperations::FetchAndDecrement(&v)); 37 AtomicOperations::FetchAndDecrement(&v));
41 EXPECT_EQ(static_cast<intptr_t>(-43), v); 38 EXPECT_EQ(static_cast<intptr_t>(-43), v);
42 } 39 }
43 40
44
45 VM_UNIT_TEST_CASE(IncrementBy) { 41 VM_UNIT_TEST_CASE(IncrementBy) {
46 intptr_t v = 42; 42 intptr_t v = 42;
47 AtomicOperations::IncrementBy(&v, 100); 43 AtomicOperations::IncrementBy(&v, 100);
48 EXPECT_EQ(static_cast<intptr_t>(142), v); 44 EXPECT_EQ(static_cast<intptr_t>(142), v);
49 } 45 }
50 46
51
52 VM_UNIT_TEST_CASE(DecrementBy) { 47 VM_UNIT_TEST_CASE(DecrementBy) {
53 intptr_t v = 42; 48 intptr_t v = 42;
54 AtomicOperations::DecrementBy(&v, 41); 49 AtomicOperations::DecrementBy(&v, 41);
55 EXPECT_EQ(static_cast<intptr_t>(1), v); 50 EXPECT_EQ(static_cast<intptr_t>(1), v);
56 } 51 }
57 52
58
59 VM_UNIT_TEST_CASE(LoadRelaxed) { 53 VM_UNIT_TEST_CASE(LoadRelaxed) {
60 uword v = 42; 54 uword v = 42;
61 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v)); 55 EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v));
62 } 56 }
63 57
64
65 TEST_CASE(CompareAndSwapWord) { 58 TEST_CASE(CompareAndSwapWord) {
66 uword old_value = 42; 59 uword old_value = 42;
67 uword new_value = 100; 60 uword new_value = 100;
68 uword result = 61 uword result =
69 AtomicOperations::CompareAndSwapWord(&old_value, old_value, new_value); 62 AtomicOperations::CompareAndSwapWord(&old_value, old_value, new_value);
70 EXPECT_EQ(static_cast<uword>(42), result); 63 EXPECT_EQ(static_cast<uword>(42), result);
71 } 64 }
72 65
73
74 TEST_CASE(CompareAndSwapUint32) { 66 TEST_CASE(CompareAndSwapUint32) {
75 uint32_t old_value = 42; 67 uint32_t old_value = 42;
76 uint32_t new_value = 100; 68 uint32_t new_value = 100;
77 uint32_t result = 69 uint32_t result =
78 AtomicOperations::CompareAndSwapUint32(&old_value, old_value, new_value); 70 AtomicOperations::CompareAndSwapUint32(&old_value, old_value, new_value);
79 EXPECT_EQ(static_cast<uint32_t>(42), result); 71 EXPECT_EQ(static_cast<uint32_t>(42), result);
80 } 72 }
81 73
82 } // namespace dart 74 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/atomic_simulator.h ('k') | runtime/vm/atomic_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698