1. Kink Programming Language
  2. Untitled project
  3. kink

Commits

Taku Miyakawa  committed 58f81a7

Improves \env.show and their tests

  • Participants
  • Parent commits b93be6c
  • Branches default

Comments (0)

Files changed (6)

File src/main/java/org/kink_lang/kink/Modules.java

View file
  • Ignore whitespace
         Fun showFun = new Fun() {
             @Override public Value run( Value actualEnv , Value ... args ) {
                 String show = "<env:#module_name=" + Strings.show( moduleName )
-                    + ":hash=" + actualEnv.hashCode() + ">";
+                    + ":hash=" + Value.value( actualEnv.hashCode() ) + ">";
                 return Value.value( show );
             }
         };

File src/main/java/org/kink_lang/kink/internal/module/Core.java

View file
  • Ignore whitespace
         public Value show( @Receiver Value envOrCore ) {
             return Value.value( envOrCore == CoreHolder.CORE
                     ? "CORE"
-                    : "<env:hash=" + envOrCore.hashCode() + ">" );
+                    : "<env:hash=" + Value.value( envOrCore.hashCode() ) + ">" );
         }
 
 

File src/test/java/org/kink_lang/kink/internal/IdentitiesTest.java

View file
  • Ignore whitespace
     public void show_identity() {
         Value value = Value.value();
         Value identity1 = Identities.identityValue( value );
-        Pattern expectedPattern = Pattern.compile( "<identity:hash=-?[0-9]+>" );
+        Pattern expectedPattern = Pattern.compile( "<identity:hash=([0-9]+|\\(-[0-9]+\\))>" );
         String actualResult1 = identity1.call( new GetSite( "show" ) ).asString( "" );
         assertThat( expectedPattern.matcher( actualResult1 ).matches() , is( true ) );
         Value identity2 = Identities.identityValue( value );

File src/test/java/org/kink_lang/kink/internal/module/CoreTest.java

View file
  • Ignore whitespace
     @Test
     public void show_of_child_of_core() {
         String show = core.child().call( new GetSite( "show" ) ).asString( "" );
-        assertThat( show.matches( "<env:hash=[0-9]+>" ) , is( true ) );
+        assertThat( show.matches( "<env:hash=([0-9]+|\\(-[0-9]+\\))>" ) , is( true ) );
     }
 
 

File src/test/kink/_internal/START_TEST.kn

View file
  • Ignore whitespace
 # 'run' makes the string representation of the environment
 test {
     :Program = 'show'.program('starttest.kn')
-    START._run(Program []).check(%"<env:#program.name='starttest.kn':hash=[0-9]+>")
+    START._run(Program []).check(%'<env:#program.name=''starttest.kn'':hash=([0-9]+|\(-[0-9]+\))>')
 }
 
 # 'run' cuts the traces

File src/test/kink/spec/MODULE_ENV_SHOW.kn

View file
  • Ignore whitespace
 use('TEST.test')
 
 test {
-    \env.show.check(%"<env:#module_name='spec/MODULE_ENV_SHOW':hash=[0-9]+>")
+    \env.show.check(%'<env:#module_name=''spec/MODULE_ENV_SHOW'':hash=([0-9]+|\(-[0-9]+\))>')
 }