Bugzilla – Attachment 128397 Details for
Bug 80731
Incorrect syntax does compile, MID without end bracket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Testing program for Mid function and Mid instruction
Test_MID_Basic_Program.txt (text/plain), 3.72 KB, created by
Pierre Lepage
on 2016-11-01 00:35:33 UTC
(
hide
)
Description:
Testing program for Mid function and Mid instruction
Filename:
MIME Type:
Creator:
Pierre Lepage
Created:
2016-11-01 00:35:33 UTC
Size:
3.72 KB
patch
obsolete
>Option Explicit > >Dim s as String ' Input string. >Dim sInjStr As String ' Injected string. >Dim r As String ' Resulting string. >Dim sir As String ' Expected result string >Dim sConc As String ' Conclusion >Dim sMidSyntax As String >Dim sSyntaxUnderTest As String ' Syntax under test. >Dim sMsg As String ' Text message. >Const LO_OK As Integer = 0 >Const TESTMID As String = "Test Mid" > >' Mid as instruction : LFunction (to the left "=" symbol or stand alone function) >' Syntax 1 : Mid(InputString, Start, Length, InjectedString) >' Syntax 2 : Mid(InputString, Start, Length) = InjectedString >' >' Mid as function : RFunction (always to the rigth of "=" symbol). Act as an extraction function into an input string. >' ResultingString = Mid(InputString, Start, Length) > > >' Syntaxes that doesn't work properly >Sub TestMid_Buggy_Syntax > > ' TEST Buggy A > sSyntaxUnderTest = "Instruction Mid LVALUE 3 arguments - Lack of closing parenthesis" > sMidSyntax = "Mid(s, 1, 1 = ""A""" > s = "abcd": r = s: sInjStr="A": sConc = "Compile but do nothing": sir = "Expected result : Error" > > Mid(s, 1, 1 = sInjStr > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "s = " & s & LOCRLF & _ > "Result : " & s > > > MsgBox sMsg, LO_OK, TESTMID > > ' TEST Buggy B > sSyntaxUnderTest = "Instruction Mid LVALUE 4 arguments - Lack of closing parenthesis" > sMidSyntax = "Mid (r, 1, 1, ""A""" > s = "abcd": r = s: sInjStr="A": sConc = "Compile but do nothing": sir = "Expected result : Error" > > Mid (r, 1, 1, sInjStr > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "r = " & s & LOCRLF & _ > "Result : " & r > > > MsgBox sMsg, LO_OK, TESTMID >End Sub > > >' Syntax that works! >Sub TestMid_Correct_Syntax > > ' TEST A > sSyntaxUnderTest = "TEST A : Instruction Mid LVALUE, 4 arguments - without parenthesis" > sMidSyntax = "Mid r, 1, 1, ""A""" > s = "abcd": r = s: sInjStr="A": sConc = "Compile and work fine": sir = "Expected result : ""Abcd""" > > Mid r, 1, 1, sInjStr > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "r = " & s & LOCRLF & _ > "Result : " & r > > > MsgBox sMsg, LO_OK, TESTMID > > ' TEST B > sSyntaxUnderTest = "TEST B : Instruction Mid LVALUE, 4 arguments - with both parenthesis" > sMidSyntax = "Mid(r, 1, 1, ""A""" & ")" > s = "abcd": r = s: sInjStr="A": sConc = "Compile and work fine": sir = "Expected result : ""Abcd""" > > Mid(r, 1, 1, sInjStr) > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "r = " & s & LOCRLF & _ > "Result : " & r > > MsgBox sMsg, LO_OK, TESTMID > > > ' TEST C > sSyntaxUnderTest = "TEST C: Instruction Mid LVALUE, 3 arguments - with both parenthesis" > sMidSyntax ="Mid(s 1, 1) = ""A""" > s = "abcd": r = s: sInjStr="A": sConc = "Compile and work fine": sir = "Expected result : ""Abcd""" > > Mid(r, 1, 1) = "A" > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "r = " & s & LOCRLF & _ > "Result : " & r > > MsgBox sMsg, LO_OK, TESTMID > > > > ' TEST D > sSyntaxUnderTest = "TEST D: Function Mid RVALUE, 3 arguments - with both parenthesis" > sMidSyntax ="r = Mid(s 1, 1)" > s = "abcd"::: sConc = "Compile and work fine": sir = "Expected result : ""a""" > > r = Mid(s, 1, 1) > > sMsg = sSyntaxUnderTest & LOCRLF & _ > sConc & LOCRLF & _ > sir & LOCRLF & _ > sMidSyntax & LO2CRLF & _ > "r = " & s & LOCRLF & _ > "Result : " & r > > MsgBox sMsg, LO_OK, TESTMID > >End Sub > >' One line feed >Function LOCRLF As string > LOCRLF = chr(10) & chr(13) >End Function > >' Two lines feed >Function LO2CRLF As string > LO2CRLF = LOCRLF & LOCRLF >End Function
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 80731
: 128397 |
129841
|
134331