
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 1.58 KB | hits: 15 | expires: Never
<?php
/* This class is part of the XP framework
*
* $Id$
*/
$package= 'net.xp_lang.tests.execution.source';
uses('net.xp_lang.tests.execution.source.ExecutionTest');
/**
* Tests null-safe object operator ?.
*
*/
class net·xp_lang·tests·execution·source·NullSafeObjectOperatorTest extends ExecutionTest {
/**
* Test
*
*/
#[@test]
public function nullDotMethod() {
$this->assertNull($this->run('$instance= null; return $instance?.method();'));
}
/**
* Test
*
*/
#[@test]
public function nullReturnedFromMethod() {
$this->assertNull($this->run('$v= new util.collections.Vector<var>(); $v.add(null); return $v.get(0)?.hashCode();'));
}
/**
* Test
*
*/
#[@test]
public function nullNotReturnedFromMethod() {
$this->assertNotEquals(NULL, $this->run('$v= new util.collections.Vector<var>(); $v.add($this); return $v.get(0)?.hashCode();'));
}
/**
* Test
*
*/
#[@test]
public function twoNullSafeObjectOperatorsInOneChain() {
$this->assertNull($this->run('$v= new util.collections.Vector<var>(); $v.add(null); return $v?.get(0)?.hashCode();'));
}
/**
* Test
*
*/
#[@test]
public function nullDotProperty() {
$this->assertNull($this->run('$instance= null; return $instance?.property;'));
}
/**
* Test
*
*/
#[@test, @ignore('Generates syntax error, unexpected ")"')]
public function nullDotInvoke() {
$this->compile('$instance= null; return $instance?.();');
}
}
?>