def test_copy_of(self): scope = activity.Scope(None) scope.mark_read(QN('foo')) self.assertTrue(QN('foo') in activity.Scope.copy_of(scope).used) child_scope = activity.Scope(scope) child_scope.mark_read(QN('bar')) self.assertTrue(QN('bar') in activity.Scope.copy_of(child_scope).used)
def test_nesting(self): scope = activity.Scope(None) scope.mark_write(QN('foo')) scope.mark_read(QN('bar')) child = activity.Scope(scope) self.assertTrue(child.has(QN('foo'))) self.assertTrue(scope.has(QN('foo'))) child.mark_write(QN('bar')) self.assertTrue(child.has(QN('bar'))) self.assertFalse(scope.has(QN('bar')))
def test_referenced(self): scope = activity.Scope(None) scope.mark_read(QN('a')) child = activity.Scope(scope) child.mark_read(QN('b')) child2 = activity.Scope(child, isolated=False) child2.mark_read(QN('c')) self.assertTrue(QN('c') in child2.referenced) self.assertTrue(QN('b') in child2.referenced) self.assertFalse(QN('a') in child2.referenced) self.assertTrue(QN('c') in child.referenced) self.assertTrue(QN('b') in child.referenced) self.assertFalse(QN('a') in child.referenced)
def test_copy(self): scope = activity.Scope(None) scope.mark_write(QN('foo')) other = activity.Scope(None) other.copy_from(scope) self.assertTrue(QN('foo') in other.created) scope.mark_write(QN('bar')) scope.copy_from(other) self.assertFalse(QN('bar') in scope.created) scope.mark_write(QN('bar')) scope.merge_from(other) self.assertTrue(QN('bar') in scope.created) self.assertFalse(QN('bar') in other.created)
def test_basic(self): scope = activity.Scope(None) self.assertFalse(scope.has(QN('foo'))) scope.mark_read(QN('foo')) self.assertFalse(scope.has(QN('foo'))) scope.mark_write(QN('foo')) self.assertTrue(scope.has(QN('foo'))) scope.mark_read(QN('bar')) self.assertFalse(scope.has(QN('bar')))