lang-smalltalk / spyvm / test /

Lars Wassermann 4d577f6 

Lars Wassermann ce39ff5 
Lars Wassermann 4d577f6 

Lars Wassermann ce39ff5 

import py
from spyvm import model, fieldtypes
from spyvm import objspace

from spyvm.fieldtypes import obj, SInt, LPI, flt

def test_simple_changes():
	a = fieldtypes.FieldTypes.of_length(3)
	assert a.types == [obj, obj, obj]
	b = a.sibling(1, SInt)
	assert b.types == [obj, SInt, obj]
	c = a.sibling(1, SInt)
	assert b is c

def test_two_level_changes_identity():
	a = fieldtypes.FieldTypes.of_length(3)
	b = a.sibling(1, SInt)
	c = a.sibling(0, SInt)
	d = b.sibling(0, SInt)
	assert d.types == [SInt, SInt, obj]
	e = c.sibling(1, SInt)
	assert d is e

def test_numberOfElements():
	a = fieldtypes.FieldTypes.of_length(3)
	a.sibling(0, SInt).sibling(1, SInt).sibling(2, SInt)
	a.sibling(1, SInt).sibling(2, SInt)
	a.sibling(2, SInt).sibling(0, SInt)
	assert a.sibling(2, SInt).sibling(0, SInt).parent is a.sibling(0, SInt)
	assert len(a.siblings) == 3
	assert len(a.sibling(0, SInt).siblings) == 2
	assert len(a.sibling(1, SInt).siblings) == 2
	assert len(a.sibling(2, SInt).siblings) == 1 # link to [o, i, i] not created

def test_multiple_changes():
	a = fieldtypes.FieldTypes.of_length(3)
	b = a.sibling(0, SInt)
	for tag in [LPI, flt]:
		assert b.sibling(0, tag).types == [tag, obj, obj]

def test_obj_replacement():
	a = fieldtypes.FieldTypes.of_length(3)
	b = a.sibling(0, SInt).sibling(1, SInt)
	c = a.sibling(1, SInt)
	assert b.sibling(0, obj) is c
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.