| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |