1 // Generated from ST_avmplus_basics.st
2 // -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*-
3 // vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
5 // ***** BEGIN LICENSE BLOCK *****
6 // Version: MPL 1.1/GPL 2.0/LGPL 2.1
8 // The contents of this file are subject to the Mozilla Public License Version
9 // 1.1 (the "License"); you may not use this file except in compliance with
10 // the License. You may obtain a copy of the License at
11 // http://www.mozilla.org/MPL/
13 // Software distributed under the License is distributed on an "AS IS" basis,
14 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15 // for the specific language governing rights and limitations under the
18 // The Original Code is [Open Source Virtual Machine.].
20 // The Initial Developer of the Original Code is
21 // Adobe System Incorporated.
22 // Portions created by the Initial Developer are Copyright (C) 2004-2006
23 // the Initial Developer. All Rights Reserved.
28 // Alternatively, the contents of this file may be used under the terms of
29 // either the GNU General Public License Version 2 or later (the "GPL"), or
30 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 // in which case the provisions of the GPL or the LGPL are applicable instead
32 // of those above. If you wish to allow use of your version of this file only
33 // under the terms of either the GPL or the LGPL, and not to allow others to
34 // use your version of this file under the terms of the MPL, indicate your
35 // decision by deleting the provisions above and replace them with the notice
36 // and other provisions required by the GPL or the LGPL. If you do not delete
37 // the provisions above, a recipient may use your version of this file under
38 // the terms of any one of the MPL, the GPL or the LGPL.
40 // ***** END LICENSE BLOCK ***** */
45 class ST_avmplus_basics
: public Selftest
{
47 ST_avmplus_basics(AvmCore
* core
);
48 virtual void run(int n
);
50 static const char* ST_names
[];
51 static const bool ST_explicits
[];
61 ST_avmplus_basics::ST_avmplus_basics(AvmCore
* core
)
62 : Selftest(core
, "avmplus", "basics", ST_avmplus_basics::ST_names
,ST_avmplus_basics::ST_explicits
)
64 const char* ST_avmplus_basics::ST_names
[] = {"unsigned_int","signed_int","equalsLatin1","containsLatin1","indexOfLatin1","matchesLatin1","matchesLatin1_caseless","bug562101", NULL
};
65 const bool ST_avmplus_basics::ST_explicits
[] = {false,false,false,false,false,false,false,false, false };
66 void ST_avmplus_basics::run(int n
) {
68 case 0: test0(); return;
69 case 1: test1(); return;
70 case 2: test2(); return;
71 case 3: test3(); return;
72 case 4: test4(); return;
73 case 5: test5(); return;
74 case 6: test6(); return;
75 case 7: test7(); return;
78 void ST_avmplus_basics::test0() {
80 // Does right shift of unsigned quantities work?
81 #line 47 "ST_avmplus_basics.st"
82 verifyPass((int)(~0U >> 1) > 0, "(int)(~0U >> 1) > 0", __FILE__
, __LINE__
);
85 void ST_avmplus_basics::test1() {
87 // Does right shift of signed quantities work?
88 #line 52 "ST_avmplus_basics.st"
89 verifyPass((-1 >> 1) == -1, "(-1 >> 1) == -1", __FILE__
, __LINE__
);
91 // verify that the "latin1" literal string calls work properly for hi-bit latin1 chars
93 void ST_avmplus_basics::test2() {
94 Stringp s
= core
->newConstantStringLatin1("ev\xADident");
95 bool equals
= s
->equalsLatin1("ev\xADident");
96 #line 58 "ST_avmplus_basics.st"
97 verifyPass(equals
== true, "equals == true", __FILE__
, __LINE__
);
100 void ST_avmplus_basics::test3() {
101 Stringp s
= core
->newConstantStringLatin1("ev\xADident");
102 bool found
= s
->containsLatin1("\xAD");
103 #line 63 "ST_avmplus_basics.st"
104 verifyPass(found
== true, "found == true", __FILE__
, __LINE__
);
107 void ST_avmplus_basics::test4() {
108 Stringp s
= core
->newConstantStringLatin1("ev\xADident");
109 int index
= s
->indexOfLatin1("\xAD");
110 #line 68 "ST_avmplus_basics.st"
111 verifyPass(index
== 2, "index == 2", __FILE__
, __LINE__
);
114 void ST_avmplus_basics::test5() {
115 Stringp s
= core
->newConstantStringLatin1("ev\xADident");
116 bool matches1
= s
->matchesLatin1("\xADi", 2, 2);
117 #line 73 "ST_avmplus_basics.st"
118 verifyPass(matches1
== true, "matches1 == true", __FILE__
, __LINE__
);
121 void ST_avmplus_basics::test6() {
122 Stringp s
= core
->newConstantStringLatin1("ev\xADident");
123 bool matches2
= s
->matchesLatin1_caseless("\xADIDENT", 2, 2);
124 #line 78 "ST_avmplus_basics.st"
125 verifyPass(matches2
== true, "matches2 == true", __FILE__
, __LINE__
);
129 void ST_avmplus_basics::test7() {
130 // XMLParser omits the last char of a DOCTYPE node
131 Stringp str
= core
->newConstantStringLatin1("<?xml version=\"1.0\"?><!DOCTYPE greeting SYSTEM><greeting>Hello, world!</greeting>");
132 XMLParser
parser(core
, str
);
133 MMgc::GC
*gc
= core
->GetGC();
137 while ((m_status
= parser
.getNext(tag
)) == XMLParser::kNoError
)
139 switch (tag
.nodeType
)
141 case XMLTag::kDocTypeDeclaration
:
144 pass
= tag
.text
->equalsLatin1("<!DOCTYPE greeting SYSTEM>");
150 #line 102 "ST_avmplus_basics.st"
151 verifyPass(pass
== true, "pass == true", __FILE__
, __LINE__
);
154 void create_avmplus_basics(AvmCore
* core
) { new ST_avmplus_basics(core
); }