RegressionTests__JavaScriptTestClass.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2006 60c218197fb0
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2001
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
public class RegressionTests::JavaScriptTestClass extends Object
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
{
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
/** category: testing **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
/**
2005
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
     9
    (new JavaScriptTestClass).testForLoop1()
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    10
 **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    11
function testForLoop1() {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    12
    var sum = 0;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    13
    
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    14
    for (var i=0; i<10; i++) {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    15
        sum += i;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    16
    }
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    17
    return sum;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    18
}
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    19
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    20
/** category: testing **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    21
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    22
/**
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    23
    (new JavaScriptTestClass).testForLoop2()
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    24
 **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    25
function testForLoop2() {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    26
    for (; ; ) {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    27
        return 0;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    28
    }
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    29
    return 1;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    30
}
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    31
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    32
/** category: testing **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    33
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    34
/**
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    35
    (new JavaScriptTestClass).testForLoop3()
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    36
 **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    37
function testForLoop3() {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    38
    var i = 0;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    39
    
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    40
    for (; ; ) {
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    41
        if (i == 10) return 0;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    42
        i++;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    43
    }
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    44
    return 1;
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    45
}
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    46
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    47
/** category: testing **/
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    48
4c96619d8445 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2004
diff changeset
    49
/**
2006
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    50
    (new JavaScriptTestClass).testInnerFunction1()
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    51
 **/
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    52
function testInnerFunction1() {
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    53
    function f(x) {
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    54
        if (x === 0) return 1;
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    55
        Transcript.showCR(x);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    56
        return 0;
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    57
    }
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    58
    
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    59
    return f(1);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    60
}
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    61
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    62
/** category: testing **/
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    63
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    64
/**
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    65
    (new JavaScriptTestClass).testInnerFunction2()
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    66
 **/
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    67
function testInnerFunction2() {
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    68
    function f(x) {
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    69
        function g(x) {
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    70
            if (x === 0) return 1;
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    71
            Transcript.showCR(x);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    72
            return 0;
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    73
        }
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    74
        
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    75
        if (x === 0) return g(1);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    76
        Transcript.showCR(x);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    77
        return g(0);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    78
    }
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    79
    
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    80
    return f(1);
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    81
}
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    82
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    83
/** category: testing **/
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    84
60c218197fb0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2005
diff changeset
    85
/**
2001
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    (new JavaScriptTestClass).testMap1()
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
 **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
function testMap1() {
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    return [1,2,3].map( el => el ** 2 );
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
/** category: testing **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
/**
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    (new JavaScriptTestClass).testMap2()
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
 **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
function testMap2() {
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    return [1,2,3].map( (el) => el ** 2 );
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
/** category: testing **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
/**
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    (new JavaScriptTestClass).testMap3()
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
 **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
function testMap3() {
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    return [1,2,3].map( (el) => { return el ** 2; } );
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
/** category: testing **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
/**
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    (new JavaScriptTestClass).testMap4()
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
 **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
function testMap4() {
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    function f(el) { return el ** 2; };
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    return [1,2,3].map( f );
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
/** category: testing **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
/**
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    (new JavaScriptTestClass).testMap5()
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
 **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
function testMap5() {
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    function f(el) { 
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        return el ** 2; 
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    }
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    return [1,2,3].map( f );
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2003
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   134
/** category: testing **/
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   135
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   136
/**
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   137
    (new JavaScriptTestClass).testMap6()
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   138
 **/
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   139
function testMap6() {
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   140
    var f = function (el) { return el ** 2; };
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   141
    
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   142
    return [1,2,3].map( f );
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   143
}
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   144
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   145
/** category: testing **/
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   146
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   147
/**
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   148
    (new JavaScriptTestClass).testMap7()
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   149
 **/
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   150
function testMap7() {
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   151
    var f = el => el ** 2;
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   152
    
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   153
    return [1,2,3].map( f );
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   154
}
710ddabaec76 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   155
2004
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   156
/** category: testing **/
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   157
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   158
/**
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   159
    (new JavaScriptTestClass).testMap8()
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   160
 **/
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   161
function testMap8() {
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   162
    var f = (el => el ** 2);
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   163
    
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   164
    return [1,2,3].map( f );
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   165
}
3b06c74f24b7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2003
diff changeset
   166
2001
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
/** category: documentation **/
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
2002
721352c71cac #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   170
static function version_CVS() {
2001
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    return("$Header$");
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
}
6fa077edd661 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173