Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check this method. #89

Open
mabdi opened this issue Jul 31, 2020 · 2 comments
Open

Check this method. #89

mabdi opened this issue Jul 31, 2020 · 2 comments
Labels
bug Something isn't working TODO

Comments

@mabdi
Copy link
Owner

mabdi commented Jul 31, 2020

This method from zinc project:

testMultiValues
	| dictionary values keys |
	dictionary := ZnMultiValueDictionary new.
	dictionary at: 'foo' add: 1; at: 'foo' add: 2.
	self assert: (dictionary at: 'foo') = #(1 2).
	self assert: dictionary keys asArray = #('foo').
	values := OrderedCollection new.
	keys := OrderedCollection new.
	dictionary keysAndValuesDo: [ :key :value | keys add: key. values add: value ].
	self assert: values = (OrderedCollection with: 1 with: 2).
	self assert: keys = (OrderedCollection with: 'foo' with: 'foo')

is converted to it:

testMultiValues_amp_L20
	<madeBySmallAmp>
	| dictionary values keys |
	dictionary := ZnMultiValueDictionary new.
	dictionary := dictionary
		at: 'foo' add: 1;
		at: 'foo' add: 1.
	values := OrderedCollection new.
	keys := OrderedCollection new.
	 dictionary
				keysAndValuesDo: [ :key :value | 
					keys add: key.
					values add: value ] 

Line 5 of Which does not look correct. Why the dictionary variable is set to the result of Dictionary>>#at:add: ?

@mabdi mabdi added the TODO label Jul 31, 2020
@mabdi
Copy link
Owner Author

mabdi commented Aug 3, 2020

And:

testMergedFields
	| request form mergedFields |
	request := ZnRequest post: 'http://host.com/foo?x=1&y=2&x=3'.
	form := ZnApplicationFormUrlEncodedEntity new.
	form
		at: #z put: '100';
		at: #z add: '200';
		at: #y put: '0'.
	request entity: form.
	mergedFields := request mergedFields.
	self assert: mergedFields keys sorted equals: #(x y z).
	self assert: (mergedFields at: #x) sorted equals: #('1' '3').
	self assert: (mergedFields at: #y) sorted equals: #('0' '2').
	self assert: (mergedFields at: #z) sorted equals: #('100' '200')

I get:

request := ZnRequest post: 'http:/D/host.com/foo?x=1&y=2&x=3'.
	form := ZnApplicationFormUrlEncodedEntity new.
	form := form
		at: #z put: '100';
		at: #z add: '200';
		at: #y put: '0'.

@mabdi mabdi added the bug Something isn't working label Aug 16, 2020
@mabdi
Copy link
Owner Author

mabdi commented Aug 16, 2020

testFailValidateInterfaceTypeExtension
	| valid |
	schema := self parseSchema: '
						schema { 
							query: Query
						}
						type GQLFilm implements RelevantData { 
							name: String
						}
						interface RelevantData{
							name : String
						}
						extend interface OtherInterface{
							id: String
						}'.
	self should: [ schema validate ] raise: GQLValidationException.
	
	schema := self parseSchema: '
						schema { 
							query: Query
						}
						type GQLFilm implements RelevantData { 
							name: String
						}
						interface RelevantData{
							name : String
						}
						extend interface RelevantData{
							name: String
							id: String
						}'.
	self should: [ schema validate ] raise: GQLValidationException.
	
	schema := self parseSchema: '
						schema { 
							query: GQLTestFilm
						}
						interface NamedEntity{
							name: String
						}
						extend interface NamedEntity{
							id: String
						}
						type GQLTestFilm implements NamedEntity{
							name: String
						}'.
	self should: [ schema validate ] raise: GQLValidationException.
	
	schema := self parseSchema: '
						schema { 
							query: GQLTestFilm
						}
						interface NamedEntity{
							name: String
						}
						extend interface NamedEntity{
							id: String
						}
						type GQLTestFilm{
							filmName: String
						}
						extend type GQLTestFilm implements NamedEntity{
							id: String
						}'.
	valid := schema validate.
	self should: [ schema validate ] raise: GQLValidationException.

I get:

testFailValidateInterfaceTypeExtension_amp
	"I test correctness of: 

- `^ query` in method: `GQLSSchemaNode >> #query` when {#query->nil}

"

	<madeBySmallAmp>
	| valid |
	schema := self
		parseSchema:
			'
						schema { 
							query: Query
						}
						type GQLFilm implements RelevantData { 
							name: String
						}
						interface RelevantData{
							name : String
						}
						extend interface OtherInterface{
							id: String
						}';
		assert: schema query isNil;
		parseSchema:
			'
						schema { 
							query: Query
						}
						type GQLFilm implements RelevantData { 
							name: String
						}
						interface RelevantData{
							name : String
						}
						extend interface RelevantData{
							name: String
							id: String
						}';
		parseSchema:
			'
						schema { 
							query: GQLTestFilm
						}
						interface NamedEntity{
							name: String
						}
						extend interface NamedEntity{
							id: String
						}
						type GQLTestFilm implements NamedEntity{
							name: String
						}'.
	valid := (self
		parseSchema:
			'
						schema { 
							query: GQLTestFilm
						}
						interface NamedEntity{
							name: String
						}
						extend interface NamedEntity{
							id: String
						}
						type GQLTestFilm{
							filmName: String
						}
						extend type GQLTestFilm implements NamedEntity{
							id: String
						}') validate

(Line with assert) It should first set schema then assert the value. Using cascade in this example is not correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working TODO
Projects
None yet
Development

No branches or pull requests

1 participant