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

Side by Side Diff: third_party/WebKit/Source/wtf/FunctionalTest.cpp

Issue 1679773002: WTF::bind: Remove the need of hand-rolled code for bound arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make callInternal() private. Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 OwnPtr<Function<int()>> function = bind(processUnwrappedClass, ClassToBeWrap ped(3), 7); 304 OwnPtr<Function<int()>> function = bind(processUnwrappedClass, ClassToBeWrap ped(3), 7);
305 EXPECT_EQ(21, (*function)()); 305 EXPECT_EQ(21, (*function)());
306 } 306 }
307 307
308 TEST(FunctionalTest, WrapUnwrapInPartialBind) 308 TEST(FunctionalTest, WrapUnwrapInPartialBind)
309 { 309 {
310 OwnPtr<Function<int(int)>> partiallyBoundFunction = bind<int>(processUnwrapp edClass, ClassToBeWrapped(3)); 310 OwnPtr<Function<int(int)>> partiallyBoundFunction = bind<int>(processUnwrapp edClass, ClassToBeWrapped(3));
311 EXPECT_EQ(21, (*partiallyBoundFunction)(7)); 311 EXPECT_EQ(21, (*partiallyBoundFunction)(7));
312 } 312 }
313 313
314 bool lotsOfArguments(int first, int second, int third, int fourth, int fifth, in t sixth, int seventh, int eighth, int ninth, int tenth)
315 {
316 return first == 1 && second == 2 && third == 3 && fourth == 4 && fifth == 5 && sixth == 6 && seventh == 7 && eighth == 8 && ninth == 9 && tenth == 10;
317 }
318
319 TEST(FunctionalTest, LotsOfBoundVariables)
320 {
321 OwnPtr<Function<bool(int, int)>> eightBound = bind<int, int>(lotsOfArguments , 1, 2, 3, 4, 5, 6, 7, 8);
322 EXPECT_TRUE((*eightBound)(9, 10));
323
324 OwnPtr<Function<bool(int)>> nineBound = bind<int>(lotsOfArguments, 1, 2, 3, 4, 5, 6, 7, 8, 9);
325 EXPECT_TRUE((*nineBound)(10));
326
327 OwnPtr<Function<bool()>> allBound = bind(lotsOfArguments, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
328 EXPECT_TRUE((*allBound)());
329 }
330
314 } // anonymous namespace 331 } // anonymous namespace
315 332
316 } // namespace WTF 333 } // namespace WTF
OLDNEW
« third_party/WebKit/Source/wtf/Functional.h ('K') | « third_party/WebKit/Source/wtf/Functional.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698