Pārlūkot izejas kodu

recursively resolve context values

master
Jonathan Cobb pirms 3 gadiem
vecāks
revīzija
ebdfcedf66
2 mainītis faili ar 9 papildinājumiem un 4 dzēšanām
  1. +6
    -1
      src/main/java/jvc/service/Toolbox.java
  2. +3
    -3
      src/test/resources/tests/test_scale.jvc

+ 6
- 1
src/main/java/jvc/service/Toolbox.java Parādīt failu

@@ -63,7 +63,12 @@ public class Toolbox {
}

public static BigDecimal evalBig(String val, Map<String, Object> ctx, JsEngine js) {
return big(eval(val, ctx, js));
final String resolved = eval(val, ctx, js);
try {
return empty(resolved) ? die("evalBig: error resolving value: '"+val+"'") : big(resolved);
} catch (NumberFormatException nfe) {
return evalBig(resolved, ctx, js);
}
}

public static BigDecimal evalBig(String val, Map<String, Object> ctx, JsEngine js, BigDecimal defaultValue) {


+ 3
- 3
src/test/resources/tests/test_scale.jvc Parādīt failu

@@ -1,7 +1,7 @@
{
"vars": [
{"name": "out_width", "value": "1024"},
{"name": "out_height", "value": "768"}
{"name": "out_height", "value": "source.height / 2"}
],
"assets": [
// wildcard matches multiple files, vid1_splits becomes a "list" asset. resolution is 320x240
@@ -17,8 +17,8 @@
"height": "out_height", // height of scaled asset. if omitted and width is present, height will be proportional
// here we reference the `out_height` variable defined above in the `vars` array
"validate": [{
"comment": "expect output resolution of 1024x768",
"test": "output.width === 1024 && output.height === 768"
"comment": "expect output resolution of 1024x(source.height/2)",
"test": "output.width === 1024 && output.height === source.height/2"
}]
},
{


Notiek ielāde…
Atcelt
Saglabāt