gdi32: Try to parse font names without FreeType.
[wine/zf.git] / dlls / jscript / tests / sunspider-string-validate-input.js
bloba027174be6a098d790da2e52b85ca4fe9a6a3dfc
1 letters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
2 numbers = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
3 colors  = new Array("FF","CC","99","66","33","00");
5 var endResult;
7 function doTest()
9    endResult = "";
11    // make up email address
12    for (var k=0;k<4000;k++)
13    {
14       username = makeName(6);
15       (k%2)?email=username+"@mac.com":email=username+"(at)mac.com";
17       // validate the email address
18       var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/;
20       if(pattern.test(email))
21       {
22          var r = email + " appears to be a valid email address.";
23          addResult(r);
24       }
25       else
26       {
27          r = email + " does NOT appear to be a valid email address.";
28          addResult(r);
29       }
30    }
32    // make up ZIP codes
33    for (var s=0;s<4000;s++)
34    {
35       var zipGood = true;
36       var zip = makeNumber(4);
37       (s%2)?zip=zip+"xyz":zip=zip.concat("7");
39       // validate the zip code
40       for (var i = 0; i < zip.length; i++) {
41           var ch = zip.charAt(i);
42           if (ch < "0" || ch > "9") {
43               zipGood = false;
44               r = zip + " contains letters.";
45               addResult(r);
46           }
47       }
48       if (zipGood && zip.length>5)
49       {
50          zipGood = false;
51          r = zip + " is longer than five characters.";
52          addResult(r);
53       }
54       if (zipGood)
55       {
56          r = zip + " appears to be a valid ZIP code.";
57          addResult(r);
58       }
59    }
62 function makeName(n)
64    var tmp = "";
65    for (var i=0;i<n;i++)
66    {
67       var l = Math.floor(26*Math.random());
68       tmp += letters[l];
69    }
70    return tmp;
73 function makeNumber(n)
75    var tmp = "";
76    for (var i=0;i<n;i++)
77    {
78       var l = Math.floor(9*Math.random());
79       tmp = tmp.concat(l);
80    }
81    return tmp;
84 function addResult(r)
86    endResult += "\n" + r;
89 doTest();