@@ -154,21 +154,24 @@ TEST(PrintEvalueTest, NaNDouble) {
154154
155155TEST (PrintEvalueTest, EmptyString) {
156156  std::string str = " "  ;
157-   EValue value (str.c_str (), str.size ());
157+   ArrayRef<char > str_ref (const_cast <char *>(str.c_str ()), str.size ());
158+   EValue value (&str_ref);
158159  expect_output (value, " \"\" "  );
159160}
160161
161162TEST (PrintEvalueTest, BasicString) {
162163  //  No escaping required.
163164  std::string str = " Test Data"  ;
164-   EValue value (str.c_str (), str.size ());
165+   ArrayRef<char > str_ref (const_cast <char *>(str.c_str ()), str.size ());
166+   EValue value (&str_ref);
165167  expect_output (value, " \" Test Data\" "  );
166168}
167169
168170TEST (PrintEvalueTest, EscapedString) {
169171  //  Contains characters that need to be escaped.
170172  std::string str = " double quote: \"  backslash: \\ "  ;
171-   EValue value (str.c_str (), str.size ());
173+   ArrayRef<char > str_ref (const_cast <char *>(str.c_str ()), str.size ());
174+   EValue value (&str_ref);
172175  expect_output (value, " \" double quote: \\\"  backslash: \\\\\" "  );
173176}
174177
@@ -267,31 +270,38 @@ TEST(PrintEvalueTest, UnelidedBoolLists) {
267270  //  case; the other scalar types use the same underlying code, so they don't
268271  //  need to test this again.
269272  {
270-     EValue value (ArrayRef<bool >(list.data (), static_cast <size_t >(0ul )));
273+     ArrayRef<bool > bool_ref (list.data (), static_cast <size_t >(0ul ));
274+     EValue value (&bool_ref);
271275    expect_output (value, " (len=0)[]"  );
272276  }
273277  {
274-     EValue value (ArrayRef<bool >(list.data (), 1 ));
278+     ArrayRef<bool > bool_ref (list.data (), 1 );
279+     EValue value (&bool_ref);
275280    expect_output (value, " (len=1)[True]"  );
276281  }
277282  {
278-     EValue value (ArrayRef<bool >(list.data (), 2 ));
283+     ArrayRef<bool > bool_ref (list.data (), 2 );
284+     EValue value (&bool_ref);
279285    expect_output (value, " (len=2)[True, False]"  );
280286  }
281287  {
282-     EValue value (ArrayRef<bool >(list.data (), 3 ));
288+     ArrayRef<bool > bool_ref (list.data (), 3 );
289+     EValue value (&bool_ref);
283290    expect_output (value, " (len=3)[True, False, True]"  );
284291  }
285292  {
286-     EValue value (ArrayRef<bool >(list.data (), 4 ));
293+     ArrayRef<bool > bool_ref (list.data (), 4 );
294+     EValue value (&bool_ref);
287295    expect_output (value, " (len=4)[True, False, True, False]"  );
288296  }
289297  {
290-     EValue value (ArrayRef<bool >(list.data (), 5 ));
298+     ArrayRef<bool > bool_ref (list.data (), 5 );
299+     EValue value (&bool_ref);
291300    expect_output (value, " (len=5)[True, False, True, False, True]"  );
292301  }
293302  {
294-     EValue value (ArrayRef<bool >(list.data (), 6 ));
303+     ArrayRef<bool > bool_ref (list.data (), 6 );
304+     EValue value (&bool_ref);
295305    expect_output (value, " (len=6)[True, False, True, False, True, False]"  );
296306  }
297307}
@@ -302,16 +312,19 @@ TEST(PrintEvalueTest, ElidedBoolLists) {
302312
303313  {
304314    //  Default edge items is 3, so the shortest elided list length is 7.
305-     EValue value (ArrayRef<bool >(list.data (), 7 ));
315+     ArrayRef<bool > bool_ref (list.data (), 7 );
316+     EValue value (&bool_ref);
306317    expect_output (value, " (len=7)[True, False, True, ..., True, False, True]"  );
307318  }
308319  {
309-     EValue value (ArrayRef<bool >(list.data (), 8 ));
320+     ArrayRef<bool > bool_ref (list.data (), 8 );
321+     EValue value (&bool_ref);
310322    expect_output (value, " (len=8)[True, False, True, ..., False, True, False]"  );
311323  }
312324  {
313325    //  Multi-digit length.
314-     EValue value (ArrayRef<bool >(list.data (), 10 ));
326+     ArrayRef<bool > bool_ref (list.data (), 10 );
327+     EValue value (&bool_ref);
315328    expect_output (
316329        value, " (len=10)[True, False, True, ..., False, True, False]"  );
317330  }
@@ -342,19 +355,19 @@ TEST(PrintEvalueTest, UnelidedIntLists) {
342355  {
343356    BoxedEvalueList<int64_t > list (
344357        wrapped_values.data (), unwrapped_values.data (), 0 );
345-     EValue value (list);
358+     EValue value (& list);
346359    expect_output (value, " (len=0)[]"  );
347360  }
348361  {
349362    BoxedEvalueList<int64_t > list (
350363        wrapped_values.data (), unwrapped_values.data (), 3 );
351-     EValue value (list);
364+     EValue value (& list);
352365    expect_output (value, " (len=3)[-2, -1, 0]"  );
353366  }
354367  {
355368    BoxedEvalueList<int64_t > list (
356369        wrapped_values.data (), unwrapped_values.data (), 6 );
357-     EValue value (list);
370+     EValue value (& list);
358371    expect_output (value, " (len=6)[-2, -1, 0, 1, 2, 3]"  );
359372  }
360373}
@@ -392,20 +405,20 @@ TEST(PrintEvalueTest, ElidedIntLists) {
392405    //  Default edge items is 3, so the shortest elided list length is 7.
393406    BoxedEvalueList<int64_t > list (
394407        wrapped_values.data (), unwrapped_values.data (), 7 );
395-     EValue value (list);
408+     EValue value (& list);
396409    expect_output (value, " (len=7)[-4, -3, -2, ..., 0, 1, 2]"  );
397410  }
398411  {
399412    BoxedEvalueList<int64_t > list (
400413        wrapped_values.data (), unwrapped_values.data (), 8 );
401-     EValue value (list);
414+     EValue value (& list);
402415    expect_output (value, " (len=8)[-4, -3, -2, ..., 1, 2, 3]"  );
403416  }
404417  {
405418    //  Multi-digit length.
406419    BoxedEvalueList<int64_t > list (
407420        wrapped_values.data (), unwrapped_values.data (), 10 );
408-     EValue value (list);
421+     EValue value (& list);
409422    expect_output (value, " (len=10)[-4, -3, -2, ..., 3, 4, 5]"  );
410423  }
411424}
@@ -419,15 +432,18 @@ TEST(PrintEvalueTest, UnelidedDoubleLists) {
419432  std::array<double , 6 > list = {-2.2 , -1 , 0 , INFINITY, NAN, 3.3 };
420433
421434  {
422-     EValue value (ArrayRef<double >(list.data (), static_cast <size_t >(0ul )));
435+     ArrayRef<double > double_ref (list.data (), static_cast <size_t >(0ul ));
436+     EValue value (&double_ref);
423437    expect_output (value, " (len=0)[]"  );
424438  }
425439  {
426-     EValue value (ArrayRef<double >(list.data (), 3 ));
440+     ArrayRef<double > double_ref (list.data (), 3 );
441+     EValue value (&double_ref);
427442    expect_output (value, " (len=3)[-2.2, -1., 0.]"  );
428443  }
429444  {
430-     EValue value (ArrayRef<double >(list.data (), 6 ));
445+     ArrayRef<double > double_ref (list.data (), 6 );
446+     EValue value (&double_ref);
431447    expect_output (value, " (len=6)[-2.2, -1., 0., inf, nan, 3.3]"  );
432448  }
433449}
@@ -438,16 +454,19 @@ TEST(PrintEvalueTest, ElidedDoubleLists) {
438454
439455  {
440456    //  Default edge items is 3, so the shortest elided list length is 7.
441-     EValue value (ArrayRef<double >(list.data (), 7 ));
457+     ArrayRef<double > double_ref (list.data (), 7 );
458+     EValue value (&double_ref);
442459    expect_output (value, " (len=7)[-4.4, -3., -2.2, ..., 0., inf, nan]"  );
443460  }
444461  {
445-     EValue value (ArrayRef<double >(list.data (), 8 ));
462+     ArrayRef<double > double_ref (list.data (), 8 );
463+     EValue value (&double_ref);
446464    expect_output (value, " (len=8)[-4.4, -3., -2.2, ..., inf, nan, 3.3]"  );
447465  }
448466  {
449467    //  Multi-digit length.
450-     EValue value (ArrayRef<double >(list.data (), 10 ));
468+     ArrayRef<double > double_ref (list.data (), 10 );
469+     EValue value (&double_ref);
451470    expect_output (value, " (len=10)[-4.4, -3., -2.2, ..., 3.3, 4., 5.5]"  );
452471  }
453472}
@@ -503,7 +522,7 @@ void expect_tensor_list_output(size_t num_tensors, const char* expected) {
503522  ASSERT_LE (num_tensors, wrapped_values.size ());
504523  BoxedEvalueList<executorch::aten::Tensor> list (
505524      wrapped_values.data (), unwrapped_values, num_tensors);
506-   EValue value (list);
525+   EValue value (& list);
507526  expect_output (value, expected);
508527}
509528
@@ -579,7 +598,7 @@ void expect_list_optional_tensor_output(
579598  ASSERT_LE (num_tensors, wrapped_values.size ());
580599  BoxedEvalueList<std::optional<executorch::aten::Tensor>> list (
581600      wrapped_values.data (), unwrapped_values, num_tensors);
582-   EValue value (list);
601+   EValue value (& list);
583602  expect_output (value, expected);
584603}
585604
@@ -628,7 +647,8 @@ TEST(PrintEvalueTest, UnknownTag) {
628647
629648TEST (PrintEvalueTest, EdgeItemsOverride) {
630649  std::array<double , 7 > list = {-3.0 , -2.2 , -1 , 0 , 3.3 , 4.0 , 5.5 };
631-   EValue value (ArrayRef<double >(list.data (), 7 ));
650+   ArrayRef<double > double_ref (list.data (), 7 );
651+   EValue value (&double_ref);
632652
633653  {
634654    //  Default edge items is 3, so this should elide.
@@ -653,7 +673,8 @@ TEST(PrintEvalueTest, EdgeItemsOverride) {
653673
654674TEST (PrintEvalueTest, EdgeItemsDefaults) {
655675  std::array<double , 7 > list = {-3.0 , -2.2 , -1 , 0 , 3.3 , 4.0 , 5.5 };
656-   EValue value (ArrayRef<double >(list.data (), 7 ));
676+   ArrayRef<double > double_ref (list.data (), 7 );
677+   EValue value (&double_ref);
657678
658679  {
659680    //  Default edge items is 3, so this should elide.
@@ -680,7 +701,8 @@ TEST(PrintEvalueTest, EdgeItemsDefaults) {
680701
681702TEST (PrintEvalueTest, EdgeItemsSingleStream) {
682703  std::array<double , 7 > list = {-3.0 , -2.2 , -1 , 0 , 3.3 , 4.0 , 5.5 };
683-   EValue value (ArrayRef<double >(list.data (), 7 ));
704+   ArrayRef<double > double_ref (list.data (), 7 );
705+   EValue value (&double_ref);
684706  std::ostringstream os_before;
685707
686708  //  Print to the same stream multiple times, showing that evalue_edge_items
@@ -750,7 +772,8 @@ TEST(PrintEvalueTest, ListWrapping) {
750772
751773  {
752774    //  Should elide by default and print on a single line.
753-     EValue value (ArrayRef<double >(list.data (), list.size ()));
775+     ArrayRef<double > double_ref (list.data (), list.size ());
776+     EValue value (&double_ref);
754777
755778    std::ostringstream os;
756779    os << value;
@@ -759,7 +782,8 @@ TEST(PrintEvalueTest, ListWrapping) {
759782  {
760783    //  Exactly the per-line length should not wrap when increasing the number of
761784    //  edge items to disable elision.
762-     EValue value (ArrayRef<double >(list.data (), kItemsPerLine ));
785+     ArrayRef<double > double_ref (list.data (), kItemsPerLine );
786+     EValue value (&double_ref);
763787
764788    std::ostringstream os;
765789    os << torch::executor::util::evalue_edge_items (1000 ) << value;
@@ -768,7 +792,8 @@ TEST(PrintEvalueTest, ListWrapping) {
768792  }
769793  {
770794    //  One more than the per-line length should wrap; no elision.
771-     EValue value (ArrayRef<double >(list.data (), kItemsPerLine  + 1 ));
795+     ArrayRef<double > double_ref (list.data (), kItemsPerLine  + 1 );
796+     EValue value (&double_ref);
772797
773798    std::ostringstream os;
774799    os << torch::executor::util::evalue_edge_items (1000 ) << value;
@@ -781,7 +806,8 @@ TEST(PrintEvalueTest, ListWrapping) {
781806  }
782807  {
783808    //  Exactly twice the per-line length, without elision.
784-     EValue value (ArrayRef<double >(list.data (), kItemsPerLine  * 2 ));
809+     ArrayRef<double > double_ref (list.data (), kItemsPerLine  * 2 );
810+     EValue value (&double_ref);
785811
786812    std::ostringstream os;
787813    os << torch::executor::util::evalue_edge_items (1000 ) << value;
@@ -795,7 +821,8 @@ TEST(PrintEvalueTest, ListWrapping) {
795821  }
796822  {
797823    //  Exactly one whole line, with elision.
798-     EValue value (ArrayRef<double >(list.data (), kItemsPerLine  * 3 ));
824+     ArrayRef<double > double_ref (list.data (), kItemsPerLine  * 3 );
825+     EValue value (&double_ref);
799826
800827    std::ostringstream os;
801828    os << torch::executor::util::evalue_edge_items (kItemsPerLine ) << value;
@@ -810,7 +837,8 @@ TEST(PrintEvalueTest, ListWrapping) {
810837  }
811838  {
812839    //  Edge item count slightly larger than per-line length, with elision.
813-     EValue value (ArrayRef<double >(list.data (), kItemsPerLine  * 3 ));
840+     ArrayRef<double > double_ref (list.data (), kItemsPerLine  * 3 );
841+     EValue value (&double_ref);
814842
815843    std::ostringstream os;
816844    os << torch::executor::util::evalue_edge_items (kItemsPerLine  + 1 ) << value;
@@ -829,7 +857,8 @@ TEST(PrintEvalueTest, ListWrapping) {
829857  }
830858  {
831859    //  Large wrapped, ragged, elided example.
832-     EValue value (ArrayRef<double >(list.data (), list.size ()));
860+     ArrayRef<double > double_ref (list.data (), list.size ());
861+     EValue value (&double_ref);
833862
834863    std::ostringstream os;
835864    os << torch::executor::util::evalue_edge_items (33 ) << value;
@@ -946,7 +975,7 @@ TEST(PrintEvalueTest, WrappedTensorLists) {
946975  //  Demonstrate the formatting when printing a list with multiple tensors.
947976  BoxedEvalueList<executorch::aten::Tensor> list (
948977      wrapped_values.data (), unwrapped_values, wrapped_values.size ());
949-   EValue value (list);
978+   EValue value (& list);
950979
951980  std::ostringstream os;
952981  os << torch::executor::util::evalue_edge_items (15 ) << value;
0 commit comments