summaryrefslogtreecommitdiff
path: root/testautomation/global/input/macros.txt
blob: ffe95be431e3c5174459bd439ed76d43d0c92b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# This is a collection of BASIC macros that can cause Syntax errors, Exceptions, 
# Runtime Errors.

# ---------------------------------------------------------------------------- #

[Default_Macro]
REM BASIC

sub main

end sub

# ---------------------------------------------------------------------------- #

[MessageBoxes]
'# MessageBoxes - Macro that opens all flavors of messageboxes
function TestMessageBoxes()

    msgbox( "0x" , 0 )
    msgbox( "1x" , 1 )
    msgbox( "2x" , 2 )
    msgbox( "3x" , 3 )
    msgbox( "4x" , 4 )
    msgbox( "5x" , 5 )
    
    msgbox( "16" , 2 + 16 )
    msgbox( "32" , 2 + 32 )
    msgbox( "48" , 2 + 48 )
    msgbox( "64" , 2 + 64 )
    msgbox( "128" , 2 + 128 )
    msgbox( "256" , 2 + 256 )
    msgbox( "512" , 2 + 512 )
    
end function

# ---------------------------------------------------------------------------- #

[TTMacro1]
'# TTMacro1: This is a short testscript for automated testing!
sub main

    print( "Hello" )

end sub

# ---------------------------------------------------------------------------- #

[TTMacro2]
'# TTMacro2: Macro that only contains a comment on the first line

# ---------------------------------------------------------------------------- #

[TTMacro3]
'# TTMacro3: Bring up a messagebox
sub main

    msgbox( "TTMacro3" )
    
end sub

# ---------------------------------------------------------------------------- #

[tBasicExport]
' This is a macro to test the BASIC library export
sub main

    msgbox( "tBasicExport" )
    
end sub

# ---------------------------------------------------------------------------- #

[i41695]
' No runtime exception 
sub main

    dim F as string
    dim S as string
    msgbox( "i41695-1" )
    F = "file://" & curdir & "/test.txt" 
    Open F for random as #17

    get #17, 1, S
    msgbox( "i41695-2" )

end sub

# ---------------------------------------------------------------------------- #

[i77436]
'# This is a macro required for verification of issue 77436
Sub Main
'test service
o= createUnoService("TestNamesComp")
msgbox o.dbg_supportedInterfaces

'test singleton
ctx = getDefaultContext
factory = ctx.getValueByName("org.openoffice.test.Names")
msgbox o.dbg_supportedInterfaces

End Sub

# ---------------------------------------------------------------------------- #

[i82830]
'should display
'12D687
'4553207
Sub Main
	dim l as long
	l = 1234567
	msgbox hex( l )
	msgbox oct( l )
end sub

# ---------------------------------------------------------------------------- #

[i81674]
Sub Main
	MsgBox Format(1250, "Currency")
	MsgBox Format(1250, "Yes/No")
	MsgBox Format(1250, "True/False")
	MsgBox Format(1250, "On/Off")
End Sub

# ---------------------------------------------------------------------------- #

[i80532]
' Should display three messageboxes: -10,1,-10
Sub Main
    aTestFunction (-10) ' will compile
    aTestFunction 1,-10 ' will compile
    aTestFunction -10 ' should now compile and run, too
End Sub

function aTestFunction( param1 as variant )
    msgbox "param1 = " & param1
end function

# ---------------------------------------------------------------------------- #

[i83978]
' This should trigger an exception

Sub Main
	BasicLibraries.LoadLibrary( "ThisLibDoesNotExist" )
End Sub

# ---------------------------------------------------------------------------- #

[i84040]
' Two messageboxes that should display "false"

Sub Main
    Dim oError1 as new com.sun.star.sdbc.SQLException
    print isnull( oError1 )
    Dim oError2 as Object
    oError2 = CreateUnoStruct( "com.sun.star.sdbc.SQLException" )
    print isnull( oError2 )
End Sub

# ---------------------------------------------------------------------------- #

[i86265]
' There should be no "Paramtheses do not match" warning
OPTION EXPLICIT
Public Const cMAX = 256

Sub Main

    Dim mRangeArray(0, 0) as String
    Dim n as Integer
    
    n = 10
    MsgBox "i86265-1"   
    ReDim mRangeArray(CInt(cMAX), n) as String
    MsgBox "i86265-2"

End Sub

# ---------------------------------------------------------------------------- #

[i92329]
Option VBASupport 1
Sub Main()

    Dim mTmp() As String  
    mTmp() = Test(False) '<-- generates an 'unexpected ')' compiler error
    MsgBox mTmp(0) & " " & mTmp(1)
    
End Sub

Function Test(ByVal bFlag As Boolean) As Variant

    Dim mRanges(100) As String

    If (bFlag = True) Then
        Test = "return a String"
    Else
        mRanges(0) = "Return an"
        mRanges(1) = "Array"
        Test = mRanges()
    End If

End Function

# ---------------------------------------------------------------------------- #

[i97038]
' Date should contain the year 1900 and the value should be 2

Sub Main
    Dim v
    v = DateSerial(0,1,1)
    Msgbox ("Date :  " & v)
    MsgBox ("Value : " & CDbl(v))
End Sub

# ---------------------------------------------------------------------------- #

[i103691]
option vbasupport 1

Sub Main
    dim a, b

    if (not a = b) then 
        msgbox( "not equal" )
    else
        msgbox( "Equal" )    
    end if
End Sub
# ---------------------------------------------------------------------------- #

[i103697]
Private Declare Function FooFunction Lib "foo" ( nVal )
Public  Declare Function FooFunction2 Lib "foo" ( nVal )

sub main
	msgbox( "i103697" )
end sub

# ---------------------------------------------------------------------------- #

[i103990]
type MyType
	a( 3 ) as integer
	b as double
end type

Sub Main
	dim mt as MyType
	mt.a(0) = 42
	mt.a(1) = 43
	mt.b = 3.14
	msgbox( mt.a(0) )
	msgbox( mt.a(1) )
	if ( mt.b = 3.14 ) then
    	msgbox( "Pi" )
    else
        msgbox( "Error" )
    endif
end sub

# ---------------------------------------------------------------------------- #

[i107070]
Sub Main
    oSingleton = com.sun.star.logging.LoggerPool

    oInstance1 = oSingleton.get()
    msgbox oInstance1.dbg_properties

    oCtx = GetDefaultContext()
    oInstance2 = oSingleton.get( oCtx )
    msgbox oInstance2.dbg_properties

    ' Uncommenting this should result in an error "Invalid procedure call"
    oInstanceErr1 = oSingleton.get( 42 )
End Sub