#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:template", "template")

#@ def test1_left():
key1: val1
#@ end

#@ def test1_right():
#@overlay/match expects=0
#@overlay/replace or_add=True
key2: val2
#@ end

test1: #@ overlay.apply(test1_left(), test1_right())

#@ def test1a_left():
key1: val1
#@ end

#@ def test1a_right():
#@overlay/match expects=0
#@overlay/replace via=lambda a,b: [a, b], or_add=True
key2: val2
#@ end

test1a: #@ overlay.apply(test1a_left(), test1a_right())

---
#@ def test2_left():
- val1
- val11
#@ end

#@ def test2_right():
#@overlay/match by=overlay.not_op(overlay.all), expects=0
#@overlay/replace or_add=True
- val2
#@ end

---
test2: #@ overlay.apply(test2_left(), test2_right())

---
#@ def test3_left():
---
val1
---
val11
#@ end

#@ def test3_right():
#@overlay/match by=overlay.not_op(overlay.all), expects=0
#@overlay/replace or_add=True
---
val2
#@ end

--- #@ template.replace(overlay.apply(test3_left(), test3_right()))

+++

test1:
  key1: val1
  key2: val2
test1a:
  key1: val1
  key2:
  - null
  - val2
---
test2:
- val1
- val11
- val2
---
val1
---
val11
---
val2
