diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-02-03 20:03:36 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-02-03 20:03:36 +0100 |
commit | 209c6412ae149cc7c503fd7da384f344a830423c (patch) | |
tree | 5baeaeb8dee2208b46bf80a118dfe59eb65f9389 /src/CBot/tests/scenarios | |
parent | 3f41f97fc47fca22634dc858c3ecdb39d0d27e32 (diff) | |
download | colobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.gz colobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.bz2 colobot-209c6412ae149cc7c503fd7da384f344a830423c.zip |
Refactoring in tests infrastructure
* all tests are now in /test/ subdirectory
* unit tests concatenated to one executable (TODO: ui, common)
* preparation for test environments (OpenGL and others)
* removed old TestCBot
Diffstat (limited to 'src/CBot/tests/scenarios')
51 files changed, 0 insertions, 1453 deletions
diff --git a/src/CBot/tests/scenarios/B.txt b/src/CBot/tests/scenarios/B.txt deleted file mode 100644 index 53715f8..0000000 --- a/src/CBot/tests/scenarios/B.txt +++ /dev/null @@ -1,18 +0,0 @@ -
- float [ ] TEST2 ( int [ ] param )
- {
- float [ ] z;
- for ( int i = 0 ; i < sizeof( param ) ; i++ ) try { z [i] = param [i] / 3; }
- return z;
- }
-
-extern public void T()
-{
- int a [4];
- for ( int i = 0 ; i < 3 ; i++ ) a[i] = 4*i;
- a [2] = 22;
-
- float [] b ;
- b = TEST2 ( a ) ;
- show ( a, b );
-}
diff --git a/src/CBot/tests/scenarios/BUG2.txt b/src/CBot/tests/scenarios/BUG2.txt deleted file mode 100644 index 44de05a..0000000 --- a/src/CBot/tests/scenarios/BUG2.txt +++ /dev/null @@ -1,107 +0,0 @@ -object object :: TT ( int n )
-{
- object XX = radar();
- if ( n == 0 ) return null;
-
- while ( null == XX ) XX = radar();
- return XX;
-}
-
-extern void object::Attack( )
-{
- show ( TT ( 0 ) ) ;
- show ( TT ( 1 ) ) ;
- return;
-
- int list[];
- int i;
- object p;
- float dist, prox;
- point dest;
- boolean advance = true;
-
- TEST(0); // ne stoppe pas si erreur
-// while ( F () != 0 ) F(1);
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
- list[i++] = 3333;
- list[i++] = 3334;
- list[i++] = 3335;
- list[i++] = 3336;
- list[i++] = 3337;
- list[i++] = 3338;
- list[i++] = 3339;
- list[i++] = 3331;
- list[i++] = 3332;
- list[i++] = 3330;
- list[i++] = 1111;
- list[i++] = 1112;
-
- F(F(0));
-
- while ( true )
- {
- p = radar(list, 0, 360, 0, 1000);
- if ( p == null )
- {
- F(2);
- }
- else
- {
- dist = F(p.position, position);
- if ( dist <= 40 && !advance )
- {
- fire(p.position);
- advance = true;
- }
- else
- {
-//? if ( RetBaseDistance() > 20 )
- {
- prox = dist-(5+F()*5);
- if ( prox < 5 ) prox = 5;
- dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
- dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
- dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
- goto(dest);
- advance = false;
- }
- }
- }
- }
-}
-
-// Calcule la distance jusqu'à la base.
-
-float object::RetBaseDistance()
-{
- object p;
- float dist;
-
- p = radar(4444, 0, 360, 0, 1000);
- if ( p == null ) return 1000;
- dist = F(p.position, position);
- return dist;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/Deleted.txt b/src/CBot/tests/scenarios/Deleted.txt deleted file mode 100644 index 469a624..0000000 --- a/src/CBot/tests/scenarios/Deleted.txt +++ /dev/null @@ -1,23 +0,0 @@ -public extern void object :: ESSAI()
-{
- while(true)
- {
- if ( true )
- {
- goto(12);
- break;
- }
- }
- object x = null ;
-
- while ( x == null ) x = radar();
-
- show ( x.position ) ;
-
- TEST(5, x);
-
- if ( x == null ) show ( "DELETED" );
-
- show ( x.position ) ;
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/MaClass.txt b/src/CBot/tests/scenarios/MaClass.txt deleted file mode 100644 index ac472b4..0000000 --- a/src/CBot/tests/scenarios/MaClass.txt +++ /dev/null @@ -1,16 +0,0 @@ -
-class MaClass
-{
- int a = 1 ;
- MaClass pointeur ;
- MaClass next = null ;
- CPoint autre = new CPoint( 1 , 1 ) ;
-}
-
-extern public void Test ( )
-{
- MaClass x () ;
- x.next = new MaClass ( ) ;
- println ( x ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/Mc2.txt b/src/CBot/tests/scenarios/Mc2.txt deleted file mode 100644 index 172c259..0000000 --- a/src/CBot/tests/scenarios/Mc2.txt +++ /dev/null @@ -1,4 +0,0 @@ -class MaClass
-{
- int t = 12;
-}
diff --git a/src/CBot/tests/scenarios/Mon fichier.txt b/src/CBot/tests/scenarios/Mon fichier.txt deleted file mode 100644 index 6b35bf8..0000000 --- a/src/CBot/tests/scenarios/Mon fichier.txt +++ /dev/null @@ -1,2 +0,0 @@ -Voici encore du texte
-et une seconde ligne
diff --git a/src/CBot/tests/scenarios/Nop.txt b/src/CBot/tests/scenarios/Nop.txt deleted file mode 100644 index 6a66f6f..0000000 --- a/src/CBot/tests/scenarios/Nop.txt +++ /dev/null @@ -1,4 +0,0 @@ -public extern void Nop()
-{
- while ( true ) {}
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/POS.txt b/src/CBot/tests/scenarios/POS.txt deleted file mode 100644 index 688e4fb..0000000 --- a/src/CBot/tests/scenarios/POS.txt +++ /dev/null @@ -1,14 +0,0 @@ -void object :: T ( )
-{
- show ( position ) ;
-}
-
-public extern void object :: POS()
-{
- for ( int i = 0; i < 10 ; i++ )
- {
- if ( i == 2 ) TEST ( 12 ) ;
-// show ( position );
- T ( ) ;
- }
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/T.txt b/src/CBot/tests/scenarios/T.txt deleted file mode 100644 index 50a792b..0000000 --- a/src/CBot/tests/scenarios/T.txt +++ /dev/null @@ -1,4 +0,0 @@ -public extern int T ( float n )
-{
- return n * 1.1;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TESTALL.txt b/src/CBot/tests/scenarios/TESTALL.txt deleted file mode 100644 index 82247a0..0000000 --- a/src/CBot/tests/scenarios/TESTALL.txt +++ /dev/null @@ -1,161 +0,0 @@ -int T ( int z )
-{
- return 45 + z ;
-}
-
-class toto
-{
- int val = 3 ;
- int x = 3 * 3 ;
- void toto( int n )
- { val = n + 3 ; }
- int retval ( int param )
- { int r = val + param + x ;
- val = param ;
- return r ; }
-}
-
-public extern void object :: Chose( )
-{
- int z [ 6 ];
- for ( int i = 0 ; i < 6 ; ) z [ i++ ] = 3 - i ;
- show ( z ) ;
- return;
-
- // test des tableaux
- int [ ] a [ 3 ] ;
-// a = null;
- if ( a == null ) show ( "NULL" );
-
- a [ 2 / 2 ] [ 2 ]= 5 ;
- int [ ] b ; b = a [1] ;
- b [ 0 ] = -4;
- a [ 4 / 2 ] [ 1 ]= 1 ;
- show ( a , b ) ;
- return ;
- {
- toto chose = new toto (5 ) ;
- toto truc = chose ;
- show ( chose, chose.retval( 100 ) ,
- truc, truc.retval (40 ) ) ;
-
- return;
- }
- {
- point A = new
- point ( 4 * 4 , 2 ) ;
- show ( A ) ;
- return;
- }
- {
- show ( T ( 1 ) , T ( 3.7 ) ) ;
- return;
- }
-
- {
- point A ( 3, 4 ) ,
- B = A ;
-
- int n = -4;
- show ( n );
-
- show ( A, B ) ;
-
- boolean a = false;
- boolean b = a or true;
- if ( not a and b ) ;
- return;
- }
- {
- // test try
- float x = nan ; int z = 0 ;
- try {
-// throw ( 3 * 4 + 33 ) ;
- int zz ; goto ( 12 ) ; z = 1 ; z = 0 / 0 ; z = 2 ;
- }
- catch ( 45 + 0 * 6000 )
- {
- show( "Exception 6000", z ) ;
- }
- catch ( x == 0 ) { show( "x nul" ) ; }
- finally { show ( "fini" ) ; }
- show ( "continue" );
- return;
- }
- {
- // test des if
- int a = 3;
- if ( a == 3 ) show ( "33");
- else show ( "44");
- if ( a != 3 ) show ( "333");
- else show ( "444");
- return;
- }
- {
- int a = 0;
- // test break
-un:
- while ( true )
- {
-deux:
- while ( true )
- {
- a++;
- if ( a == 2 ) continue;
- if ( a == 3 ) break deux;
- show ( a ) ;
- if ( a == 5 ) break un;
- }
- show ( "DEUX" );
- }
- return;
- }
- {
- // test switch
- int a = 0;
-
- switch ( a )
- {
- case 1 : show( "un" ) ; break;
- case 2 : show( "deux" ) ; // break;
- case 3 : show( "trois" ) ; break;
- case 4 : show( "quatre" ) ; // break;
- default : show( "par défaut" ) ;
- }
- return;
- }
- {
- // test boucle while
- float z = 3.3;
- while ( z > 0 )
- { show ( z-- ) ; }
- return;
- }
-
- {
- // test boucle do
- float y = 3.3;
- do { int x = 0; show(y); y++; } while ( y < 7 ) ;
- return;
- }
- // test boucle for
- int j = -7; show ( j );
- for ( int ii = 3, j = 31; ii < 6 ; ++ii, j = j -3 )
- {
- j = 10 * j;
- show ( ii, j );
- }
- return;
-{
- // déclarations de variables
- int a; int b = 3; int c = 4*b, d = 1, e;
- float x; float y = 3.3; float z = y / 2, u = 1, v;
- boolean t; boolean tt = true or false; boolean ttt = false, tttt = true, t5;
- string s; string ss = "hello"; string s2 = ss + " plus", s3 = "s3", s4;
-
- show( b, c, d );
- show( y, z, u );
- show( tt, ttt, tttt );
- show( ss, s2, s3 );
-}
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestCB1.txt b/src/CBot/tests/scenarios/TestCB1.txt deleted file mode 100644 index 516db47..0000000 --- a/src/CBot/tests/scenarios/TestCB1.txt +++ /dev/null @@ -1,18 +0,0 @@ -extern public void toto()
-{
- print( "hello" ) ;
- print( fac(5) );
- print( t() ) ;
-}
-
-public int fac(int n)
-{
- if ( n<2 ) return 1;
- return n * fac(n-1);
-}
-
-point t()
-{
- point a(1,2);
- return a;
-}
diff --git a/src/CBot/tests/scenarios/TestCBot1.txt b/src/CBot/tests/scenarios/TestCBot1.txt deleted file mode 100644 index d27b4f8..0000000 --- a/src/CBot/tests/scenarios/TestCBot1.txt +++ /dev/null @@ -1,27 +0,0 @@ -
-class CPoint2
-{
- float x, y;
- void CPoint2(float x, float y)
- {
- this.x = x;
- this.y = y;
- }
-}
-
-public extern void T ( )
-{
- CPoint2 X( 12, 33 ), Y ( -4, 4/3 );
- print ( X, Y ) ;
-}
-
-public extern void Hello ( )
-
-{
- println ( "Hello" );
-}
-
-public extern void test ( int n )
-{
- for ( int i = n; i>0 ; i--) print (i);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestCBot3.txt b/src/CBot/tests/scenarios/TestCBot3.txt deleted file mode 100644 index b915f96..0000000 --- a/src/CBot/tests/scenarios/TestCBot3.txt +++ /dev/null @@ -1,24 +0,0 @@ -public extern void Test ()
-{
- for ( int x = 100000; x>0 ; x-- ) { }
-}
-
-float MaRoutine( CPoint A, CPoint B )
-{
- A.x -= B.x ; // distance en x
- A.y -= B.y ; // distance en y
- A.x *= A.x; // carré de la distance
- A.y += A.y; // carré de la distance
- println ( A, B ) ;
- return ( A.x + A.y ) ;
-}
-
-public extern void TestAB ( )
-{
- CPoint A(3, 5) ;
- CPoint B(4, -2);
- println ( A, B ) ;
- MaRoutine( A, B ) ;
- println ( A, B ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/TestNull.txt b/src/CBot/tests/scenarios/TestNull.txt deleted file mode 100644 index f447245..0000000 --- a/src/CBot/tests/scenarios/TestNull.txt +++ /dev/null @@ -1,15 +0,0 @@ -extern public void TestNull ()
-{
- CPoint pointeur = null;
-
- try {
- pointeur.x = 4; }
- catch ( 6007 ) {}
-
- pointeur = new CPoint(1,2);
-
- print ( pointeur.x, pointeur.y,
- pointeur );
-
- pointeur.x = 5;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestRestoreState.txt b/src/CBot/tests/scenarios/TestRestoreState.txt deleted file mode 100644 index 1e49e37..0000000 --- a/src/CBot/tests/scenarios/TestRestoreState.txt +++ /dev/null @@ -1,67 +0,0 @@ -// routine de Daniel qui plante après RestoreState
-
-extern void object::Attack( )
-{
- int list[], i;
- object p;
- float dist, prox;
- point nav1, nav2, dest;
- boolean advance = true;
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
-
- nav1.x = 1;//cmdline(0);
- nav1.y = 1;//cmdline(1);
- nav2.x = 2;//cmdline(2);
- nav2.y = 2;//cmdline(3);
-
- while ( true )
- {
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point A
- goto(nav1);
-
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point B
- goto(nav2);
- }
-}
-
diff --git a/src/CBot/tests/scenarios/TestStatic.txt b/src/CBot/tests/scenarios/TestStatic.txt deleted file mode 100644 index f501aa5..0000000 --- a/src/CBot/tests/scenarios/TestStatic.txt +++ /dev/null @@ -1,31 +0,0 @@ -class ESSAI
-{
- int x = 0;
- static int nb = 3;
- static int [ ] array ;
-
- void Put( int val)
- {
-show(nb);
- array[ nb ] = val;
-// this.nb++;
- this.nb = this.nb + 1;
-show(nb, array);
- }
- int Get( )
- {
- nb--;
-show("out", nb, array);
- return array[ nb ] ;
- }
-}
-
-extern public void T()
-{
- ESSAI t1 ( ) ;
- ESSAI t2 ( ) ;
- t1.nb++;
- t1.Put( 11 ); t1.Put( 12 ); t2.Put( 13 );
-
- show ( t1.Get(), t2.Get(), t2.Get() ) ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestStr.txt b/src/CBot/tests/scenarios/TestStr.txt deleted file mode 100644 index 683ec1b..0000000 --- a/src/CBot/tests/scenarios/TestStr.txt +++ /dev/null @@ -1,17 +0,0 @@ -extern public void TSTR()
-{
- string s = "C'est un essai";
-
- print ( s, strlen(s), strleft(s, 3), strright(s,3), strmid(s, 2), strmid(s,2,3), strfind(s, "un"), strfind(s, "sdgfld") );
-
- show ( strupper(s), strlower(s) );
-
- s = "123.45" ;
- print ( strval(s) );
-
-
- string sub = strright("abcdef", 2); // sub vaut "ef###", # étant un caractère bizarre quelconque
- show (sub);
- int pos = strfind("abcdef", "xy"); // pos vaut -1. Pourquoi pas nan ?
- show(pos);
-}
diff --git a/src/CBot/tests/scenarios/Z.txt b/src/CBot/tests/scenarios/Z.txt deleted file mode 100644 index 714119b..0000000 --- a/src/CBot/tests/scenarios/Z.txt +++ /dev/null @@ -1,14 +0,0 @@ -public extern void tp()
-{
- int a [4], b[];
- a [ 0 ] = 8 ;
-
- b = T ( a ) ;
- show ( a, b );
-}
-
-int[] T ( int[] Z )
-{
- for ( int i = 0; i < 4 ; i++ ) Z[ i ] = i * i ;
- return Z;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/a1.txt b/src/CBot/tests/scenarios/a1.txt deleted file mode 100644 index 165bc95..0000000 --- a/src/CBot/tests/scenarios/a1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist) -{ - int i; - object pr, r; - float mindist; - - i = 0; - mindist = 1000; - while (i<30) - { - pr = radar(i); - if (pr != null) - { - - if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3) - { - mindist = distance(orig, pr.position); - r = pr; - } - } - i = i+1; - } - if (mindist < dist) return(r); else return(null); -} - - -class Guepe -{ - - point pos; - - - void cherche(point orig, float dist) - { - object p; - point o; - - p = radarGuepe(orig, dist); - while (p == null) - { - wait(0.1); - p = radarGuepe(orig, dist); - } - - pos.x = p.position.x; - pos.y = p.position.y; - pos.z = p.position.z; - - //o = p.position; - //wait(0.1); - - //vitessex = (p.position.x - o.x)/0.1; - //vitessey = (p.position.y - o.y)/0.1; - //vitessez = (p.position.z - o.z)/0.1; - - } - - - void tire(point orig, float orient) - { - //float t = 3; //temps d'anticipation - float angle; - point cible; - - cible.x = pos.x;// + t*vitessex; - cible.y = pos.y;// + t*vitessey; - cible.z = pos.z;// + t*vitessez; - - if (cible.x == 0) angle = 90; else - angle = atan(cible.y / cible.x); - if (cible.x < 0) angle = angle + 180; - angle = angle - orient; - if (angle > 180) angle = angle - 360; - if (angle < -180) angle = angle + 360; - turn(angle); - - angle = atan((cible.z-orig.z) / distance2d(orig, cible)); - aim(angle); - - fire(0.1); - - } -} - -extern void object::Fourmi6() -{ - //fps(1000); - Guepe guepe = new Guepe(); - - while (true) - { - guepe.cherche(position, 50); - - guepe.tire(position, orientation); - } -} diff --git a/src/CBot/tests/scenarios/array.txt b/src/CBot/tests/scenarios/array.txt deleted file mode 100644 index 081b60e..0000000 --- a/src/CBot/tests/scenarios/array.txt +++ /dev/null @@ -1,24 +0,0 @@ -
-public extern void TestTableau ()
-{
- int tableau [ 12 ] ;
-
- point array[ 12 ] [ 14 ] ;
-
- point zéro ( 1, 2 ) ;
- point a = zéro ;
-
- for ( int i = 0 ; i < 10 ; i++ ) array[ i ] [ i ]= zéro ;
-
- array[ 5 ] [3 ] . x =1.5 ;
-
- array[ 2 ] [ 2 ] . y = array[ 5 ] [ 5 ] . x ;
-
- array[ 4 ] = array [ 2 ] ;
-
- for ( int i = 0 ; i < 10 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) println ( i, j, array [ i ] [ j ] ) ;
-
- show( zéro, a, array );
-
-}
-
diff --git a/src/CBot/tests/scenarios/až1.txt b/src/CBot/tests/scenarios/až1.txt deleted file mode 100644 index 165bc95..0000000 --- a/src/CBot/tests/scenarios/až1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist) -{ - int i; - object pr, r; - float mindist; - - i = 0; - mindist = 1000; - while (i<30) - { - pr = radar(i); - if (pr != null) - { - - if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3) - { - mindist = distance(orig, pr.position); - r = pr; - } - } - i = i+1; - } - if (mindist < dist) return(r); else return(null); -} - - -class Guepe -{ - - point pos; - - - void cherche(point orig, float dist) - { - object p; - point o; - - p = radarGuepe(orig, dist); - while (p == null) - { - wait(0.1); - p = radarGuepe(orig, dist); - } - - pos.x = p.position.x; - pos.y = p.position.y; - pos.z = p.position.z; - - //o = p.position; - //wait(0.1); - - //vitessex = (p.position.x - o.x)/0.1; - //vitessey = (p.position.y - o.y)/0.1; - //vitessez = (p.position.z - o.z)/0.1; - - } - - - void tire(point orig, float orient) - { - //float t = 3; //temps d'anticipation - float angle; - point cible; - - cible.x = pos.x;// + t*vitessex; - cible.y = pos.y;// + t*vitessey; - cible.z = pos.z;// + t*vitessez; - - if (cible.x == 0) angle = 90; else - angle = atan(cible.y / cible.x); - if (cible.x < 0) angle = angle + 180; - angle = angle - orient; - if (angle > 180) angle = angle - 360; - if (angle < -180) angle = angle + 360; - turn(angle); - - angle = atan((cible.z-orig.z) / distance2d(orig, cible)); - aim(angle); - - fire(0.1); - - } -} - -extern void object::Fourmi6() -{ - //fps(1000); - Guepe guepe = new Guepe(); - - while (true) - { - guepe.cherche(position, 50); - - guepe.tire(position, orientation); - } -} diff --git a/src/CBot/tests/scenarios/a§1.txt b/src/CBot/tests/scenarios/a§1.txt deleted file mode 100644 index 0c57950..0000000 --- a/src/CBot/tests/scenarios/a§1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/scenarios/bug.txt b/src/CBot/tests/scenarios/bug.txt deleted file mode 100644 index 4ec6eb3..0000000 --- a/src/CBot/tests/scenarios/bug.txt +++ /dev/null @@ -1,12 +0,0 @@ -public extern void object::Bug()
-{
- point a;
- a = position;
- TEST();
- float d=dist(a, position);
-}
-
-float dist(point a, point b)
-{
- return a.x-b.x;
-}
diff --git a/src/CBot/tests/scenarios/bugmw.txt b/src/CBot/tests/scenarios/bugmw.txt deleted file mode 100644 index 284ee43..0000000 --- a/src/CBot/tests/scenarios/bugmw.txt +++ /dev/null @@ -1,9 +0,0 @@ -extern public void main()
-{
- show(fact(30)) ;
-}
-
-public int fact(int n)
-{
- return (fact(n-1)*n) ;
-}
diff --git a/src/CBot/tests/scenarios/ccc.txt b/src/CBot/tests/scenarios/ccc.txt deleted file mode 100644 index dbcd1d5..0000000 --- a/src/CBot/tests/scenarios/ccc.txt +++ /dev/null @@ -1,8 +0,0 @@ -public extern void ccc()
-{
- int a;
- a = 0 ;
-
- if ( a == 0 );
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/enum.txt b/src/CBot/tests/scenarios/enum.txt deleted file mode 100644 index a592a7f..0000000 --- a/src/CBot/tests/scenarios/enum.txt +++ /dev/null @@ -1,9 +0,0 @@ -
-enum JourDeLaSemaine {
- lundi = 1,
- mardi,
- mercredi,
- jeudi,
- vendredi,
- samedi,
- dimanche = 0 }
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/fibo.txt b/src/CBot/tests/scenarios/fibo.txt deleted file mode 100644 index 88f5357..0000000 --- a/src/CBot/tests/scenarios/fibo.txt +++ /dev/null @@ -1,25 +0,0 @@ -
-extern public int Fibo( int n, boolean b )
-{
- if ( n < 2 ) return n;
- int a = Fibo(n-1, b) + Fibo(n-2, false);
- if ( b ) print (n + "=" + a);
- return a;
-}
-
-extern public void t()
-{
- Fibo( 23, true);
-}
-
-extern public void tt()
-{
- t();
-}
-
-// cette routine n'est évidemment pas du tout obtimisée
-// c'est même un très mauvais exemple de programmation récursive
-
-// pour un test de durée, Fibo(23, true) prend
-// en mode Debug 67 secondes
-// en mode Release 8 secondes
diff --git a/src/CBot/tests/scenarios/file.txt b/src/CBot/tests/scenarios/file.txt deleted file mode 100644 index 2a22dd9..0000000 --- a/src/CBot/tests/scenarios/file.txt +++ /dev/null @@ -1,70 +0,0 @@ -class CLASS22
-{
- static int nb = 2;
- void T22 ( ) { nb = nb / 0 ; }
-}
-
-public extern void object :: TEST()
-{
- switch ( 1 )
- {
- case 1:
- {
- file h();
- h.open("Mon Fichier.txt", "r");
-show ( h.filename, h.handle );
-h.filename = "xx";
-h.handle = 1 ;
- h.readln();
- h.close();
- }
- case 2:
- {
- file h("Mon Fichier.txt");
- h.open("r");
- h.readln();
- h.close();
- }
- case 3:
- {
- file h("Mon Fichier.txt", "r");
- h.readln();
- h.close();
- }
- case 4:
- {
- file h();
- h.filename = "Mon Fichier.txt";
- h.open("r");
- h.readln();
- h.close();
- }
- case 5:
- {
- file h = fileopen( "Mon 2Fichier.txt", "r" );
- h.readln();
- h.close();
- }
- }
-{
- file h( ) ;
- h.filename = "Test.h";
- h.open ( "r" );
-
-
- file pf ( "Mon Fichier.txt" ) ;
- pf . open ( "w" ) ;
- pf . writeln ( "Voici encore du texte" ) ;
- pf . writeln ( "et une seconde ligne" ) ;
- pf . close( );
-
- pf . open ( "r" ) ;
-
- while ( not pf . eof( ) )
- {
- string s = pf . readln ( );
- show ( s );
- }
- pf.close( );
-}
-}
diff --git a/src/CBot/tests/scenarios/h.txt b/src/CBot/tests/scenarios/h.txt deleted file mode 100644 index c395319..0000000 --- a/src/CBot/tests/scenarios/h.txt +++ /dev/null @@ -1,5 +0,0 @@ -void tf()
-{
- file h;
- h.handle += 1 ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/include.txt b/src/CBot/tests/scenarios/include.txt deleted file mode 100644 index e8f8cc9..0000000 --- a/src/CBot/tests/scenarios/include.txt +++ /dev/null @@ -1,27 +0,0 @@ -class Z
-{
- static int x = 0;
- private int y;
-
- void T( )
- {
- // autorisé ici
- y = x ;
- this.y = this.x ;
- x = y ;
- this.x = this.y ;
- }
-}
-
-extern public void test()
-{
- Z a();
- 3 * a.x; // autorisé
-//vu 3 * a.y; // interdit
-//vu a.y = 3; // interdit ici
- a.x = 1; // autorisé
-
- show ( a );
- a.T();
- show ( a );
-}
diff --git a/src/CBot/tests/scenarios/intrinsic.txt b/src/CBot/tests/scenarios/intrinsic.txt deleted file mode 100644 index f215791..0000000 --- a/src/CBot/tests/scenarios/intrinsic.txt +++ /dev/null @@ -1,16 +0,0 @@ -public extern void TestIntrinsic()
-{
- point a ( 1, 2 );
- print (a);
-
- a.x = 3;
- a.y = 4;
-
- point b = a;
-
- println ( b.x, b.y, b ) ;
- if ( b == a ) b.y = 0;
- println (a,b);
- if ( b != a ) b.y = a.y;
- println(a,b);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/methode1.txt b/src/CBot/tests/scenarios/methode1.txt deleted file mode 100644 index 080bba2..0000000 --- a/src/CBot/tests/scenarios/methode1.txt +++ /dev/null @@ -1,57 +0,0 @@ -class t {
- point p;
-}
-
-void object :: toto()
-{
- show ( Position ) ;
-}
-
-extern public void object :: XX()
-{
- int test [];
- test [ 9999 ] = 3;
-
- toto () ;
-/*
- Radar();
-
- object test ;
- test = this. Radar();
-
- do {
- test = this.Radar();
- } while ( test == null );
-
-/*
- t test [ 4 ];
- for ( int i = 0 ; i < 4 ; i++ ) test [ i ] = new t();
- test [ 3 ] .p.x = 2;
- show ( test );
-/*
- int a = nan;
- show ( a ) ;
-
- a = TypeMarkPath;
- show ( a, a++, --a ) ;
-
- if ( a != nan ) a += 1 ;
-
- a = TypeMarkPath;
- float q = a ;
- show ( a, q ) ;
-
-return;
-
- a += ++a;
- show ( a ) ;
-
- boolean i = false;
-
- if ( i == true ) {}
-
- object p;
- if ( p == null) { p = p ; }
-*/
-}
-
diff --git a/src/CBot/tests/scenarios/methode2.txt b/src/CBot/tests/scenarios/methode2.txt deleted file mode 100644 index 76ce7f4..0000000 --- a/src/CBot/tests/scenarios/methode2.txt +++ /dev/null @@ -1,50 +0,0 @@ -
-extern void Toto()
-{
- TEST(12);
-
- for ( int i = 0 ; i<1000; i++)
- {
- int j = 1;
- if (i==55) TEST(12);
- }
-
- TEST(2);
-
-
-// Nouveau();
- int toto[4];
- point Z[3];
-
- Z[1].x = 11; Z[1].y = 12;
-
- toto[2] = 12;
- toto[1] = nan;
-
-// point test, autre(2,3) ;
-// object titi = Radar();
-
- TEST ( 1 ) ;
-
- toto[0] = 11;
-
- TEST ( 2 ) ;
-
- toto[6] = 0;
-}
-
-extern void object::Nouveau()
-{
- point a;
- a = np(Position);
-}
-
-point np(point b)
-{
- point c;
- c.x = b.y;
- c.y = b.x;
- return c ;
-}
-
-
diff --git a/src/CBot/tests/scenarios/mp1.txt b/src/CBot/tests/scenarios/mp1.txt deleted file mode 100644 index 599cfc4..0000000 --- a/src/CBot/tests/scenarios/mp1.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe =new Guepet();
-
- guepe.init();
-
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mp2.txt b/src/CBot/tests/scenarios/mp2.txt deleted file mode 100644 index 1c2972c..0000000 --- a/src/CBot/tests/scenarios/mp2.txt +++ /dev/null @@ -1,28 +0,0 @@ -class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
-
- object x = radar(123);
- show("radar "+x.position.x);
- show("C'est fait");
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mw.txt b/src/CBot/tests/scenarios/mw.txt deleted file mode 100644 index c237670..0000000 --- a/src/CBot/tests/scenarios/mw.txt +++ /dev/null @@ -1,16 +0,0 @@ -extern public void main()
-{
-// goto( 3, 4 );
-
- while( true )
- {
- try { goto (12) ; }
- catch( FF( ) )
- { show( "ko"); }
- }
-}
-
-boolean FF()
-{
- return false;
-}
diff --git a/src/CBot/tests/scenarios/null.txt b/src/CBot/tests/scenarios/null.txt deleted file mode 100644 index ae76b74..0000000 --- a/src/CBot/tests/scenarios/null.txt +++ /dev/null @@ -1,5 +0,0 @@ -extern public void xxx ()
-{
- CPoint test = null ;
- if ( test == null ) show ( "NULL" );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/opnew.txt b/src/CBot/tests/scenarios/opnew.txt deleted file mode 100644 index 7d6838c..0000000 --- a/src/CBot/tests/scenarios/opnew.txt +++ /dev/null @@ -1,20 +0,0 @@ -extern public void xx ()
-{
- CPoint pointeur, test = null ;
- pointeur = new CPoint ( 3, 4 );
-
- if ( test == null ) show ( "NULL" );
-
- CPoint pp = pointeur;
-
-show( pointeur , pp );
-
- pp.x = 33.3;
- if ( pointeur.x != pp.x ) 0/0;
-
- pp = new CPoint();
-// pointeur = pp;
-
-show( pointeur , pp );
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/plante.txt b/src/CBot/tests/scenarios/plante.txt deleted file mode 100644 index 363461b..0000000 --- a/src/CBot/tests/scenarios/plante.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Guepet
-{
-
- point pos;
- float t = 0.1;
-
- void init()
- {
- pos.x = 12.123;
- pos.y = 34.345;
-
- F(t);
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show ( guepe );
-}
diff --git a/src/CBot/tests/scenarios/pointer.txt b/src/CBot/tests/scenarios/pointer.txt deleted file mode 100644 index 2d4d907..0000000 --- a/src/CBot/tests/scenarios/pointer.txt +++ /dev/null @@ -1,41 +0,0 @@ -extern public void x ()
-{
- show ( 3 ** 4 );
- float z = 1e-3;
- show ( z );
-
- CPoint b ( 4,5 );
- show ( b );
-
- CPoint a ( ) ;
- a.x = 21; a.y = 12;
- show ( a ) ;
-
- CPoint test = new CPoint ( 1,1 );
- test = new CPoint ( 2, 2 );
- show ( test );
-}
-
-// crée un objet et retourne son pointeur
-CPoint newcpoint()
-{
- CPoint p = new CPoint ( 3, 3 );
- return p;
-}
-
-extern public void y ()
-{
- CPoint test = newcpoint();
- println ( test );
- dontmodif( test );
- println ( test );
-}
-
-// ne doit pas modifier l'objet en paramètre
-void dontmodif ( CPoint pp )
-{
- pp.x = 5;
- pp.y = 2;
- println ( pp, pp.x, pp.y );
-}
-
diff --git a/src/CBot/tests/scenarios/postinc.txt b/src/CBot/tests/scenarios/postinc.txt deleted file mode 100644 index cdf6ab5..0000000 --- a/src/CBot/tests/scenarios/postinc.txt +++ /dev/null @@ -1,7 +0,0 @@ -extern public void X()
-{
- point A [ ] ;
- A[5] = new point (2,3);
- int val = A[5].x++ + --A[5].y;
- show ( A, val );
-}
diff --git a/src/CBot/tests/scenarios/radar.txt b/src/CBot/tests/scenarios/radar.txt deleted file mode 100644 index 09d84a2..0000000 --- a/src/CBot/tests/scenarios/radar.txt +++ /dev/null @@ -1,39 +0,0 @@ -extern void object::Bug( )
-{
- try{ int a = 44 ; a = 12 / 0 ; }
- catch(6000) { int b = 4 ; }
- finally { int z = 1 ; }
-
-// tp ( A, B );
-
-/* int a = 4, b = 2, c = nan;
- float x, y = 3/2, z = nan;
- boolean i, j = false, k = true;
-
- string s, ss = "xyz";
-
- while ( false )
- {
- object left, right;
-
- left = Radar(TypeMarkPath, -45, 120, 100);
- right = Radar(TypeMarkPath, 45, 120, 100);
-
- if ( left == null && right == null )
- {
- }
- }
- int t = fact ( 4 ) ;*/
-}
-
-void tp( point a , point b )
-{
- a.x += b.x;
-}
-
-
-int fact( int n )
-{
- if ( n < 2 ) return n;
- return n * fact ( n - 1 ) ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/solution.txt b/src/CBot/tests/scenarios/solution.txt deleted file mode 100644 index f78cf12..0000000 --- a/src/CBot/tests/scenarios/solution.txt +++ /dev/null @@ -1,13 +0,0 @@ -extern void object::Solution( )
-{
-show ( "Solution " + Position );
- Carré(15);
- Carré(25);
-}
-
-void object::Carré(float côté)
-{
-show ( "Carré " + Position );
- Move(côté);
- Turn(-90);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/test.txt b/src/CBot/tests/scenarios/test.txt deleted file mode 100644 index 0693994..0000000 --- a/src/CBot/tests/scenarios/test.txt +++ /dev/null @@ -1,8 +0,0 @@ -extern public void x()
-{
- float a= 1, b = 2;
- a = b * ( 2 + 2 );
- print (a);
- a += 4;
- print (a);
-}
diff --git a/src/CBot/tests/scenarios/test23.txt b/src/CBot/tests/scenarios/test23.txt deleted file mode 100644 index d6e1ddd..0000000 --- a/src/CBot/tests/scenarios/test23.txt +++ /dev/null @@ -1,10 +0,0 @@ -extern public void object::TEST23()
-{
- CLASS22 T;
- T.T22( ) ;
-
- show( position );
- show( this.position );
-
-// T22();
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/testmw.txt b/src/CBot/tests/scenarios/testmw.txt deleted file mode 100644 index 6570f6d..0000000 --- a/src/CBot/tests/scenarios/testmw.txt +++ /dev/null @@ -1,14 +0,0 @@ -extern public int testmw( int a)
-{
- boolean b = true ;
-
- if (b)
- return 1 ;
- else
- return a ; 0 * testmw(a-1) ;
-}
-
-public int Fibo2 ( int n )
-{
- print ( " bof " );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/this.txt b/src/CBot/tests/scenarios/this.txt deleted file mode 100644 index b8a9e04..0000000 --- a/src/CBot/tests/scenarios/this.txt +++ /dev/null @@ -1,13 +0,0 @@ -extern void object :: TEST22 ( )
-{
- show( position );
- show( this.position );
-
- T();
-}
-
-public void object :: T22()
-{
- show( position );
- show( this.position );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/tt.txt b/src/CBot/tests/scenarios/tt.txt deleted file mode 100644 index cd13c9d..0000000 --- a/src/CBot/tests/scenarios/tt.txt +++ /dev/null @@ -1,12 +0,0 @@ -extern public void T() { T1(); }
-
-public void T1()
-{
- show( "T1" );
- T2();
-}
-
-public void T2()
-{
- show( "T2" );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/tt2.txt b/src/CBot/tests/scenarios/tt2.txt deleted file mode 100644 index ad9dc1d..0000000 --- a/src/CBot/tests/scenarios/tt2.txt +++ /dev/null @@ -1,5 +0,0 @@ -extern public void TT()
-{
- T1();
- T2();
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/vide.txt b/src/CBot/tests/scenarios/vide.txt deleted file mode 100644 index e69de29..0000000 --- a/src/CBot/tests/scenarios/vide.txt +++ /dev/null diff --git a/src/CBot/tests/scenarios/zz.txt b/src/CBot/tests/scenarios/zz.txt deleted file mode 100644 index da764ac..0000000 --- a/src/CBot/tests/scenarios/zz.txt +++ /dev/null @@ -1,6 +0,0 @@ -extern public void zz()
-{
- MaClass TOTO ();
-
- show (TOTO);
-}
\ No newline at end of file |