~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to tads/tads3/test/data/vec_bug.t

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// from Sean T Barrett - vector trash bug test case
 
2
 
 
3
#include "tads.h"
 
4
#include "t3.h"
 
5
#include "vector.h"
 
6
 
 
7
#define TEST_STRINGS     // if you disable this, builds a vector of ints,
 
8
                         // which doesn't memory trash
 
9
 
 
10
#ifdef TEST_STRINGS
 
11
  #define VALUE(x)  #@x
 
12
#else
 
13
  #define VALUE(x)  x
 
14
#endif
 
15
 
 
16
main(args)
 
17
{
 
18
   local x = new Vector(1);  // if you make this 3, it doesn't trash
 
19
                             // (the vector will eventually have 3 elements)
 
20
 
 
21
   x.append(VALUE(1));       // append 1 or '1'
 
22
   x.append(VALUE(2));       // append 2 or '2'
 
23
 
 
24
   x[2] = x[2];              // this assignment doesn't trash x[1] or x[2]
 
25
 
 
26
   "<<x[1]>> <<x[2]>>\n";
 
27
 
 
28
   x.append(VALUE(3));       // append 3 or '3'
 
29
 
 
30
   "<<x[1]>> <<x[2]>> <<x[3]>>\n";
 
31
 
 
32
   x[3] = 3;                 // ERROR! this assignment trashes x[2] NOT x[3]
 
33
   // x[3] = x[3];           // this would trash too
 
34
 
 
35
   "<<x[1]>> <<x[2]>>\n";    // this line will fault on x[2]
 
36
 
 
37
   // convert it to a list and display it
 
38
   local y = x.toList();
 
39
   "y = [<<y[1]>>, <<y[2]>>, <<y[3]>>]\n";
 
40
}