mirror of
https://github.com/SSCLI/sscli_20021101
synced 2026-06-08 12:28:57 +00:00
9fa3874800
Moved the original file to the archive subfolder.
139 lines
3.8 KiB
JavaScript
139 lines
3.8 KiB
JavaScript
//# ==++==
|
|
//#
|
|
//#
|
|
//# Copyright (c) 2002 Microsoft Corporation. All rights reserved.
|
|
//#
|
|
//# The use and distribution terms for this software are contained in the file
|
|
//# named license.txt, which can be found in the root of this distribution.
|
|
//# By using this software in any fashion, you are agreeing to be bound by the
|
|
//# terms of this license.
|
|
//#
|
|
//# You must not remove this notice, or any other, from this software.
|
|
//#
|
|
//#
|
|
//# ==--==
|
|
//####################################################################################
|
|
@cc_on
|
|
|
|
|
|
import System;
|
|
|
|
var NULL_DISPATCH = null;
|
|
var apGlobalObj;
|
|
var apPlatform;
|
|
var lFailCount;
|
|
|
|
|
|
var iTestID = 53660;
|
|
|
|
function subst02() {
|
|
|
|
apInitTest("subst02 ");
|
|
|
|
var Result , Expected;
|
|
var StringVar;
|
|
var SINGLEVar;
|
|
|
|
apInitScenario(" 1: Use substring() with a numeric constant for the start value.");
|
|
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring(5,2.01);
|
|
Expected = "sti"
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE constant START failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apInitScenario(" 2: Use substring() with a numeric variable for the start value.");
|
|
|
|
SINGLEVar = 2.999;
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring( SINGLEVar, 6);
|
|
Expected = "stin";
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE variable START failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apInitScenario(" 3: Use substring() with a numeric expression for the start value.");
|
|
|
|
SINGLEVar = 1.99;
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring( 5,SINGLEVar * 2);
|
|
Expected = "ti";
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE variable START failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apInitScenario(" 4: Use substring() with a numeric constant for the end value.");
|
|
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring( 4.999,2);
|
|
Expected = "st";
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE constant LENGTH failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apInitScenario(" 5: Use substring() with a numeric variable for the end value.");
|
|
|
|
SINGLEVar = 7.999;
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring( 4, SINGLEVar);
|
|
Expected = "ing";
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE variable LENGTH failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apInitScenario(" 6: Use substring() with a numeric expression for the end value.");
|
|
|
|
SINGLEVar = 15.999;
|
|
StringVar = "Testing MID";
|
|
Result = StringVar.substring( 5, SINGLEVar / 2)
|
|
Expected = "ng"
|
|
|
|
if ( Result != Expected ) {
|
|
apLogFailInfo("SINGLE expression LENGTH failed" ,Expected,Result,"");
|
|
}
|
|
|
|
apEndTest();
|
|
|
|
}
|
|
|
|
|
|
subst02();
|
|
|
|
|
|
if(lFailCount >= 0) System.Environment.ExitCode = lFailCount;
|
|
else System.Environment.ExitCode = 1;
|
|
|
|
function apInitTest(stTestName) {
|
|
lFailCount = 0;
|
|
|
|
apGlobalObj = new Object();
|
|
apGlobalObj.apGetPlatform = function Funca() { return "Rotor" }
|
|
apGlobalObj.LangHost = function Funcb() { return 1033;}
|
|
apGlobalObj.apGetLangExt = function Funcc(num) { return "EN"; }
|
|
|
|
apPlatform = apGlobalObj.apGetPlatform();
|
|
var sVer = "1.0"; //navigator.appVersion.toUpperCase().charAt(navigator.appVersion.toUpperCase().indexOf("MSIE")+5);
|
|
apGlobalObj.apGetHost = function Funcp() { return "Rotor " + sVer; }
|
|
print ("apInitTest: " + stTestName);
|
|
}
|
|
|
|
function apInitScenario(stScenarioName) {print( "\tapInitScenario: " + stScenarioName);}
|
|
|
|
function apLogFailInfo(stMessage, stExpected, stActual, stBugNum) {
|
|
lFailCount = lFailCount + 1;
|
|
print ("***** FAILED:");
|
|
print ("\t\t" + stMessage);
|
|
print ("\t\tExpected: " + stExpected);
|
|
print ("\t\tActual: " + stActual);
|
|
}
|
|
|
|
function apGetLocale(){ return 1033; }
|
|
function apWriteDebug(s) { print("dbg ---> " + s) }
|
|
function apEndTest() {}
|