[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[jx8-android] 013 - More Arrays

"boolean array object"
| array r |
array := Java current
	newArray: 'java.lang.Boolean'
	withAll: (Array with: true with: false).
r := Java current
	callStaticMethodSync: #Test
	method: #staticBooleanArray
	with: array.
r size = 2 ifFalse: [
	self error: 'Invalid length'
].
(r first = true and: [ r second = false ]) ifFalse: [
	self error: 'Invalid contents'
].


"byte array object"
| r |
r := Java current
	newArray: #byte
	withAll: (#(1 2 3) collect:[:i|
		Java current newByte: i
		]) handles.
r size = 3 ifFalse: [
	self error: 'Invalid length - missing wrapper?'
].
(r first = 1
and: [ r second = 2
and: [ r last   = 3 ] ]) ifFalse: [
	self error: 'Invalid contents'
].


"boolean array"
| r |
r := Java current
	newArray: #boolean
	withAll: (Array with: true with: false).
r size = 2 ifFalse: [
	self error: 'Invalid length - missing wrapper?'
].
(r first = true and: [ r second = false ]) ifFalse: [
	self error: 'Invalid contents'
].


"int array"
| r |
r := Java current
	newArray: #int
	withAll: #(1 2).
r size = 2 ifFalse: [
	self error: 'Invalid length - missing wrapper?'
].
(r first = 1 and: [ r second = 2 ]) ifFalse: [
	self error: 'Invalid contents'
].


"double array"
| r |
r := Java current
	newArray: #double
	withAll: (#(1.2 4) collect:[:i|
		Java current newDouble: i
		]) handles.
r size = 2 ifFalse: [
	self error: 'Invalid length - missing wrapper?'
].
(r first = 1.2 and: [ r second = 4 ]) ifFalse: [
	self error: 'Invalid contents'
].


"short array objects"
| array r |
array := Java current
	newArray: 'java.lang.Short'
	withAll: (#(1 2) collect:[:i|
		Java current newShort: i
		]) handles.
r := Java current
	callStaticMethodSync: #Test
	method: #staticShortArray
	with: array.
r size = 2 ifFalse: [
	self error: 'Invalid length'
].
(r first = 1 and: [ r second = 2 ]) ifFalse: [
	self error: 'Invalid contents'
].


"short array"

| array r |
array := Java current
	newArray: #short
	withAll: (#(1 2) collect:[:i|
		Java current newShort: i
		]) handles.
r := Java current
	callStaticMethodSync: #Test
	method: #staticShortArray
	with: array.
r size = 2 ifFalse: [
	self error: 'Invalid length - missing wrapper?'
].
(r first = 1 and: [ r second = 2 ]) ifFalse: [
	self error: 'Invalid contents'
].