8 MySequenceConversionObject {
13 property bool success: true
15 property variant intList
16 property variant qrealList
17 property variant boolList
18 property variant stringList
19 property variant urlList
20 property variant qstringList
22 // this test ensures that the "copy resource" codepaths work
23 function testCopySequences() {
26 // create "copy resource" sequences
27 var jsIntList = msco.generateIntSequence();
28 var jsQrealList = msco.generateQrealSequence();
29 var jsBoolList = msco.generateBoolSequence();
30 var jsStringList = msco.generateStringSequence();
31 var jsUrlList = msco.generateUrlSequence();
32 var jsQStringList = msco.generateQStringSequence();
34 if (jsIntList.toString() != [1, 2, 3].toString())
36 if (jsQrealList.toString() != [1.1, 2.2, 3.3].toString())
38 if (jsBoolList.toString() != [true, false, true].toString())
40 if (jsStringList.toString() != ["one", "two", "three"].toString())
42 if (jsUrlList.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString())
44 if (jsQStringList.toString() != ["one", "two", "three"].toString())
47 // copy the sequence; should result in a new copy
49 qrealList = jsQrealList;
50 boolList = jsBoolList;
51 stringList = jsStringList;
53 qstringList = jsQStringList;
55 // these operations shouldn't modify either variables - because
56 // we don't handle writing to the intermediate variant at list[index]
57 // for variant properties.
61 stringList[1] = "eight";
62 urlList[1] = "http://www.example8.com";
63 qstringList[1] = "eight";
65 if (jsIntList[1] == 8)
67 if (jsQrealList[1] == 8.8)
69 if (jsBoolList[1] == true)
71 if (jsStringList[1] == "eight")
73 if (jsUrlList[1] == "http://www.example8.com")
75 if (jsQStringList[1] == "eight")
78 // assign a "copy resource" sequence to a QObject Q_PROPERTY
79 msco.intListProperty = intList;
80 msco.qrealListProperty = qrealList;
81 msco.boolListProperty = boolList;
82 msco.stringListProperty = stringList;
83 msco.urlListProperty = urlList;
84 msco.qstringListProperty = qstringList;
86 if (msco.intListProperty.toString() != [1, 2, 3].toString())
88 if (msco.qrealListProperty.toString() != [1.1, 2.2, 3.3].toString())
90 if (msco.boolListProperty.toString() != [true, false, true].toString())
92 if (msco.stringListProperty.toString() != ["one", "two", "three"].toString())
94 if (msco.urlListProperty.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString())
96 if (msco.qstringListProperty.toString() != ["one", "two", "three"].toString())
99 // now modify the QObject Q_PROPERTY (reference resource) sequences - shouldn't modify the copy resource sequences.
100 msco.intListProperty[2] = 9;
101 msco.qrealListProperty[2] = 9.9;
102 msco.boolListProperty[2] = false;
103 msco.stringListProperty[2] = "nine";
104 msco.urlListProperty[2] = "http://www.example9.com";
105 msco.qstringListProperty[2] = "nine";
109 if (qrealList[2] == 9.9)
111 if (boolList[2] == false)
113 if (stringList[2] == "nine")
115 if (urlList[2] == "http://www.example9.com")
117 if (qstringList[2] == "nine")
122 property real qrealVal
123 property bool boolVal
124 property string stringVal
126 // this test ensures that indexed access works for copy resource sequences.
127 function readSequenceCopyElements() {
130 var jsIntList = msco.generateIntSequence();
131 var jsQrealList = msco.generateQrealSequence();
132 var jsBoolList = msco.generateBoolSequence();
133 var jsStringList = msco.generateStringSequence();
135 intVal = jsIntList[1];
136 qrealVal = jsQrealList[1];
137 boolVal = jsBoolList[1];
138 stringVal = jsStringList[1];
144 if (boolVal != false)
146 if (stringVal != "two")
150 // this test ensures that equality works for copy resource sequences.
151 function testEqualitySemantics() {
154 var jsIntList = msco.generateIntSequence();
155 var jsIntList2 = msco.generateIntSequence();
157 if (jsIntList == jsIntList2) success = false;
158 if (jsIntList != jsIntList) success = false;