[squeak-dev] The Trunk: Tests-mt.328.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Aug 27 08:54:12 UTC 2015
Marcel Taeumel uploaded a new version of Tests to project The Trunk:
http://source.squeak.org/trunk/Tests-mt.328.mcz
==================== Summary ====================
Name: Tests-mt.328
Author: mt
Time: 27 August 2015, 10:54:02.079 am
UUID: 2b490fe8-250d-2e48-84c2-41d50b1ae410
Ancestors: Tests-eem.327
New tests for preferences.
=============== Diff against Tests-eem.327 ===============
Item was changed:
SystemOrganization addCategory: #'Tests-Bugs'!
SystemOrganization addCategory: #'Tests-Compiler'!
SystemOrganization addCategory: #'Tests-Dependencies'!
SystemOrganization addCategory: #'Tests-Digital Signatures'!
SystemOrganization addCategory: #'Tests-Environments'!
SystemOrganization addCategory: #'Tests-Exceptions'!
SystemOrganization addCategory: #'Tests-FilePackage'!
SystemOrganization addCategory: #'Tests-Files'!
SystemOrganization addCategory: #'Tests-Finalization'!
SystemOrganization addCategory: #'Tests-Hex'!
SystemOrganization addCategory: #'Tests-Installer-Core'!
SystemOrganization addCategory: #'Tests-Localization'!
SystemOrganization addCategory: #'Tests-Monticello'!
SystemOrganization addCategory: #'Tests-Monticello-Mocks'!
SystemOrganization addCategory: #'Tests-Monticello-Utils'!
SystemOrganization addCategory: #'Tests-Object Events'!
SystemOrganization addCategory: #'Tests-ObjectsAsMethods'!
SystemOrganization addCategory: #'Tests-PrimCallController'!
SystemOrganization addCategory: #'Tests-Release'!
SystemOrganization addCategory: #'Tests-System-Object Storage'!
SystemOrganization addCategory: #'Tests-System-Support'!
SystemOrganization addCategory: #'Tests-Utilities'!
SystemOrganization addCategory: #'Tests-VM'!
SystemOrganization addCategory: #'Tests-System-Digital Signatures'!
+ SystemOrganization addCategory: #'Tests-System-Preferences'!
Item was added:
+ TestCase subclass: #PreferencesTest
+ instanceVariableNames: 'sut'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Tests-System-Preferences'!
Item was added:
+ ----- Method: PreferencesTest>>setUp (in category 'running') -----
+ setUp
+
+ super setUp.
+ sut := PreferencesTestPreferences.!
Item was added:
+ ----- Method: PreferencesTest>>tearDown (in category 'running') -----
+ tearDown
+
+ sut allPreferences do: [:pref | sut removePreference: pref id].
+ sut class organization removeEmptyCategories.
+
+ super tearDown.!
Item was added:
+ ----- Method: PreferencesTest>>test01Empty (in category 'tests') -----
+ test01Empty
+
+ self assert: sut dictionaryOfPreferences isEmpty.!
Item was added:
+ ----- Method: PreferencesTest>>test02AddSetRemovePreference (in category 'tests') -----
+ test02AddSetRemovePreference
+
+ self assert: (sut valueOfPreference: #foo ifAbsent: []) isNil.
+ self assert: (sut respondsTo: #foo) not. "auto-generated accessor"
+
+ sut addPreference: #foo category: #bar default: false.
+ self assert: (sut valueOfPreference: #foo ifAbsent: []) = false.
+ self assert: (sut perform: #foo) = false.
+
+ sut setPreference: #foo toValue: true.
+ self assert: (sut valueOfPreference: #foo ifAbsent: []) = true.
+ self assert: (sut perform: #foo) = true.
+
+ sut removePreference: #foo.
+ self assert: (sut valueOfPreference: #foo ifAbsent: []) isNil.
+ self assert: (sut respondsTo: #foo) not.!
Item was added:
+ ----- Method: PreferencesTest>>test03Type (in category 'tests') -----
+ test03Type
+
+ sut addPreference: #foo default: true.
+ self assert: (sut preferenceAt: #foo) type == #Boolean.
+
+ sut addPreference: #foo default: 123.
+ self assert: (sut preferenceAt: #foo) type == #Number.
+
+ sut addPreference: #foo default: 'Hello, World'.
+ self assert: (sut preferenceAt: #foo) type == #String.
+
+ sut addPreference: #foo default: Color red.
+ self assert: (sut preferenceAt: #foo) type == #Color.
+
+ sut addPreference: #foo default: 1 at 5.
+ self assert: (sut preferenceAt: #foo) type == #Object.
+ !
Item was added:
+ ----- Method: PreferencesTest>>test04TypeNoUpdate (in category 'tests') -----
+ test04TypeNoUpdate
+
+ sut addPreference: #foo default: true.
+ sut setPreference: #foo toValue: 123.
+
+ self assert: (sut preferenceAt: #foo) type == #Boolean.!
Item was added:
+ ----- Method: PreferencesTest>>test05AutoAdd (in category 'tests') -----
+ test05AutoAdd
+
+ | pref |
+ self assert: (sut valueOfPreference: #foo ifAbsent: []) isNil.
+ pref := sut setPreference: #foo toValue: 123.
+
+ self assert: pref preferenceValue = 123.!
Item was added:
+ ----- Method: PreferencesTest>>test06Flags (in category 'tests') -----
+ test06Flags
+ "Flags are boolean preferences."
+
+ self assert: (sut valueOfFlag: #isHappy) == false. "Not known but false for default."
+
+ sut setFlag: #isHappy toValue: true.
+ self assert: (sut valueOfFlag: #isHappy) == true.
+ self assert: (sut perform: #isHappy) == true.
+
+ sut disable: #useIt.
+ self assert: (sut valueOfFlag: #useIt) == false.
+ self assert: (sut perform: #useIt) == false.
+
+ sut enable: #useIt.
+ self assert: (sut valueOfFlag: #useIt) == true.
+ self assert: (sut perform: #useIt) == true.
+
+ sut toggle: #useIt.
+ self assert: (sut valueOfFlag: #useIt) == false. !
Item was added:
+ ----- Method: PreferencesTest>>test07UnknownPreference (in category 'tests') -----
+ test07UnknownPreference
+
+ self assert: (sut valueOfPreference: #notKnown) isNil.
+ self assert: (sut valueOfPreference: #notKnown ifAbsent: [#default]) = #default.!
Item was added:
+ ----- Method: PreferencesTest>>test08DNUFallback (in category 'tests') -----
+ test08DNUFallback
+
+ sut setPreference: #foo toValue: 123.
+ sut class removeSelectorSilently: #foo.
+
+ self assert: (sut perform: #foo) = 123.
+ self assert: (sut perform: #unknownSelector) isNil.!
Item was added:
+ ----- Method: PreferencesTest>>test09AddSetRemovePragmaPreference (in category 'tests') -----
+ test09AddSetRemovePragmaPreference
+
+ | id pref |
+ id := PreferencesTestExample name, '>>', #textPref.
+ pref := sut addPragmaPreference: (PreferencesTestExample class >> #textPref) pragmas first.
+
+ self assert: id equals: pref id.
+ self assert: (sut preferenceAt: pref id) == pref.
+
+ "Reset the preference explicitely."
+ PreferencesTestExample textPref: ''.
+ self assert: '' equals: PreferencesTestExample textPref.
+
+ sut setPreference: pref id toValue: 'foo'.
+ self assert: 'foo' equals: (sut valueOfPreference: pref id).
+ self assert: 'foo' equals: PreferencesTestExample textPref.
+
+ sut removePreference: pref id.
+ self assert: (sut preferenceAt: pref id ifAbsent: []) isNil.!
Item was added:
+ ----- Method: PreferencesTest>>test10Unclassified (in category 'tests') -----
+ test10Unclassified
+
+ | pref |
+ pref := sut addPreference: #foobar default: 123.
+ self assert: sut unclassifiedCategory equals: pref categoryList first.!
Item was added:
+ ----- Method: PreferencesTest>>test11CategoryList (in category 'tests') -----
+ test11CategoryList
+
+ sut addPreference: #foo category: #blubb default: 123.
+ self assert: #(blubb) equals: (sut categoryListOfPreference: #foo). !
Item was added:
+ ----- Method: PreferencesTest>>test12HardCodedPreference (in category 'tests') -----
+ test12HardCodedPreference
+
+ self assert: (sut respondsTo: #someStaticFoo) not.
+ sut compileAccessorForPreferenceNamed: #someStaticFoo value: 42.
+ self assert: 42 equals: (sut perform: #someStaticFoo).
+ self assert: (sut valueOfPreference: #someStaticFoo ifAbsent: []) isNil.
+
+ "Hard-coded preferences have their value only in the source code. We must leave them in the same package."
+ self deny: ((sut class organization categoryOfElement: #someStaticFoo) beginsWith: '*').
+
+ sut class removeSelectorSilently: #someStaticFoo.!
Item was added:
+ Object subclass: #PreferencesTestExample
+ instanceVariableNames: ''
+ classVariableNames: 'BooleanPref ColorPref NumericPref TextPref'
+ poolDictionaries: ''
+ category: 'Tests-System-Preferences'!
+
+ !PreferencesTestExample commentStamp: 'ar 3/3/2009 22:40' prior: 0!
+ This class provides an example for how to use preference pragmas.!
Item was added:
+ ----- Method: PreferencesTestExample class>>booleanPref (in category 'preferences') -----
+ booleanPref
+ <preference: 'Boolean Preference Example'
+ category: 'Examples'
+ description: 'A simple example for a boolean preference (see PreferenceExample>>booleanPref)'
+ type: #Boolean>
+ ^BooleanPref!
Item was added:
+ ----- Method: PreferencesTestExample class>>booleanPref: (in category 'preferences') -----
+ booleanPref: aBool
+ BooleanPref := aBool.
+ self inform: 'The new preference value is: ', aBool asString.!
Item was added:
+ ----- Method: PreferencesTestExample class>>colorPref (in category 'preferences') -----
+ colorPref
+ <preference: 'Color Preference Example'
+ category: 'Examples'
+ description: 'A simple example for a color preference (see PreferenceExample>>colorPref)'
+ type: #Color>
+ ^ColorPref!
Item was added:
+ ----- Method: PreferencesTestExample class>>colorPref: (in category 'preferences') -----
+ colorPref: aColor
+ ColorPref := aColor.
+ self inform: 'The new preference value is: ', aColor asString.!
Item was added:
+ ----- Method: PreferencesTestExample class>>initialize (in category 'preferences') -----
+ initialize "PreferenceExample initialize"
+ "Initialize the default values and register preferences"
+ TextPref := 'Hello World'.
+ NumericPref := 1234.
+ BooleanPref := true.
+ ColorPref := Color green.!
Item was added:
+ ----- Method: PreferencesTestExample class>>numericPref (in category 'preferences') -----
+ numericPref
+ <preference: 'Numeric Preference Example'
+ category: 'Examples'
+ description: 'A simple example for a numeric preference (see PreferenceExample>>numericPref)'
+ type: #Number>
+ ^NumericPref!
Item was added:
+ ----- Method: PreferencesTestExample class>>numericPref: (in category 'preferences') -----
+ numericPref: aNumber
+ NumericPref := aNumber.
+ self inform: 'The new preference value is: ', aNumber asString.!
Item was added:
+ ----- Method: PreferencesTestExample class>>textPref (in category 'preferences') -----
+ textPref
+ <preference: 'Textual Preference Example'
+ category: 'Examples'
+ description: 'A simple example for a textual preference (see PreferenceExample>>textPref)'
+ type: #String>
+ ^TextPref!
Item was added:
+ ----- Method: PreferencesTestExample class>>textPref: (in category 'preferences') -----
+ textPref: aString
+ TextPref := aString.!
Item was added:
+ Preferences subclass: #PreferencesTestPreferences
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Tests-System-Preferences'!
More information about the Squeak-dev
mailing list
|