Skip to content

Commit

Permalink
Merge branch 'release/4.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktekinay committed Aug 7, 2019
2 parents d8501a2 + 9686451 commit 34e8217
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 172 deletions.
86 changes: 86 additions & 0 deletions JSONItem_MTC Harness/FormatCodePreferences.xojo_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#tag Module
Protected Module FormatCodePreferences
#tag Note, Name = About

This module is optional. If present, the FormatCode IDE Script will use the constants found here instead
of the ones in the script.

The module does not need all of these constants, but must have at lease one or the script will fail.

Most of the constants are booleans. The KeywordsTo... provide exceptions to the default CaseConversion.
For example, if you want all of your keywords as title case except for if/then/else, you would
set CaseConversion = "kTitleCase" and KeywordsToLowerCase to "if,then,else". (Spaces around the
keywords will be stripped by the script).

The KeywordsTo... constants are comma-delimited strings.
#tag EndNote


#tag Constant, Name = AlignAs, Type = Boolean, Dynamic = False, Default = \"False", Scope = Protected
#tag EndConstant

#tag Constant, Name = CaseConversion, Type = String, Dynamic = False, Default = \"kLowerCase", Scope = Protected
#tag EndConstant

#tag Constant, Name = DoDebug, Type = Boolean, Dynamic = False, Default = \"False", Scope = Protected
#tag EndConstant

#tag Constant, Name = KeywordsToLowerCase, Type = String, Dynamic = False, Default = \"if\x2C then\x2C end\x2C while\x2C wend\x2C select\x2C case\n", Scope = Protected
#tag EndConstant

#tag Constant, Name = KeywordsToTitleCase, Type = String, Dynamic = False, Default = \"Integer\x2C Byte\x2C Short\x2C Int8\x2C Int16\x2C Int32\x2C Int64\x2C UInt8\x2C UInt16\x2C UInt32\x2C UInt64\x2C Double\x2C Single\x2C String\x2C Text\x2C Variant\n\nDictionary\x2C Date\n\nTrue\x2C False\n\nClose\n\nRaiseEvent\n\nBackgroundTasks\nNilObjectChecking\nStackOverflowChecking\nBoundsChecking\nDebugBuild", Scope = Protected
#tag EndConstant

#tag Constant, Name = KeywordsToUpperCase, Type = String, Dynamic = False, Default = \"", Scope = Protected
#tag EndConstant

#tag Constant, Name = PadComma, Type = Boolean, Dynamic = False, Default = \"True", Scope = Protected
#tag EndConstant

#tag Constant, Name = PadOperators, Type = Boolean, Dynamic = False, Default = \"True", Scope = Protected
#tag EndConstant

#tag Constant, Name = PadParensInner, Type = Boolean, Dynamic = False, Default = \"True", Scope = Protected
#tag EndConstant

#tag Constant, Name = PadParensOuter, Type = Boolean, Dynamic = False, Default = \"False", Scope = Protected
#tag EndConstant


#tag ViewBehavior
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior
End Module
#tag EndModule
3 changes: 2 additions & 1 deletion JSONItem_MTC Harness/JSONItem_MTC Harness.xojo_project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Type=Desktop
RBProjectVersion=2018.04
RBProjectVersion=2019.011
MinIDEVersion=20070100
Class=App;App.xojo_code;&h0000000014C611D3;&h0000000000000000;false
MenuBar=MenuBar1;MenuBar1.xojo_menu;&h0000000018745784;&h0000000000000000;false
Expand All @@ -8,6 +8,7 @@ Window=WndPlayground;WndPlayground.xojo_window;&h0000000057BC7FF2;&h000000000000
Folder=XojoUnit;XojoUnit;&h000000002516B04D;&h0000000000000000;false
Folder=Tests;Tests;&h000000001962C3CC;&h0000000000000000;false
Class=Stopwatch_MTC;Stopwatch_MTC.xojo_code;&h0000000034CE49A5;&h0000000000000000;false
Module=FormatCodePreferences;FormatCodePreferences.xojo_code;&h000000002977F6F1;&h0000000000000000;false
BuildSteps=Build Automation;Build Automation.xojo_code;&h000000007E1DE94C;&h0000000000000000;false
Class=JSONItem_MTC;../JSONItem_MTC.xojo_xml_code;&h000000002DCCA46D;&h0000000000000000;false
Class=JSONWebToken_MTC;../JSONWebToken_MTC.xojo_xml_code;&h00000000034117FF;&h0000000000000000;false
Expand Down
10 changes: 7 additions & 3 deletions JSONItem_MTC Harness/M_JSON.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ Protected Module M_JSON
#pragma StackOverflowChecking false
#endif

const kSlash as integer = 47
const kA as integer = 65
const kB as integer = 98
const kF as integer = 102
const kN as integer = 110
Expand Down Expand Up @@ -425,6 +423,12 @@ Protected Module M_JSON
dim thisByte as integer = pIn.Byte( inIndex )

select case thisByte
case kQuote, kBackslash
pOut.Byte( outIndex ) = kBackslash
outIndex = outIndex + 1
pOut.Byte( outIndex ) = thisByte
outIndex = outIndex + 1

case 8 // vertical tab
pOut.Byte( outIndex ) = kBackslash
outIndex = outIndex + 1
Expand Down Expand Up @@ -1310,7 +1314,7 @@ Protected Module M_JSON
#tag Constant, Name = kTab, Type = Double, Dynamic = False, Default = \"9", Scope = Private
#tag EndConstant

#tag Constant, Name = kVersion, Type = Double, Dynamic = False, Default = \"4.1", Scope = Protected
#tag Constant, Name = kVersion, Type = String, Dynamic = False, Default = \"4.1.1", Scope = Protected
#tag EndConstant


Expand Down
60 changes: 45 additions & 15 deletions JSONItem_MTC Harness/Tests/BasicTests_JSONItem.xojo_code
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#tag Class
Protected Class BasicTests_JSONItem
Inherits TestGroup
#tag Method, Flags = &h21
Private Sub CaseSensitiveKeyTest()
#tag Method, Flags = &h0
Sub CaseSensitiveKeyTest()
dim j as new JSONItem

dim storedKeys() as string = array( _
Expand Down Expand Up @@ -43,8 +43,38 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub IllegalStringTest()
#tag Method, Flags = &h0
Sub EmbeddedBackslashTest()
dim jI as new JSONItem
jI.Value( "name" ) = "John \Doey\ Doe"

dim raw as String = jI.ToString

dim jO as new JSONItem( raw )

for each k as String in jI.Names
Assert.IsTrue( jI.Value( k ) = jO.Value( k ), k.ToText )
next
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub EmbeddedQuoteTest()
dim jI as new JSONItem
jI.Value( "name" ) = "John ""Doey"" Doe"

dim raw as String = jI.ToString

dim jO as new JSONItem( raw )

for each k as String in jI.Names
Assert.IsTrue( jI.Value( k ) = jO.Value( k ), k.ToText )
next
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub IllegalStringTest()
dim j as JSONItem

dim badStrings() as string = Array( Chr( 13 ), Chr( 9 ), Chr( 8 ), Chr( 5 ), Chr( 29 ) )
Expand All @@ -65,8 +95,8 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub LoadAdditionalTest()
#tag Method, Flags = &h0
Sub LoadAdditionalTest()
dim j as new JSONItem
j.Value( "one" ) = 1.0

Expand All @@ -76,8 +106,8 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub LoadEncodingTest()
#tag Method, Flags = &h0
Sub LoadEncodingTest()
#pragma BreakOnExceptions false

const kOriginal = "[""abc""]"
Expand Down Expand Up @@ -132,8 +162,8 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub LoadInterruptionTest()
#tag Method, Flags = &h0
Sub LoadInterruptionTest()
dim j as JSONItem
dim load as string = "{""first"" : 1.0, ""second"" : interrupt}"

Expand All @@ -144,7 +174,7 @@ Inherits TestGroup
Assert.Fail( "Loading through the Constructor should have failed" )
return
catch err as JSONException
end
end

Assert.IsTrue( j is nil, "An interrupted load in the Constructor should lead to a nil object" )

Expand Down Expand Up @@ -173,8 +203,8 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub TextTest()
#tag Method, Flags = &h0
Sub TextTest()
dim j as new JSONItem

dim t1 as text = "hi"
Expand Down Expand Up @@ -205,8 +235,8 @@ Inherits TestGroup
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub UnicodeTest()
#tag Method, Flags = &h0
Sub UnicodeTest()
dim j as new JSONItem

j.Value( "a" + chr( 1 ) ) = "something" + chr( 2 )
Expand Down
Loading

0 comments on commit 34e8217

Please sign in to comment.