Skip to content

Commit

Permalink
Fix : applied git ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
myeonginwoo committed Dec 14, 2016
1 parent 8f5efd2 commit 4247c6e
Show file tree
Hide file tree
Showing 14 changed files with 796 additions and 45 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ proguard/
# Captures
captures/
out/
/.gradle/
Binary file modified .gradle/3.1/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/3.1/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/3.1/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/3.1/taskArtifacts/taskArtifacts.bin
Binary file not shown.
16 changes: 0 additions & 16 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

752 changes: 724 additions & 28 deletions .idea/workspace.xml

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions Either/src/main/kotlin/Either.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main.kotlin

/**
* Created by Lazysoul on 2016. 12. 14..
*/
sealed class Either<L : Any, R : Any> {

var isLeft: Boolean = false
var isRight: Boolean = false

var left: Left<L, Nothing>? = null
var right: Right<Nothing, R>? = null
abstract fun get(): Any

class Left<L : Any, R : Any>(val value: L) : Either<L, R>() {
init {
isLeft = true
}

override fun get(): L {
return value
}

}

class Right<L : Any, R : Any>(val value: R) : Either<L, R>() {
init {
isRight = true
}

override fun get(): R {
return value
}
}
}
29 changes: 29 additions & 0 deletions Either/src/test/kotlin/EitherTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package test.kotlin

import main.kotlin.Either
import main.kotlin.Either.Left
import main.kotlin.Either.Right
import org.junit.Assert.assertEquals
import org.junit.Test

/**
* Created by Lazysoul on 2016. 12. 14..
*/
class EitherTest {

@Test fun leftTest() {
val left: Either<String, Int> = Left("test")
assertEquals("test", left.get())
assertEquals(true, left.isLeft)
assertEquals(false, left.isRight)
assertEquals(null, left.right?.get())
}

@Test fun rightTest() {
val right: Either<String, Int> = Right(6)
assertEquals(6, right.get())
assertEquals(false, right.isLeft)
assertEquals(true, right.isRight)
assertEquals(null, right.left?.get())
}
}
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ repositories {
mavenCentral()
}

sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
test.kotlin.srcDirs += 'src/test/kotlin'
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testCompile 'junit:junit:4.12'
}
Binary file added lib/kotlin-reflect.jar
Binary file not shown.
Binary file added lib/kotlin-runtime-sources.jar
Binary file not shown.
Binary file added lib/kotlin-runtime.jar
Binary file not shown.

0 comments on commit 4247c6e

Please sign in to comment.