@@ -28,6 +28,15 @@ void run({required TestRunnerCallback testRunner}) {
2828 ..releasedBy (arena);
2929 }
3030
31+ JList <JString ?> testNullableDataList (Arena arena) {
32+ return [
33+ '1' .toJString ()..releasedBy (arena),
34+ '2' .toJString ()..releasedBy (arena),
35+ null ,
36+ ].toJList (JString .nullableType)
37+ ..releasedBy (arena);
38+ }
39+
3140 testRunner ('length get' , () {
3241 using ((arena) {
3342 final list = testDataList (arena);
@@ -57,6 +66,14 @@ void run({required TestRunnerCallback testRunner}) {
5766 expect (list[2 ].toDartString (releaseOriginal: true ), '3' );
5867 });
5968 });
69+ testRunner ('nullable []' , () {
70+ using ((arena) {
71+ final list = testNullableDataList (arena);
72+ expect (list[0 ]! .toDartString (releaseOriginal: true ), '1' );
73+ expect (list[1 ]! .toDartString (releaseOriginal: true ), '2' );
74+ expect (list[2 ], isNull);
75+ });
76+ });
6077 testRunner ('[]=' , () {
6178 using ((arena) {
6279 final list = testDataList (arena);
@@ -65,6 +82,16 @@ void run({required TestRunnerCallback testRunner}) {
6582 expect (list[0 ].toDartString (releaseOriginal: true ), '2' );
6683 });
6784 });
85+ testRunner ('nullable []=' , () {
86+ using ((arena) {
87+ final list = testNullableDataList (arena);
88+ expect (list[0 ]! .toDartString (releaseOriginal: true ), '1' );
89+ list[0 ] = '2' .toJString ()..releasedBy (arena);
90+ expect (list[0 ]! .toDartString (releaseOriginal: true ), '2' );
91+ list[0 ] = null ;
92+ expect (list[0 ], isNull);
93+ });
94+ });
6895 testRunner ('add' , () {
6996 using ((arena) {
7097 final list = testDataList (arena);
@@ -73,6 +100,16 @@ void run({required TestRunnerCallback testRunner}) {
73100 expect (list[3 ].toDartString (releaseOriginal: true ), '4' );
74101 });
75102 });
103+ testRunner ('nullable add' , () {
104+ using ((arena) {
105+ final list = testNullableDataList (arena);
106+ list.add ('4' .toJString ()..releasedBy (arena));
107+ expect (list.length, 4 );
108+ expect (list[3 ]! .toDartString (releaseOriginal: true ), '4' );
109+ list.add (null );
110+ expect (list[3 ]! .toDartString (releaseOriginal: true ), '4' );
111+ });
112+ });
76113 testRunner ('addAll' , () {
77114 using ((arena) {
78115 final list = testDataList (arena);
@@ -102,6 +139,16 @@ void run({required TestRunnerCallback testRunner}) {
102139 expect (list.contains ('4' .toJString ()..releasedBy (arena)), false );
103140 });
104141 });
142+ testRunner ('nullable contains' , () {
143+ using ((arena) {
144+ final list = testNullableDataList (arena);
145+ // ignore: collection_methods_unrelated_type
146+ expect (list.contains ('1' ), false );
147+ expect (list.contains ('1' .toJString ()..releasedBy (arena)), true );
148+ expect (list.contains ('4' .toJString ()..releasedBy (arena)), false );
149+ expect (list.contains (null ), true );
150+ });
151+ });
105152 testRunner ('getRange' , () {
106153 using ((arena) {
107154 final list = testDataList (arena);
@@ -121,6 +168,37 @@ void run({required TestRunnerCallback testRunner}) {
121168 expect (list.indexOf ('1' .toJString ()..toDartString (), - 1 ), 0 );
122169 });
123170 });
171+ testRunner ('nullable indexOf' , () {
172+ using ((arena) {
173+ final list = testNullableDataList (arena);
174+ expect (list.indexOf (1 ), - 1 );
175+ expect (list.indexOf ('1' .toJString ()..toDartString ()), 0 );
176+ expect (list.indexOf ('2' .toJString ()..toDartString ()), 1 );
177+ expect (list.indexOf (null ), 2 );
178+ expect (list.indexOf ('1' .toJString ()..toDartString (), 1 ), - 1 );
179+ expect (list.indexOf ('1' .toJString ()..toDartString (), - 1 ), 0 );
180+ });
181+ });
182+ testRunner ('lastIndexOf' , () {
183+ using ((arena) {
184+ final list = testDataList (arena);
185+ expect (list.lastIndexOf (1 ), - 1 );
186+ expect (list.lastIndexOf ('1' .toJString ()..toDartString ()), 0 );
187+ expect (list.lastIndexOf ('2' .toJString ()..toDartString ()), 1 );
188+ expect (list.lastIndexOf ('3' .toJString ()..toDartString ()), 2 );
189+ expect (list.lastIndexOf ('3' .toJString ()..toDartString (), 1 ), - 1 );
190+ });
191+ });
192+ testRunner ('nullable lastIndexOf' , () {
193+ using ((arena) {
194+ final list = testNullableDataList (arena);
195+ expect (list.lastIndexOf (1 ), - 1 );
196+ expect (list.lastIndexOf ('1' .toJString ()..toDartString ()), 0 );
197+ expect (list.lastIndexOf ('2' .toJString ()..toDartString ()), 1 );
198+ expect (list.lastIndexOf (null ), 2 );
199+ expect (list.lastIndexOf (null , 1 ), - 1 );
200+ });
201+ });
124202 testRunner ('insert' , () {
125203 using ((arena) {
126204 final list = testDataList (arena);
@@ -164,6 +242,17 @@ void run({required TestRunnerCallback testRunner}) {
164242 expect (list.remove (1 ), false );
165243 });
166244 });
245+ testRunner ('nullable remove' , () {
246+ using ((arena) {
247+ final list = testNullableDataList (arena);
248+ expect (list.remove ('3' .toJString ()..releasedBy (arena)), false );
249+ expect (list.length, 3 );
250+ expect (list.remove (null ), true );
251+ expect (list.length, 2 );
252+ // ignore: collection_methods_unrelated_type
253+ expect (list.remove (1 ), false );
254+ });
255+ });
167256 testRunner ('removeAt' , () {
168257 using ((arena) {
169258 final list = testDataList (arena);
0 commit comments