@@ -430,6 +430,11 @@ new Test.Unit.Runner({
430
430
this . assert ( ! 'hello world' . startsWith ( 'bye' ) ) ;
431
431
this . assert ( ! '' . startsWith ( 'bye' ) ) ;
432
432
this . assert ( ! 'hell' . startsWith ( 'hello' ) ) ;
433
+
434
+ var str = "To be, or not to be, that is the question" ;
435
+ this . assert ( str . startsWith ( "To be" ) , 'str.startsWith("To be")' ) ;
436
+ this . assert ( ! str . startsWith ( "not to be" ) , 'str.startsWith("not to be")' ) ;
437
+ this . assert ( str . startsWith ( "not to be" , 10 ) , 'str.startsWith("not to be", 10)' ) ;
433
438
} ,
434
439
435
440
testEndsWith : function ( ) {
@@ -439,6 +444,25 @@ new Test.Unit.Runner({
439
444
this . assert ( ! '' . endsWith ( 'planet' ) ) ;
440
445
this . assert ( 'hello world world' . endsWith ( ' world' ) ) ;
441
446
this . assert ( ! 'z' . endsWith ( 'az' ) ) ;
447
+
448
+ var str = "To be, or not to be, that is the question" ;
449
+ this . assert ( str . endsWith ( "question" ) , 'str.endsWith("question")' ) ;
450
+ this . assert ( ! str . endsWith ( "to be" ) , 'str.endsWith("to be")' ) ;
451
+ this . assert ( str . endsWith ( "to be" , 19 ) , 'str.endsWith("to be", 19)' ) ;
452
+
453
+ str = "12345" ;
454
+ this . assert ( str . endsWith ( "5" ) ) ;
455
+ this . assert ( str . endsWith ( "5" , 6 ) ) ;
456
+ this . assert ( str . endsWith ( "5" , 5 ) ) ;
457
+ this . assert ( ! str . endsWith ( "5" , 4 ) ) ;
458
+ this . assert ( ! str . endsWith ( "5" , 1 ) ) ;
459
+ this . assert ( ! str . endsWith ( "5" , 0 ) ) ;
460
+
461
+ this . assert ( str . endsWith ( "1" , 1 ) ) ;
462
+ this . assert ( ! str . endsWith ( "1" , 0 ) ) ;
463
+ this . assert ( ! str . endsWith ( "1" , - 1 ) ) ;
464
+
465
+ this . assert ( str . endsWith ( "" , 0 ) ) ;
442
466
} ,
443
467
444
468
testBlank : function ( ) {
@@ -551,4 +575,4 @@ new Test.Unit.Runner({
551
575
this . assertIdentical ( false , 'false' . evalJSON ( ) ) ;
552
576
this . assertEqual ( '"' , '"\\""' . evalJSON ( ) ) ;
553
577
}
554
- } ) ;
578
+ } ) ;
0 commit comments