Skip to content

Commit 8f127bc

Browse files
authored
Merge pull request #48 from javecs/feature/lb-kg
ポンドをキログラムに変換しました。
2 parents 196521f + 507c2ae commit 8f127bc

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
}
1717

1818
group 'xyz.javecs.tools'
19-
version '0.1.7'
19+
version '0.1.8'
2020

2121
apply plugin: 'kotlin'
2222
apply plugin: 'antlr'

src/main/resources/rule-template.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ templates:
44
- rule: rules/temperature/celsiusToFahrenheit.txt
55
template: templates/fahrenheit.st
66
- rule: rules/temperature/fahrenheitToCelsius.txt
7-
template: templates/celsius.st
7+
template: templates/celsius.st
8+
- rule: rules/weight/poundToKilogram.txt
9+
template: templates/kilogram.st
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x=P2?数(1)
2+
SF:ポンド|"lb"
3+
SF?キログラム|"kg"|"kg"
4+
5+
kg = x * 0.45359237
6+
format(kg, 5)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<value>kg
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package xyz.javecs.tools.text2expr.test.kotlin.rules.weight
2+
3+
import org.junit.Test
4+
import xyz.javecs.tools.text2expr.Text2Expr
5+
import kotlin.test.assertEquals
6+
7+
class WeightTest {
8+
9+
val text2Expr = Text2Expr()
10+
11+
@Test fun poundToKilogram1() {
12+
assertEquals("0.45359", text2Expr.eval("1ポンドは、なんキログラム?"))
13+
assertEquals("0.45359", text2Expr.eval("ポンドは、なんキログラム?"))
14+
assertEquals("0.45359", text2Expr.eval("1lbは、なんkg?"))
15+
assertEquals("0.45359", text2Expr.eval("1lbをkgにしたら"))
16+
assertEquals("0.45359", text2Expr.eval("1ポンド?"))
17+
assertEquals("1.36078kg", text2Expr.eval("3ポンド?", rendered = true))
18+
}
19+
20+
}

0 commit comments

Comments
 (0)