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

Side by Side Diff: tests/html/js_array_test.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library jsArrayTest; 5 library jsArrayTest;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:js'; 8 import 'dart:js';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 // Calling a method from Dart List on an arbitrary target object. 152 // Calling a method from Dart List on an arbitrary target object.
153 function callListMethodOnTarget(dartArray, target, methodName, args) { 153 function callListMethodOnTarget(dartArray, target, methodName, args) {
154 return dartArray[methodName].apply(target, args); 154 return dartArray[methodName].apply(target, args);
155 } 155 }
156 156
157 """); 157 """);
158 } 158 }
159 159
160 // TODO(jacobr): depend on package:js instead of defining this annotation here.
161 class JsName {
162 const JsName();
163 }
164
165 @JsName()
166 class SimpleJsLiteralClass extends JavaScriptObject {
167 get foo => JsNative.getProperty(this, 'foo');
168 }
169
160 class Foo {} 170 class Foo {}
161 171
162 callJsMethod(List array, String methodName, List args) => 172 callJsMethod(List array, String methodName, List args) => JsNative.callMethod3(
163 context.callMethod("callJsMethod", [array, methodName, args]); 173 nativeContext, "callJsMethod", array, methodName, args);
164 174
165 callIndexOf(List array, value) => callJsMethod(array, "indexOf", [value]); 175 callIndexOf(List array, value) => callJsMethod(array, "indexOf", [value]);
166 callLastIndexOf(List array, value) => 176 callLastIndexOf(List array, value) =>
167 callJsMethod(array, "lastIndexOf", [value]); 177 callJsMethod(array, "lastIndexOf", [value]);
168 178
169 callPop(List array) => callJsMethod(array, "pop", []); 179 callPop(List array) => callJsMethod(array, "pop", []);
170 callPush(List array, element) => callJsMethod(array, "push", [element]); 180 callPush(List array, element) => callJsMethod(array, "push", [element]);
171 callShift(List array) => callJsMethod(array, "shift", []); 181 callShift(List array) => callJsMethod(array, "shift", []);
172 callReverse(List array) => callJsMethod(array, "reverse", []); 182 callReverse(List array) => callJsMethod(array, "reverse", []);
173 callSetLength(List array, length) => 183 callSetLength(List array, length) =>
174 context.callMethod("setLength", [array, length]); 184 JsNative.callMethod2(nativeContext, "setLength", array, length);
175 185
176 callListMethodOnObject(JsObject object, String methodName, List args) => context 186 callListMethodOnObject(object, String methodName, List args) =>
177 .callMethod("callListMethodOnTarget", [[], object, methodName, args]); 187 JsNative.callMethod4(
188 nativeContext, "callListMethodOnTarget", [], object, methodName, args);
178 189
179 jsonStringify(JsObject object) => context.callMethod("jsonStringify", [object]); 190 jsonStringify(object) =>
191 JsNative.callMethod1(nativeContext, "jsonStringify", object);
180 192
181 main() { 193 main() {
182 _injectJs(); 194 _injectJs();
183 useHtmlConfiguration(); 195 useHtmlConfiguration();
184 196
185 group('indexOf', () { 197 group('indexOf', () {
186 var div = new DivElement(); 198 var div = new DivElement();
187 var list = [3, 42, "foo", 42, div]; 199 var list = [3, 42, "foo", 42, div];
188 test('found', () { 200 test('found', () {
189 expect(callIndexOf(list, 3), equals(0)); 201 expect(callIndexOf(list, 3), equals(0));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 expect(list.length, equals(2)); 243 expect(list.length, equals(2));
232 }); 244 });
233 }); 245 });
234 246
235 group('join', () { 247 group('join', () {
236 var list = [3, 42, "foo"]; 248 var list = [3, 42, "foo"];
237 var listWithDartClasses = [3, new Foo(), 42, "foo", new Object()]; 249 var listWithDartClasses = [3, new Foo(), 42, "foo", new Object()];
238 test('default', () { 250 test('default', () {
239 expect(callJsMethod(list, "join", []), equals("3,42,foo")); 251 expect(callJsMethod(list, "join", []), equals("3,42,foo"));
240 expect(callJsMethod(listWithDartClasses, "join", []), 252 expect(callJsMethod(listWithDartClasses, "join", []),
241 equals("3,Instance of 'Foo',42,foo,Instance of 'Object'")); 253 equals("3,${new Foo()},42,foo,${new Object()}"));
242 }); 254 });
243 255
244 test('custom separator', () { 256 test('custom separator', () {
245 expect(callJsMethod(list, "join", ["##"]), equals("3##42##foo")); 257 expect(callJsMethod(list, "join", ["##"]), equals("3##42##foo"));
246 }); 258 });
247 }); 259 });
248 260
249 group('lastIndexOf', () { 261 group('lastIndexOf', () {
250 var list = [3, 42, "foo", 42]; 262 var list = [3, 42, "foo", 42];
251 test('found', () { 263 test('found', () {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 expect(callJsMethod(list, "slice", [-2, 3]), equals([92])); 380 expect(callJsMethod(list, "slice", [-2, 3]), equals([92]));
369 381
370 // Past the end of the front of the array. 382 // Past the end of the front of the array.
371 expect(callJsMethod(list, "slice", [-10, 2]), equals([3, 42])); 383 expect(callJsMethod(list, "slice", [-10, 2]), equals([3, 42]));
372 }); 384 });
373 }); 385 });
374 386
375 group("js snippet tests", () { 387 group("js snippet tests", () {
376 test("enumerate indices", () { 388 test("enumerate indices", () {
377 var list = ["a", "b", "c", "d"]; 389 var list = ["a", "b", "c", "d"];
378 var indices = context.callMethod('jsEnumerateIndices', [list]); 390 var indices =
391 JsNative.callMethod1(nativeContext, 'jsEnumerateIndices', list);
379 expect(indices.length, equals(4)); 392 expect(indices.length, equals(4));
380 for (int i = 0; i < 4; i++) { 393 for (int i = 0; i < 4; i++) {
381 expect(indices[i], equals('$i')); 394 expect(indices[i], equals('$i'));
382 } 395 }
383 }); 396 });
384 397
385 test("set element", () { 398 test("set element", () {
386 var list = ["a", "b", "c", "d"]; 399 var list = ["a", "b", "c", "d"];
387 context.callMethod('setValue', [list, 0, 42]); 400 JsNative.callMethod3(nativeContext, 'setValue', list, 0, 42);
388 expect(list[0], equals(42)); 401 expect(list[0], equals(42));
389 context.callMethod('setValue', [list, 1, 84]); 402 JsNative.callMethod3(nativeContext, 'setValue', list, 1, 84);
390 expect(list[1], equals(84)); 403 expect(list[1], equals(84));
391 context.callMethod( 404 JsNative.callMethod3(
392 'setValue', [list, 6, 100]); // Off the end of the list. 405 nativeContext, 'setValue', list, 6, 100); // Off the end of the list.
393 expect(list.length, equals(7)); 406 expect(list.length, equals(7));
394 expect(list[4], equals(null)); 407 expect(list[4], equals(null));
395 expect(list[6], equals(100)); 408 expect(list[6], equals(100));
396 409
397 // These tests have to be commented out because we don't persist 410 // These tests have to be commented out because we don't persist
398 // JS proxies for Dart objects like we could/should. 411 // JS proxies for Dart objects like we could/should.
399 // context.callMethod('setValue', [list, -1, "foo"]); // Not a valid array index 412 // JsNative.callMethod3(nativeContext, 'setValue', list, -1, "foo"); // No t a valid array index
400 // expect(context.callMethod('getValue', [list, -1]), equals("foo")); 413 // expect(JsNative.callMethod2(nativeContext, 'getValue', list, -1), equal s("foo"));
401 // expect(context.callMethod('getValue', [list, "-1"]), equals("foo")); 414 // expect(JsNative.callMethod2(nativeContext, 'getValue', list, "-1"), equ als("foo"));
402 }); 415 });
403 416
404 test("get element", () { 417 test("get element", () {
405 var list = ["a", "b", "c", "d"]; 418 var list = ["a", "b", "c", "d"];
406 expect(context.callMethod('getValue', [list, 0]), equals("a")); 419 expect(JsNative.callMethod2(nativeContext, 'getValue', list, 0),
407 expect(context.callMethod('getValue', [list, 1]), equals("b")); 420 equals("a"));
408 expect(context.callMethod('getValue', [list, 6]), equals(null)); 421 expect(JsNative.callMethod2(nativeContext, 'getValue', list, 1),
409 expect(context.callMethod('getValue', [list, -1]), equals(null)); 422 equals("b"));
423 expect(JsNative.callMethod2(nativeContext, 'getValue', list, 6),
424 equals(null));
425 expect(JsNative.callMethod2(nativeContext, 'getValue', list, -1),
426 equals(null));
410 427
411 expect(context.callMethod('getValue', [list, "0"]), equals("a")); 428 expect(JsNative.callMethod2(nativeContext, 'getValue', list, "0"),
412 expect(context.callMethod('getValue', [list, "1"]), equals("b")); 429 equals("a"));
430 expect(JsNative.callMethod2(nativeContext, 'getValue', list, "1"),
431 equals("b"));
413 }); 432 });
414 433
415 test("is array", () { 434 test("is array", () {
416 var list = ["a", "b"]; 435 var list = ["a", "b"];
417 expect(context.callMethod("checkIsArray", [list]), isTrue); 436 expect(JsNative.callMethod1(nativeContext, "checkIsArray", list), isTrue);
418 }); 437 });
419 438
420 test("property descriptors", () { 439 test("property descriptors", () {
421 // This test matters to make behavior consistent with JS native arrays 440 // This test matters to make behavior consistent with JS native arrays
422 // and to make devtools integration work well. 441 // and to make devtools integration work well.
423 var list = ["a", "b"]; 442 var list = ["a", "b"];
424 expect(context.callMethod("getOwnPropertyDescriptorJson", [list, 0]), 443 expect(
444 JsNative.callMethod2(
445 nativeContext, "getOwnPropertyDescriptorJson", list, 0),
425 equals('{"value":"a",' 446 equals('{"value":"a",'
426 '"writable":true,' 447 '"writable":true,'
427 '"enumerable":true,' 448 '"enumerable":true,'
428 '"configurable":true}')); 449 '"configurable":true}'));
429 450
430 expect( 451 expect(
431 context.callMethod("getOwnPropertyDescriptorJson", [list, "length"]), 452 JsNative.callMethod2(
453 nativeContext, "getOwnPropertyDescriptorJson", list, "length"),
432 equals('{"value":2,' 454 equals('{"value":2,'
433 '"writable":true,' 455 '"writable":true,'
434 '"enumerable":false,' 456 '"enumerable":false,'
435 '"configurable":false}')); 457 '"configurable":false}'));
436 }); 458 });
437 459
438 test("concat js arrays", () { 460 test("concat js arrays", () {
439 var list = ["1", "2"]; 461 var list = ["1", "2"];
440 // Tests that calling the concat method from JS will flatten out JS arrays 462 // Tests that calling the concat method from JS will flatten out JS arrays
441 // We concat the array with "a", "b", ["c", "d"], 42, {foo: 10} 463 // We concat the array with "a", "b", ["c", "d"], 42, {foo: 10}
442 // which should generate ["1", "2", "a", "b", ["c", "d"], 42, {foo: 10}] 464 // which should generate ["1", "2", "a", "b", ["c", "d"], 42, {foo: 10}]
443 var ret = context.callMethod("concatValues", [list]); 465 var ret = JsNative.callMethod1(nativeContext, "concatValues", list);
444 expect(list.length, equals(2)); 466 expect(list.length, equals(2));
445 expect(ret.length, equals(8)); 467 expect(ret.length, equals(8));
446 expect(ret[0], equals("1")); 468 expect(ret[0], equals("1"));
447 expect(ret[3], equals("b")); 469 expect(ret[3], equals("b"));
448 expect(ret[5], equals("d")); 470 expect(ret[5], equals("d"));
449 expect(ret[6], equals(42)); 471 expect(ret[6], equals(42));
450 expect(ret[7]['foo'], equals(10)); 472 expect(ret[7].foo, equals(10));
451 }); 473 });
452 474
453 test("concat onto arrays", () { 475 test("concat onto arrays", () {
454 // This test only passes if we have monkey patched the core Array object 476 // This test only passes if we have monkey patched the core Array object
455 // prototype to handle Dart Lists. 477 // prototype to handle Dart Lists.
456 var list = ["a", "b"]; 478 var list = ["a", "b"];
457 var ret = context.callMethod("concatOntoArray", [list]); 479 var ret = JsNative.callMethod1(nativeContext, "concatOntoArray", list);
458 expect(list.length, equals(2)); 480 expect(list.length, equals(2));
459 expect(ret, equals([1, 2, 3, "a", "b", "foo"])); 481 expect(ret, equals([1, 2, 3, "a", "b", "foo"]));
460 }); 482 });
461 483
462 test("dart arrays on dart arrays", () { 484 test("dart arrays on dart arrays", () {
463 // This test only passes if we have monkey patched the core Array object 485 // This test only passes if we have monkey patched the core Array object
464 // prototype to handle Dart Lists. 486 // prototype to handle Dart Lists.
465 var list = ["a", "b"]; 487 var list = ["a", "b"];
466 var ret = callJsMethod(list, "concat", [["c", "d"], "e", ["f", "g"]]); 488 var ret = callJsMethod(list, "concat", [
489 ["c", "d"],
490 "e",
491 ["f", "g"]
492 ]);
467 expect(list.length, equals(2)); 493 expect(list.length, equals(2));
468 expect(ret, equals(["a", "b", "c", "d", "e", "f", "g"])); 494 expect(ret, equals(["a", "b", "c", "d", "e", "f", "g"]));
469 }); 495 });
470 496
471 test("every greater than zero", () { 497 test("every greater than zero", () {
472 expect(context.callMethod("everyGreaterThanZero", [[1, 5]]), isTrue); 498 expect(
473 expect(context.callMethod("everyGreaterThanZeroCheckThisArg", [[1, 5]]), 499 JsNative.callMethod1(nativeContext, "everyGreaterThanZero", [1, 5]),
474 isTrue); 500 isTrue);
475 expect(context.callMethod("everyGreaterThanZero", [[1, 0]]), isFalse); 501 expect(
476 expect(context.callMethod("everyGreaterThanZero", [[]]), isTrue); 502 JsNative.callMethod1(
503 nativeContext, "everyGreaterThanZeroCheckThisArg", [1, 5]),
504 isTrue);
505 expect(
506 JsNative.callMethod1(nativeContext, "everyGreaterThanZero", [1, 0]),
507 isFalse);
508 expect(JsNative.callMethod1(nativeContext, "everyGreaterThanZero", []),
509 isTrue);
477 }); 510 });
478 511
479 test("filter greater than 42", () { 512 test("filter greater than 42", () {
480 expect(context.callMethod("filterGreater42", [[1, 5]]), equals([])); 513 expect(JsNative.callMethod1(nativeContext, "filterGreater42", [1, 5]),
481 expect(context.callMethod("filterGreater42", [[43, 5, 49]]), 514 equals([]));
515 expect(
516 JsNative.callMethod1(nativeContext, "filterGreater42", [43, 5, 49]),
482 equals([43, 49])); 517 equals([43, 49]));
483 expect(context.callMethod("filterGreater42", [["43", "5", "49"]]), 518 expect(
519 JsNative.callMethod1(
520 nativeContext, "filterGreater42", ["43", "5", "49"]),
484 equals(["43", "49"])); 521 equals(["43", "49"]));
485 }); 522 });
486 523
487 test("for each collect result", () { 524 test("for each collect result", () {
488 expect(context.callMethod("forEachCollectResult", [[1, 5, 7]]), 525 expect(
526 JsNative.callMethod1(
527 nativeContext, "forEachCollectResult", [1, 5, 7]),
489 equals([2, 10, 14])); 528 equals([2, 10, 14]));
490 }); 529 });
491 530
492 test("some", () { 531 test("some", () {
493 expect(context.callMethod("someEqual42", [[1, 5, 9]]), isFalse); 532 expect(JsNative.callMethod1(nativeContext, "someEqual42", [1, 5, 9]),
494 expect(context.callMethod("someEqual42", [[1, 42, 9]]), isTrue); 533 isFalse);
534 expect(JsNative.callMethod1(nativeContext, "someEqual42", [1, 42, 9]),
535 isTrue);
495 }); 536 });
496 537
497 test("sort backwards", () { 538 test("sort backwards", () {
498 var arr = [1, 5, 9]; 539 var arr = [1, 5, 9];
499 var ret = context.callMethod("sortNumbersBackwards", [arr]); 540 var ret =
541 JsNative.callMethod1(nativeContext, "sortNumbersBackwards", arr);
500 expect(identical(arr, ret), isTrue); 542 expect(identical(arr, ret), isTrue);
501 expect(ret, equals([9, 5, 1])); 543 expect(ret, equals([9, 5, 1]));
502 }); 544 });
503 545
504 test("splice dummy items", () { 546 test("splice dummy items", () {
505 var list = [1, 2, 3, 4]; 547 var list = [1, 2, 3, 4];
506 var removed = context.callMethod("spliceDummyItems", [list]); 548 var removed =
549 JsNative.callMethod1(nativeContext, "spliceDummyItems", list);
507 expect(removed.length, equals(2)); 550 expect(removed.length, equals(2));
508 expect(removed[0], equals(2)); 551 expect(removed[0], equals(2));
509 expect(removed[1], equals(3)); 552 expect(removed[1], equals(3));
510 expect(list.first, equals(1)); 553 expect(list.first, equals(1));
511 expect(list[1], equals("quick")); 554 expect(list[1], equals("quick"));
512 expect(list[2], equals("brown")); 555 expect(list[2], equals("brown"));
513 expect(list[3], equals("fox")); 556 expect(list[3], equals("fox"));
514 expect(list.last, equals(4)); 557 expect(list.last, equals(4));
515 }); 558 });
516 559
517 test("splice string args", () { 560 test("splice string args", () {
518 var list = [1, 2, 3, 4]; 561 var list = [1, 2, 3, 4];
519 var removed = context.callMethod("spliceTestStringArgs", [list]); 562 var removed =
563 JsNative.callMethod1(nativeContext, "spliceTestStringArgs", list);
520 expect(removed.length, equals(2)); 564 expect(removed.length, equals(2));
521 expect(removed[0], equals(2)); 565 expect(removed[0], equals(2));
522 expect(removed[1], equals(3)); 566 expect(removed[1], equals(3));
523 expect(list.first, equals(1)); 567 expect(list.first, equals(1));
524 expect(list[1], equals("quick")); 568 expect(list[1], equals("quick"));
525 expect(list[2], equals("brown")); 569 expect(list[2], equals("brown"));
526 expect(list[3], equals("fox")); 570 expect(list[3], equals("fox"));
527 expect(list.last, equals(4)); 571 expect(list.last, equals(4));
528 }); 572 });
529 573
530 test("splice pastEndOfArray", () { 574 test("splice pastEndOfArray", () {
531 var list = [1, 2, 3, 4]; 575 var list = [1, 2, 3, 4];
532 var removed = context.callMethod("splicePastEnd", [list]); 576 var removed = JsNative.callMethod1(nativeContext, "splicePastEnd", list);
533 expect(removed.length, equals(3)); 577 expect(removed.length, equals(3));
534 expect(list.first, equals(1)); 578 expect(list.first, equals(1));
535 expect(list.length, equals(4)); 579 expect(list.length, equals(4));
536 expect(list[1], equals("quick")); 580 expect(list[1], equals("quick"));
537 expect(list[2], equals("brown")); 581 expect(list[2], equals("brown"));
538 expect(list[3], equals("fox")); 582 expect(list[3], equals("fox"));
539 }); 583 });
540 584
541 test("splice both bounds past end of array", () { 585 test("splice both bounds past end of array", () {
542 var list = [1]; 586 var list = [1];
543 var removed = context.callMethod("splicePastEnd", [list]); 587 var removed = JsNative.callMethod1(nativeContext, "splicePastEnd", list);
544 expect(removed.length, equals(0)); 588 expect(removed.length, equals(0));
545 expect(list.first, equals(1)); 589 expect(list.first, equals(1));
546 expect(list.length, equals(4)); 590 expect(list.length, equals(4));
547 expect(list[1], equals("quick")); 591 expect(list[1], equals("quick"));
548 expect(list[2], equals("brown")); 592 expect(list[2], equals("brown"));
549 expect(list[3], equals("fox")); 593 expect(list[3], equals("fox"));
550 }); 594 });
551 595
552 test("call List method on JavaScript object", () { 596 test("call List method on JavaScript object", () {
553 var jsObject = new JsObject.jsify({}); 597 var jsObject = JsNative.newLiteral();
554 callListMethodOnObject(jsObject, 'push', ["a"]); 598 callListMethodOnObject(jsObject, 'push', ["a"]);
555 callListMethodOnObject(jsObject, 'push', ["b"]); 599 callListMethodOnObject(jsObject, 'push', ["b"]);
556 callListMethodOnObject(jsObject, 'push', ["c", "d"]); 600 callListMethodOnObject(jsObject, 'push', ["c", "d"]);
557 callListMethodOnObject(jsObject, 'push', []); 601 callListMethodOnObject(jsObject, 'push', []);
558 602
559 expect(jsonStringify(jsObject), 603 expect(jsonStringify(jsObject),
560 equals('{"0":"a","1":"b","2":"c","3":"d","length":4}')); 604 equals('{"0":"a","1":"b","2":"c","3":"d","length":4}'));
561 605
562 expect(callListMethodOnObject(jsObject, 'pop', []), equals("d")); 606 expect(callListMethodOnObject(jsObject, 'pop', []), equals("d"));
563 expect(callListMethodOnObject(jsObject, 'join', ["#"]), equals("a#b#c")); 607 expect(callListMethodOnObject(jsObject, 'join', ["#"]), equals("a#b#c"));
564 608
565 var jsArray = new JsObject.jsify([]); 609 var jsArray = JsNative.newArray();
566 callListMethodOnObject(jsArray, 'push', ["a"]); 610 callListMethodOnObject(jsArray, 'push', ["a"]);
567 callListMethodOnObject(jsArray, 'push', ["b"]); 611 callListMethodOnObject(jsArray, 'push', ["b"]);
568 callListMethodOnObject(jsArray, 'push', ["c", "d"]); 612 callListMethodOnObject(jsArray, 'push', ["c", "d"]);
569 callListMethodOnObject(jsArray, 'push', []); 613 callListMethodOnObject(jsArray, 'push', []);
570 614
571 expect(jsonStringify(jsArray), equals('["a","b","c","d"]')); 615 expect(jsonStringify(jsArray), equals('["a","b","c","d"]'));
572 }); 616 });
573 }); 617 });
574 618
575 // This test group is disabled until we figure out an efficient way to 619 // This test group is disabled until we figure out an efficient way to
576 // distinguish between "array" Dart List types and non-array Dart list types. 620 // distinguish between "array" Dart List types and non-array Dart list types.
577 /* 621 /*
578 group('Non-array Lists', () { 622 group('Non-array Lists', () {
579 test('opaque proxy', () { 623 test('opaque proxy', () {
580 // Dartium could easily support making LinkedList and all other classes 624 // Dartium could easily support making LinkedList and all other classes
581 // implementing List behave like a JavaScript array but that would 625 // implementing List behave like a JavaScript array but that would
582 // be challenging to implement in dart2js until browsers support ES6. 626 // be challenging to implement in dart2js until browsers support ES6.
583 var list = ["a", "b", "c", "d"]; 627 var list = ["a", "b", "c", "d"];
584 var listView = new UnmodifiableListView(list.getRange(1,3)); 628 var listView = new UnmodifiableListView(list.getRange(1,3));
585 expect(listView is List, isTrue); 629 expect(listView is List, isTrue);
586 expect(listView.length, equals(2)); 630 expect(listView.length, equals(2));
587 expect(context.callMethod("checkIsArray", [listView]), isFalse); 631 expect(JsNative.callMethod1(nativeContext, "checkIsArray", listView), isFa lse);
588 expect(context.callMethod("checkIsArray", [listView.toList()]), isTrue); 632 expect(JsNative.callMethod1(nativeContext, "checkIsArray", listView.toList ()), isTrue);
589 expect(context.callMethod("getOwnPropertyDescriptorJson", 633 expect(JsNative.callMethod2(nativeContext, "getOwnPropertyDescriptorJson",
590 [listView, "length"]), equals("null")); 634 listView, "length"), equals("null"));
591 }); 635 });
592 }); 636 });
593 */ 637 */
594 } 638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698