| 30 | using namespace tvm::ffi::testing; |
| 31 | |
| 32 | TEST(RValueRef, Basic) { |
| 33 | auto append = |
| 34 | Function::FromTyped([](RValueRef<Array<int>> ref, int val, bool is_unique) -> Array<int> { |
| 35 | Array<int> arr = *std::move(ref); |
| 36 | EXPECT_EQ(arr.unique(), is_unique); |
| 37 | arr.push_back(val); |
| 38 | return arr; |
| 39 | }); |
| 40 | auto a = append(RValueRef(Array<int>({1, 2})), 3, true).cast<Array<int>>(); |
| 41 | EXPECT_EQ(a.size(), 3); |
| 42 | a = append(RValueRef(std::move(a)), 4, true).cast<Array<int>>(); |
| 43 | EXPECT_EQ(a.size(), 4); |
| 44 | // pass in lvalue instead, the append still will succeed but array will not be unique |
| 45 | a = append(a, 5, false).cast<Array<int>>(); |
| 46 | EXPECT_EQ(a.size(), 5); |
| 47 | } |
| 48 | |
| 49 | TEST(RValueRef, ParamChecking) { |
| 50 | // try decution |