{"action":"created","comment":{"url":"https://api.github.com/repos/iphydf/tox4j/pulls/comments/32972509","id":32972509,"diff_hunk":"@@ -0,0 +1,150 @@\n+package im.tox.hlapi.storage\n+\n+import scala.collection.immutable.{ HashMap, Map }\n+\n+import org.scalacheck._\n+import org.scalacheck.commands._\n+import org.scalacheck.Arbitrary._\n+\n+import org.scalatest._\n+import org.scalatest.prop.PropertyChecks\n+\n+private object FileSpecification extends Commands {\n+\n+  type Sut = MappedFile\n+\n+  final case class State(val size: Long, val values: HashMap[Long, Byte]) {\n+    def get(position: Long): Option[Byte] = values.get(position)\n+    def set(position: Long, value: Byte): State =\n+      copy(values = values + ((position, value)))\n+  }\n+\n+  def genInitialState: Gen[State] =\n+    for {\n+      keys <- Gen.nonEmptyContainerOf[List, Long](Gen.choose(0, 2 * 1024 * 1024 * 1024));\n+      values <- Gen.containerOfN[List, Byte](keys.size, arbitrary[Byte]);\n+      size <- Gen.choose(\n+        1 + 10.toLong max keys.max,\n+        2 * 10.toLong max keys.max\n+      )\n+    } yield State(size, HashMap(keys.zip(values): _*))\n+\n+  def initialPreCondition(s: State): Boolean = true\n+  def canCreateNewSut(newState: State, initStuts: Traversable[State],\n+    runningStuts: Traversable[Sut]): Boolean = true\n+  def newSut(state: State): Sut = TempMappedFile(state.size.toInt)\n+\n+  def destroySut(sut: Sut): Unit = ()\n+\n+  /* TODO(nbraud) Check that any sequence of read/write to any number of\n+   * (potentially overlapping) slices (in a single thread, over the same\n+   * FileLike) produce the same trace as the equivalent read/write sequence\n+   * on the model.\n+   */\n+\n+  private final case class Get(position: Long) extends SuccessCommand {\n+    type Result = Option[Byte]\n+    def nextState(s: State): State = s\n+\n+    def preCondition(s: State): Boolean = true\n+    def postCondition(s: State, r: Option[Byte]): Prop = {\n+      r match {\n+        case None => Prop(false)\n+        case Some(_) =>\n+          Prop(s.get(position) == r || s.get(position) == None)\n+      }\n+    }\n+\n+    def run(sut: Sut): Result = {\n+      val slice = sut(position, 1).orNull\n+      sut.get(slice)(0)\n+    }\n+  }\n+\n+  private final case class Set(position: Long, value: Byte) extends SuccessCommand {\n+    type Result = Boolean\n+    def nextState(s: State): State = {\n+      s.set(position, value)\n+    }\n+\n+    def preCondition(s: State): Boolean = true\n+    def postCondition(s: State, r: Boolean): Prop = Prop(r)\n+\n+    def run(sut: Sut): Result = {\n+      val slice = sut(position, 1).orNull\n+      sut.set(slice)(0, value)\n+    }\n+\n+  }\n+\n+  private final case class Overlap(\n+      position: Long,\n+      length1: Int, overlap: Int, length2: Int\n+  ) extends SuccessCommand {\n+    type Result = (Byte, Byte, Byte, Byte)\n+    def nextState(s: State): State = {\n+      s.set(position + length1 - overlap, 0xCA.toByte)\n+        .set(position + length1 - overlap + 1, 0xFE.toByte)\n+    }\n+\n+    def preCondition(s: State): Boolean = true\n+\n+    def postCondition(s: State, r: Result): Prop = {\n+      r == ((0xCA.toByte, 0xFE.toByte, 0xCA.toByte, 0xFE.toByte))\n+    }\n+\n+    def run(sut: Sut): Result = {","path":"src/test/java/im/tox/hlapi/storage/FileLikeTest.scala","position":96,"original_position":96,"commit_id":"f11ff9e6aeef16eff6c43a19f29b59ffb7a28176","original_commit_id":"f11ff9e6aeef16eff6c43a19f29b59ffb7a28176","user":{"login":"iphydf","id":10647936,"avatar_url":"https://avatars.githubusercontent.com/u/10647936?v=3","gravatar_id":"","url":"https://api.github.com/users/iphydf","html_url":"https://github.com/iphydf","followers_url":"https://api.github.com/users/iphydf/followers","following_url":"https://api.github.com/users/iphydf/following{/other_user}","gists_url":"https://api.github.com/users/iphydf/gists{/gist_id}","starred_url":"https://api.github.com/users/iphydf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iphydf/subscriptions","organizations_url":"https://api.github.com/users/iphydf/orgs","repos_url":"https://api.github.com/users/iphydf/repos","events_url":"https://api.github.com/users/iphydf/events{/privacy}","received_events_url":"https://api.github.com/users/iphydf/received_events","type":"User","site_admin":false},"body":"can this sut variable get a better name? It's a MappedFile, so maybe call it file?","created_at":"2015-06-22T19:18:38Z","updated_at":"2015-06-22T19:18:38Z","html_url":"https://github.com/iphydf/tox4j/pull/6#discussion_r32972509","pull_request_url":"https://api.github.com/repos/iphydf/tox4j/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/comments/32972509"},"html":{"href":"https://github.com/iphydf/tox4j/pull/6#discussion_r32972509"},"pull_request":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/iphydf/tox4j/pulls/6","id":37702437,"html_url":"https://github.com/iphydf/tox4j/pull/6","diff_url":"https://github.com/iphydf/tox4j/pull/6.diff","patch_url":"https://github.com/iphydf/tox4j/pull/6.patch","issue_url":"https://api.github.com/repos/iphydf/tox4j/issues/6","number":6,"state":"open","locked":false,"title":"HLAPI: Add FileLike component","user":{"login":"nbraud","id":1155801,"avatar_url":"https://avatars.githubusercontent.com/u/1155801?v=3","gravatar_id":"","url":"https://api.github.com/users/nbraud","html_url":"https://github.com/nbraud","followers_url":"https://api.github.com/users/nbraud/followers","following_url":"https://api.github.com/users/nbraud/following{/other_user}","gists_url":"https://api.github.com/users/nbraud/gists{/gist_id}","starred_url":"https://api.github.com/users/nbraud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbraud/subscriptions","organizations_url":"https://api.github.com/users/nbraud/orgs","repos_url":"https://api.github.com/users/nbraud/repos","events_url":"https://api.github.com/users/nbraud/events{/privacy}","received_events_url":"https://api.github.com/users/nbraud/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-15T15:15:51Z","updated_at":"2015-06-22T19:18:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8142d42e0c5b667451a3fe013ad32566146359e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/iphydf/tox4j/pulls/6/commits","review_comments_url":"https://api.github.com/repos/iphydf/tox4j/pulls/6/comments","review_comment_url":"https://api.github.com/repos/iphydf/tox4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iphydf/tox4j/issues/6/comments","statuses_url":"https://api.github.com/repos/iphydf/tox4j/statuses/f11ff9e6aeef16eff6c43a19f29b59ffb7a28176","head":{"label":"nbraud:FileLike","ref":"FileLike","sha":"f11ff9e6aeef16eff6c43a19f29b59ffb7a28176","user":{"login":"nbraud","id":1155801,"avatar_url":"https://avatars.githubusercontent.com/u/1155801?v=3","gravatar_id":"","url":"https://api.github.com/users/nbraud","html_url":"https://github.com/nbraud","followers_url":"https://api.github.com/users/nbraud/followers","following_url":"https://api.github.com/users/nbraud/following{/other_user}","gists_url":"https://api.github.com/users/nbraud/gists{/gist_id}","starred_url":"https://api.github.com/users/nbraud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbraud/subscriptions","organizations_url":"https://api.github.com/users/nbraud/orgs","repos_url":"https://api.github.com/users/nbraud/repos","events_url":"https://api.github.com/users/nbraud/events{/privacy}","received_events_url":"https://api.github.com/users/nbraud/received_events","type":"User","site_admin":false},"repo":{"id":35310249,"name":"tox4j","full_name":"nbraud/tox4j","owner":{"login":"nbraud","id":1155801,"avatar_url":"https://avatars.githubusercontent.com/u/1155801?v=3","gravatar_id":"","url":"https://api.github.com/users/nbraud","html_url":"https://github.com/nbraud","followers_url":"https://api.github.com/users/nbraud/followers","following_url":"https://api.github.com/users/nbraud/following{/other_user}","gists_url":"https://api.github.com/users/nbraud/gists{/gist_id}","starred_url":"https://api.github.com/users/nbraud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbraud/subscriptions","organizations_url":"https://api.github.com/users/nbraud/orgs","repos_url":"https://api.github.com/users/nbraud/repos","events_url":"https://api.github.com/users/nbraud/events{/privacy}","received_events_url":"https://api.github.com/users/nbraud/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nbraud/tox4j","description":"New and improved java wrapper for Tox","fork":true,"url":"https://api.github.com/repos/nbraud/tox4j","forks_url":"https://api.github.com/repos/nbraud/tox4j/forks","keys_url":"https://api.github.com/repos/nbraud/tox4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nbraud/tox4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nbraud/tox4j/teams","hooks_url":"https://api.github.com/repos/nbraud/tox4j/hooks","issue_events_url":"https://api.github.com/repos/nbraud/tox4j/issues/events{/number}","events_url":"https://api.github.com/repos/nbraud/tox4j/events","assignees_url":"https://api.github.com/repos/nbraud/tox4j/assignees{/user}","branches_url":"https://api.github.com/repos/nbraud/tox4j/branches{/branch}","tags_url":"https://api.github.com/repos/nbraud/tox4j/tags","blobs_url":"https://api.github.com/repos/nbraud/tox4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nbraud/tox4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nbraud/tox4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/nbraud/tox4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nbraud/tox4j/statuses/{sha}","languages_url":"https://api.github.com/repos/nbraud/tox4j/languages","stargazers_url":"https://api.github.com/repos/nbraud/tox4j/stargazers","contributors_url":"https://api.github.com/repos/nbraud/tox4j/contributors","subscribers_url":"https://api.github.com/repos/nbraud/tox4j/subscribers","subscription_url":"https://api.github.com/repos/nbraud/tox4j/subscription","commits_url":"https://api.github.com/repos/nbraud/tox4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/nbraud/tox4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/nbraud/tox4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/nbraud/tox4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/nbraud/tox4j/contents/{+path}","compare_url":"https://api.github.com/repos/nbraud/tox4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nbraud/tox4j/merges","archive_url":"https://api.github.com/repos/nbraud/tox4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nbraud/tox4j/downloads","issues_url":"https://api.github.com/repos/nbraud/tox4j/issues{/number}","pulls_url":"https://api.github.com/repos/nbraud/tox4j/pulls{/number}","milestones_url":"https://api.github.com/repos/nbraud/tox4j/milestones{/number}","notifications_url":"https://api.github.com/repos/nbraud/tox4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nbraud/tox4j/labels{/name}","releases_url":"https://api.github.com/repos/nbraud/tox4j/releases{/id}","created_at":"2015-05-09T01:40:39Z","updated_at":"2015-06-06T14:20:20Z","pushed_at":"2015-06-21T16:11:29Z","git_url":"git://github.com/nbraud/tox4j.git","ssh_url":"git@github.com:nbraud/tox4j.git","clone_url":"https://github.com/nbraud/tox4j.git","svn_url":"https://github.com/nbraud/tox4j","homepage":null,"size":2306,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"hlapi"}},"base":{"label":"iphydf:auto","ref":"auto","sha":"2835281b6e348f55ff172a1a43279f7bb47d4290","user":{"login":"iphydf","id":10647936,"avatar_url":"https://avatars.githubusercontent.com/u/10647936?v=3","gravatar_id":"","url":"https://api.github.com/users/iphydf","html_url":"https://github.com/iphydf","followers_url":"https://api.github.com/users/iphydf/followers","following_url":"https://api.github.com/users/iphydf/following{/other_user}","gists_url":"https://api.github.com/users/iphydf/gists{/gist_id}","starred_url":"https://api.github.com/users/iphydf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iphydf/subscriptions","organizations_url":"https://api.github.com/users/iphydf/orgs","repos_url":"https://api.github.com/users/iphydf/repos","events_url":"https://api.github.com/users/iphydf/events{/privacy}","received_events_url":"https://api.github.com/users/iphydf/received_events","type":"User","site_admin":false},"repo":{"id":32993709,"name":"tox4j","full_name":"iphydf/tox4j","owner":{"login":"iphydf","id":10647936,"avatar_url":"https://avatars.githubusercontent.com/u/10647936?v=3","gravatar_id":"","url":"https://api.github.com/users/iphydf","html_url":"https://github.com/iphydf","followers_url":"https://api.github.com/users/iphydf/followers","following_url":"https://api.github.com/users/iphydf/following{/other_user}","gists_url":"https://api.github.com/users/iphydf/gists{/gist_id}","starred_url":"https://api.github.com/users/iphydf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iphydf/subscriptions","organizations_url":"https://api.github.com/users/iphydf/orgs","repos_url":"https://api.github.com/users/iphydf/repos","events_url":"https://api.github.com/users/iphydf/events{/privacy}","received_events_url":"https://api.github.com/users/iphydf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iphydf/tox4j","description":"New and improved java wrapper for Tox","fork":true,"url":"https://api.github.com/repos/iphydf/tox4j","forks_url":"https://api.github.com/repos/iphydf/tox4j/forks","keys_url":"https://api.github.com/repos/iphydf/tox4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iphydf/tox4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iphydf/tox4j/teams","hooks_url":"https://api.github.com/repos/iphydf/tox4j/hooks","issue_events_url":"https://api.github.com/repos/iphydf/tox4j/issues/events{/number}","events_url":"https://api.github.com/repos/iphydf/tox4j/events","assignees_url":"https://api.github.com/repos/iphydf/tox4j/assignees{/user}","branches_url":"https://api.github.com/repos/iphydf/tox4j/branches{/branch}","tags_url":"https://api.github.com/repos/iphydf/tox4j/tags","blobs_url":"https://api.github.com/repos/iphydf/tox4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iphydf/tox4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iphydf/tox4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/iphydf/tox4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iphydf/tox4j/statuses/{sha}","languages_url":"https://api.github.com/repos/iphydf/tox4j/languages","stargazers_url":"https://api.github.com/repos/iphydf/tox4j/stargazers","contributors_url":"https://api.github.com/repos/iphydf/tox4j/contributors","subscribers_url":"https://api.github.com/repos/iphydf/tox4j/subscribers","subscription_url":"https://api.github.com/repos/iphydf/tox4j/subscription","commits_url":"https://api.github.com/repos/iphydf/tox4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/iphydf/tox4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/iphydf/tox4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/iphydf/tox4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/iphydf/tox4j/contents/{+path}","compare_url":"https://api.github.com/repos/iphydf/tox4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iphydf/tox4j/merges","archive_url":"https://api.github.com/repos/iphydf/tox4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iphydf/tox4j/downloads","issues_url":"https://api.github.com/repos/iphydf/tox4j/issues{/number}","pulls_url":"https://api.github.com/repos/iphydf/tox4j/pulls{/number}","milestones_url":"https://api.github.com/repos/iphydf/tox4j/milestones{/number}","notifications_url":"https://api.github.com/repos/iphydf/tox4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iphydf/tox4j/labels{/name}","releases_url":"https://api.github.com/repos/iphydf/tox4j/releases{/id}","created_at":"2015-03-27T15:26:33Z","updated_at":"2015-06-06T19:17:42Z","pushed_at":"2015-06-21T16:11:29Z","git_url":"git://github.com/iphydf/tox4j.git","ssh_url":"git@github.com:iphydf/tox4j.git","clone_url":"https://github.com/iphydf/tox4j.git","svn_url":"https://github.com/iphydf/tox4j","homepage":null,"size":3320,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":1,"default_branch":"auto"}},"_links":{"self":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/6"},"html":{"href":"https://github.com/iphydf/tox4j/pull/6"},"issue":{"href":"https://api.github.com/repos/iphydf/tox4j/issues/6"},"comments":{"href":"https://api.github.com/repos/iphydf/tox4j/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iphydf/tox4j/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/iphydf/tox4j/statuses/f11ff9e6aeef16eff6c43a19f29b59ffb7a28176"}}}}