Java - (build 1.8.0_161-b12)
Anvils don't work for enchanting,
Adding enchantments to weapons don't work on any way that I have seen.
If a normal full durability diamond sword is put in the first slot, and an enchanted diamond sword with sharpness III in the second slot, the outcome is a normal diamond sword.
It seems to just give you exactly what is put in the first slot again, no matter what.
If the first slot is an efficiency II iron shovel and the second is an unbreaking III iron shovel, it will put out an efficiency II iron shovel.
This is also the deal with enchanted books, as it just pops out like the book was never there.