-
Notifications
You must be signed in to change notification settings - Fork 16
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
#1984 (texto en visual objects) y #1985 (objetos invisibles) #1986
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ct.wollok.game/src/org/uqbar/project/wollok/game/helpers/WollokConventionExtensions.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...llok.tests/src/org/uqbar/project/wollok/tests/interpreter/language/WollokObjectTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package org.uqbar.project.wollok.tests.interpreter.language | ||
|
||
import org.junit.Test | ||
import org.uqbar.project.wollok.interpreter.core.WollokObject | ||
import org.uqbar.project.wollok.tests.interpreter.AbstractWollokInterpreterTestCase | ||
|
||
class WollokObjectTest extends AbstractWollokInterpreterTestCase { | ||
|
||
@Test | ||
def void testUnderstand() { | ||
''' | ||
object myObject { | ||
|
||
var privateVar = "private" | ||
var property aVarProperty = "writable" | ||
const property aConstProperty = "readOnly" | ||
|
||
method aGetter() { | ||
return "foo" | ||
} | ||
|
||
method aSetter(foo) { | ||
|
||
} | ||
|
||
method aMethod(foo, bar) { | ||
|
||
} | ||
} | ||
|
||
//A program is necessary in order to evaluate and create the WollokObject | ||
program abc { | ||
myObject | ||
} | ||
'''.interpretPropagatingErrors | ||
|
||
val myWollokObject = "myObject".asWollokObject | ||
|
||
myWollokObject.assertProperties | ||
myWollokObject.assertVarProperties | ||
myWollokObject.assertConstantProperties | ||
myWollokObject.assertUnderstands | ||
|
||
} | ||
|
||
def assertUnderstands(WollokObject myWollokObject) { | ||
val zeroParams = #[] as WollokObject[] | ||
val oneParam = #[myWollokObject] as WollokObject[] | ||
val twoParams = #[myWollokObject , myWollokObject] as WollokObject[] | ||
|
||
assertFalse(myWollokObject.understands("privateVar", zeroParams)) | ||
assertFalse(myWollokObject.understands("privateVar", oneParam)) | ||
assertFalse(myWollokObject.understands("privateVar", twoParams)) | ||
|
||
assertTrue(myWollokObject.understands("aVarProperty", zeroParams)) | ||
assertTrue(myWollokObject.understands("aVarProperty", oneParam)) | ||
assertFalse(myWollokObject.understands("aVarProperty", twoParams)) | ||
|
||
assertTrue(myWollokObject.understands("aConstProperty", zeroParams)) | ||
assertFalse(myWollokObject.understands("aConstProperty", oneParam)) | ||
assertFalse(myWollokObject.understands("aConstProperty", twoParams)) | ||
|
||
assertTrue(myWollokObject.understands("aGetter", zeroParams)) | ||
assertFalse(myWollokObject.understands("aGetter", oneParam)) | ||
assertFalse(myWollokObject.understands("aGetter", twoParams)) | ||
|
||
assertFalse(myWollokObject.understands("aSetter", zeroParams)) | ||
assertTrue(myWollokObject.understands("aSetter", oneParam)) | ||
assertFalse(myWollokObject.understands("aSetter", twoParams)) | ||
|
||
assertFalse(myWollokObject.understands("aMethod", zeroParams)) | ||
assertFalse(myWollokObject.understands("aMethod", oneParam)) | ||
assertTrue(myWollokObject.understands("aMethod", twoParams)) | ||
|
||
assertFalse(myWollokObject.understands("nonExistent", zeroParams)) | ||
assertFalse(myWollokObject.understands("nonExistent", oneParam)) | ||
assertFalse(myWollokObject.understands("nonExistent", twoParams)) | ||
} | ||
|
||
def assertConstantProperties(WollokObject myWollokObject) { | ||
assertFalse(myWollokObject.hasConstantProperty("privateVar")) | ||
assertFalse(myWollokObject.hasConstantProperty("aVarProperty")) | ||
assertTrue(myWollokObject.hasConstantProperty("aConstProperty")) | ||
assertFalse(myWollokObject.hasConstantProperty("aGetter")) | ||
assertFalse(myWollokObject.hasConstantProperty("aSetter")) | ||
assertFalse(myWollokObject.hasConstantProperty("aMetthod")) | ||
assertFalse(myWollokObject.hasConstantProperty("nonExistent")) | ||
} | ||
|
||
def assertVarProperties(WollokObject myWollokObject) { | ||
assertFalse(myWollokObject.hasVarProperty("privateVar")) | ||
assertTrue(myWollokObject.hasVarProperty("aVarProperty")) | ||
assertFalse(myWollokObject.hasVarProperty("aConstProperty")) | ||
assertFalse(myWollokObject.hasVarProperty("aGetter")) | ||
assertFalse(myWollokObject.hasVarProperty("aSetter")) | ||
assertFalse(myWollokObject.hasVarProperty("aMetthod")) | ||
assertFalse(myWollokObject.hasVarProperty("nonExistent")) | ||
} | ||
|
||
def assertProperties(WollokObject myWollokObject) { | ||
assertFalse(myWollokObject.hasProperty("privateVar")) | ||
assertTrue(myWollokObject.hasProperty("aVarProperty")) | ||
assertTrue(myWollokObject.hasProperty("aConstProperty")) | ||
assertFalse(myWollokObject.hasProperty("aGetter")) | ||
assertFalse(myWollokObject.hasProperty("aSetter")) | ||
assertFalse(myWollokObject.hasProperty("aMetthod")) | ||
assertFalse(myWollokObject.hasProperty("nonExistent")) | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hay que tener cuidado con esto. Este objeto tiene 2 constructores por las dos formas que tiene WG de indicar la posición de un objeto:
game.addVisual
usa el primero, e indica que el objeto es quien conoce a su posición.game.addVisualIn
la posición es pasada por parámetro y el objeto no la conoce.Si hacemos que uno delegue en el otro, CREO que el primer (y más usado) caso cachearía la posición inicial pero no se actualizaría a medida que el objeto cambie su posición.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sí, efectivamente acá había quedado ese bug, ahí lo arreglé en #1990 junto con otros detalles consecuencias de este PR) 😃